Skip to content

Commit

Permalink
makes sure projectSpecificLossRate is valid when switching to nationa…
Browse files Browse the repository at this point in the history
…l loss rate
  • Loading branch information
agnlez committed Jan 29, 2025
1 parent 3d4fc9d commit f066990
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ export default function ConservationProjectDetails() {
"parameters.lossRateUsed",
v as LOSS_RATE_USED,
);
if (v === LOSS_RATE_USED.NATIONAL_AVERAGE) {
form.setValue(
"parameters.projectSpecificLossRate",
// prettier-ignore
form.getFieldState("parameters.projectSpecificLossRate").invalid ?
// @ts-expect-error fix later
form.formState.defaultValues?.parameters?.projectSpecificLossRate
// @ts-expect-error fix later
: form.getValues().parameters?.projectSpecificLossRate,
);
await form.trigger("parameters.projectSpecificLossRate");
}
await form.trigger("parameters.lossRateUsed");
}}
>
Expand Down

0 comments on commit f066990

Please sign in to comment.