Skip to content

Commit

Permalink
fixes cost surfaces sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Oct 30, 2023
1 parent a381d20 commit 76698b0
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ const InventoryPanelCostSurface = ({ noData: noDataMessage }: { noData: string }
const filteredData = useMemo(() => {
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);
Expand Down

0 comments on commit 76698b0

Please sign in to comment.