Skip to content

Commit fa64549

Browse files
committed
👌 [#234] PR Feedback
1 parent fa14e34 commit fa64549

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

frontend/src/lib/api/private.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ export type ZaaktypeChoice = Option & {
1010
extra: string;
1111
};
1212

13-
export type ZaaktypeChoicesQueryParam = {
14-
destructionList?: DestructionList["uuid"];
15-
review?: Review["pk"];
16-
};
17-
1813
/**
1914
* This takes the 'selectielijstprocestype' from the 'zaaktype', then retrieves all the 'resultaten' possible for this
2015
* 'procestype' from the selectielijst API.
@@ -40,9 +35,18 @@ export async function listSelectieLijstKlasseChoices(
4035
* an the value is the URL. The response is cached for 15 minutes.
4136
*/
4237
export async function listZaaktypeChoices(
43-
zaaktypeChoicesQueryParam?: ZaaktypeChoicesQueryParam,
38+
destructionListUuid?: DestructionList["uuid"],
39+
reviewPk?: Review["pk"],
4440
) {
45-
const params = zaaktypeChoicesQueryParam || undefined;
41+
let params;
42+
if (reviewPk) {
43+
params = { review: reviewPk };
44+
} else if (destructionListUuid) {
45+
params = { destructionList: destructionListUuid };
46+
} else {
47+
params = undefined;
48+
}
49+
4650
const response = await request("GET", "/_zaaktypen-choices/", params);
4751
const promise: Promise<ZaaktypeChoice[]> = response.json();
4852
return promise;

frontend/src/pages/destructionlist/create/components/DestructionList/DestructionList.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { DataGridProps, ListTemplate } from "@maykin-ui/admin-ui";
2-
import { useActionData, useNavigation } from "react-router-dom";
2+
import { useActionData, useLoaderData, useNavigation } from "react-router-dom";
33

44
import { PaginatedZaken } from "../../../../../lib/api/zaken";
55
import { Zaak } from "../../../../../types";
66
import {
77
DataGridAction,
88
useDataGridProps,
99
} from "../../../hooks/useDataGridProps";
10+
import { DestructionListReviewContext } from "../../../review";
1011

1112
export type DestructionList = React.PropsWithChildren<
1213
{
@@ -39,11 +40,14 @@ export function DestructionList({
3940
}: DestructionList) {
4041
const { state } = useNavigation();
4142
const actionErrors = useActionData() || {};
43+
const { uuid: destructionListUuid } =
44+
useLoaderData() as DestructionListReviewContext;
4245
const { props: dataGridProps, error } = useDataGridProps(
4346
storageKey,
4447
zaken,
4548
selectedZaken,
4649
actions,
50+
destructionListUuid,
4751
);
4852
const _errors =
4953
errors || [...Object.values(actionErrors), error].filter((v) => v);

frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function DestructionListEdit() {
135135
: destructionListItems,
136136
isEditingState ? [...zakenOnPage, ...selectedUrls] : [],
137137
undefined,
138-
{ destructionList: destructionList.uuid },
138+
destructionList.uuid,
139139
);
140140

141141
// Update the selected zaken to session storage.

frontend/src/pages/destructionlist/detail/components/DestructionListProcessReview/DestructionListProcessReview.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ export function DestructionListProcessReview() {
311311
},
312312
selectedUrls,
313313
processZaakReviewZaakActions,
314-
review ? { review: review.pk } : undefined,
314+
undefined,
315+
review?.pk,
315316
);
316317

317318
// Update the selected zaken to session storage.

frontend/src/pages/destructionlist/hooks/useDataGridProps.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import {
1010
import { ReactNode, useEffect, useRef, useState } from "react";
1111
import { useNavigation, useSearchParams } from "react-router-dom";
1212

13+
import { DestructionList } from "../../../lib/api/destructionLists";
1314
import {
1415
DestructionListItem,
1516
PaginatedDestructionListItems,
1617
} from "../../../lib/api/destructionListsItem";
17-
import {
18-
ZaaktypeChoice,
19-
ZaaktypeChoicesQueryParam,
20-
listZaaktypeChoices,
21-
} from "../../../lib/api/private";
18+
import { ZaaktypeChoice, listZaaktypeChoices } from "../../../lib/api/private";
19+
import { Review } from "../../../lib/api/review";
2220
import { PaginatedZaken } from "../../../lib/api/zaken";
2321
import {
2422
FieldSelection,
@@ -52,7 +50,8 @@ export function useDataGridProps(
5250
paginatedResults: PaginatedDestructionListItems | PaginatedZaken,
5351
selectedResults: (Zaak | { url: string })[],
5452
actions?: DataGridAction[],
55-
zaaktypeChoicesQueryParams?: ZaaktypeChoicesQueryParam,
53+
destructionListUuid?: DestructionList["uuid"],
54+
reviewPk?: Review["pk"],
5655
): { props: DataGridProps; error: unknown } {
5756
const { state } = useNavigation();
5857
const [searchParams, setSearchParams] = useSearchParams();
@@ -84,7 +83,7 @@ export function useDataGridProps(
8483
ZaaktypeChoice[]
8584
>([]);
8685
useEffect(() => {
87-
listZaaktypeChoices(zaaktypeChoicesQueryParams)
86+
listZaaktypeChoices(destructionListUuid, reviewPk)
8887
.then((z) => setZaaktypeChoicesState(z))
8988
.catch((e) => setErrorState(e));
9089
}, []);

0 commit comments

Comments
 (0)