Skip to content

Commit

Permalink
Revert changes and add toeristischeVerhuur to pageRouteResolvers in Z…
Browse files Browse the repository at this point in the history
…aakStatus.tsx
  • Loading branch information
OscarBakker committed Dec 19, 2024
1 parent ca9b5e1 commit ca34a7f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
45 changes: 25 additions & 20 deletions src/client/pages/ZaakStatus/ZaakStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,34 +36,39 @@ const pageRouteResolvers: PageRouteResolvers = {
vergunningen: {
baseRoute: AppRoutes.VERGUNNINGEN,
getRoute: (detailPageItemId, appState) => {
if (
isError(appState.VERGUNNINGEN) ||
isError(appState.TOERISTISCHE_VERHUUR)
) {
if (isError(appState.VERGUNNINGEN)) {
return STATE_ERROR;
}
if (
!isLoading(appState.VERGUNNINGEN) &&
!isLoading(appState.TOERISTISCHE_VERHUUR)
) {
// Combine the toeristische verhuur vergunningen with the other vergunningen
const toeristischeVerhuurVergunningen = [
...Object.values(appState.TOERISTISCHE_VERHUUR.content || {}).flat(),
];

const combined = [
...toeristischeVerhuurVergunningen,
...(appState.VERGUNNINGEN.content || []),
];

if (!isLoading(appState.VERGUNNINGEN)) {
return (
combined?.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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export interface BBVergunning extends ZaakDetail {
result: BBVergunningZaakResult;
status: BBVergunningZaakStatus | BBVergunningZaakResult;
zaaknummer: string;
identifier: string;
documents: GenericDocument[];
title: 'Vergunning bed & breakfast';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ function transformZaak(zaak: PBZaakRecord): BBVergunning {
dateEndFormatted: dateEnd ? defaultDateFormat(dateEnd) : '-',
result,
id,
identifier: pbZaak.zaaknummer ?? zaak.id,
zaaknummer: pbZaak.zaaknummer ?? zaak.id,
link: {
to: generatePath(AppRoutes['TOERISTISCHE_VERHUUR/VERGUNNING'], {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export interface LVVRegistratie {
registrationNumber: string;
agreementDate: string | null;
agreementDateFormatted: string | null;
identifier?: string;
}

export interface LVVRegistratiesSourceData {
Expand All @@ -53,7 +52,6 @@ export interface VakantieverhuurVergunning extends ZaakDetail {
status: string;
title: 'Vergunning vakantieverhuur';
zaaknummer: string;
identifier: string;
}

export type ToeristischeVerhuurVergunning =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export function transformVakantieverhuurVergunningen(
adres: vergunning.location ?? '-',
result: vergunning.decision as VakantieverhuurVergunning['result'],
zaaknummer: vergunning.identifier,
identifier: vergunning.identifier,
steps,
documents: [],
fetchDocumentsUrl: vergunning.documentsUrl,
Expand Down Expand Up @@ -172,7 +171,7 @@ export async function fetchVakantieverhuurVergunningen(
id: ':id',
});
default:
return AppRoutes.TOERISTISCHE_VERHUUR;
return AppRoutes['TOERISTISCHE_VERHUUR'];
}
},
filter: (vergunning): vergunning is VakantieverhuurVergunningDecos =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ describe('Toeristische verhuur service', () => {
result: 'Verleend',
id: 'Z-23-2130506',
zaaknummer: 'Z/23/2130506',
identifier: 'Z/23/2130506',
heeftOvergangsRecht: false,
link: {
to: '/toeristische-verhuur/vergunning/bed-and-breakfast/Z-23-2130506',
Expand Down

0 comments on commit ca34a7f

Please sign in to comment.