Skip to content

Commit

Permalink
prevents selecting default cost surface
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Feb 19, 2024
1 parent 582295b commit f8ba1c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ const InventoryPanelCostSurface = ({ noData: noDataMessage }: { noData: string }

const handleSelectAll = useCallback(
(evt: ChangeEvent<HTMLInputElement>) => {
setSelectedCostSurfaceIds(evt.target.checked ? costSurfaceIds : []);
setSelectedCostSurfaceIds(
evt.target.checked
? filteredData?.filter(({ isCustom }) => isCustom).map((cs) => cs.id)
: []
);
},
[costSurfaceIds]
[filteredData]
);

const handleSelectCostSurface = useCallback((evt: ChangeEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ const DeleteModal = ({

const selectedCostSurfaces = useMemo(() => {
return (
allProjectCostSurfacesQuery.data?.filter(({ id }) => selectedCostSurfacesIds.includes(id)) ||
[]
allProjectCostSurfacesQuery.data?.filter(
({ id, isDefault }) => selectedCostSurfacesIds.includes(id) && !isDefault
) || []
);
}, [allProjectCostSurfacesQuery.data, selectedCostSurfacesIds]);

Expand Down

0 comments on commit f8ba1c7

Please sign in to comment.