Update obligations

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-09-23 14:02:18 +02:00
parent c54051dd8a
commit 98d7e7b7b9
39 changed files with 3746 additions and 394 deletions

View File

@@ -19,6 +19,7 @@ export { getAssetTypeVariant, getCriticityVariant } from "./assets";
export { getSnapshotTypeLabel, getSnapshotTypeUrlPath, snapshotTypes, validateSnapshotConsistency } from "./snapshots";
export { getAuditStateLabel, getAuditStateVariant, auditStates } from "./audits";
export { getStatusVariant, getStatusLabel, getStatusOptions } from "./registryStatus";
export { getObligationStatusVariant, getObligationStatusLabel, getObligationStatusOptions } from "./obligationStatus";
export { promisifyMutation } from "./relay";
export { fileType, fileSize } from "./file";
export { formatDatetime, formatDate } from "./date";

View File

@@ -0,0 +1,46 @@
type Translator = (s: string) => string;
export type ObligationStatus = "NON_COMPLIANT" | "PARTIALLY_COMPLIANT" | "COMPLIANT";
export const obligationStatuses = [
"NON_COMPLIANT",
"PARTIALLY_COMPLIANT",
"COMPLIANT",
] as const;
export const getObligationStatusVariant = (status: ObligationStatus) => {
switch (status) {
case "NON_COMPLIANT":
return "danger" as const;
case "PARTIALLY_COMPLIANT":
return "warning" as const;
case "COMPLIANT":
return "success" as const;
default:
return "neutral" as const;
}
};
export const getObligationStatusLabel = (status: ObligationStatus) => {
switch (status) {
case "NON_COMPLIANT":
return "Non-compliant";
case "PARTIALLY_COMPLIANT":
return "Partially compliant";
case "COMPLIANT":
return "Compliant";
default:
return status;
}
};
export function getObligationStatusOptions(__: Translator) {
return obligationStatuses.map((status) => ({
value: status,
label: __({
"NON_COMPLIANT": "Non-compliant",
"PARTIALLY_COMPLIANT": "Partially compliant",
"COMPLIANT": "Compliant",
}[status]),
}));
}