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 committed Jun 7, 2024
1 parent ca4a28b commit 2348d84
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 2348d84

Please sign in to comment.