From 6d890bf9e6c30970fd577d0a62315b3703e3b9b7 Mon Sep 17 00:00:00 2001 From: Nick Charlton Date: Mon, 30 Jan 2023 22:24:16 +0000 Subject: [PATCH] feat: omit default values from searchParams --- src/context/CapturesContext.js | 9 +++++---- src/context/GrowerContext.js | 5 +++-- src/context/VerifyContext.js | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/context/CapturesContext.js b/src/context/CapturesContext.js index 931fd5d42..d1a8264e2 100644 --- a/src/context/CapturesContext.js +++ b/src/context/CapturesContext.js @@ -59,10 +59,11 @@ export function CapturesProvider(props) { useEffect(() => { handleQuerySearchParams({ - rowsPerPage, - page, - order, - orderBy, + rowsPerPage: + rowsPerPage === DEFAULT_ROWS_PER_PAGE ? undefined : rowsPerPage, + page: page === DEFAULT_PAGE ? undefined : page, + order: order === DEFAULT_ORDER ? undefined : order, + orderBy: porderByage === DEFAULT_ORDER_BY ? undefined : orderBy, ...filter.toSearchParams(), }); diff --git a/src/context/GrowerContext.js b/src/context/GrowerContext.js index 0d05d7ad2..566a35717 100644 --- a/src/context/GrowerContext.js +++ b/src/context/GrowerContext.js @@ -55,8 +55,9 @@ export function GrowerProvider(props) { useEffect(() => { if (searchParams) { handleQuerySearchParams({ - pageSize, - currentPage, + pageSize: pageSize === DEFAULT_PAGE_SIZE ? undefined : pageSize, + currentPage: + currentPage === DEFAULT_CURRENT_PAGE ? undefined : currentPage, ...filter.toSearchParams(), }); } diff --git a/src/context/VerifyContext.js b/src/context/VerifyContext.js index 5d4fd7f14..af0ec7812 100644 --- a/src/context/VerifyContext.js +++ b/src/context/VerifyContext.js @@ -75,8 +75,9 @@ export function VerifyProvider(props) { useEffect(() => { if (searchParams) { handleQuerySearchParams({ - pageSize, - currentPage, + pageSize: pageSize === DEFAULT_PAGE_SIZE ? undefined : pageSize, + currentPage: + currentPage === DEFAULT_CURRENT_PAGE ? undefined : currentPage, ...filter.toSearchParams(), }); }