Skip to content

Commit

Permalink
🐛 - fix: fix a bug that caused the field selection not to be saved
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jun 10, 2024
1 parent 1fd6c50 commit 34d67b8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions frontend/src/components/DestructionList/DestructionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import { ZaaktypeChoice } from "../../lib/api/private";
import { PaginatedZaken } from "../../lib/api/zaken";
import {
FieldSelection,
addToFieldSelection,
getFieldSelection,
removeFromFieldSelection,
} from "../../lib/fieldSelection/fieldSelection";
import {
addToZaakSelection,
Expand Down Expand Up @@ -92,6 +94,19 @@ export function DestructionList({
setSearchParams(activeParams);
};

/**
* Gets called when the fields selection is changed.
* @param fields
*/
const onFieldsChange = async (fields: TypedField[]) => {
const activeFields = fields.filter((f) => f.active !== false);
const inActiveFields = fields.filter((f) => f.active === false);
await addToFieldSelection(storageKey, activeFields);
await removeFromFieldSelection(storageKey, inActiveFields);
const fieldSelection = await getFieldSelection(storageKey);
setFieldSelectionState(fieldSelection);
};

/**
* Gets called when the selection is changed.
* @param attributeData
Expand Down Expand Up @@ -122,6 +137,7 @@ export function DestructionList({
count: zaken.count,
equalityChecker: (a, b) => a.uuid === b.uuid,
fields: fields,
fieldsSelectable: true,
loading: state === "loading",
objectList: objectList,
pageSize: 100,
Expand All @@ -145,6 +161,7 @@ export function DestructionList({
filterable: true,
page: Number(searchParams.get("page")) || 1,
onFilter: onFilter,
onFieldsChange: onFieldsChange,
onSelect: onSelect,
onPageChange: (page) =>
setSearchParams({
Expand Down

0 comments on commit 34d67b8

Please sign in to comment.