lavoce #27
@@ -95,11 +95,18 @@ const AddBrandDevice = () => {
|
|||||||
name: '',
|
name: '',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
text: '',
|
text: '',
|
||||||
status: true
|
status: true,
|
||||||
|
fileUpload: null,
|
||||||
|
file: null,
|
||||||
|
path_solution: null,
|
||||||
|
fileName: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
setSolutionFields([0]);
|
||||||
|
setSolutionTypes({ 0: 'text' });
|
||||||
|
setSolutionStatuses({ 0: true });
|
||||||
setCurrentSolutionData([]);
|
setCurrentSolutionData([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ const SolutionFieldNew = ({
|
|||||||
|
|
||||||
const [deleteCounter, setDeleteCounter] = useState(0);
|
const [deleteCounter, setDeleteCounter] = useState(0);
|
||||||
|
|
||||||
|
// Reset internal state when form is reset to initial values
|
||||||
|
React.useEffect(() => {
|
||||||
|
// Check if form is in initial/reset state (name is empty)
|
||||||
|
if (!nameValue || nameValue === '') {
|
||||||
|
setCurrentFile(null);
|
||||||
|
setIsDeleted(false);
|
||||||
|
setDeleteCounter(prev => prev + 1);
|
||||||
|
}
|
||||||
|
}, [nameValue]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const getFileFromFormValues = () => {
|
const getFileFromFormValues = () => {
|
||||||
const hasValidFileUpload = fileUpload && typeof fileUpload === 'object' && Object.keys(fileUpload).length > 0;
|
const hasValidFileUpload = fileUpload && typeof fileUpload === 'object' && Object.keys(fileUpload).length > 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user