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