import { Badge, Group, Paper, Stack, Table, Text } from '@mantine/core'; import { useTranslation } from 'react-i18next'; import { useLocalized, type LicenseType } from '@ema-platform/api'; interface Props { licenseType: LicenseType; } /** * The STCW identity of a certificate type — regulation, level, and the * function and capacity rows a Certificate of Competency prints. * * Read-only for now: these are seeded configuration, and editing them safely * needs the approval workflow the designer guide describes. Showing them * matters regardless — an officer configuring fees or documents has no other * way to see what the certificate will actually claim. */ export function StcwMappingPanel({ licenseType }: Props) { const { t } = useTranslation(); const localized = useLocalized(); if (!licenseType.stcwControlled && !licenseType.certificateCategory) { return null; } const functions = licenseType.stcwFunctions ?? []; const capacities = licenseType.stcwCapacities ?? []; return ( {t('configuration.stcw.title', 'STCW mapping')} {licenseType.certificateCategory && ( {licenseType.certificateCategory} )} {licenseType.stcwControlled && ( {t('configuration.stcw.controlled', 'STCW controlled')} )} {functions.length > 0 && ( {t('configuration.stcw.functions', 'Functions')} {t('configuration.stcw.function', 'Function')} {t('configuration.stcw.level', 'Level')} {t('configuration.stcw.limitation', 'Limitation')} {functions.map((row, i) => ( {localized(row.function)} {row.level} {row.limitation ? localized(row.limitation) : t('configuration.stcw.none', 'None')} ))}
)} {capacities.length > 0 && ( {t('configuration.stcw.capacities', 'Capacities')} {t('configuration.stcw.capacity', 'Capacity')} {t('configuration.stcw.limitation', 'Limitation')} {capacities.map((row, i) => ( {localized(row.capacity)} {row.limitation ? localized(row.limitation) : t('configuration.stcw.none', 'None')} ))}
)} {licenseType.prerequisiteLicenseKeys?.length ? ( {t('configuration.stcw.prerequisites', 'Must already hold')} {licenseType.prerequisiteLicenseKeys.map((key) => ( {key} ))} ) : null}
); } function Field({ label, value }: { label: string; value?: string | null }) { return (
{label} {value || '—'}
); }