Skip to content

Commit

Permalink
🚧 [#45] Added paginator to component for editing zaken
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm authored and svenvandescheur committed Jun 11, 2024
1 parent 29922e8 commit 7f3496c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion frontend/src/pages/destructionlist/DestructionListItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
TypedField,
} from "@maykin-ui/admin-ui";
import React, { useState } from "react";
import { useLoaderData } from "react-router-dom";
import {
useLoaderData,
useNavigation,
useSearchParams,
} from "react-router-dom";

import { Zaak } from "../../types";
import "./DestructionListDetail.css";
Expand All @@ -18,6 +22,8 @@ export type DestructionListItemsProps = {
export function DestructionListItems({ zaken }: DestructionListItemsProps) {
const [isEditing, setIsEditing] = useState(false);
const { zaken: allZaken } = useLoaderData() as DestructionListDetailContext;
const [searchParams, setSearchParams] = useSearchParams();
const { state } = useNavigation();

const fields: TypedField[] = [
{
Expand Down Expand Up @@ -99,6 +105,19 @@ export function DestructionListItems({ zaken }: DestructionListItemsProps) {
},
]}
customComparisonFunction={(item1, item2) => item1.uuid === item2.uuid}
paginatorProps={{
count: allZaken.count,
pageSize: 100,
page: Number(searchParams.get("page")) || 1,
loading: state === "loading",
labelLoading: "Loading...",
onPageChange: (page) =>
setSearchParams({
...Object.fromEntries(searchParams),
page: String(page),
}),
}}
loading={state === "loading"}
/>
) : (
<DataGrid
Expand Down

0 comments on commit 7f3496c

Please sign in to comment.