Skip to content

Commit

Permalink
♻️ #64 - refactor: accommodate API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jun 18, 2024
1 parent 7704769 commit 665b69a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 42 deletions.
4 changes: 2 additions & 2 deletions frontend/src/lib/api/destruction-list-reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export interface CreateDestructionListReviewData {
destructionList: string; // uuid
decision: "accepted" | "rejected";
listFeedback: string;
itemReviews: {
zaak: string;
zakenReviews: {
zaak_url: string;
feedback: string;
}[];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react";

import { ReactRouterDecorator } from "../../../../.storybook/decorators";
import { FIXTURE_DESTRUCTION_LIST } from "../../../fixtures/destructionList";
import { FIXTURE_PAGINATED_ZAKEN } from "../../../fixtures/paginatedZaken";
import { FIXTURE_USERS } from "../../../fixtures/users";
import {
Expand Down Expand Up @@ -39,42 +40,7 @@ const FIXTURE: DestructionListReviewLoaderContext = {
zaken: FIXTURE_PAGINATED_ZAKEN,
selectedZaken: [],
uuid: "00000000-0000-0000-0000-000000000000",
list: {
items: [
{
zaak: "example.com",
status: "",
pk: 1,
zaakData: {
uuid: "00000000-0000-0000-0000-000000000001",
url: "example.com",
},
},
],
name: "Ding",
status: "processing",
uuid: "00000000-0000-0000-0000-000000000001",
assignees: [
{
user: {
pk: 1,
email: "[email protected]",
firstName: "John",
lastName: "Doe",
role: {
name: "None",
canReviewDestruction: true,
canStartDestruction: false,
canViewCaseDetails: false,
},
username: "John-Doe",
},
order: 1,
},
],
created: new Date(),
statusChanged: new Date(),
},
list: FIXTURE_DESTRUCTION_LIST,
};

export const ReviewDestructionList: Story = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface ListModalDataState {
interface FormDataState {
motivation: string;
uuid: string;
url: string;
}

/**
Expand Down Expand Up @@ -149,6 +150,7 @@ export function DestructionListReviewPage() {
motivation: string;
}),
uuid: zaakModalDataState.uuid!,
url: zaak.url as string,
});
setZaakModalDataState({ open: false });
await updateZaakSelectionCountState();
Expand Down Expand Up @@ -258,8 +260,9 @@ export const destructionListReviewLoader = async ({
return redirect("/destruction-lists/create"); // TODO: How do we want to handle this?
}
searchParams.set("destruction_list", uuid);
const objParams = Object.fromEntries(searchParams);

const zakenPromise = listZaken(searchParams);
const zakenPromise = listZaken({ ...objParams, in_destruction_list: uuid });
const listsPromise = getDestructionList(uuid);
const reviewersPromise = listReviewers();

Expand Down Expand Up @@ -326,14 +329,14 @@ export const destructionListReviewAction = async ({
destructionList: destructionListUuid,
decision: zaakSelectionValid.length > 0 ? "rejected" : "accepted",
listFeedback: details.listFeedback,
itemReviews: zaakSelectionValid.map((zaak) => {
zakenReviews: zaakSelectionValid.map((zaak) => {
if (!zaak.detail) {
throw new Error("Details are missing for one or more zaken");
}
const detail = zaak.detail as Record<string, string>;
const detail = zaak.detail as FormDataState;

return {
zaak: detail.uuid,
zaak_url: detail.url,
feedback: detail.motivation,
};
}),
Expand Down

0 comments on commit 665b69a

Please sign in to comment.