From 704fe155af76d0c4f77e3032075c5e7f21f438e4 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Wed, 18 Oct 2023 19:26:15 +0530 Subject: [PATCH] chore: fetch cycles, modules and views in the project wrapper (#2479) --- web/layouts/auth-layout/project-wrapper.tsx | 29 ++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/web/layouts/auth-layout/project-wrapper.tsx b/web/layouts/auth-layout/project-wrapper.tsx index 122c2ab92..e5a9bd4cd 100644 --- a/web/layouts/auth-layout/project-wrapper.tsx +++ b/web/layouts/auth-layout/project-wrapper.tsx @@ -18,7 +18,14 @@ interface IProjectAuthWrapper { export const ProjectAuthWrapper: FC = observer((props) => { const { children } = props; // store - const { user: userStore, project: projectStore, inbox: inboxStore } = useMobxStore(); + const { + user: userStore, + project: projectStore, + cycle: cycleStore, + module: moduleStore, + projectViews: projectViewsStore, + inbox: inboxStore, + } = useMobxStore(); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -58,6 +65,26 @@ export const ProjectAuthWrapper: FC = observer((props) => { ? () => projectStore.fetchProjectStates(workspaceSlug.toString(), projectId.toString()) : null ); + // fetching project cycles + useSWR( + workspaceSlug && projectId ? `PROJECT_ALL_CYCLES_${workspaceSlug}_${projectId}` : null, + workspaceSlug && projectId + ? () => cycleStore.fetchCycles(workspaceSlug.toString(), projectId.toString(), "all") + : null + ); + // fetching project modules + useSWR( + workspaceSlug && projectId ? `PROJECT_MODULES_${workspaceSlug}_${projectId}` : null, + workspaceSlug && projectId ? () => moduleStore.fetchModules(workspaceSlug.toString(), projectId.toString()) : null + ); + // fetching project views + useSWR( + workspaceSlug && projectId ? `PROJECT_VIEWS_${workspaceSlug}_${projectId}` : null, + workspaceSlug && projectId + ? () => projectViewsStore.fetchAllViews(workspaceSlug.toString(), projectId.toString()) + : null + ); + // TODO: fetching project pages // fetching project inboxes if inbox is enabled useSWR( workspaceSlug && projectId && inboxStore.isInboxEnabled ? `PROJECT_INBOXES_${workspaceSlug}_${projectId}` : null,