* feat: added independent stickies page * chore: randomized sticky color * chore: search in stickies * feat: dnd * fix: quick links * fix: stickies abrupt rendering * fix: handled edge cases for dnd * fix: empty states * fix: build and lint * fix: handled new sticky when last sticky is emoty * fix: new sticky condition * refactor: stickies empty states, store * chore: update stickies empty states * fix: random sticky color * fix: header * refactor: better error handling --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
// helpers
|
|
import { STICKIES_PER_PAGE } from "@plane/constants";
|
|
import { TSticky } from "@plane/types";
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
|
// services
|
|
import { APIService } from "@/services/api.service";
|
|
|
|
export class StickyService extends APIService {
|
|
constructor() {
|
|
super(API_BASE_URL);
|
|
}
|
|
|
|
async createSticky(workspaceSlug: string, payload: Partial<TSticky>) {
|
|
return this.post(`/api/workspaces/${workspaceSlug}/stickies/`, payload)
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
async getStickies(
|
|
workspaceSlug: string,
|
|
cursor: string,
|
|
query?: string
|
|
): Promise<{ results: TSticky[]; total_pages: number }> {
|
|
return this.get(`/api/workspaces/${workspaceSlug}/stickies/`, {
|
|
params: {
|
|
cursor,
|
|
per_page: STICKIES_PER_PAGE,
|
|
query,
|
|
},
|
|
})
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
async getSticky(workspaceSlug: string, id: string) {
|
|
return this.get(`/api/workspaces/${workspaceSlug}/stickies/${id}`)
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
async updateSticky(workspaceSlug: string, id: string, data: Partial<TSticky>) {
|
|
return await this.patch(`/api/workspaces/${workspaceSlug}/stickies/${id}/`, data)
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
async deleteSticky(workspaceSlug: string, id: string) {
|
|
return await this.delete(`/api/workspaces/${workspaceSlug}/stickies/${id}`)
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
}
|