ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: source-side принятие и возврат внешнего запроса

This commit is contained in:
DCCONSTRUCTIONS
2026-04-19 00:29:23 +03:00
parent 3fe3539614
commit 8195c3fc80
17 changed files with 366 additions and 23 deletions
@@ -76,4 +76,19 @@ export class ExternalContourService extends APIService {
throw error?.response?.data;
});
}
async decide(
workspaceSlug: string,
projectId: string,
requestId: string,
action: "accept" | "decline"
): Promise<TExternalContourRequest> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/external-contours/${requestId}/decision/`, {
action,
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}
@@ -34,6 +34,12 @@ export interface IProjectExternalContoursStore {
projectId: string,
data: Partial<TIssue> & { target_project_id?: string | null }
) => Promise<TExternalContourRequest | undefined>;
decideRequest: (
workspaceSlug: string,
projectId: string,
requestId: string,
action: "accept" | "decline"
) => Promise<TExternalContourRequest | undefined>;
fetchTargetProjects: (workspaceSlug: string, projectId: string) => Promise<void>;
fetchTargetOptions: (workspaceSlug: string, projectId: string, targetProjectId: string) => Promise<TExternalContourTargetOptions | undefined>;
fetchRequestById: (workspaceSlug: string, projectId: string, requestId: string) => Promise<TExternalContourRequest | undefined>;
@@ -82,6 +88,7 @@ export class ProjectExternalContoursStore implements IProjectExternalContoursSto
fetchRequests: action,
fetchRequestById: action,
createRequest: action,
decideRequest: action,
handleCurrentTab: action,
upsertRequests: action,
updateRequestIssue: action,
@@ -220,6 +227,28 @@ export class ProjectExternalContoursStore implements IProjectExternalContoursSto
}
};
decideRequest = async (
workspaceSlug: string,
projectId: string,
requestId: string,
action: "accept" | "decline"
) => {
this.loader = "mutation-loading";
try {
const request = await this.externalContourService.decide(workspaceSlug, projectId, requestId, action);
runInAction(() => {
this.upsertRequests([request]);
this.loader = undefined;
});
return request;
} catch (error) {
runInAction(() => {
this.loader = undefined;
});
throw error;
}
};
updateRequestIssue = (requestId: string, issueData: Partial<TExternalContourRequest["issue"]>) => {
if (!this.requests[requestId]) return;
const nextStatus =