From 701500df9f2aef90b612ccd0eca9d2d8ca7841b9 Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Mon, 19 Feb 2024 18:00:07 +0530 Subject: [PATCH] change module and cycle types --- packages/types/src/cycles.d.ts | 8 ++-- packages/types/src/modules.d.ts | 13 ++----- .../sidebar/sidebar-header.tsx | 3 +- .../custom-analytics/sidebar/sidebar.tsx | 31 ++++++++++------ .../cycles/active-cycle-details.tsx | 9 +++-- web/components/cycles/cycles-board-card.tsx | 14 ++++--- web/components/cycles/cycles-list-item.tsx | 14 ++++--- web/components/cycles/form.tsx | 6 +-- web/components/cycles/gantt-chart/blocks.tsx | 4 +- .../cycles/gantt-chart/cycles-list-layout.tsx | 2 +- web/components/cycles/modal.tsx | 8 ++-- .../modules/delete-module-modal.tsx | 2 +- web/components/modules/form.tsx | 16 ++++---- web/components/modules/gantt-chart/blocks.tsx | 8 +++- .../gantt-chart/modules-list-layout.tsx | 2 +- web/components/modules/modal.tsx | 12 +++--- web/components/modules/module-card-item.tsx | 20 +++++----- web/components/modules/module-list-item.tsx | 16 ++++---- web/components/modules/sidebar.tsx | 37 +++++++++++-------- web/store/cycle.store.ts | 14 +++---- web/store/module.store.ts | 4 +- 21 files changed, 132 insertions(+), 111 deletions(-) diff --git a/packages/types/src/cycles.d.ts b/packages/types/src/cycles.d.ts index 5d715385a..0e4890b7f 100644 --- a/packages/types/src/cycles.d.ts +++ b/packages/types/src/cycles.d.ts @@ -32,8 +32,7 @@ export interface ICycle { name: string; owned_by: string; progress_snapshot: TProgressSnapshot; - project: string; - project_detail: IProjectLite; + project_id: string; status: TCycleGroups; sort_order: number; start_date: string | null; @@ -42,12 +41,11 @@ export interface ICycle { unstarted_issues: number; updated_at: Date; updated_by: string; - assignees: IUserLite[]; + assignee_ids: string[]; view_props: { filters: IIssueFilterOptions; }; - workspace: string; - workspace_detail: IWorkspaceLite; + workspace_id: string; } export type TProgressSnapshot = { diff --git a/packages/types/src/modules.d.ts b/packages/types/src/modules.d.ts index 0e49da7fe..fcf2d86a2 100644 --- a/packages/types/src/modules.d.ts +++ b/packages/types/src/modules.d.ts @@ -27,16 +27,12 @@ export interface IModule { labels: TLabelsDistribution[]; }; id: string; - lead: string | null; - lead_detail: IUserLite | null; + lead_id: string | null; link_module: ILinkDetails[]; - links_list: ModuleLink[]; - members: string[]; - members_detail: IUserLite[]; + member_ids: string[]; is_favorite: boolean; name: string; - project: string; - project_detail: IProjectLite; + project_id: string; sort_order: number; start_date: string | null; started_issues: number; @@ -49,8 +45,7 @@ export interface IModule { view_props: { filters: IIssueFilterOptions; }; - workspace: string; - workspace_detail: IWorkspaceLite; + workspace_id: string; } export interface ModuleIssueResponse { diff --git a/web/components/analytics/custom-analytics/sidebar/sidebar-header.tsx b/web/components/analytics/custom-analytics/sidebar/sidebar-header.tsx index ee677fe91..c2644abe0 100644 --- a/web/components/analytics/custom-analytics/sidebar/sidebar-header.tsx +++ b/web/components/analytics/custom-analytics/sidebar/sidebar-header.tsx @@ -21,6 +21,7 @@ export const CustomAnalyticsSidebarHeader = observer(() => { const moduleDetails = moduleId ? getModuleById(moduleId.toString()) : undefined; const projectDetails = projectId ? getProjectById(projectId.toString()) : undefined; const cycleOwnerDetails = cycleDetails ? getUserDetails(cycleDetails.owned_by) : undefined; + const moduleLeadDetails = moduleDetails && moduleDetails.lead_id ? getUserDetails(moduleDetails.lead_id) : undefined; return ( <> @@ -57,7 +58,7 @@ export const CustomAnalyticsSidebarHeader = observer(() => {
Lead
- {moduleDetails.lead_detail?.display_name} + {moduleLeadDetails && {moduleLeadDetails?.display_name}}
Start Date
diff --git a/web/components/analytics/custom-analytics/sidebar/sidebar.tsx b/web/components/analytics/custom-analytics/sidebar/sidebar.tsx index c2e12dc3c..3ad2805f2 100644 --- a/web/components/analytics/custom-analytics/sidebar/sidebar.tsx +++ b/web/components/analytics/custom-analytics/sidebar/sidebar.tsx @@ -5,7 +5,7 @@ import { mutate } from "swr"; // services import { AnalyticsService } from "services/analytics.service"; // hooks -import { useCycle, useModule, useProject, useUser } from "hooks/store"; +import { useCycle, useModule, useProject, useUser, useWorkspace } from "hooks/store"; import useToast from "hooks/use-toast"; // components import { CustomAnalyticsSidebarHeader, CustomAnalyticsSidebarProjectsList } from "components/analytics"; @@ -39,6 +39,8 @@ export const CustomAnalyticsSidebar: React.FC = observer((props) => { // store hooks const { currentUser } = useUser(); const { workspaceProjectIds, getProjectById } = useProject(); + const { getWorkspaceById } = useWorkspace(); + const { fetchCycleDetails, getCycleById } = useCycle(); const { fetchModuleDetails, getModuleById } = useModule(); @@ -70,11 +72,14 @@ export const CustomAnalyticsSidebar: React.FC = observer((props) => { if (cycleDetails || moduleDetails) { const details = cycleDetails || moduleDetails; - eventPayload.workspaceId = details?.workspace_detail?.id; - eventPayload.workspaceName = details?.workspace_detail?.name; - eventPayload.projectId = details?.project_detail.id; - eventPayload.projectIdentifier = details?.project_detail.identifier; - eventPayload.projectName = details?.project_detail.name; + const currentProjectDetails = getProjectById(details?.project_id || ""); + const currentWorkspaceDetails = getWorkspaceById(details?.workspace_id || ""); + + eventPayload.workspaceId = details?.workspace_id; + eventPayload.workspaceName = currentWorkspaceDetails?.name; + eventPayload.projectId = details?.project_id; + eventPayload.projectIdentifier = currentProjectDetails?.identifier; + eventPayload.projectName = currentProjectDetails?.name; } if (cycleDetails) { @@ -138,14 +143,18 @@ export const CustomAnalyticsSidebar: React.FC = observer((props) => { const selectedProjects = params.project && params.project.length > 0 ? params.project : workspaceProjectIds; - return ( -
- {analytics ? analytics.total : "..."}
Issues
+ {analytics ? analytics.total : "..."} +
Issues
{isProjectLevel && (
@@ -154,8 +163,8 @@ export const CustomAnalyticsSidebar: React.FC = observer((props) => { (cycleId ? cycleDetails?.created_at : moduleId - ? moduleDetails?.created_at - : projectDetails?.created_at) ?? "" + ? moduleDetails?.created_at + : projectDetails?.created_at) ?? "" )}
)} diff --git a/web/components/cycles/active-cycle-details.tsx b/web/components/cycles/active-cycle-details.tsx index 5d4bcd768..7e885635f 100644 --- a/web/components/cycles/active-cycle-details.tsx +++ b/web/components/cycles/active-cycle-details.tsx @@ -222,12 +222,13 @@ export const ActiveCycleDetails: React.FC = observer((props {cycleOwnerDetails?.display_name}
- {activeCycle.assignees.length > 0 && ( + {activeCycle.assignee_ids.length > 0 && (
- {activeCycle.assignees.map((assignee) => ( - - ))} + {activeCycle.assignee_ids.map((assigne_id) => { + const member = getUserDetails(assigne_id); + return ; + })}
)} diff --git a/web/components/cycles/cycles-board-card.tsx b/web/components/cycles/cycles-board-card.tsx index e96b01858..7d6b1e000 100644 --- a/web/components/cycles/cycles-board-card.tsx +++ b/web/components/cycles/cycles-board-card.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import Link from "next/link"; import { observer } from "mobx-react"; // hooks -import { useEventTracker, useCycle, useUser } from "hooks/store"; +import { useEventTracker, useCycle, useUser, useMember } from "hooks/store"; import useToast from "hooks/use-toast"; // components import { CycleCreateUpdateModal, CycleDeleteModal } from "components/cycles"; @@ -40,6 +40,7 @@ export const CyclesBoardCard: FC = observer((props) => { membership: { currentProjectRole }, } = useUser(); const { addCycleToFavorites, removeCycleFromFavorites, getCycleById } = useCycle(); + const { getUserDetails } = useMember(); // toast alert const { setToastAlert } = useToast(); // computed @@ -212,13 +213,14 @@ export const CyclesBoardCard: FC = observer((props) => { {issueCount}
- {cycleDetails.assignees.length > 0 && ( - + {cycleDetails.assignee_ids.length > 0 && ( +
- {cycleDetails.assignees.map((assignee) => ( - - ))} + {cycleDetails.assignee_ids.map((assigne_id) => { + const member = getUserDetails(assigne_id); + return ; + })}
diff --git a/web/components/cycles/cycles-list-item.tsx b/web/components/cycles/cycles-list-item.tsx index ed2b26c53..31958cd84 100644 --- a/web/components/cycles/cycles-list-item.tsx +++ b/web/components/cycles/cycles-list-item.tsx @@ -3,7 +3,7 @@ import Link from "next/link"; import { useRouter } from "next/router"; import { observer } from "mobx-react"; // hooks -import { useEventTracker, useCycle, useUser } from "hooks/store"; +import { useEventTracker, useCycle, useUser, useMember } from "hooks/store"; import useToast from "hooks/use-toast"; // components import { CycleCreateUpdateModal, CycleDeleteModal } from "components/cycles"; @@ -44,6 +44,7 @@ export const CyclesListItem: FC = observer((props) => { membership: { currentProjectRole }, } = useUser(); const { getCycleById, addCycleToFavorites, removeCycleFromFavorites } = useCycle(); + const { getUserDetails } = useMember(); // toast alert const { setToastAlert } = useToast(); @@ -230,13 +231,14 @@ export const CyclesListItem: FC = observer((props) => {
- +
- {cycleDetails.assignees.length > 0 ? ( + {cycleDetails.assignee_ids?.length > 0 ? ( - {cycleDetails.assignees.map((assignee) => ( - - ))} + {cycleDetails.assignee_ids?.map((assigne_id) => { + const member = getUserDetails(assigne_id); + return ; + })} ) : ( diff --git a/web/components/cycles/form.tsx b/web/components/cycles/form.tsx index dfe2a878e..46aefcb0b 100644 --- a/web/components/cycles/form.tsx +++ b/web/components/cycles/form.tsx @@ -36,7 +36,7 @@ export const CycleForm: React.FC = (props) => { reset, } = useForm({ defaultValues: { - project: projectId, + project_id: projectId, name: data?.name || "", description: data?.description || "", start_date: data?.start_date || null, @@ -61,13 +61,13 @@ export const CycleForm: React.FC = (props) => { maxDate?.setDate(maxDate.getDate() - 1); return ( -
handleFormSubmit(formData,dirtyFields))}> + handleFormSubmit(formData, dirtyFields))}>
{!status && ( ( = observer((props) => { ? "rgb(var(--color-text-200))" : "", }} - onClick={() => router.push(`/${workspaceSlug}/projects/${cycleDetails?.project}/cycles/${cycleDetails?.id}`)} + onClick={() => router.push(`/${workspaceSlug}/projects/${cycleDetails?.project_id}/cycles/${cycleDetails?.id}`)} >
= observer((props) => { return (
router.push(`/${workspaceSlug}/projects/${cycleDetails?.project}/cycles/${cycleDetails?.id}`)} + onClick={() => router.push(`/${workspaceSlug}/projects/${cycleDetails?.project_id}/cycles/${cycleDetails?.id}`)} > = observer((props) => { const payload: any = { ...data }; if (data.sort_order) payload.sort_order = data.sort_order.newSortOrder; - await updateCycleDetails(workspaceSlug.toString(), cycle.project, cycle.id, payload); + await updateCycleDetails(workspaceSlug.toString(), cycle.project_id, cycle.id, payload); }; const blockFormat = (blocks: (ICycle | null)[]) => { diff --git a/web/components/cycles/modal.tsx b/web/components/cycles/modal.tsx index e8f19d6a1..b22afb2b4 100644 --- a/web/components/cycles/modal.tsx +++ b/web/components/cycles/modal.tsx @@ -40,7 +40,7 @@ export const CycleCreateUpdateModal: React.FC = (props) => { const handleCreateCycle = async (payload: Partial) => { if (!workspaceSlug || !projectId) return; - const selectedProjectId = payload.project ?? projectId.toString(); + const selectedProjectId = payload.project_id ?? projectId.toString(); await createCycle(workspaceSlug, selectedProjectId, payload) .then((res) => { setToastAlert({ @@ -69,7 +69,7 @@ export const CycleCreateUpdateModal: React.FC = (props) => { const handleUpdateCycle = async (cycleId: string, payload: Partial, dirtyFields: any) => { if (!workspaceSlug || !projectId) return; - const selectedProjectId = payload.project ?? projectId.toString(); + const selectedProjectId = payload.project_id ?? projectId.toString(); await updateCycleDetails(workspaceSlug, selectedProjectId, cycleId, payload) .then((res) => { const changed_properties = Object.keys(dirtyFields); @@ -155,8 +155,8 @@ export const CycleCreateUpdateModal: React.FC = (props) => { // if data is present, set active project to the project of the // issue. This has more priority than the project in the url. - if (data && data.project) { - setActiveProject(data.project); + if (data && data.project_id) { + setActiveProject(data.project_id); return; } diff --git a/web/components/modules/delete-module-modal.tsx b/web/components/modules/delete-module-modal.tsx index 636a828ae..bf2e529b7 100644 --- a/web/components/modules/delete-module-modal.tsx +++ b/web/components/modules/delete-module-modal.tsx @@ -45,7 +45,7 @@ export const DeleteModuleModal: React.FC = observer((props) => { await deleteModule(workspaceSlug.toString(), projectId.toString(), data.id) .then(() => { - if (moduleId || peekModule) router.push(`/${workspaceSlug}/projects/${data.project}/modules`); + if (moduleId || peekModule) router.push(`/${workspaceSlug}/projects/${data.project_id}/modules`); handleClose(); setToastAlert({ type: "success", diff --git a/web/components/modules/form.tsx b/web/components/modules/form.tsx index 8fa63e826..a6f04ec54 100644 --- a/web/components/modules/form.tsx +++ b/web/components/modules/form.tsx @@ -23,8 +23,8 @@ const defaultValues: Partial = { name: "", description: "", status: "backlog", - lead: null, - members: [], + lead_id: null, + member_ids: [], }; export const ModuleForm: React.FC = ({ @@ -43,12 +43,12 @@ export const ModuleForm: React.FC = ({ reset, } = useForm({ defaultValues: { - project: projectId, + project_id: projectId, name: data?.name || "", description: data?.description || "", status: data?.status || "backlog", - lead: data?.lead || null, - members: data?.members || [], + lead_id: data?.lead_id || null, + member_ids: data?.member_ids || [], }, }); @@ -83,7 +83,7 @@ export const ModuleForm: React.FC = ({ {!status && ( (
= ({ (
= ({ /> (
= observer((props) => {
s.value === moduleDetails?.status)?.color }} - onClick={() => router.push(`/${workspaceSlug}/projects/${moduleDetails?.project}/modules/${moduleDetails?.id}`)} + onClick={() => + router.push(`/${workspaceSlug}/projects/${moduleDetails?.project_id}/modules/${moduleDetails?.id}`) + } >
= observer((props) => { return (
router.push(`/${workspaceSlug}/projects/${moduleDetails?.project}/modules/${moduleDetails?.id}`)} + onClick={() => + router.push(`/${workspaceSlug}/projects/${moduleDetails?.project_id}/modules/${moduleDetails?.id}`) + } >
{moduleDetails?.name}
diff --git a/web/components/modules/gantt-chart/modules-list-layout.tsx b/web/components/modules/gantt-chart/modules-list-layout.tsx index 8384c164e..c6caacc92 100644 --- a/web/components/modules/gantt-chart/modules-list-layout.tsx +++ b/web/components/modules/gantt-chart/modules-list-layout.tsx @@ -22,7 +22,7 @@ export const ModulesListGanttChartView: React.FC = observer(() => { const payload: any = { ...data }; if (data.sort_order) payload.sort_order = data.sort_order.newSortOrder; - await updateModuleDetails(workspaceSlug.toString(), module.project, module.id, payload); + await updateModuleDetails(workspaceSlug.toString(), module.project_id, module.id, payload); }; const blockFormat = (blocks: string[]) => diff --git a/web/components/modules/modal.tsx b/web/components/modules/modal.tsx index 7990386df..47f331396 100644 --- a/web/components/modules/modal.tsx +++ b/web/components/modules/modal.tsx @@ -24,8 +24,8 @@ const defaultValues: Partial = { name: "", description: "", status: "backlog", - lead: null, - members: [], + lead_id: null, + member_ids: [], }; export const CreateUpdateModuleModal: React.FC = observer((props) => { @@ -51,7 +51,7 @@ export const CreateUpdateModuleModal: React.FC = observer((props) => { const handleCreateModule = async (payload: Partial) => { if (!workspaceSlug || !projectId) return; - const selectedProjectId = payload.project ?? projectId.toString(); + const selectedProjectId = payload.project_id ?? projectId.toString(); await createModule(workspaceSlug.toString(), selectedProjectId, payload) .then((res) => { handleClose(); @@ -81,7 +81,7 @@ export const CreateUpdateModuleModal: React.FC = observer((props) => { const handleUpdateModule = async (payload: Partial, dirtyFields: any) => { if (!workspaceSlug || !projectId || !data) return; - const selectedProjectId = payload.project ?? projectId.toString(); + const selectedProjectId = payload.project_id ?? projectId.toString(); await updateModuleDetails(workspaceSlug.toString(), selectedProjectId, data.id, payload) .then((res) => { handleClose(); @@ -129,8 +129,8 @@ export const CreateUpdateModuleModal: React.FC = observer((props) => { // if data is present, set active project to the project of the // issue. This has more priority than the project in the url. - if (data && data.project) { - setActiveProject(data.project); + if (data && data.project_id) { + setActiveProject(data.project_id); return; } diff --git a/web/components/modules/module-card-item.tsx b/web/components/modules/module-card-item.tsx index ce93ff961..4dec3df6e 100644 --- a/web/components/modules/module-card-item.tsx +++ b/web/components/modules/module-card-item.tsx @@ -4,7 +4,7 @@ import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { Info, LinkIcon, Pencil, Star, Trash2 } from "lucide-react"; // hooks -import { useEventTracker, useModule, useUser } from "hooks/store"; +import { useEventTracker, useMember, useModule, useUser } from "hooks/store"; import useToast from "hooks/use-toast"; // components import { CreateUpdateModuleModal, DeleteModuleModal } from "components/modules"; @@ -37,6 +37,7 @@ export const ModuleCardItem: React.FC = observer((props) => { membership: { currentProjectRole }, } = useUser(); const { getModuleById, addModuleToFavorites, removeModuleFromFavorites } = useModule(); + const { getUserDetails } = useMember(); const { setTrackElement, captureEvent } = useEventTracker(); // derived values const moduleDetails = getModuleById(moduleId); @@ -147,8 +148,8 @@ export const ModuleCardItem: React.FC = observer((props) => { ? !moduleTotalIssues || moduleTotalIssues === 0 ? "0 Issue" : moduleTotalIssues === moduleDetails.completed_issues - ? `${moduleTotalIssues} Issue${moduleTotalIssues > 1 ? "s" : ""}` - : `${moduleDetails.completed_issues}/${moduleTotalIssues} Issues` + ? `${moduleTotalIssues} Issue${moduleTotalIssues > 1 ? "s" : ""}` + : `${moduleDetails.completed_issues}/${moduleTotalIssues} Issues` : "0 Issue"; return ( @@ -163,7 +164,7 @@ export const ModuleCardItem: React.FC = observer((props) => { /> )} setDeleteModal(false)} /> - +
@@ -195,13 +196,14 @@ export const ModuleCardItem: React.FC = observer((props) => { {issueCount ?? "0 Issue"}
- {moduleDetails.members_detail.length > 0 && ( - + {moduleDetails.member_ids?.length > 0 && ( +
- {moduleDetails.members_detail.map((member) => ( - - ))} + {moduleDetails.member_ids.map((member_id) => { + const member = getUserDetails(member_id); + return ; + })}
diff --git a/web/components/modules/module-list-item.tsx b/web/components/modules/module-list-item.tsx index 79e559ca7..e3913115e 100644 --- a/web/components/modules/module-list-item.tsx +++ b/web/components/modules/module-list-item.tsx @@ -4,7 +4,7 @@ import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { Check, Info, LinkIcon, Pencil, Star, Trash2, User2 } from "lucide-react"; // hooks -import { useModule, useUser, useEventTracker } from "hooks/store"; +import { useModule, useUser, useEventTracker, useMember } from "hooks/store"; import useToast from "hooks/use-toast"; // components import { CreateUpdateModuleModal, DeleteModuleModal } from "components/modules"; @@ -37,6 +37,7 @@ export const ModuleListItem: React.FC = observer((props) => { membership: { currentProjectRole }, } = useUser(); const { getModuleById, addModuleToFavorites, removeModuleFromFavorites } = useModule(); + const { getUserDetails } = useMember(); const { setTrackElement, captureEvent } = useEventTracker(); // derived values const moduleDetails = getModuleById(moduleId); @@ -153,7 +154,7 @@ export const ModuleListItem: React.FC = observer((props) => { /> )} setDeleteModal(false)} /> - +
@@ -206,13 +207,14 @@ export const ModuleListItem: React.FC = observer((props) => {
- +
- {moduleDetails.members_detail.length > 0 ? ( + {moduleDetails.member_ids.length > 0 ? ( - {moduleDetails.members_detail.map((member) => ( - - ))} + {moduleDetails.member_ids.map((member_id) => { + const member = getUserDetails(member_id); + return ; + })} ) : ( diff --git a/web/components/modules/sidebar.tsx b/web/components/modules/sidebar.tsx index 5e674b303..b37875386 100644 --- a/web/components/modules/sidebar.tsx +++ b/web/components/modules/sidebar.tsx @@ -37,8 +37,8 @@ import { EUserProjectRoles } from "constants/project"; import { MODULE_LINK_CREATED, MODULE_LINK_DELETED, MODULE_LINK_UPDATED, MODULE_UPDATED } from "constants/event-tracker"; const defaultValues: Partial = { - lead: "", - members: [], + lead_id: "", + member_ids: [], start_date: null, target_date: null, status: "backlog", @@ -323,8 +323,9 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { = observer((props) => { <> {renderFormattedDate(startDate) ?? "No date selected"} @@ -427,13 +430,15 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { <> {renderFormattedDate(endDate) ?? "No date selected"} @@ -485,13 +490,13 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => {
(
{ - submitChanges({ lead: val }); + submitChanges({ lead_id: val }); }} projectId={projectId?.toString() ?? ""} multiple={false} @@ -509,13 +514,13 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => {
(
{ - submitChanges({ members: val }); + submitChanges({ member_ids: val }); }} multiple projectId={projectId?.toString() ?? ""} diff --git a/web/store/cycle.store.ts b/web/store/cycle.store.ts index 51340d740..917fd8022 100644 --- a/web/store/cycle.store.ts +++ b/web/store/cycle.store.ts @@ -102,7 +102,7 @@ export class CycleStore implements ICycleStore { get currentProjectCycleIds() { const projectId = this.rootStore.app.router.projectId; if (!projectId || !this.fetchedMap[projectId]) return null; - let allCycles = Object.values(this.cycleMap ?? {}).filter((c) => c?.project === projectId); + let allCycles = Object.values(this.cycleMap ?? {}).filter((c) => c?.project_id === projectId); allCycles = sortBy(allCycles, [(c) => c.sort_order]); const allCycleIds = allCycles.map((c) => c.id); return allCycleIds; @@ -116,7 +116,7 @@ export class CycleStore implements ICycleStore { if (!projectId || !this.fetchedMap[projectId]) return null; let completedCycles = Object.values(this.cycleMap ?? {}).filter((c) => { const hasEndDatePassed = isPast(new Date(c.end_date ?? "")); - return c.project === projectId && hasEndDatePassed; + return c.project_id === projectId && hasEndDatePassed; }); completedCycles = sortBy(completedCycles, [(c) => c.sort_order]); const completedCycleIds = completedCycles.map((c) => c.id); @@ -131,7 +131,7 @@ export class CycleStore implements ICycleStore { if (!projectId || !this.fetchedMap[projectId]) return null; let upcomingCycles = Object.values(this.cycleMap ?? {}).filter((c) => { const isStartDateUpcoming = isFuture(new Date(c.start_date ?? "")); - return c.project === projectId && isStartDateUpcoming; + return c.project_id === projectId && isStartDateUpcoming; }); upcomingCycles = sortBy(upcomingCycles, [(c) => c.sort_order]); const upcomingCycleIds = upcomingCycles.map((c) => c.id); @@ -146,7 +146,7 @@ export class CycleStore implements ICycleStore { if (!projectId || !this.fetchedMap[projectId]) return null; let incompleteCycles = Object.values(this.cycleMap ?? {}).filter((c) => { const hasEndDatePassed = isPast(new Date(c.end_date ?? "")); - return c.project === projectId && !hasEndDatePassed; + return c.project_id === projectId && !hasEndDatePassed; }); incompleteCycles = sortBy(incompleteCycles, [(c) => c.sort_order]); const incompleteCycleIds = incompleteCycles.map((c) => c.id); @@ -160,7 +160,7 @@ export class CycleStore implements ICycleStore { const projectId = this.rootStore.app.router.projectId; if (!projectId || !this.fetchedMap[projectId]) return null; let draftCycles = Object.values(this.cycleMap ?? {}).filter( - (c) => c.project === projectId && !c.start_date && !c.end_date + (c) => c.project_id === projectId && !c.start_date && !c.end_date ); draftCycles = sortBy(draftCycles, [(c) => c.sort_order]); const draftCycleIds = draftCycles.map((c) => c.id); @@ -174,7 +174,7 @@ export class CycleStore implements ICycleStore { const projectId = this.rootStore.app.router.projectId; if (!projectId) return null; const activeCycle = Object.keys(this.activeCycleIdMap ?? {}).find( - (cycleId) => this.cycleMap?.[cycleId]?.project === projectId + (cycleId) => this.cycleMap?.[cycleId]?.project_id === projectId ); return activeCycle || null; } @@ -202,7 +202,7 @@ export class CycleStore implements ICycleStore { getProjectCycleIds = computedFn((projectId: string): string[] | null => { if (!this.fetchedMap[projectId]) return null; - let cycles = Object.values(this.cycleMap ?? {}).filter((c) => c.project === projectId); + let cycles = Object.values(this.cycleMap ?? {}).filter((c) => c.project_id === projectId); cycles = sortBy(cycles, [(c) => c.sort_order]); const cycleIds = cycles.map((c) => c.id); return cycleIds || null; diff --git a/web/store/module.store.ts b/web/store/module.store.ts index 5c80e39d0..e550dc7a0 100644 --- a/web/store/module.store.ts +++ b/web/store/module.store.ts @@ -99,7 +99,7 @@ export class ModulesStore implements IModuleStore { get projectModuleIds() { const projectId = this.rootStore.app.router.projectId; if (!projectId || !this.fetchedMap[projectId]) return null; - let projectModules = Object.values(this.moduleMap).filter((m) => m.project === projectId); + let projectModules = Object.values(this.moduleMap).filter((m) => m.project_id === projectId); projectModules = sortBy(projectModules, [(m) => m.sort_order]); const projectModuleIds = projectModules.map((m) => m.id); return projectModuleIds || null; @@ -119,7 +119,7 @@ export class ModulesStore implements IModuleStore { getProjectModuleIds = computedFn((projectId: string) => { if (!this.fetchedMap[projectId]) return null; - let projectModules = Object.values(this.moduleMap).filter((m) => m.project === projectId); + let projectModules = Object.values(this.moduleMap).filter((m) => m.project_id === projectId); projectModules = sortBy(projectModules, [(m) => m.sort_order]); const projectModuleIds = projectModules.map((m) => m.id); return projectModuleIds;