mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 13:02:50 +00:00
Fix for rank selection
This commit is contained in:
@@ -102,16 +102,24 @@ export function CertificateDesignerPage() {
|
||||
const selectedType = licenseTypes?.items?.find((type) => type.id === typeId);
|
||||
|
||||
// A rank ladder only exists for CoC/CoP — every other licence type designs
|
||||
// one certificate for everyone who holds it. CoC/CoP are each a single
|
||||
// LicenseType spanning every department's ladder (stcwDepartment is null
|
||||
// on both — the applicant's own department, not the type, decides which
|
||||
// ladder they climb), so the picker offers every rank in the category
|
||||
// across all departments rather than one department's ladder.
|
||||
const isRankScoped =
|
||||
selectedType?.certificateCategory === 'COC' || selectedType?.certificateCategory === 'COP';
|
||||
// one certificate for everyone who holds it. Keyed on `key`, not
|
||||
// `certificateCategory`: that STCW-mapping column is unset on the seeded
|
||||
// CoC/CoP rows (it's authored later, per StcwMappingPanel), while `key` is
|
||||
// the stable identity CertificateEligibilityService itself branches on.
|
||||
// CoC/CoP are each a single LicenseType spanning every department's ladder
|
||||
// (the applicant's own department, not the type, decides which ladder they
|
||||
// climb), so the picker offers every rank in the ladder across all
|
||||
// departments rather than one department's.
|
||||
const rankCategory: 'COC' | 'COP' | null =
|
||||
selectedType?.key === 'CERTIFICATE_OF_COMPETENCY'
|
||||
? 'COC'
|
||||
: selectedType?.key === 'CERTIFICATE_OF_PROFICIENCY'
|
||||
? 'COP'
|
||||
: null;
|
||||
const isRankScoped = rankCategory !== null;
|
||||
const { data: allRanks } = useGetRanksQuery(undefined, { skip: !isRankScoped });
|
||||
const ranks = (allRanks?.items ?? [])
|
||||
.filter((r) => r.certificateCategory === selectedType?.certificateCategory)
|
||||
.filter((r) => r.certificateCategory === rankCategory)
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder);
|
||||
|
||||
// Default to the first licence type so the page is never an empty shell.
|
||||
|
||||
Reference in New Issue
Block a user