diff --git a/src/assets/scss/components/appForm.scss b/src/assets/scss/components/appForm.scss index 4420fbe..0a4ae48 100644 --- a/src/assets/scss/components/appForm.scss +++ b/src/assets/scss/components/appForm.scss @@ -174,6 +174,20 @@ } } +.appForm__switchFieldWrapper { + display: flex; + gap: 1em; + + .appForm__field.switch { + width: 90px; + } + + > div:nth-of-type(2) { + width: 100%; + margin-bottom: 20px; + } +} + .appForm__repeaterItem { padding: 0.5rem 0.5rem 0.5rem 1rem; border-left: 3px solid #dadada; @@ -279,4 +293,11 @@ .appForm__delegaFormHeader { text-align: center; +} + +.appForm__delegaFormActions { + display: flex; + justify-content: flex-start; + gap: 0.5em; + width: 100%; } \ No newline at end of file diff --git a/src/components/FileuploadStandalone/index.js b/src/components/FileuploadStandalone/index.js new file mode 100644 index 0000000..60d49d1 --- /dev/null +++ b/src/components/FileuploadStandalone/index.js @@ -0,0 +1,167 @@ +import React, { useEffect, useState, useRef } from 'react'; +import { __ } from '@wordpress/i18n'; +import { isEmpty } from 'ramda'; + +import FileUploadService from '../../service/file-upload-service'; + +import { FileUpload } from 'primereact/fileupload'; +import { Tag } from 'primereact/tag'; +import { Button } from 'primereact/button'; + +const FileuploadStandalone = ({ + fieldName, + setDataFn, + defaultValue = [], + accept = ['image/*'], + doctype = 'images', + maxSize = 100000000, + emptyText = __('Trascina qui il tuo file', 'gepafin'), + chooseLabel = __('Aggiungi immagine', 'gepafin'), + multiple = false, + sourceId = 0, + source = 'application', + disabled = false + }) => { + const [stateFieldData, setStateFieldData] = useState([]); + const [acceptFormats, setAcceptFormats] = useState(''); + const inputRef = useRef(); + + const customBase64Uploader = (event) => { + const formData = new FormData() + for (const file of event.files) { + formData.append('file', file) + } + FileUploadService.uploadFile(sourceId, formData, callback, errorCallback, [ + ['documentType', doctype.toUpperCase()], + ['sourceType', source.toUpperCase()] + ]); + }; + + const callback = (data) => { + if (data.status === 'SUCCESS') { + setStateFieldData(data.data); + const files = inputRef.current.getFiles(); + inputRef.current.setUploadedFiles(files); + inputRef.current.setFiles([]); + } + } + + const errorCallback = (err) => { + console.log('err', err); + } + + const itemTemplate = (file) => { + return ( +
{__('Per procedere come delegato, compila il form seguente, scarica il documento della delega, fallo firmare dal rappresentante legale e ricaricalo.', 'gepafin')}
+ {!isLegalRepresentant + ?{__('Per procedere come delegato, compila il form seguente, scarica il documento della delega, fallo firmare dal rappresentante legale e ricaricalo.', 'gepafin')}
+