Skip to content

Commit

Permalink
Merge pull request #1600 from Vizzuality/chore/client/cost-surface-se…
Browse files Browse the repository at this point in the history
…lector-adjustments

makes default cost surface a regular option instead of a reset
  • Loading branch information
agnlez authored Dec 4, 2023
2 parents d9d691e + 4803ec6 commit 2f17338
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

1 comment on commit 2f17338

@vercel
Copy link

@vercel vercel bot commented on 2f17338 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marxan – ./

marxan-git-develop-vizzuality1.vercel.app
marxan-vizzuality1.vercel.app
marxan23.vercel.app

Please sign in to comment.