import { Button, Group, Select, Stack, Text } from '@mantine/core'; import { IconPlus } from '@tabler/icons-react'; import { useTranslation } from 'react-i18next'; import { useLocalized, type LicenseType, type Rank } from '@ema-platform/api'; import { groupedTypeOptions } from '../config/designer'; interface Props { licenseTypes: LicenseType[]; typeId: string | null; onTypeChange: (id: string | null) => void; /** The selected licence type's rank ladder — empty for non-CoC/CoP types. */ ranks: Rank[]; rankId: string | null; onRankChange: (id: string | null) => void; /** Shown for context only; edited on Certificate Requirements → Behaviour. */ validityMonths: number; /** Non-null when the type is configured in days rather than months. */ validityDays?: number | null; canEdit: boolean; onNewVersion: () => void; } /** Licence type, certificate validity, and the entry point for a new version. */ export function DesignerToolbar({ licenseTypes, typeId, onTypeChange, ranks, rankId, onRankChange, validityMonths, validityDays, canEdit, onNewVersion, }: Props) { const { t } = useTranslation(); const localized = useLocalized(); return ( {/* Grouped and searchable because the catalogue is 80+ types, over 50 of them STCW certificates: a flat list buries the CoC/CoP a user is looking for among the logistics operator licences. */} ({ value: r.id, label: localized(r.name) })), ]} value={rankId ?? ''} onChange={(value) => onRankChange(value || null)} w={220} /> )} {/* Read-only here. Validity is one policy decision with the renewal window and the expiry reminders, so it is edited in one place — Certificate Requirements → Behaviour — rather than from two screens behind two different permissions. Still shown, because a designer laying out a certificate that prints an expiry needs to see the term it promises. */} {typeId && ( {t('designer.validity', 'Valid for')} {validityDays != null ? t('designer.validityDays', '{{count}} days', { count: validityDays }) : validityMonths ? t('designer.validityMonths', '{{count}} months', { count: validityMonths, }) : t('designer.validityNone', 'Does not expire')} {t('designer.validityEditedOn', '— set on Certificate Requirements → Behaviour')} )}
); }