@@ -20,14 +20,15 @@ import {
20
20
convertInputValues ,
21
21
getEquipmentTypeFromModificationType ,
22
22
getFieldType ,
23
+ TABULAR_MODIFICATION_FIELDS ,
23
24
TABULAR_MODIFICATION_TYPES ,
24
25
transformModificationsTable ,
25
26
} from './tabular-modification-utils.js' ;
26
27
import {
27
28
addPropertiesFromBack ,
28
29
convertReactiveCapabilityCurvePointsFromFrontToBack ,
29
- emptyTabularFormData ,
30
30
formatModification ,
31
+ getEmptyTabularFormData ,
31
32
Modification ,
32
33
tabularFormSchema ,
33
34
TabularFormType ,
@@ -42,6 +43,7 @@ import {
42
43
convertCreationFieldFromBackToFront ,
43
44
convertCreationFieldFromFrontToBack ,
44
45
getEquipmentTypeFromCreationType ,
46
+ TABULAR_CREATION_FIELDS ,
45
47
TABULAR_CREATION_TYPES ,
46
48
} from './tabular-creation-utils' ;
47
49
import { NetworkModificationDialogProps } from '../../../graph/menus/network-modifications/network-modification-menu.type' ;
@@ -63,8 +65,14 @@ export function TabularDialog({
63
65
const currentNodeUuid = currentNode ?. id ;
64
66
const { snackError } = useSnackMessage ( ) ;
65
67
68
+ const defaultEquipmentType = useMemo ( ( ) => {
69
+ return dialogMode === TabularModificationType . CREATION
70
+ ? ( Object . keys ( TABULAR_CREATION_FIELDS ) . at ( 0 ) ?? '' )
71
+ : ( Object . keys ( TABULAR_MODIFICATION_FIELDS ) . at ( 0 ) ?? '' ) ;
72
+ } , [ dialogMode ] ) ;
73
+
66
74
const formMethods = useForm < TabularFormType > ( {
67
- defaultValues : emptyTabularFormData ,
75
+ defaultValues : getEmptyTabularFormData ( defaultEquipmentType ) ,
68
76
resolver : yupResolver ( tabularFormSchema ) ,
69
77
} ) ;
70
78
@@ -207,8 +215,8 @@ export function TabularDialog({
207
215
) ;
208
216
209
217
const clear = useCallback ( ( ) => {
210
- reset ( emptyTabularFormData ) ;
211
- } , [ reset ] ) ;
218
+ reset ( getEmptyTabularFormData ( defaultEquipmentType ) ) ;
219
+ } , [ defaultEquipmentType , reset ] ) ;
212
220
213
221
const open = useOpenShortWaitFetching ( {
214
222
isDataFetched :
0 commit comments