From 9f23aaf7fe99b20d432b2d434caf1ae35bc37e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez=20Mu=C3=B1oz?= Date: Mon, 30 Oct 2023 17:56:08 +0100 Subject: [PATCH] fixes cost surfaces sorting --- .../inventory-panel/cost-surfaces/index.tsx | 21 ++++++++++--------- .../features/modals/upload/index.tsx | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx index e82991610c..21d7b8ad2b 100644 --- a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx @@ -62,20 +62,21 @@ const InventoryPanelCostSurface = ({ noData: noDataMessage }: { noData: string } ); const filteredData = useMemo(() => { + if (!allProjectCostSurfacesQuery.data.length) return allProjectCostSurfacesQuery.data; let sortedData = allProjectCostSurfacesQuery.data; - if (filters.sort === '-name') { - sortedData = orderBy(allProjectCostSurfacesQuery.data, 'name', 'desc'); + switch (filters.sort) { + case 'name': + sortedData = orderBy(allProjectCostSurfacesQuery.data, 'name', 'asc'); + break; + case '-name': + sortedData = orderBy(allProjectCostSurfacesQuery.data, 'name', 'desc'); + break; } - if (search) { - sortedData = sortedData.filter((cs) => - cs.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) - ); - } - - // the API assumes the default sort is ascending - return sortedData; + return sortedData.filter((cs) => + cs.name.toLocaleLowerCase().includes(search?.toLocaleLowerCase()) + ); }, [filters, allProjectCostSurfacesQuery.data, search]); const costSurfaceIds = filteredData?.map((cs) => cs.id); diff --git a/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx b/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx index a233151024..4417304f2a 100644 --- a/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx @@ -283,7 +283,7 @@ export const FeatureUploadModal = ({ saveUploadMode(mode)} /> {uploadMode === 'csv' && ( -

+

Please download and fill in the{' '}