From cfd97041b85efaf6a3e177061a2c213176d2a9ed Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Wed, 29 Mar 2023 19:21:15 +0530 Subject: [PATCH] feat: incomplete cycle endpoint added , issue sidebar cycle fix (#582) * feat: incomplete cycle endpoint added , issue sidebar cycle fix * fix: fetch key --- .../components/issues/sidebar-select/cycle.tsx | 16 ++++++++-------- apps/app/constants/fetch-keys.ts | 1 + apps/app/services/cycles.service.ts | 8 ++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/app/components/issues/sidebar-select/cycle.tsx b/apps/app/components/issues/sidebar-select/cycle.tsx index 4738aedd6..4dcf16f77 100644 --- a/apps/app/components/issues/sidebar-select/cycle.tsx +++ b/apps/app/components/issues/sidebar-select/cycle.tsx @@ -14,7 +14,7 @@ import { CyclesIcon } from "components/icons"; // types import { ICycle, IIssue, UserAuth } from "types"; // fetch-keys -import { CYCLE_ISSUES, CYCLE_LIST, ISSUE_DETAILS } from "constants/fetch-keys"; +import { CYCLE_ISSUES, CYCLE_INCOMPLETE_LIST, ISSUE_DETAILS } from "constants/fetch-keys"; type Props = { issueDetail: IIssue | undefined; @@ -30,10 +30,10 @@ export const SidebarCycleSelect: React.FC = ({ const router = useRouter(); const { workspaceSlug, projectId, issueId } = router.query; - const { data: cycles } = useSWR( - workspaceSlug && projectId ? CYCLE_LIST(projectId as string) : null, + const { data: incompleteCycles } = useSWR( + workspaceSlug && projectId ? CYCLE_INCOMPLETE_LIST(projectId as string) : null, workspaceSlug && projectId - ? () => cyclesService.getCycles(workspaceSlug as string, projectId as string) + ? () => cyclesService.getIncompleteCycles(workspaceSlug as string, projectId as string) : null ); @@ -77,16 +77,16 @@ export const SidebarCycleSelect: React.FC = ({ onChange={(value: any) => { !value ? removeIssueFromCycle(issueCycle?.id ?? "", issueCycle?.cycle ?? "") - : handleCycleChange(cycles?.find((c) => c.id === value) as ICycle); + : handleCycleChange(incompleteCycles?.find((c) => c.id === value) as ICycle); }} width="w-full" position="right" disabled={isNotAllowed} > - {cycles ? ( - cycles.length > 0 ? ( + {incompleteCycles ? ( + incompleteCycles.length > 0 ? ( <> - {cycles.map((option) => ( + {incompleteCycles.map((option) => ( {option.name} diff --git a/apps/app/constants/fetch-keys.ts b/apps/app/constants/fetch-keys.ts index be3895670..0da34739d 100644 --- a/apps/app/constants/fetch-keys.ts +++ b/apps/app/constants/fetch-keys.ts @@ -72,6 +72,7 @@ export const PROJECT_GITHUB_REPOSITORY = (projectId: string) => `PROJECT_GITHUB_REPOSITORY_${projectId.toUpperCase()}`; export const CYCLE_LIST = (projectId: string) => `CYCLE_LIST_${projectId.toUpperCase()}`; +export const CYCLE_INCOMPLETE_LIST = (projectId: string) => `CYCLE_INCOMPLETE_LIST_${projectId.toUpperCase()}`; export const CYCLE_ISSUES = (cycleId: string) => `CYCLE_ISSUES_${cycleId.toUpperCase()}`; export const CYCLE_ISSUES_WITH_PARAMS = (cycleId: string, params?: any) => { if (!params) return `CYCLE_ISSUES_WITH_PARAMS_${cycleId.toUpperCase()}`; diff --git a/apps/app/services/cycles.service.ts b/apps/app/services/cycles.service.ts index 75ffe8e98..12d4ae0e9 100644 --- a/apps/app/services/cycles.service.ts +++ b/apps/app/services/cycles.service.ts @@ -42,6 +42,14 @@ class ProjectCycleServices extends APIService { }); } + async getIncompleteCycles(workspaceSlug: string, projectId: string): Promise { + return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/incomplete-cycles/`) + .then((response) => response?.data) + .catch((error) => { + throw error?.response?.data; + }); + } + async getCycleDetails( workspaceSlug: string, projectId: string,