From b9e7fd93ae3a5b6f4eb95b6056e433d47bde0264 Mon Sep 17 00:00:00 2001 From: dakshesh14 Date: Mon, 30 Oct 2023 15:26:14 +0530 Subject: [PATCH] fix: reverted to old API response --- web/services/issue/issue_draft.service.ts | 4 +-- web/store/draft-issues/issue.store.ts | 42 +---------------------- web/types/issues.d.ts | 4 --- 3 files changed, 3 insertions(+), 47 deletions(-) diff --git a/web/services/issue/issue_draft.service.ts b/web/services/issue/issue_draft.service.ts index 7565bd58b..519d4ac7b 100644 --- a/web/services/issue/issue_draft.service.ts +++ b/web/services/issue/issue_draft.service.ts @@ -2,14 +2,14 @@ import { APIService } from "services/api.service"; // helpers import { API_BASE_URL } from "helpers/common.helper"; // types -import { IDraftIssueResponse } from "types"; +import { IIssue } from "types"; export class IssueDraftService extends APIService { constructor() { super(API_BASE_URL); } - async getDraftIssues(workspaceSlug: string, projectId: string, params?: any): Promise { + async getDraftIssues(workspaceSlug: string, projectId: string, params?: any): Promise { return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-drafts/`, { params, }) diff --git a/web/store/draft-issues/issue.store.ts b/web/store/draft-issues/issue.store.ts index e095f287f..ebbdb4369 100644 --- a/web/store/draft-issues/issue.store.ts +++ b/web/store/draft-issues/issue.store.ts @@ -33,19 +33,6 @@ export interface IIssueDraftStore { ungrouped: IIssue[]; }; }; - totalIssues: { - [project_id: string]: { - grouped: { - [group_id: string]: number; - }; - groupWithSubGroups: { - [group_id: string]: { - [sub_group_id: string]: number; - }; - }; - ungrouped: number; - }; - }; rootStore: RootStore; // computed @@ -84,7 +71,6 @@ export class IssueDraftStore implements IIssueDraftStore { loader: boolean = false; error: any | null = null; draftIssues: IIssueDraftStore["draftIssues"] = {}; - totalIssues: IIssueDraftStore["totalIssues"] = {}; // service draftIssueService: IssueDraftService; rootStore; @@ -162,15 +148,7 @@ export class IssueDraftStore implements IIssueDraftStore { ...this.draftIssues, [projectId]: { ...this.draftIssues[projectId], - [issueType]: issueResponse.data, - }, - }; - - const _totalIssues = { - ...this.totalIssues, - [projectId]: { - ...this.totalIssues[projectId], - [issueType]: issueResponse.total_issues, + [issueType]: issueResponse, }, }; @@ -178,7 +156,6 @@ export class IssueDraftStore implements IIssueDraftStore { this.loader = false; this.error = null; this.draftIssues = _issues; - this.totalIssues = _totalIssues; }); } @@ -364,7 +341,6 @@ export class IssueDraftStore implements IIssueDraftStore { if (issueType) { let issues = originalIssues?.[projectId]?.[issueType] || null; - let totalIssues = this.totalIssues?.[projectId]?.[issueType] || null; if (!issues) return null; if (issueType === "grouped") { @@ -373,8 +349,6 @@ export class IssueDraftStore implements IIssueDraftStore { ...issues, [group_id]: issues[group_id].filter((i) => i?.id !== issueId), }; - totalIssues = totalIssues as { [group_id: string]: number }; - totalIssues = { ...totalIssues, [group_id]: totalIssues[group_id] - 1 }; } if (issueType === "groupWithSubGroups") { @@ -386,21 +360,11 @@ export class IssueDraftStore implements IIssueDraftStore { [group_id]: issues[sub_group_id][group_id].filter((i) => i?.id !== issueId), }, }; - totalIssues = totalIssues as { [group_id: string]: { [sub_group_id: string]: number } }; - totalIssues = { - ...totalIssues, - [sub_group_id]: { - ...totalIssues[sub_group_id], - [group_id]: totalIssues[sub_group_id][group_id] - 1, - }, - }; } if (issueType === "ungrouped") { issues = issues as IIssueUnGroupedStructure; issues = issues.filter((i) => i?.id !== issueId); - totalIssues = totalIssues as number; - totalIssues = totalIssues - 1; } // optimistic removing draft issue @@ -409,10 +373,6 @@ export class IssueDraftStore implements IIssueDraftStore { ...this.draftIssues, [projectId]: { ...this.draftIssues[projectId], [issueType]: issues }, }; - this.totalIssues = { - ...this.totalIssues, - [projectId]: { ...this.totalIssues[projectId], [issueType]: totalIssues }, - }; }); } diff --git a/web/types/issues.d.ts b/web/types/issues.d.ts index 4790d9b77..cc51ba97f 100644 --- a/web/types/issues.d.ts +++ b/web/types/issues.d.ts @@ -130,10 +130,6 @@ export interface IIssue { workspace_detail: IWorkspaceLite; } -export interface IDraftIssueResponse { - data: IIssue[]; - total_issues: number; -} export interface ISubIssuesState { backlog: number;