From c8caa925b19078ee3d5db414affd976a00b073cc Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Mon, 29 May 2023 18:35:16 +0530 Subject: [PATCH] chore: page and cycle refactor (#1159) * fix: release note modal fix * chore: cycle and page endpoint refactor --- .../components/cycles/cycles-list/all-cycles-list.tsx | 4 +--- .../cycles/cycles-list/completed-cycles-list.tsx | 8 +++++--- .../cycles/cycles-list/draft-cycles-list.tsx | 4 +--- .../cycles/cycles-list/upcoming-cycles-list.tsx | 8 +++++--- apps/app/components/cycles/select.tsx | 5 +---- apps/app/components/cycles/transfer-issues-modal.tsx | 8 +++++--- apps/app/components/issues/sidebar-select/cycle.tsx | 8 +++++--- .../app/components/pages/pages-list/all-pages-list.tsx | 5 +---- .../pages/pages-list/favorite-pages-list.tsx | 4 +--- apps/app/components/pages/pages-list/my-pages-list.tsx | 8 +++++--- .../components/pages/pages-list/other-pages-list.tsx | 8 +++++--- apps/app/pages/[workspaceSlug]/index.tsx | 10 ++++++---- .../projects/[projectId]/cycles/[cycleId].tsx | 5 +---- .../projects/[projectId]/cycles/index.tsx | 4 +--- apps/app/services/cycles.service.ts | 6 ++++-- apps/app/services/pages.service.ts | 6 ++++-- 16 files changed, 51 insertions(+), 50 deletions(-) diff --git a/apps/app/components/cycles/cycles-list/all-cycles-list.tsx b/apps/app/components/cycles/cycles-list/all-cycles-list.tsx index 11dc08b3e..7ebd92a50 100644 --- a/apps/app/components/cycles/cycles-list/all-cycles-list.tsx +++ b/apps/app/components/cycles/cycles-list/all-cycles-list.tsx @@ -21,9 +21,7 @@ export const AllCyclesList: React.FC = ({ viewType }) => { workspaceSlug && projectId ? CYCLES_LIST(projectId.toString()) : null, workspaceSlug && projectId ? () => - cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), { - cycle_view: "all", - }) + cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), "all") : null ); diff --git a/apps/app/components/cycles/cycles-list/completed-cycles-list.tsx b/apps/app/components/cycles/cycles-list/completed-cycles-list.tsx index bcbb11d4a..79a427d95 100644 --- a/apps/app/components/cycles/cycles-list/completed-cycles-list.tsx +++ b/apps/app/components/cycles/cycles-list/completed-cycles-list.tsx @@ -21,9 +21,11 @@ export const CompletedCyclesList: React.FC = ({ viewType }) => { workspaceSlug && projectId ? COMPLETED_CYCLES_LIST(projectId.toString()) : null, workspaceSlug && projectId ? () => - cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), { - cycle_view: "completed", - }) + cyclesService.getCyclesWithParams( + workspaceSlug.toString(), + projectId.toString(), + "completed" + ) : null ); diff --git a/apps/app/components/cycles/cycles-list/draft-cycles-list.tsx b/apps/app/components/cycles/cycles-list/draft-cycles-list.tsx index e64e49dfd..fd2dccc93 100644 --- a/apps/app/components/cycles/cycles-list/draft-cycles-list.tsx +++ b/apps/app/components/cycles/cycles-list/draft-cycles-list.tsx @@ -21,9 +21,7 @@ export const DraftCyclesList: React.FC = ({ viewType }) => { workspaceSlug && projectId ? DRAFT_CYCLES_LIST(projectId.toString()) : null, workspaceSlug && projectId ? () => - cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), { - cycle_view: "draft", - }) + cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), "draft") : null ); diff --git a/apps/app/components/cycles/cycles-list/upcoming-cycles-list.tsx b/apps/app/components/cycles/cycles-list/upcoming-cycles-list.tsx index 44023e618..140727cb8 100644 --- a/apps/app/components/cycles/cycles-list/upcoming-cycles-list.tsx +++ b/apps/app/components/cycles/cycles-list/upcoming-cycles-list.tsx @@ -21,9 +21,11 @@ export const UpcomingCyclesList: React.FC = ({ viewType }) => { workspaceSlug && projectId ? UPCOMING_CYCLES_LIST(projectId.toString()) : null, workspaceSlug && projectId ? () => - cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), { - cycle_view: "upcoming", - }) + cyclesService.getCyclesWithParams( + workspaceSlug.toString(), + projectId.toString(), + "upcoming" + ) : null ); diff --git a/apps/app/components/cycles/select.tsx b/apps/app/components/cycles/select.tsx index 5a6f00ada..b5ec8a462 100644 --- a/apps/app/components/cycles/select.tsx +++ b/apps/app/components/cycles/select.tsx @@ -38,10 +38,7 @@ export const CycleSelect: React.FC = ({ const { data: cycles } = useSWR( workspaceSlug && projectId ? CYCLES_LIST(projectId) : null, workspaceSlug && projectId - ? () => - cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, { - cycle_view: "all", - }) + ? () => cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, "all") : null ); diff --git a/apps/app/components/cycles/transfer-issues-modal.tsx b/apps/app/components/cycles/transfer-issues-modal.tsx index 30db2f320..6eea69342 100644 --- a/apps/app/components/cycles/transfer-issues-modal.tsx +++ b/apps/app/components/cycles/transfer-issues-modal.tsx @@ -60,9 +60,11 @@ export const TransferIssuesModal: React.FC = ({ isOpen, handleClose }) => workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null, workspaceSlug && projectId ? () => - cyclesService.getCyclesWithParams(workspaceSlug as string, projectId as string, { - cycle_view: "incomplete", - }) + cyclesService.getCyclesWithParams( + workspaceSlug as string, + projectId as string, + "incomplete" + ) : null ); diff --git a/apps/app/components/issues/sidebar-select/cycle.tsx b/apps/app/components/issues/sidebar-select/cycle.tsx index ad112ab52..0d8beaab8 100644 --- a/apps/app/components/issues/sidebar-select/cycle.tsx +++ b/apps/app/components/issues/sidebar-select/cycle.tsx @@ -36,9 +36,11 @@ export const SidebarCycleSelect: React.FC = ({ workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null, workspaceSlug && projectId ? () => - cyclesService.getCyclesWithParams(workspaceSlug as string, projectId as string, { - cycle_view: "incomplete", - }) + cyclesService.getCyclesWithParams( + workspaceSlug as string, + projectId as string, + "incomplete" + ) : null ); diff --git a/apps/app/components/pages/pages-list/all-pages-list.tsx b/apps/app/components/pages/pages-list/all-pages-list.tsx index 67f6135ed..f25d00fd5 100644 --- a/apps/app/components/pages/pages-list/all-pages-list.tsx +++ b/apps/app/components/pages/pages-list/all-pages-list.tsx @@ -18,10 +18,7 @@ export const AllPagesList: React.FC = ({ viewType }) => { const { data: pages } = useSWR( workspaceSlug && projectId ? ALL_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId - ? () => - pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { - page_view: "all", - }) + ? () => pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, "all") : null ); diff --git a/apps/app/components/pages/pages-list/favorite-pages-list.tsx b/apps/app/components/pages/pages-list/favorite-pages-list.tsx index 89ba6d293..2faa4bf72 100644 --- a/apps/app/components/pages/pages-list/favorite-pages-list.tsx +++ b/apps/app/components/pages/pages-list/favorite-pages-list.tsx @@ -19,9 +19,7 @@ export const FavoritePagesList: React.FC = ({ viewType }) => { workspaceSlug && projectId ? FAVORITE_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId ? () => - pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { - page_view: "favorite", - }) + pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, "favorite") : null ); diff --git a/apps/app/components/pages/pages-list/my-pages-list.tsx b/apps/app/components/pages/pages-list/my-pages-list.tsx index d821eb655..c225a0ac5 100644 --- a/apps/app/components/pages/pages-list/my-pages-list.tsx +++ b/apps/app/components/pages/pages-list/my-pages-list.tsx @@ -19,9 +19,11 @@ export const MyPagesList: React.FC = ({ viewType }) => { workspaceSlug && projectId ? MY_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId ? () => - pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { - page_view: "created_by_me", - }) + pagesService.getPagesWithParams( + workspaceSlug as string, + projectId as string, + "created_by_me" + ) : null ); diff --git a/apps/app/components/pages/pages-list/other-pages-list.tsx b/apps/app/components/pages/pages-list/other-pages-list.tsx index dc476408e..64764533f 100644 --- a/apps/app/components/pages/pages-list/other-pages-list.tsx +++ b/apps/app/components/pages/pages-list/other-pages-list.tsx @@ -19,9 +19,11 @@ export const OtherPagesList: React.FC = ({ viewType }) => { workspaceSlug && projectId ? OTHER_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId ? () => - pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { - page_view: "created_by_other", - }) + pagesService.getPagesWithParams( + workspaceSlug as string, + projectId as string, + "created_by_other" + ) : null ); diff --git a/apps/app/pages/[workspaceSlug]/index.tsx b/apps/app/pages/[workspaceSlug]/index.tsx index 6d8f3f9ed..233fd9b8a 100644 --- a/apps/app/pages/[workspaceSlug]/index.tsx +++ b/apps/app/pages/[workspaceSlug]/index.tsx @@ -41,10 +41,12 @@ const WorkspacePage: NextPage = () => { return ( - + {isProductUpdatesModalOpen && ( + + )}
diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx index 08c04a736..087747153 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx @@ -56,10 +56,7 @@ const SingleCycle: React.FC = () => { const { data: cycles } = useSWR( workspaceSlug && projectId ? CYCLES_LIST(projectId as string) : null, workspaceSlug && projectId - ? () => - cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, { - cycle_view: "all", - }) + ? () => cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, "all") : null ); diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx index 0e56ad57e..bac59acc9 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx @@ -73,9 +73,7 @@ const ProjectCycles: NextPage = () => { workspaceSlug && projectId ? CURRENT_CYCLE_LIST(projectId as string) : null, workspaceSlug && projectId ? () => - cycleService.getCyclesWithParams(workspaceSlug as string, projectId as string, { - cycle_view: "current", - }) + cycleService.getCyclesWithParams(workspaceSlug as string, projectId as string, "current") : null ); diff --git a/apps/app/services/cycles.service.ts b/apps/app/services/cycles.service.ts index 4d443a110..d2cb4f5f3 100644 --- a/apps/app/services/cycles.service.ts +++ b/apps/app/services/cycles.service.ts @@ -29,10 +29,12 @@ class ProjectCycleServices extends APIService { async getCyclesWithParams( workspaceSlug: string, projectId: string, - queries: any + cycleType: "all" | "current" | "upcoming" | "draft" | "completed" | "incomplete" ): Promise { return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/`, { - params: queries, + params: { + cycle_view: cycleType, + }, }) .then((response) => response?.data) .catch((error) => { diff --git a/apps/app/services/pages.service.ts b/apps/app/services/pages.service.ts index 72776c29e..5805ac538 100644 --- a/apps/app/services/pages.service.ts +++ b/apps/app/services/pages.service.ts @@ -86,10 +86,12 @@ class PageServices extends APIService { async getPagesWithParams( workspaceSlug: string, projectId: string, - queries: any + pageType: "all" | "favorite" | "created_by_me" | "created_by_other" ): Promise { return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/`, { - params: queries, + params: { + page_view: pageType, + }, }) .then((response) => response?.data) .catch((error) => {