Skip to content

Commit

Permalink
✨ [#498] feat: implement prepopulation of zaken
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaohs committed Nov 27, 2024
1 parent 1d04890 commit 7c84145
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions frontend/src/lib/api/destructionListsItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function listDestructionListItems(
page_size?: number;
"item-processing_status"?: ProcessingStatus;
"item-status": DestructionListItemStatus; // TODO ?
"item-order_review_ignored"?: string;
},
) {
const response = await request("GET", "/destruction-list-items/", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
DestructionList,
getDestructionList,
} from "../../../lib/api/destructionLists";
import {
PaginatedDestructionListItems,
listDestructionListItems,
} from "../../../lib/api/destructionListsItem";
import {
Review,
ReviewItemWithZaak,
Expand All @@ -17,7 +21,6 @@ import {
getLatestReviewResponse,
} from "../../../lib/api/reviewResponse";
import { listReviewers } from "../../../lib/api/reviewers";
import { PaginatedZaken, listZaken } from "../../../lib/api/zaken";
import {
canReviewDestructionListRequired,
loginRequired,
Expand All @@ -31,7 +34,7 @@ export type DestructionListReviewContext = {
destructionList: DestructionList;
logItems: AuditLogItem[];

paginatedZaken: PaginatedZaken;
paginatedZaken: PaginatedDestructionListItems;
review: Review;
reviewItems?: ReviewItemWithZaak[];
reviewResponse?: ReviewResponse;
Expand Down Expand Up @@ -76,9 +79,9 @@ export const destructionListReviewLoader = loginRequired(
reviewItemsPromise,
reviewResponsePromise,
listReviewers(),
listZaken({
...objParams,
in_destruction_list: uuid,
listDestructionListItems(uuid, {
"item-order_review_ignored": String(true),
...(objParams as unknown as URLSearchParams),
}),
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
destructionListAssigneesFactory,
destructionListFactory,
} from "../../../fixtures/destructionList";
import { paginatedZakenFactory } from "../../../fixtures/paginatedZaken";
import { paginatedDestructionListItemsFactory } from "../../../fixtures/destructionListItem";
import { reviewFactory } from "../../../fixtures/review";
import {
beoordelaarFactory,
Expand Down Expand Up @@ -167,7 +167,7 @@ const FIXTURE: DestructionListReviewContext = {
logItems: [],
review: reviewFactory(),
reviewers: usersFactory(),
paginatedZaken: paginatedZakenFactory(),
paginatedZaken: paginatedDestructionListItemsFactory(),
};

export const ReviewerCanApproveZaak: Story = {
Expand All @@ -186,8 +186,10 @@ export const ReviewerCanApproveZaak: Story = {
});
const approve = approves[0];
await userEvent.click(approve);
const checkbox = await canvas.findByRole("checkbox", { checked: true });
await expect(checkbox).toBeInTheDocument();
// Find all checkboxes
const checkboxes = await canvas.findAllByRole("checkbox");
const checkbox = checkboxes[0];
await expect(checkbox).toBeChecked();
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useConfirm,
usePrompt,
} from "@maykin-ui/admin-ui";
import React, { useMemo } from "react";
import { useMemo } from "react";
import { useLoaderData } from "react-router-dom";

import {
Expand Down Expand Up @@ -60,6 +60,9 @@ export function DestructionListReviewPage() {
reviewItems,
reviewResponse,
} = useLoaderData() as DestructionListReviewContext;
const zakenResults = paginatedZaken.results
.map((zaak) => zaak.zaak)
.filter((zaak) => zaak !== null) as Zaak[];

const user = useWhoAmI();

Expand All @@ -70,7 +73,7 @@ export function DestructionListReviewPage() {
comment: string;
}>(
storageKey,
paginatedZaken.results,
zakenResults,
filterSelectionZaken,
getSelectionDetail,
RestBackend,
Expand All @@ -84,7 +87,7 @@ export function DestructionListReviewPage() {
comment: string;
}>(
storageKey,
paginatedZaken.results.map((z) => z.url as string),
paginatedZaken.results.map((z) => z.zaak?.url as string),
true,
RestBackend,
);
Expand Down Expand Up @@ -125,14 +128,15 @@ export function DestructionListReviewPage() {
uuid,
destructionList.status,
);
const zaakReviewStatusBadges = useZaakReviewStatusBadges(
paginatedZaken.results,
{ ...approvedZaakSelection, ...excludedZaakSelection },
);
const zaakReviewStatusBadges = useZaakReviewStatusBadges(zakenResults, {
...approvedZaakSelection,
...excludedZaakSelection,
});

// The object list of the current page with review actions appended.
const objectList = useMemo(() => {
return paginatedZaken.results.map((zaak) => {
return paginatedZaken.results.map((result) => {
const zaak = result.zaak as Zaak;
const badge = zaakReviewStatusBadges[zaak.url as string].badge;
const actions = getActionsToolbarForZaak(zaak);
return { ...zaak, Beoordeling: badge, Acties: actions };
Expand Down

0 comments on commit 7c84145

Please sign in to comment.