diff --git a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx index ca7b5e0793..e50c590dba 100644 --- a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx @@ -197,7 +197,7 @@ export default function CreateVoltageLevelSectionDialog({ : POSITION_NEW_SECTION_SIDE.BEFORE.id, [SWITCHES_BEFORE_SECTIONS]: editData?.leftSwitchKind ?? null, [SWITCHES_AFTER_SECTIONS]: editData?.rightSwitchKind ?? null, - [NEW_SWITCH_STATES]: editData?.switchOpen ?? false, + [NEW_SWITCH_STATES]: !(editData?.switchOpen ?? false), }); }, [reset] @@ -243,7 +243,7 @@ export default function CreateVoltageLevelSectionDialog({ voltageLevelSection?.isAfterBusBarSectionId === POSITION_NEW_SECTION_SIDE.AFTER.id, leftSwitchKind: voltageLevelSection?.switchesBeforeSections || null, rightSwitchKind: voltageLevelSection?.switchesAfterSections || null, - switchOpen: voltageLevelSection?.newSwitchStates || false, + switchOpen: !voltageLevelSection?.newSwitchStates || false, } satisfies CreateVoltageLevelSectionInfos; createVoltageLevelSection({ voltageLevelSectionInfos: voltageLevelSectionInfos, diff --git a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx index a1d26a17d0..287ed00784 100644 --- a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx @@ -10,6 +10,7 @@ import { BUS_BAR_INDEX, BUSBAR_SECTION_ID, IS_AFTER_BUSBAR_SECTION_ID, + NEW_SWITCH_STATES, SWITCH_AFTER_NOT_REQUIRED, SWITCH_BEFORE_NOT_REQUIRED, SWITCHES_AFTER_SECTIONS, @@ -19,7 +20,7 @@ import { Box, Button, Grid, Slider, TextField, Tooltip, Typography } from '@mui/ import { filledTextField } from '../../../dialog-utils'; import { FormattedMessage, useIntl } from 'react-intl'; import { CurrentTreeNode } from 'components/graph/tree-node.type'; -import { AutocompleteInput, Option, SelectInput } from '@gridsuite/commons-ui'; +import { AutocompleteInput, Option, SelectInput, SwitchInput } from '@gridsuite/commons-ui'; import GridSection from '../../../commons/grid-section'; import { isNodeBuilt } from 'components/graph/util/model-functions'; import { InfoOutlined } from '@mui/icons-material'; @@ -93,6 +94,7 @@ export function CreateVoltageLevelSectionForm({ {...filledTextField} /> ); + const isNewSwitchOpen = useWatch({ name: NEW_SWITCH_STATES }); useEffect(() => { if (busBarSectionInfos && busbarIndex) { @@ -280,6 +282,12 @@ export function CreateVoltageLevelSectionForm({ disabled={!busbarIndex || isNotRequiredSwitchAfter || isNotFoundOrNotSupported} /> ); + const newSwitchState = ( + + ); const getLabelDescription = useCallback(() => { return intl.formatMessage({ id: 'newSection' }); }, [intl]); @@ -372,6 +380,9 @@ export function CreateVoltageLevelSectionForm({ {switchAfterField} + + {newSwitchState} +