repair: sollution brand-device

This commit is contained in:
2025-12-12 15:58:11 +07:00
parent 1f8ee62721
commit 2ff50342e8
2 changed files with 18 additions and 1 deletions

View File

@@ -95,11 +95,18 @@ const AddBrandDevice = () => {
name: '',
type: 'text',
text: '',
status: true
status: true,
fileUpload: null,
file: null,
path_solution: null,
fileName: null
}
}
});
}
setSolutionFields([0]);
setSolutionTypes({ 0: 'text' });
setSolutionStatuses({ 0: true });
setCurrentSolutionData([]);
};

View File

@@ -48,6 +48,16 @@ const SolutionFieldNew = ({
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(() => {
const getFileFromFormValues = () => {
const hasValidFileUpload = fileUpload && typeof fileUpload === 'object' && Object.keys(fileUpload).length > 0;