From 156aac3d20ff5cd4e9f95d1a5f18611bf22d267c Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Thu, 10 Oct 2024 14:42:19 +0200 Subject: [PATCH] - fixed fileupload; --- .../FormField/components/Fileupload/index.js | 32 ++-- src/configData.js | 2 +- .../ApplicationSteps/index.js | 10 +- src/pages/BandoApplication/index.js | 138 ++++++++++-------- src/pages/BandoViewBeneficiario/index.js | 37 ++++- 5 files changed, 132 insertions(+), 87 deletions(-) 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}
-