forked from github/plane
fix: reverted to old API response
This commit is contained in:
parent
308e6781a1
commit
b9e7fd93ae
@ -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<IDraftIssueResponse> {
|
||||
async getDraftIssues(workspaceSlug: string, projectId: string, params?: any): Promise<IIssue> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-drafts/`, {
|
||||
params,
|
||||
})
|
||||
|
@ -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 },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
4
web/types/issues.d.ts
vendored
4
web/types/issues.d.ts
vendored
@ -130,10 +130,6 @@ export interface IIssue {
|
||||
workspace_detail: IWorkspaceLite;
|
||||
}
|
||||
|
||||
export interface IDraftIssueResponse {
|
||||
data: IIssue[];
|
||||
total_issues: number;
|
||||
}
|
||||
|
||||
export interface ISubIssuesState {
|
||||
backlog: number;
|
||||
|
Loading…
Reference in New Issue
Block a user