Skip to content

Commit

Permalink
makes default cost surface a regular option instead of a reset
Browse files Browse the repository at this point in the history
  • Loading branch information
agnlez committed Nov 28, 2023
1 parent d9d691e commit 4803ec6
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useAppDispatch } from 'store/hooks';
import { getScenarioEditSlice } from 'store/slices/scenarios/edit';

import { motion } from 'framer-motion';
import { sortBy } from 'lodash';
import { HiOutlineArrowUpOnSquareStack } from 'react-icons/hi2';
import { useEffectOnceWhen } from 'rooks';

Expand Down Expand Up @@ -58,11 +57,18 @@ export const GridSetupCostSurface = (): JSX.Element => {
{},
{
select: (data) =>
sortBy(data, 'name')?.map(({ id, name, isDefault }) => ({
value: id,
label: name,
isDefault,
})),
data
?.map(({ id, name, isDefault }) => ({
value: id,
label: isDefault ? 'Default cost surface' : name,
isDefault,
}))
.sort((a, b) => {
if (a.isDefault) return -1;
if (b.isDefault) return 1;

return a.label.localeCompare(b.label);
}),
}
);
const scenarioQuery = useScenario(sid, {
Expand Down Expand Up @@ -287,10 +293,9 @@ export const GridSetupCostSurface = (): JSX.Element => {
size="base"
theme="dark"
selected={fprops.values.costSurfaceId}
options={costSurfaceQuery.data?.filter(({ isDefault }) => !isDefault)}
clearSelectionActive
options={costSurfaceQuery.data}
onChange={onChangeCostSurface}
clearSelectionLabel="Default cost surface"
placeholder="Select a cost surface"
/>
)}
</Field>
Expand Down

0 comments on commit 4803ec6

Please sign in to comment.