Add nonconformity registries
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -16,6 +16,7 @@ export { availableFrameworks } from "./frameworks";
|
||||
export { getDocumentTypeLabel, documentTypes } from "./documents";
|
||||
export { getAssetTypeVariant, getCriticityVariant } from "./assets";
|
||||
export { getAuditStateLabel, getAuditStateVariant, auditStates } from "./audits";
|
||||
export { getStatusVariant, getStatusLabel, getNonconformityRegistryStatusOptions, registryStatuses } from "./registryStatus";
|
||||
export { promisifyMutation } from "./relay";
|
||||
export { fileType, fileSize } from "./file";
|
||||
export { formatDatetime } from "./date";
|
||||
|
||||
46
packages/helpers/src/registryStatus.ts
Normal file
46
packages/helpers/src/registryStatus.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
type Translator = (s: string) => string;
|
||||
|
||||
export type NonconformityRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
|
||||
export const registryStatuses = [
|
||||
"OPEN",
|
||||
"IN_PROGRESS",
|
||||
"CLOSED",
|
||||
] as const;
|
||||
|
||||
export const getStatusVariant = (status: NonconformityRegistryStatus) => {
|
||||
switch (status) {
|
||||
case "OPEN":
|
||||
return "danger" as const;
|
||||
case "IN_PROGRESS":
|
||||
return "warning" as const;
|
||||
case "CLOSED":
|
||||
return "success" as const;
|
||||
default:
|
||||
return "neutral" as const;
|
||||
}
|
||||
};
|
||||
|
||||
export const getStatusLabel = (status: NonconformityRegistryStatus) => {
|
||||
switch (status) {
|
||||
case "OPEN":
|
||||
return "Open";
|
||||
case "IN_PROGRESS":
|
||||
return "In Progress";
|
||||
case "CLOSED":
|
||||
return "Closed";
|
||||
default:
|
||||
return status;
|
||||
}
|
||||
};
|
||||
|
||||
export function getNonconformityRegistryStatusOptions(__: Translator) {
|
||||
return registryStatuses.map((status) => ({
|
||||
value: status,
|
||||
label: __({
|
||||
"OPEN": "Open",
|
||||
"IN_PROGRESS": "In Progress",
|
||||
"CLOSED": "Closed",
|
||||
}[status]),
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user