Skip to content

Commit

Permalink
fix reset for modification dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <[email protected]>
  • Loading branch information
EtienneLt committed Jul 9, 2024
1 parent c387aca commit 4567f43
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ const BatteryModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setBatteryToModify(null);
setDataFetchStatus(FetchStatus.FAILED);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setBatteryToModify(null);
reset(emptyFormData);
}
});
} else {
setValuesAndEmptyOthers();
Expand All @@ -272,6 +274,7 @@ const BatteryModificationDialog = ({
setValue,
setValuesAndEmptyOthers,
reset,
editData
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ const GeneratorModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setGeneratorToModify(null);
reset(emptyFormData);
setDataFetchStatus(FetchStatus.FAILED);
if (editData?.equipmentId !== equipmentId) {
setGeneratorToModify(null);
reset(emptyFormData);
}
});
} else {
setValuesAndEmptyOthers();
Expand All @@ -326,6 +328,7 @@ const GeneratorModificationDialog = ({
getValues,
setValue,
setValuesAndEmptyOthers,
editData
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ const LineModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setLineToModify(null);
setDataFetchStatus(FetchStatus.FAILED);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setLineToModify(null);
reset(emptyFormData);
}
});
} else {
setLineToModify(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,21 @@ const ShuntCompensatorModificationDialog = ({
setLoading(false);
})
.catch((error) => {
setShuntCompensatorInfos(null);
setDataFetchStatus(FetchStatus.FAILED);
if (error.status === 404) {
setIdExists(true);
}
setLoading(false);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setShuntCompensatorInfos(null);
reset(emptyFormData);
}
});
} else {
setShuntCompensatorInfos(null);
}
},
[currentNode.id, snackError, studyUuid, reset, getValues]
[currentNode.id, snackError, studyUuid, reset, getValues, editData]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,15 +760,18 @@ const TwoWindingsTransformerModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setTwtToModify(null);
setDataFetchStatus(FetchStatus.FAILED);
if (editData?.equipmentId !== equipmentId) {
setTwtToModify(null);
reset(emptyFormData)
}
});
} else {
setTwtToModify(null);
reset(emptyFormData, { keepDefaultValues: true });
}
},
[studyUuid, currentNodeUuid, selectedId, editData, reset, getValues]
[studyUuid, currentNodeUuid, selectedId, editData, reset, getValues, editData]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,18 @@ const VoltageLevelModificationDialog = ({
}
})
.catch(() => {
setVoltageLevelInfos(null);
setDataFetchStatus(FetchStatus.FAILED);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setVoltageLevelInfos(null);
reset(emptyFormData);
}
});
} else {
setVoltageLevelInfos(null);
reset(emptyFormData, { keepDefaultValues: true });
}
},
[studyUuid, currentNodeUuid, reset, getValues]
[studyUuid, currentNodeUuid, reset, getValues, editData]
);

useEffect(() => {
Expand Down

0 comments on commit 4567f43

Please sign in to comment.