Skip to content

Commit

Permalink
♻️ [#45] Refactor function for updating zaken selection
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Jun 7, 2024
1 parent 7a3e4c6 commit f4c5e57
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
addToZaakSelection,
removeFromZaakSelection,
} from "../../lib/zaakSelection/zaakSelection";
import { getFields } from "../../pages/destructionlist/utils";
import { Zaak } from "../../types";
import {getFields} from "../../pages/destructionlist/utils";

export type DestructionList = {
zaken: PaginatedZaken;
Expand Down
23 changes: 22 additions & 1 deletion frontend/src/pages/destructionlist/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { TypedField } from "@maykin-ui/admin-ui";
import { AttributeData, TypedField } from "@maykin-ui/admin-ui";

import { ZaaktypeChoice } from "../../lib/api/private";
import {
addToZaakSelection,
removeFromZaakSelection,
} from "../../lib/zaakSelection/zaakSelection";
import { Zaak } from "../../types";

export function getFields(
Expand Down Expand Up @@ -95,3 +99,20 @@ export function getFields(
},
];
}

export async function updateSelectedZaken(
selected: boolean,
attributeData: AttributeData[],
destructionListKey: string,
zaken: Zaak[],
) {
selected
? await addToZaakSelection(
destructionListKey,
attributeData as unknown as Zaak[],
)
: await removeFromZaakSelection(
destructionListKey,
attributeData.length ? (attributeData as unknown as Zaak[]) : zaken,
);
}

0 comments on commit f4c5e57

Please sign in to comment.