69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
export type SafetyActionFeedbackTone = "success" | "warning" | "error";
|
|
|
|
export interface SafetyActionFeedbackLink {
|
|
label: string;
|
|
href: string;
|
|
}
|
|
|
|
export interface SafetyActionFeedback {
|
|
tone: SafetyActionFeedbackTone;
|
|
title: string;
|
|
description: string;
|
|
links: SafetyActionFeedbackLink[];
|
|
}
|
|
|
|
export interface SafetyPlanResult {
|
|
success: boolean;
|
|
status: string;
|
|
href?: string;
|
|
executable?: boolean;
|
|
planId?: string | null;
|
|
}
|
|
|
|
export const buildSafetyStateFeedback = (
|
|
kind: "finding" | "recommendation",
|
|
id: string,
|
|
status: string,
|
|
): SafetyActionFeedback => ({
|
|
tone: "success",
|
|
title: kind === "finding" ? "Finding status bijgewerkt" : "Recommendation verborgen",
|
|
description: `${id} staat nu op ${status}. Dit is metadata-only governance; er is geen externe connectoractie uitgevoerd.`,
|
|
links: [
|
|
{ label: "Open audit", href: `/audit?query=${encodeURIComponent(id)}` },
|
|
{ label: "Refresh safety", href: "/safety" },
|
|
],
|
|
});
|
|
|
|
export const buildSafetyPlanFeedback = (
|
|
recommendationId: string,
|
|
result: SafetyPlanResult,
|
|
): SafetyActionFeedback => {
|
|
if (!result.success) {
|
|
return {
|
|
tone: "error",
|
|
title: "Remediation plan niet aangemaakt",
|
|
description: `${recommendationId} kon niet naar een niet-uitvoerend remediation plan worden omgezet.`,
|
|
links: [{ label: "Open planner", href: "/ai/remediation-planner" }],
|
|
};
|
|
}
|
|
|
|
return {
|
|
tone: result.executable ? "warning" : "success",
|
|
title: "Remediation plan gekoppeld",
|
|
description: result.executable
|
|
? "Plan is aangemaakt. Controleer execution-instellingen voordat je iets uitvoert."
|
|
: "Plan is aangemaakt als niet-uitvoerend advies. Er zijn geen connector-, policy- of infrastructuurmutaties uitgevoerd.",
|
|
links: [
|
|
{ label: "Open plan", href: result.href || "/ai/remediation-planner" },
|
|
{ label: "Open audit", href: `/audit?query=${encodeURIComponent(result.planId || recommendationId)}` },
|
|
],
|
|
};
|
|
};
|
|
|
|
export const buildSafetyActionErrorFeedback = (label: string, error: unknown): SafetyActionFeedback => ({
|
|
tone: "error",
|
|
title: `${label} mislukt`,
|
|
description: error instanceof Error ? error.message : "Safety actie kon niet worden verwerkt.",
|
|
links: [{ label: "Open audit", href: "/audit" }],
|
|
});
|