mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 07:38:10 +00:00
changes
This commit is contained in:
@@ -24,6 +24,30 @@ export interface RuleEngineReorderPayload {
|
||||
requiresDirectorApproval?: boolean;
|
||||
}
|
||||
|
||||
/** Priority-rule approval workflow (all priority-config changes go through it). */
|
||||
const PRIORITY_RULE_CHANGES_BASE = "/priority-rule-change-requests";
|
||||
|
||||
export interface PriorityRuleChangeRequest {
|
||||
id: string;
|
||||
action: "CREATE" | "UPDATE" | "DELETE";
|
||||
priorityConfigId: string | null;
|
||||
priorityConfig?: RuleEngineRecord | null;
|
||||
payload: Record<string, unknown> | null;
|
||||
status: "PENDING" | "APPROVED" | "REJECTED";
|
||||
requestedByUserId: string | null;
|
||||
decidedByUserId: string | null;
|
||||
decidedAt: string | null;
|
||||
decisionNote: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface SubmitPriorityRuleChangePayload {
|
||||
action: "CREATE" | "UPDATE" | "DELETE";
|
||||
priorityConfigId?: string;
|
||||
create?: Record<string, unknown>;
|
||||
update?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
const RESOURCE_BASE: Record<RuleEngineResourceSlug, string> = {
|
||||
"cargo-types": URL_CONSTANTS.RULE_ENGINE.CARGO_TYPES,
|
||||
"container-types": URL_CONSTANTS.RULE_ENGINE.CONTAINER_TYPES,
|
||||
@@ -242,6 +266,46 @@ export const ruleEngineService = {
|
||||
return normalizeEntity<T>(response.data);
|
||||
},
|
||||
|
||||
/** File a priority-rule change (create/update/delete) for approval. */
|
||||
submitPriorityRuleChange: async (
|
||||
payload: SubmitPriorityRuleChangePayload,
|
||||
): Promise<PriorityRuleChangeRequest> => {
|
||||
const response = await client.post(PRIORITY_RULE_CHANGES_BASE, payload);
|
||||
return unwrap(response.data) as PriorityRuleChangeRequest;
|
||||
},
|
||||
|
||||
listPriorityRuleChanges: async (
|
||||
status?: PriorityRuleChangeRequest["status"],
|
||||
): Promise<PriorityRuleChangeRequest[]> => {
|
||||
const response = await client.get(PRIORITY_RULE_CHANGES_BASE, {
|
||||
params: status ? { status } : undefined,
|
||||
});
|
||||
const body = unwrap(response.data) as unknown;
|
||||
return Array.isArray(body) ? (body as PriorityRuleChangeRequest[]) : [];
|
||||
},
|
||||
|
||||
approvePriorityRuleChange: async (
|
||||
id: string,
|
||||
decisionNote?: string,
|
||||
): Promise<PriorityRuleChangeRequest> => {
|
||||
const response = await client.post(
|
||||
`${PRIORITY_RULE_CHANGES_BASE}/${id}/approve`,
|
||||
{ decisionNote },
|
||||
);
|
||||
return unwrap(response.data) as PriorityRuleChangeRequest;
|
||||
},
|
||||
|
||||
rejectPriorityRuleChange: async (
|
||||
id: string,
|
||||
decisionNote?: string,
|
||||
): Promise<PriorityRuleChangeRequest> => {
|
||||
const response = await client.post(
|
||||
`${PRIORITY_RULE_CHANGES_BASE}/${id}/reject`,
|
||||
{ decisionNote },
|
||||
);
|
||||
return unwrap(response.data) as PriorityRuleChangeRequest;
|
||||
},
|
||||
|
||||
getApprovalChain: async (
|
||||
requiresDirectorApproval = true,
|
||||
): Promise<RuleEngineRecord[]> => {
|
||||
|
||||
Reference in New Issue
Block a user