Update obligations
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -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";
|
||||
|
||||
46
packages/helpers/src/obligationStatus.ts
Normal file
46
packages/helpers/src/obligationStatus.ts
Normal 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]),
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user