From aaaf8eea0e02ffc4bf55cb1bda4e0d8229d82ef1 Mon Sep 17 00:00:00 2001 From: Oscar Date: Thu, 19 Dec 2024 16:51:48 +0100 Subject: [PATCH] Mijn-9853-feature/url naar ma in tf bevestigingsmail van vergunning vakantieverhuur heeft verkeerde themanaam (#1671) * Combine vergunningen en toeristische verhuur in zaakstatus * Change imports * Add identifier attrs * Revert changes and add toeristischeVerhuur to pageRouteResolvers in ZaakStatus.tsx * Handle empty array --- src/client/pages/ZaakStatus/ZaakStatus.tsx | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/client/pages/ZaakStatus/ZaakStatus.tsx b/src/client/pages/ZaakStatus/ZaakStatus.tsx index b7867093a6..0fc8c04b0d 100644 --- a/src/client/pages/ZaakStatus/ZaakStatus.tsx +++ b/src/client/pages/ZaakStatus/ZaakStatus.tsx @@ -20,7 +20,7 @@ import { useAppStateGetter, useAppStateReady } from '../../hooks/useAppState'; const ITEM_NOT_FOUND = 'not-found'; const STATE_ERROR = 'state-error'; -type ThemaQueryParam = 'vergunningen'; +type ThemaQueryParam = 'vergunningen' | 'toeristischeVerhuur'; type PageRouteResolver = { baseRoute: AppRoute; @@ -41,13 +41,34 @@ const pageRouteResolvers: PageRouteResolvers = { } if (!isLoading(appState.VERGUNNINGEN)) { return ( - appState.VERGUNNINGEN.content?.find( + (appState.VERGUNNINGEN.content || []).find( (vergunning) => vergunning.identifier === detailPageItemId )?.link.to ?? ITEM_NOT_FOUND ); } }, }, + toeristischeVerhuur: { + baseRoute: AppRoutes.TOERISTISCHE_VERHUUR, + getRoute: (detailPageItemId, appState) => { + if (isError(appState.TOERISTISCHE_VERHUUR)) { + return STATE_ERROR; + } + + if (!isLoading(appState.TOERISTISCHE_VERHUUR)) { + return ( + ( + appState.TOERISTISCHE_VERHUUR.content + ?.vakantieverhuurVergunningen || [] + ).find((toeristischeVerhuur) => { + if (toeristischeVerhuur.zaaknummer === detailPageItemId) { + return toeristischeVerhuur; + } + })?.link.to ?? ITEM_NOT_FOUND + ); + } + }, + }, }; function useNavigateToPage(queryParams: URLSearchParams) {