diff --git a/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form-utils.ts b/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form-utils.ts index f28b429cc0..91f010a023 100644 --- a/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form-utils.ts +++ b/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form-utils.ts @@ -91,12 +91,15 @@ export const getStandbyAutomatonFormValidationSchema = () => [Q0]: requiredWhenQatNominalVChoice(yup.number().nullable()), }); +export const computeQ0 = (b0?: number | null, nominalV?: number | null): number | undefined => { + return b0 != null && nominalV != null ? b0 * Math.pow(nominalV, 2) : undefined; +}; + export const getStandbyAutomatonFormData = ({ addStandbyAutomaton, standby, b0, q0, - nominalV, lVoltageSetpoint, hVoltageSetpoint, lVoltageThreshold, @@ -106,7 +109,6 @@ export const getStandbyAutomatonFormData = ({ standby: any; b0: any; q0?: any; - nominalV?: any; lVoltageSetpoint: any; hVoltageSetpoint: any; lVoltageThreshold: any; @@ -120,6 +122,6 @@ export const getStandbyAutomatonFormData = ({ [LOW_VOLTAGE_THRESHOLD]: lVoltageThreshold, [HIGH_VOLTAGE_THRESHOLD]: hVoltageThreshold, [B0]: b0, - [Q0]: q0 === null && nominalV !== null && b0 !== null ? b0 * Math.pow(nominalV, 2) : q0, + [Q0]: q0, }, }); diff --git a/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx b/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx index b368cee421..cfabee9557 100644 --- a/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx @@ -78,6 +78,7 @@ import { getReactiveFormValidationSchema, } from './set-points-limits-form-utils'; import { + computeQ0, getStandbyAutomatonEmptyFormData, getStandbyAutomatonFormData, getStandbyAutomatonFormValidationSchema, @@ -220,8 +221,7 @@ const StaticVarCompensatorCreationDialog: FC = ({ addStandbyAutomaton: !!staticCompensator.standbyAutomatonInfos, standby: staticCompensator.standbyAutomatonInfos?.standby, b0: staticCompensator.standbyAutomatonInfos?.b0, - q0: null, - nominalV: staticCompensator.nominalV, + q0: computeQ0(staticCompensator.standbyAutomatonInfos?.b0, staticCompensator.nominalV), lVoltageSetpoint: staticCompensator.standbyAutomatonInfos?.lowVoltageSetpoint, hVoltageSetpoint: staticCompensator.standbyAutomatonInfos?.highVoltageSetpoint, lVoltageThreshold: staticCompensator.standbyAutomatonInfos?.lowVoltageThreshold, @@ -274,7 +274,6 @@ const StaticVarCompensatorCreationDialog: FC = ({ standby: staticCompensator.standby, b0: staticCompensator.b0 ?? null, q0: staticCompensator.q0 ?? null, - nominalV: null, lVoltageSetpoint: staticCompensator.lowVoltageSetpoint ?? null, hVoltageSetpoint: staticCompensator.highVoltageSetpoint ?? null, lVoltageThreshold: staticCompensator.lowVoltageThreshold ?? null,