Skip to content

Commit

Permalink
project creation: ignores restoration years when creating conservatio…
Browse files Browse the repository at this point in the history
…n project
  • Loading branch information
andresgnlez committed Dec 18, 2024
1 parent a90b1e6 commit 8cb5c38
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions client/src/containers/projects/new/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ export const onSubmit = async (data: CreateCustomProjectForm) => {
{},
);

const validYears = // @ts-expect-error fix later
(originalValues.parameters.restorationYearlyBreakdown as number[])
.map((v, index) => {
// if (!v) return undefined;
const isRestoration = data.activity === ACTIVITY.RESTORATION;

return {
const validYears = isRestoration // @ts-expect-error fix later
? (originalValues.parameters.restorationYearlyBreakdown as number[])
.map((v, index) => ({
year: index == 0 ? -1 : index,
hectares: v,
};
})
.filter((v) => v.hectares > 0);
}))
.filter((v) => v.hectares > 0)
: [];

const {
// @ts-expect-error fix later
Expand All @@ -96,7 +95,7 @@ export const onSubmit = async (data: CreateCustomProjectForm) => {
// @ts-expect-error fix later
restParameters.plantingSuccessRate / 100,
}),
...(originalValues.activity === ACTIVITY.RESTORATION && {
...(isRestoration && {
...(validYears.length > 0 && {
restorationYearlyBreakdown: validYears.map(({ year, hectares }) => ({
year,
Expand Down

0 comments on commit 8cb5c38

Please sign in to comment.