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 9f23aaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export const FeatureUploadModal = ({

<UploadTabs mode={uploadMode} onChange={(mode) => saveUploadMode(mode)} />
{uploadMode === 'csv' && (
<p className="!mt-4 text-sm text-gray-100">
<p className="!mt-4 text-sm text-gray-900">
Please download and fill in the{' '}
<button
className="text-primary-500 underline hover:no-underline"
Expand Down

0 comments on commit 9f23aaf

Please sign in to comment.