mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-09-07 14:15:45 +00:00
Add rank selection and condition handling to certificate designer and requirements
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { Button, Group, NumberInput, Select, Tooltip } from '@mantine/core';
|
||||
import { IconPlus } from '@tabler/icons-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useLocalized, type LicenseType } from '@ema-platform/api';
|
||||
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;
|
||||
validityMonths: number;
|
||||
onValidityChange: (months: number) => void;
|
||||
currentValidityMonths?: number | null;
|
||||
@@ -22,6 +26,9 @@ export function DesignerToolbar({
|
||||
licenseTypes,
|
||||
typeId,
|
||||
onTypeChange,
|
||||
ranks,
|
||||
rankId,
|
||||
onRankChange,
|
||||
validityMonths,
|
||||
onValidityChange,
|
||||
currentValidityMonths,
|
||||
@@ -49,6 +56,23 @@ export function DesignerToolbar({
|
||||
w={340}
|
||||
/>
|
||||
|
||||
{/* CoC/CoP only — a rank can carry its own design (e.g. Master's
|
||||
certificate differs from an OOW's). "Default" (null) is the design
|
||||
every other rank under the type falls back to. */}
|
||||
{ranks.length > 0 && (
|
||||
<Select
|
||||
label={t('designer.rank', 'Rank')}
|
||||
description={t('designer.rankHint', 'Leave as Default to design for every rank')}
|
||||
data={[
|
||||
{ value: '', label: t('designer.rankDefault', 'Default (all ranks)') },
|
||||
...ranks.map((r) => ({ value: r.id, label: localized(r.name) })),
|
||||
]}
|
||||
value={rankId ?? ''}
|
||||
onChange={(value) => onRankChange(value || null)}
|
||||
w={220}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Validity lives beside the design because it is the other half of
|
||||
what a certificate promises. */}
|
||||
<NumberInput
|
||||
|
||||
Reference in New Issue
Block a user