From f7586ba046bef7cdc1c7988968c5b642b594c4b1 Mon Sep 17 00:00:00 2001 From: Rahul R Date: Mon, 22 Jan 2024 14:11:03 +0530 Subject: [PATCH] fix state and label types --- packages/types/src/issues.d.ts | 3 +-- packages/types/src/state.d.ts | 11 ++--------- .../issues/issue-layouts/properties/labels.tsx | 5 +++-- web/components/states/delete-state-modal.tsx | 2 +- web/store/label.store.ts | 2 +- web/store/state.store.ts | 6 +++--- 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/types/src/issues.d.ts b/packages/types/src/issues.d.ts index 1f4398acc..73a99f66f 100644 --- a/packages/types/src/issues.d.ts +++ b/packages/types/src/issues.d.ts @@ -110,10 +110,9 @@ export type IssuePriorities = { export interface IIssueLabel { id: string; name: string; - description: string; color: string; project_id: string; - workspace_slug: string; + workspace__slug: string; parent: string | null; sort_order: number; } diff --git a/packages/types/src/state.d.ts b/packages/types/src/state.d.ts index 822b99f17..b4146fe7e 100644 --- a/packages/types/src/state.d.ts +++ b/packages/types/src/state.d.ts @@ -5,20 +5,13 @@ export type TStateGroups = "backlog" | "unstarted" | "started" | "completed" | " export interface IState { readonly id: string; color: string; - readonly created_at: Date; - readonly created_by: string; default: boolean; description: string; group: TStateGroups; name: string; - project: string; - readonly project_detail: IProjectLite; + project_id: string; sequence: number; - readonly slug: string; - readonly updated_at: Date; - readonly updated_by: string; - workspace: string; - workspace_detail: IWorkspaceLite; + workspace__slug: string; } export interface IStateLite { diff --git a/web/components/issues/issue-layouts/properties/labels.tsx b/web/components/issues/issue-layouts/properties/labels.tsx index d38ff577b..0a33ed886 100644 --- a/web/components/issues/issue-layouts/properties/labels.tsx +++ b/web/components/issues/issue-layouts/properties/labels.tsx @@ -58,9 +58,10 @@ export const IssuePropertyLabels: React.FC = observer((pro const storeLabels = getProjectLabels(projectId); const openDropDown = () => { - setIsLoading(true); - if (!storeLabels && workspaceSlug && projectId) + if (!storeLabels && workspaceSlug && projectId) { + setIsLoading(true); fetchProjectLabels(workspaceSlug, projectId).then(() => setIsLoading(false)); + } }; const { styles, attributes } = usePopper(referenceElement, popperElement, { diff --git a/web/components/states/delete-state-modal.tsx b/web/components/states/delete-state-modal.tsx index 6cbeb84e0..26b542b71 100644 --- a/web/components/states/delete-state-modal.tsx +++ b/web/components/states/delete-state-modal.tsx @@ -42,7 +42,7 @@ export const DeleteStateModal: React.FC = observer((props) => { setIsDeleteLoading(true); - await deleteState(workspaceSlug.toString(), data.project, data.id) + await deleteState(workspaceSlug.toString(), data.project_id, data.id) .then(() => { postHogEventTracker("STATE_DELETE", { state: "SUCCESS", diff --git a/web/store/label.store.ts b/web/store/label.store.ts index fad52261c..f5fe7549b 100644 --- a/web/store/label.store.ts +++ b/web/store/label.store.ts @@ -82,7 +82,7 @@ export class LabelStore implements ILabelStore { const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace; const worksapceSlug = this.rootStore.app.router.workspaceSlug || ""; if (!currentWorkspaceDetails || !this.fetchedMap[worksapceSlug]) return; - return Object.values(this.labelMap).filter((label) => label.workspace_slug === currentWorkspaceDetails.slug); + return Object.values(this.labelMap).filter((label) => label.workspace__slug === currentWorkspaceDetails.slug); } /** diff --git a/web/store/state.store.ts b/web/store/state.store.ts index 1da0707dc..12b2d9815 100644 --- a/web/store/state.store.ts +++ b/web/store/state.store.ts @@ -78,7 +78,7 @@ export class StateStore implements IStateStore { const projectId = this.router.projectId; const worksapceSlug = this.router.workspaceSlug || ""; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return; - return Object.values(this.stateMap).filter((state) => state.project === this.router.query.projectId); + return Object.values(this.stateMap).filter((state) => state.project_id === projectId); } /** @@ -106,7 +106,7 @@ export class StateStore implements IStateStore { getProjectStates = computedFn((projectId: string) => { const worksapceSlug = this.router.workspaceSlug || ""; if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[worksapceSlug])) return; - return Object.values(this.stateMap).filter((state) => state.project === projectId); + return Object.values(this.stateMap).filter((state) => state.project_id === projectId); }); /** @@ -208,7 +208,7 @@ export class StateStore implements IStateStore { markStateAsDefault = async (workspaceSlug: string, projectId: string, stateId: string) => { const originalStates = this.stateMap; const currentDefaultState = Object.values(this.stateMap).find( - (state) => state.project === projectId && state.default + (state) => state.project_id === projectId && state.default ); try { runInAction(() => {