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
|
// helpers
|
||||||
import { API_BASE_URL } from "helpers/common.helper";
|
import { API_BASE_URL } from "helpers/common.helper";
|
||||||
// types
|
// types
|
||||||
import { IDraftIssueResponse } from "types";
|
import { IIssue } from "types";
|
||||||
|
|
||||||
export class IssueDraftService extends APIService {
|
export class IssueDraftService extends APIService {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(API_BASE_URL);
|
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/`, {
|
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-drafts/`, {
|
||||||
params,
|
params,
|
||||||
})
|
})
|
||||||
|
@ -33,19 +33,6 @@ export interface IIssueDraftStore {
|
|||||||
ungrouped: IIssue[];
|
ungrouped: IIssue[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
totalIssues: {
|
|
||||||
[project_id: string]: {
|
|
||||||
grouped: {
|
|
||||||
[group_id: string]: number;
|
|
||||||
};
|
|
||||||
groupWithSubGroups: {
|
|
||||||
[group_id: string]: {
|
|
||||||
[sub_group_id: string]: number;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
ungrouped: number;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
rootStore: RootStore;
|
rootStore: RootStore;
|
||||||
|
|
||||||
// computed
|
// computed
|
||||||
@ -84,7 +71,6 @@ export class IssueDraftStore implements IIssueDraftStore {
|
|||||||
loader: boolean = false;
|
loader: boolean = false;
|
||||||
error: any | null = null;
|
error: any | null = null;
|
||||||
draftIssues: IIssueDraftStore["draftIssues"] = {};
|
draftIssues: IIssueDraftStore["draftIssues"] = {};
|
||||||
totalIssues: IIssueDraftStore["totalIssues"] = {};
|
|
||||||
// service
|
// service
|
||||||
draftIssueService: IssueDraftService;
|
draftIssueService: IssueDraftService;
|
||||||
rootStore;
|
rootStore;
|
||||||
@ -162,15 +148,7 @@ export class IssueDraftStore implements IIssueDraftStore {
|
|||||||
...this.draftIssues,
|
...this.draftIssues,
|
||||||
[projectId]: {
|
[projectId]: {
|
||||||
...this.draftIssues[projectId],
|
...this.draftIssues[projectId],
|
||||||
[issueType]: issueResponse.data,
|
[issueType]: issueResponse,
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const _totalIssues = {
|
|
||||||
...this.totalIssues,
|
|
||||||
[projectId]: {
|
|
||||||
...this.totalIssues[projectId],
|
|
||||||
[issueType]: issueResponse.total_issues,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -178,7 +156,6 @@ export class IssueDraftStore implements IIssueDraftStore {
|
|||||||
this.loader = false;
|
this.loader = false;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this.draftIssues = _issues;
|
this.draftIssues = _issues;
|
||||||
this.totalIssues = _totalIssues;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,7 +341,6 @@ export class IssueDraftStore implements IIssueDraftStore {
|
|||||||
|
|
||||||
if (issueType) {
|
if (issueType) {
|
||||||
let issues = originalIssues?.[projectId]?.[issueType] || null;
|
let issues = originalIssues?.[projectId]?.[issueType] || null;
|
||||||
let totalIssues = this.totalIssues?.[projectId]?.[issueType] || null;
|
|
||||||
if (!issues) return null;
|
if (!issues) return null;
|
||||||
|
|
||||||
if (issueType === "grouped") {
|
if (issueType === "grouped") {
|
||||||
@ -373,8 +349,6 @@ export class IssueDraftStore implements IIssueDraftStore {
|
|||||||
...issues,
|
...issues,
|
||||||
[group_id]: issues[group_id].filter((i) => i?.id !== issueId),
|
[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") {
|
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),
|
[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") {
|
if (issueType === "ungrouped") {
|
||||||
issues = issues as IIssueUnGroupedStructure;
|
issues = issues as IIssueUnGroupedStructure;
|
||||||
issues = issues.filter((i) => i?.id !== issueId);
|
issues = issues.filter((i) => i?.id !== issueId);
|
||||||
totalIssues = totalIssues as number;
|
|
||||||
totalIssues = totalIssues - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// optimistic removing draft issue
|
// optimistic removing draft issue
|
||||||
@ -409,10 +373,6 @@ export class IssueDraftStore implements IIssueDraftStore {
|
|||||||
...this.draftIssues,
|
...this.draftIssues,
|
||||||
[projectId]: { ...this.draftIssues[projectId], [issueType]: issues },
|
[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;
|
workspace_detail: IWorkspaceLite;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDraftIssueResponse {
|
|
||||||
data: IIssue[];
|
|
||||||
total_issues: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISubIssuesState {
|
export interface ISubIssuesState {
|
||||||
backlog: number;
|
backlog: number;
|
||||||
|
Loading…
Reference in New Issue
Block a user