From 3c8e414aef4c873c6551e8390dc5fe67192745f4 Mon Sep 17 00:00:00 2001 From: Donkie Date: Thu, 6 Jul 2023 19:32:48 +0200 Subject: [PATCH] Client: Make table use the refine sorters/filters That way, Refine is in charge of the sorters/filters state, instead of Refine and AntD each having their own state for it. --- client/src/pages/filaments/list.tsx | 47 ++++++++++------------------- client/src/pages/spools/list.tsx | 27 ++++++----------- client/src/pages/vendors/list.tsx | 8 ++--- 3 files changed, 29 insertions(+), 53 deletions(-) diff --git a/client/src/pages/filaments/list.tsx b/client/src/pages/filaments/list.tsx index ff21443..42a6b15 100644 --- a/client/src/pages/filaments/list.tsx +++ b/client/src/pages/filaments/list.tsx @@ -108,49 +108,43 @@ export const FilamentList: React.FC = () => { dataIndex="id" title="Id" sorter={true} - defaultSortOrder={getSortOrderForField(sorters_initial, "id")} + sortOrder={getSortOrderForField(sorters, "id")} /> ( = () => { dataIndex="diameter" title="Diameter" sorter={true} - defaultSortOrder={getSortOrderForField(sorters_initial, "diameter")} + sortOrder={getSortOrderForField(sorters, "diameter")} render={(value) => ( = () => { dataIndex="weight" title="Weight" sorter={true} - defaultSortOrder={getSortOrderForField(sorters_initial, "weight")} + sortOrder={getSortOrderForField(sorters, "weight")} render={(value) => { if (value === null || value === undefined) { return <>; @@ -200,10 +194,7 @@ export const FilamentList: React.FC = () => { dataIndex="spool_weight" title="Spool Weight" sorter={true} - defaultSortOrder={getSortOrderForField( - sorters_initial, - "spool_weight" - )} + sortOrder={getSortOrderForField(sorters, "spool_weight")} render={(value) => { if (value === null || value === undefined) { return <>; @@ -223,21 +214,15 @@ export const FilamentList: React.FC = () => { dataIndex="article_number" title="Article Number" sorter={true} - defaultSortOrder={getSortOrderForField( - sorters_initial, - "article_number" - )} + sortOrder={getSortOrderForField(sorters, "article_number")} filters={filterPopulator(dataSource, "article_number")} - defaultFilteredValue={getFiltersForField( - filters_initial, - "article_number" - )} + filteredValue={getFiltersForField(filters, "article_number")} /> ( = () => { dataIndex={["comment"]} title="Comment" sorter={true} - defaultSortOrder={getSortOrderForField(sorters_initial, "comment")} + sortOrder={getSortOrderForField(sorters, "comment")} /> = () => { dataIndex="id" title="Id" sorter={true} - defaultSortOrder={getSortOrderForField(sorters_initial, "id")} + sortOrder={getSortOrderForField(sorters, "id")} /> { return ( = () => { dataIndex="remaining_weight" title="Estimated Remaining Weight" sorter={true} - defaultSortOrder={getSortOrderForField( - sorters_initial, - "remaining_weight" - )} + sortOrder={getSortOrderForField(sorters, "remaining_weight")} render={(value) => { if (value === null || value === undefined) { return ; @@ -139,19 +130,19 @@ export const SpoolList: React.FC = () => { dataIndex="location" title="Location" sorter={true} - defaultSortOrder={getSortOrderForField(sorters_initial, "location")} + sortOrder={getSortOrderForField(sorters, "location")} /> (