From a84177cf121aec7f9a7b5ea7b8a64532c4728bb9 Mon Sep 17 00:00:00 2001 From: Nati Date: Mon, 24 Aug 2026 07:49:10 +0000 Subject: [PATCH] Fix --- .../pages/CertificateDesignerPage.tsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/backoffice/src/app/features/certificate-designer/pages/CertificateDesignerPage.tsx b/apps/backoffice/src/app/features/certificate-designer/pages/CertificateDesignerPage.tsx index 421e815ad..bcde60efc 100644 --- a/apps/backoffice/src/app/features/certificate-designer/pages/CertificateDesignerPage.tsx +++ b/apps/backoffice/src/app/features/certificate-designer/pages/CertificateDesignerPage.tsx @@ -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(() => {