@@ -17,17 +17,18 @@ import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modi
1717import { FORM_LOADING_DELAY } from 'components/network/constants' ;
1818import { deleteEquipment } from '../../../../services/study/network-modifications' ;
1919import { UUID } from 'node:crypto' ;
20- import { CurrentTreeNode } from 'components/graph/tree-node.type' ;
2120import { FetchStatus } from 'services/utils.type' ;
2221import { DeepNullable } from 'components/utils/ts-utils' ;
2322import { EquipmentDeletionInfos } from './equipement-deletion-dialog.type' ;
23+ import { NetworkModificationDialogProps } from '../../../graph/menus/network-modifications/network-modification-menu.type' ;
24+ import { getHvdcLccDeletionSchema } from './hvdc-lcc-deletion/hvdc-lcc-deletion-utils' ;
2425
2526const formSchema = yup
2627 . object ( )
2728 . shape ( {
2829 [ EQUIPMENT_ID ] : yup . string ( ) . nullable ( ) . required ( ) ,
2930 [ TYPE ] : yup . mixed < EquipmentType > ( ) . oneOf ( Object . values ( EquipmentType ) ) . nullable ( ) . required ( ) ,
30- [ DELETION_SPECIFIC_DATA ] : yup . string ( ) . nullable ( ) ,
31+ [ DELETION_SPECIFIC_DATA ] : getHvdcLccDeletionSchema ( ) ,
3132 } )
3233 . required ( ) ;
3334
@@ -39,18 +40,12 @@ const emptyFormData: EquipmentDeletionFormInfos = {
3940 [ DELETION_SPECIFIC_DATA ] : null ,
4041} ;
4142
42- interface EquipmentDeletionDialogProps {
43- studyUuid : UUID ;
44- currentNode : CurrentTreeNode ;
45- currentRootNetworkUuid : UUID ;
43+ type EquipmentDeletionDialogProps = NetworkModificationDialogProps & {
4644 editData ?: EquipmentDeletionInfos ;
47- isUpdate : boolean ;
4845 defaultIdValue ?: UUID ;
4946 equipmentType : EquipmentType ;
5047 editDataFetchStatus ?: FetchStatus ;
51- onClose ?: ( ) => void ;
52- onValidated ?: ( ) => void ;
53- }
48+ } ;
5449
5550/**
5651 * Dialog to delete equipment from its type and ID.
@@ -95,6 +90,7 @@ const EquipmentDeletionDialog = ({
9590 reset ( {
9691 [ TYPE ] : editData . equipmentType ,
9792 [ EQUIPMENT_ID ] : editData . equipmentId ,
93+ [ DELETION_SPECIFIC_DATA ] : null ,
9894 } ) ;
9995 } ,
10096 [ reset ]
@@ -139,18 +135,16 @@ const EquipmentDeletionDialog = ({
139135
140136 const onSubmit = useCallback (
141137 ( formData : EquipmentDeletionFormInfos ) => {
142- if ( formData [ EQUIPMENT_ID ] ) {
143- deleteEquipment ( {
144- studyUuid,
145- nodeUuid : currentNodeUuid ,
146- uuid : editData ?. uuid ,
147- equipmentId : formData [ EQUIPMENT_ID ] as UUID ,
148- equipmentType : formData [ TYPE ] ,
149- equipmentSpecificInfos : formData [ DELETION_SPECIFIC_DATA ] ,
150- } ) . catch ( ( error ) => {
151- snackWithFallback ( snackError , error , { headerId : 'UnableToDeleteEquipment' } ) ;
152- } ) ;
153- }
138+ deleteEquipment ( {
139+ studyUuid,
140+ nodeUuid : currentNodeUuid ,
141+ uuid : editData ?. uuid ,
142+ equipmentId : formData [ EQUIPMENT_ID ] as UUID ,
143+ equipmentType : formData [ TYPE ] ,
144+ equipmentSpecificInfos : formData [ DELETION_SPECIFIC_DATA ] ?? undefined ,
145+ } ) . catch ( ( error ) => {
146+ snackWithFallback ( snackError , error , { headerId : 'UnableToDeleteEquipment' } ) ;
147+ } ) ;
154148 } ,
155149 [ currentNodeUuid , editData , snackError , studyUuid ]
156150 ) ;
0 commit comments