mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
feat: consolidate CoC and GOC endorsement workflows into a new ENDORSEMENT_SEAFARER type and add anyOf support to conditional form field logic.
This commit is contained in:
@@ -3,6 +3,7 @@ import { resolveTokenFromStorage } from '../../session';
|
||||
import type {
|
||||
Bilingual,
|
||||
FamilyKind,
|
||||
FieldCondition,
|
||||
FormFieldConfig,
|
||||
FormSectionConfig,
|
||||
LicenseApplication,
|
||||
@@ -179,6 +180,7 @@ export const APPLICANT_NAME_TYPE_KEYS = [
|
||||
'CERTIFICATE_OF_PROFICIENCY',
|
||||
'VESSEL_REGISTRATION',
|
||||
'VESSEL_OWNERSHIP_TRANSFER',
|
||||
'ENDORSEMENT_SEAFARER',
|
||||
'ENDORSEMENT_COC',
|
||||
'ENDORSEMENT_GOC',
|
||||
];
|
||||
@@ -190,6 +192,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',
|
||||
@@ -557,7 +560,14 @@ 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;
|
||||
@@ -569,7 +579,7 @@ interface ConditionLike {
|
||||
}
|
||||
|
||||
export function conditionHolds(
|
||||
condition: ConditionLike | undefined | null,
|
||||
condition: FieldCondition | undefined | null,
|
||||
formData: Record<string, Record<string, unknown>>,
|
||||
): boolean {
|
||||
if (!condition) return true;
|
||||
|
||||
@@ -67,6 +67,8 @@ export type FormFieldType =
|
||||
| "TIN";
|
||||
|
||||
export interface FieldCondition {
|
||||
/** Omitted when `anyOf` is used instead — see below. */
|
||||
field?: string;
|
||||
/** Omitted when `anyOf` is used instead — see below. */
|
||||
field?: string;
|
||||
equals?: string | number | boolean;
|
||||
@@ -74,9 +76,9 @@ export interface FieldCondition {
|
||||
in?: (string | number)[];
|
||||
isSet?: boolean;
|
||||
/**
|
||||
* Holds when ANY listed condition holds — for a value that can live on one
|
||||
* of several mutually-exclusive fields (e.g. a rank split by department).
|
||||
* `field`/`equals`/etc are ignored when this is present.
|
||||
* Alternative to a single-field check: holds when ANY listed condition
|
||||
* holds. `field`/`equals`/etc are ignored when this is present. Mirrors
|
||||
* the server's `FieldCondition` (form-schema.type.ts).
|
||||
*/
|
||||
anyOf?: FieldCondition[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user