From 7ab6eb7b487f8db6b5af5784ad8fa17ce0a49571 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Wed, 1 Mar 2023 11:56:14 +0530 Subject: [PATCH] chore: draft cycle services and types --- apps/app/constants/cycle.ts | 5 ----- apps/app/constants/fetch-keys.ts | 1 + apps/app/services/cycles.service.ts | 12 +++++++++++- apps/app/types/cycles.d.ts | 10 +++++++--- 4 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 apps/app/constants/cycle.ts diff --git a/apps/app/constants/cycle.ts b/apps/app/constants/cycle.ts deleted file mode 100644 index 93336fb8c..000000000 --- a/apps/app/constants/cycle.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const CYCLE_STATUS = [ - { label: "Started", value: "started", color: "#5e6ad2" }, - { label: "Completed", value: "completed", color: "#eb5757" }, - { label: "Draft", value: "draft", color: "#f2c94c" }, - ]; \ No newline at end of file diff --git a/apps/app/constants/fetch-keys.ts b/apps/app/constants/fetch-keys.ts index 99dcff81f..42a3c3051 100644 --- a/apps/app/constants/fetch-keys.ts +++ b/apps/app/constants/fetch-keys.ts @@ -36,6 +36,7 @@ export const CYCLE_LIST = (projectId: string) => `CYCLE_LIST_${projectId}`; export const CYCLE_ISSUES = (cycleId: string) => `CYCLE_ISSUES_${cycleId}`; export const CYCLE_DETAILS = (cycleId: string) => `CYCLE_DETAIL_${cycleId}`; export const CYCLE_CURRENT_AND_UPCOMING_LIST = (projectId: string) => `CYCLE_CURRENT_AND_UPCOMING_LIST_${projectId}`; +export const CYCLE_DRAFT_LIST = (projectId: string) => `CYCLE_DRAFT_LIST_${projectId}`; export const CYCLE_COMPLETE_LIST = (projectId: string) => `CYCLE_COMPLETE_LIST_${projectId}`; export const STATE_LIST = (projectId: string) => `STATE_LIST_${projectId}`; diff --git a/apps/app/services/cycles.service.ts b/apps/app/services/cycles.service.ts index 42f2f21ae..eac138030 100644 --- a/apps/app/services/cycles.service.ts +++ b/apps/app/services/cycles.service.ts @@ -1,7 +1,7 @@ // services import APIService from "services/api.service"; // types -import type { CompletedCyclesResponse, CurrentAndUpcomingCyclesResponse, ICycle } from "types"; +import type { CompletedCyclesResponse, CurrentAndUpcomingCyclesResponse, DraftCyclesResponse, ICycle } from "types"; const { NEXT_PUBLIC_API_BASE_URL } = process.env; @@ -109,6 +109,16 @@ class ProjectCycleServices extends APIService { }); } + async getDraftCycles(workspaceSlug: string, projectId: string): Promise { + return this.get( + `/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/draft-cycles/` + ) + .then((response) => response?.data) + .catch((error) => { + throw error?.response?.data; + }); + } + async getCompletedCycles(workspaceSlug: string, projectId: string): Promise { return this.get( `/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/completed-cycles/` diff --git a/apps/app/types/cycles.d.ts b/apps/app/types/cycles.d.ts index 060fe53f3..928166a32 100644 --- a/apps/app/types/cycles.d.ts +++ b/apps/app/types/cycles.d.ts @@ -7,9 +7,8 @@ export interface ICycle { updated_at: Date; name: string; description: string; - start_date: string; - end_date: string; - status: string; + start_date: string | null; + end_date: string | null; created_by: string; updated_by: string; project: string; @@ -25,6 +24,11 @@ export interface CurrentAndUpcomingCyclesResponse { upcoming_cycle : ICycle[]; } + +export interface DraftCyclesResponse { + draft_cycles : ICycle[]; + } + export interface CompletedCyclesResponse { completed_cycles : ICycle[]; }