diff --git a/src/components/FormField/components/Fileupload/index.js b/src/components/FormField/components/Fileupload/index.js index 3a17fcb..1509156 100644 --- a/src/components/FormField/components/Fileupload/index.js +++ b/src/components/FormField/components/Fileupload/index.js @@ -14,6 +14,7 @@ import { mimeTypes } from '../../../../configData'; const Fileupload = ({ fieldName, setDataFn, + control, label, errors, register, @@ -21,7 +22,7 @@ const Fileupload = ({ config = {}, infoText = null, accept = ['image/*'], - doctype = 'images', + doctype = 'document', maxSize = 100000000, emptyText = __('Trascina qui il tuo file', 'gepafin'), chooseLabel = __('Aggiungi file', 'gepafin'), @@ -29,7 +30,7 @@ const Fileupload = ({ sourceId = 0, source = 'application', disabled = false, - maxFileSize = 100000000 + saveFormCallback = () => {} }) => { const [stateFieldData, setStateFieldData] = useState([]); const [acceptFormats, setAcceptFormats] = useState(''); @@ -51,7 +52,9 @@ const Fileupload = ({ setStateFieldData(data.data); const files = inputRef.current.getFiles(); inputRef.current.setUploadedFiles(files); + setDataFn(fieldName, data.data, { shouldValidate: true }); inputRef.current.setFiles([]); + saveFormCallback(); } } @@ -60,11 +63,12 @@ const Fileupload = ({ } const itemTemplate = (file) => { + let fileName = file.fileName ? file.fileName : file.name; return (
- {file.name} + {fileName}
@@ -72,7 +76,9 @@ const Fileupload = ({ {!file.id ? : null}
-