From 98d158390200dd025d1c6f286f866ebfab79083d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez=20Mu=C3=B1oz?= Date: Fri, 8 Nov 2024 13:18:07 +0100 Subject: [PATCH] prevents sending empty filters to API --- client/src/containers/projects/header/index.tsx | 2 +- client/src/containers/projects/table/utils.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/containers/projects/header/index.tsx b/client/src/containers/projects/header/index.tsx index ae123b66..92f0f9a8 100644 --- a/client/src/containers/projects/header/index.tsx +++ b/client/src/containers/projects/header/index.tsx @@ -61,7 +61,7 @@ export default function ProjectsHeader() { Filters {!filtersEqual && ( - + )} diff --git a/client/src/containers/projects/table/utils.ts b/client/src/containers/projects/table/utils.ts index 7d589a36..4ef5a7ad 100644 --- a/client/src/containers/projects/table/utils.ts +++ b/client/src/containers/projects/table/utils.ts @@ -13,7 +13,9 @@ export const filtersToQueryParams = ( .reduce( (acc, key) => ({ ...acc, - [`filter[${key}]`]: filters[key as keyof typeof filters], + ...(filters[key as keyof typeof filters]?.length && { + [`filter[${key}]`]: filters[key as keyof typeof filters], + }), }), {}, );