chore: cycles endpoint updated and code refactor (#1135)

* chore: cycles endpoint updated and code refactor

* chore: incomplete cycle endpoint updated

* chore: code refactor
This commit is contained in:
Anmol Singh Bhatia
2023-05-26 15:38:56 +05:30
committed by GitHub
parent 4ce0ac6ea1
commit 394f0bf555
15 changed files with 226 additions and 462 deletions

View File

@@ -3,15 +3,7 @@ import APIService from "services/api.service";
import trackEventServices from "services/track-event.service";
// types
import type {
CycleIssueResponse,
CompletedCyclesResponse,
CurrentAndUpcomingCyclesResponse,
DraftCyclesResponse,
ICycle,
IIssue,
IIssueViewOptions,
} from "types";
import type { ICycle, IIssue, IIssueViewOptions } from "types";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
@@ -34,16 +26,14 @@ class ProjectCycleServices extends APIService {
});
}
async getCycles(workspaceSlug: string, projectId: string): Promise<ICycle[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getIncompleteCycles(workspaceSlug: string, projectId: string): Promise<ICycle[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/incomplete-cycles/`)
async getCyclesWithParams(
workspaceSlug: string,
projectId: string,
queries: any
): Promise<ICycle[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/`, {
params: queries,
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
@@ -159,40 +149,6 @@ class ProjectCycleServices extends APIService {
});
}
async getCurrentAndUpcomingCycles(
workspaceSlug: string,
projectId: string
): Promise<CurrentAndUpcomingCyclesResponse> {
return this.get(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/current-upcoming-cycles/`
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getDraftCycles(workspaceSlug: string, projectId: string): Promise<DraftCyclesResponse> {
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<CompletedCyclesResponse> {
return this.get(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/completed-cycles/`
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async addCycleToFavorites(
workspaceSlug: string,
projectId: string,