mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-09-07 14:15:45 +00:00
Enhance certificate designer and seafarer registration features with image support and dynamic department/rank options
This commit is contained in:
@@ -210,14 +210,22 @@ const OPTION_LABELS: Partial<Record<keyof SeafarerRegistrationAnswers, { value:
|
||||
bloodType: BLOOD_TYPE_OPTIONS,
|
||||
};
|
||||
|
||||
/** Display value for one answer: option label for enums, "—" when blank. */
|
||||
/**
|
||||
* Display value for one answer: option label for enums, "—" when blank.
|
||||
*
|
||||
* `departmentOptions` overrides the hardcoded `DEPARTMENT_OPTIONS` fallback
|
||||
* for the `department` field — the live list from `GET /departments`, so a
|
||||
* department added in the backoffice after this constants file was written
|
||||
* still gets its name instead of falling back to the raw code.
|
||||
*/
|
||||
export function displaySeafarerAnswer(
|
||||
field: keyof SeafarerRegistrationAnswers,
|
||||
value: unknown,
|
||||
departmentOptions?: { value: string; label: string }[],
|
||||
): string {
|
||||
if (value === null || value === undefined || value === '') return '—';
|
||||
if (typeof value === 'boolean') return value ? 'Yes' : 'No';
|
||||
const options = OPTION_LABELS[field];
|
||||
const options = field === 'department' && departmentOptions ? departmentOptions : OPTION_LABELS[field];
|
||||
if (options) return options.find((o) => o.value === value)?.label ?? String(value);
|
||||
return String(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user