mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
Fix
This commit is contained in:
@@ -23,11 +23,10 @@ import {
|
||||
useArchiveLicenseTemplateMutation,
|
||||
useCreateLicenseTemplateMutation,
|
||||
useDeleteLicenseTemplateMutation,
|
||||
useGetActiveDepartmentsQuery,
|
||||
useGetBuiltInTemplateQuery,
|
||||
useGetLicenseTemplatesQuery,
|
||||
useGetLicenseTypesQuery,
|
||||
useGetRankLadderQuery,
|
||||
useGetRanksQuery,
|
||||
useGetTemplateVariablesQuery,
|
||||
usePublishLicenseTemplateMutation,
|
||||
useUpdateLicenseValidityMutation,
|
||||
@@ -103,18 +102,17 @@ 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.
|
||||
// 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';
|
||||
const { data: departments } = useGetActiveDepartmentsQuery(undefined, { skip: !isRankScoped });
|
||||
const department = departments?.find((d) => d.code === selectedType?.stcwDepartment);
|
||||
const { data: ranks = [] } = useGetRankLadderQuery(
|
||||
{
|
||||
departmentId: department?.id ?? '',
|
||||
certificateCategory: (selectedType?.certificateCategory ?? 'COC') as 'COC' | 'COP',
|
||||
},
|
||||
{ skip: !isRankScoped || !department },
|
||||
);
|
||||
const { data: allRanks } = useGetRanksQuery(undefined, { skip: !isRankScoped });
|
||||
const ranks = (allRanks?.items ?? [])
|
||||
.filter((r) => r.certificateCategory === selectedType?.certificateCategory)
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder);
|
||||
|
||||
// Default to the first licence type so the page is never an empty shell.
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user