mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-29 17:38:14 +00:00
Merge branch 'WorkflowChange' into logestic_chnage
This commit is contained in:
@@ -3,6 +3,7 @@ import { resolveTokenFromStorage } from '../../session';
|
||||
import type {
|
||||
Bilingual,
|
||||
FamilyKind,
|
||||
FieldCondition,
|
||||
FormFieldConfig,
|
||||
FormSectionConfig,
|
||||
LicenseApplication,
|
||||
@@ -68,6 +69,7 @@ export const STATUS_LABELS: Record<LicenseStatus, string> = {
|
||||
REVIEW_REPORTED: 'Review Reported',
|
||||
INSPECTION_COMPLETED: 'Inspection Completed',
|
||||
INSPECTION_REPORTED: 'Inspection Reported',
|
||||
INSPECTION_FAILED: 'Inspection Failed',
|
||||
APPROVED: 'Approved',
|
||||
REJECTED: 'Rejected',
|
||||
ON_HOLD: 'On Hold',
|
||||
@@ -99,6 +101,8 @@ export const STATUS_COLORS: Record<LicenseStatus, string> = {
|
||||
REVIEW_REPORTED: 'orange',
|
||||
INSPECTION_COMPLETED: 'cyan',
|
||||
INSPECTION_REPORTED: 'orange',
|
||||
// Orange, not red: recoverable — a re-inspection can still pass.
|
||||
INSPECTION_FAILED: 'orange',
|
||||
APPROVED: 'teal',
|
||||
REJECTED: 'red',
|
||||
ON_HOLD: 'gray',
|
||||
@@ -134,6 +138,8 @@ export const STATUS_PROGRESS: Record<LicenseStatus, number> = {
|
||||
REVIEW_REPORTED: 50,
|
||||
INSPECTION_COMPLETED: 65,
|
||||
INSPECTION_REPORTED: 70,
|
||||
// A re-inspection returns to the pending step, so no further along than it.
|
||||
INSPECTION_FAILED: 55,
|
||||
APPROVED: 75,
|
||||
// Parked, so it keeps the progress of wherever it was held from.
|
||||
ON_HOLD: 45,
|
||||
@@ -187,6 +193,7 @@ export const APPLICANT_NAME_TYPE_KEYS = [
|
||||
'CERTIFICATE_OF_PROFICIENCY',
|
||||
'VESSEL_REGISTRATION',
|
||||
'VESSEL_OWNERSHIP_TRANSFER',
|
||||
'ENDORSEMENT_SEAFARER',
|
||||
'ENDORSEMENT_COC',
|
||||
'ENDORSEMENT_GOC',
|
||||
];
|
||||
@@ -198,6 +205,7 @@ const FAMILY_KIND_BY_KEY: Partial<Record<string, FamilyKind>> = {
|
||||
BTC_BASIC_TRAINING: 'CERTIFICATE',
|
||||
CERTIFICATE_OF_COMPETENCY: 'CERTIFICATE',
|
||||
CERTIFICATE_OF_PROFICIENCY: 'CERTIFICATE',
|
||||
ENDORSEMENT_SEAFARER: 'CERTIFICATE',
|
||||
ENDORSEMENT_COC: 'CERTIFICATE',
|
||||
ENDORSEMENT_GOC: 'CERTIFICATE',
|
||||
FREIGHT_FORWARDER: 'LOGISTICS_LICENSE',
|
||||
@@ -381,6 +389,10 @@ const ERROR_MESSAGES: Record<string, string> = {
|
||||
application_not_awaiting_inspection:
|
||||
'This application is not waiting for an inspection.',
|
||||
inspection_already_completed: 'This inspection has already been recorded.',
|
||||
inspection_not_yet_due:
|
||||
'Inspection results can be recorded after the scheduled inspection date and time.',
|
||||
inspection_not_passed:
|
||||
'Approval requires a passed inspection. Schedule a re-inspection or request corrections.',
|
||||
license_type_inactive: 'This licence type is not currently accepting applications.',
|
||||
};
|
||||
|
||||
@@ -565,15 +577,33 @@ export function validateSections(
|
||||
return errors;
|
||||
}
|
||||
|
||||
/** Evaluates a config condition against the current form answers. */
|
||||
/**
|
||||
* Evaluates a config condition against the current form answers.
|
||||
*
|
||||
* Mirrors the server's `ApplicationValidationService.conditionHolds` —
|
||||
* `anyOf` holds when any listed sub-condition holds, needed for an answer
|
||||
* that can live on one of several mutually-exclusive fields (e.g. a CoP rank
|
||||
* split by department).
|
||||
*/
|
||||
interface ConditionLike {
|
||||
field?: string;
|
||||
equals?: unknown;
|
||||
notEquals?: unknown;
|
||||
in?: (string | number)[];
|
||||
isSet?: boolean;
|
||||
/** Holds when ANY listed sub-condition holds — see FieldCondition.anyOf. */
|
||||
anyOf?: ConditionLike[];
|
||||
}
|
||||
|
||||
export function conditionHolds(
|
||||
condition:
|
||||
| { field: string; equals?: unknown; notEquals?: unknown; in?: (string | number)[]; isSet?: boolean }
|
||||
| undefined
|
||||
| null,
|
||||
condition: FieldCondition | undefined | null,
|
||||
formData: Record<string, Record<string, unknown>>,
|
||||
): boolean {
|
||||
if (!condition?.field) return true;
|
||||
if (!condition) return true;
|
||||
if (condition.anyOf) {
|
||||
return condition.anyOf.some((sub) => conditionHolds(sub, formData));
|
||||
}
|
||||
if (!condition.field) return true;
|
||||
const value = condition.field
|
||||
.split('.')
|
||||
.reduce<unknown>(
|
||||
|
||||
Reference in New Issue
Block a user