Skip to content

Commit

Permalink
👌 - pr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Roeland committed Dec 3, 2024
1 parent ed2930a commit d0074e9
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 16 deletions.
3 changes: 3 additions & 0 deletions frontend/src/fixtures/destructionListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const FIXTURE_DESTRUCTION_LIST_ITEM: DestructionListItem = {
zaak: zaakFactory(),
processingStatus: "new",
plannedDestructionDate: null,
reviewAdviceIgnored: null,
};
export const FIXTURE_DESTRUCTION_LIST_ITEM_DELETED: DestructionListItem = {
pk: 2,
Expand All @@ -20,6 +21,7 @@ export const FIXTURE_DESTRUCTION_LIST_ITEM_DELETED: DestructionListItem = {
zaak: null,
processingStatus: "succeeded",
plannedDestructionDate: "2026-01-01T00:00:00Z",
reviewAdviceIgnored: null,
};
export const FIXTURE_DESTRUCTION_LIST_ITEM_FAILED: DestructionListItem = {
pk: 3,
Expand All @@ -28,6 +30,7 @@ export const FIXTURE_DESTRUCTION_LIST_ITEM_FAILED: DestructionListItem = {
zaak: zaakFactory(),
processingStatus: "failed",
plannedDestructionDate: "2026-01-01T00:00:00Z",
reviewAdviceIgnored: null,
};

export const destructionListItemFactory = createObjectFactory(
Expand Down
21 changes: 16 additions & 5 deletions frontend/src/hooks/useZaakReviewStatusBadges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@ import {
export function useZaakReviewStatusBadges(
zakenOnPage: Zaak[],
reviewedZaakSelectionOnPage: ZaakSelection<{ approved: boolean }>,
reviewAdviceIgnoredResults: Record<string, boolean>, // Map of reviewAdviceIgnored
): Record<string, { badge: React.ReactNode; status: ZAAK_REVIEW_STATUS_ENUM }> {
const statuses = useZaakReviewStatuses(
zakenOnPage,
reviewedZaakSelectionOnPage,
);

return useMemo(() => {
const badges = zakenOnPage.map((z) => {
const status = statuses[z.url as string];
const reviewAdviceIgnored = reviewAdviceIgnoredResults[z.url as string];

if (reviewAdviceIgnored) {
// Display "Herboordelen" badge for reviewAdviceIgnored zaken
return (
// @ts-expect-error - style props not supported (yet?)
<Badge key={z.uuid} level="info" style={{ display: "block" }}>
<Solid.ClockIcon /> Herboordelen
</Badge>
);
}

if (typeof status === "boolean") {
if (status) {
Expand All @@ -37,17 +50,15 @@ export function useZaakReviewStatusBadges(
return (
// @ts-expect-error - style props not supported (yet?)
<Badge key={z.uuid} level="danger" style={{ display: "block" }}>
<Solid.HandThumbDownIcon />
Uitgezonderd
<Solid.HandThumbDownIcon /> Uitgezonderd
</Badge>
);
}
} else {
return (
// @ts-expect-error - style props not supported (yet?)
<Badge key={z.uuid} style={{ display: "block" }}>
<Solid.QuestionMarkCircleIcon />
Niet beoordeeld
<Solid.QuestionMarkCircleIcon /> Niet beoordeeld
</Badge>
);
}
Expand All @@ -58,5 +69,5 @@ export function useZaakReviewStatusBadges(
{ badge: badges[i], status: statuses[z.url as string] },
]);
return Object.fromEntries(entries);
}, [statuses]);
}, [statuses, reviewAdviceIgnoredResults, zakenOnPage]);
}
19 changes: 15 additions & 4 deletions frontend/src/lib/api/destructionListsItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type DestructionListItem = {
zaak: Zaak | null;
processingStatus: ProcessingStatus;
plannedDestructionDate: string | null;
reviewAdviceIgnored: boolean | null;
};

export interface ZaakItem extends Zaak {
Expand All @@ -32,15 +33,25 @@ export async function listDestructionListItems(
page?: number;
page_size?: number;
"item-processing_status"?: ProcessingStatus;
"item-status": DestructionListItemStatus; // TODO ?
"item-order_review_ignored"?: string;
"item-status"?: DestructionListItemStatus;
"item-order_review_ignored"?: string | boolean;
},
) {
if (params && !(params instanceof URLSearchParams)) {
if (typeof params["item-order_review_ignored"] === "boolean") {
params["item-order_review_ignored"] = String(
params["item-order_review_ignored"],
);
}
}

// Use the params object directly in the request
const response = await request("GET", "/destruction-list-items/", {
"item-destruction_list": destructionListUuid,
"item-status": "suggested",
...params,
} as typeof params & { "item-destruction_list": string });
...((params as Record<string, string>) || {}),
});

const promise: Promise<PaginatedDestructionListItems> = response.json();
return promise;
}
2 changes: 1 addition & 1 deletion frontend/src/lib/api/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { request } from "./request";

export type Review = {
destructionList: string;
decision: "accepted" | "rejected";
decision: "accepted" | "rejected" | "ignored_review";
listFeedback: string;
pk?: number;
author?: User;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/pages/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Review } from "../lib/api/review";
export const REVIEW_DECISION_MAPPING: Record<Review["decision"], string> = {
accepted: "Goedgekeurd",
rejected: "Afgewezen",
ignored_review: "Herboordelen",
};

export const REVIEW_DECISION_LEVEL_MAPPING: Record<
Expand All @@ -18,6 +19,7 @@ export const REVIEW_DECISION_LEVEL_MAPPING: Record<
> = {
accepted: "success",
rejected: "danger",
ignored_review: "info",
};

export const STATUSES_ELIGIBLE_FOR_EDIT = ["new", "changes_requested"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export const destructionListReviewLoader = loginRequired(
reviewResponsePromise,
listReviewers(),
listDestructionListItems(uuid, {
"item-order_review_ignored": String(true),
...(objParams as unknown as URLSearchParams),
"item-order_review_ignored": true,
...objParams,
}),
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,26 @@ export function DestructionListReviewPage() {
),
);

const reviewAdviceIgnoredResults = Object.fromEntries(
paginatedZaken.results.map((result) => [
result.zaak?.url as string,
result.reviewAdviceIgnored || false,
]),
);

const submitAction = useSubmitAction<ReviewDestructionListAction>();
const destructionListReviewKey = getDestructionListReviewKey(
uuid,
destructionList.status,
);
const zaakReviewStatusBadges = useZaakReviewStatusBadges(zakenResults, {
...approvedZaakSelection,
...excludedZaakSelection,
});
const zaakReviewStatusBadges = useZaakReviewStatusBadges(
zakenResults,
{
...approvedZaakSelection,
...excludedZaakSelection,
},
reviewAdviceIgnoredResults,
);

// The object list of the current page with review actions appended.
const objectList = useMemo(() => {
Expand Down

0 comments on commit d0074e9

Please sign in to comment.