- updated flow of appl submission;
- updated max file size across the app;
This commit is contained in:
@@ -9,22 +9,22 @@ import { Button } from 'primereact/button';
|
||||
// api
|
||||
import ApplicationService from '../../service/application-service';
|
||||
|
||||
import { mimeTypes } from '../../configData';
|
||||
import { defaultMaxFileSize, mimeTypes } from '../../configData';
|
||||
|
||||
const FileuploadApplicationSignedPdf = ({
|
||||
fieldName,
|
||||
setDataFn,
|
||||
defaultValue = [],
|
||||
accept = [],
|
||||
maxSize = 100000000,
|
||||
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||
chooseLabel = __('Aggiungi documento', 'gepafin'),
|
||||
uploadLabel = __('Salva documento', 'gepafin'),
|
||||
cancelLabel = __('Cancella documento', 'gepafin'),
|
||||
multiple = false,
|
||||
applicationId = 0,
|
||||
disabled = false
|
||||
}) => {
|
||||
fieldName,
|
||||
setDataFn,
|
||||
defaultValue = [],
|
||||
accept = [],
|
||||
maxSize = defaultMaxFileSize,
|
||||
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||
chooseLabel = __('Aggiungi documento', 'gepafin'),
|
||||
uploadLabel = __('Salva documento', 'gepafin'),
|
||||
cancelLabel = __('Cancella documento', 'gepafin'),
|
||||
multiple = false,
|
||||
applicationId = 0,
|
||||
disabled = false
|
||||
}) => {
|
||||
const [stateFieldData, setStateFieldData] = useState([]);
|
||||
const [acceptFormats, setAcceptFormats] = useState('');
|
||||
const [formatsForInput, setFormatsForInput] = useState('');
|
||||
@@ -145,19 +145,19 @@ const FileuploadApplicationSignedPdf = ({
|
||||
useEffect(() => {
|
||||
const properMime = accept.map
|
||||
? accept
|
||||
.map(v => {
|
||||
const found = head(mimeTypes.filter(o => o.code.includes(v)));
|
||||
let res = v;
|
||||
.map(v => {
|
||||
const found = head(mimeTypes.filter(o => o.code.includes(v)));
|
||||
let res = v;
|
||||
|
||||
if (found) {
|
||||
res = found.code;
|
||||
}
|
||||
if (found) {
|
||||
res = found.code;
|
||||
}
|
||||
|
||||
return res;
|
||||
}) : [];
|
||||
return res;
|
||||
}) : [];
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
setAcceptFormats(properMime.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||
setFormatsForInput(properMime.join(','))
|
||||
setFormatsForInput(properMime.join(','));
|
||||
}, [accept]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -8,14 +8,14 @@ import { Button } from 'primereact/button';
|
||||
|
||||
// api
|
||||
import CompanyService from '../../service/company-service';
|
||||
import { mimeTypes } from '../../configData';
|
||||
import { defaultMaxFileSize, mimeTypes } from '../../configData';
|
||||
|
||||
const FileuploadDelega = ({
|
||||
fieldName,
|
||||
setDataFn,
|
||||
defaultValue = [],
|
||||
accept = [],
|
||||
maxSize = 100000000,
|
||||
maxSize = defaultMaxFileSize,
|
||||
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||
chooseLabel = __('Aggiungi delega', 'gepafin'),
|
||||
uploadLabel = __('Salva documento', 'gepafin'),
|
||||
|
||||
@@ -14,7 +14,8 @@ import { FileUpload } from 'primereact/fileupload';
|
||||
import { Tag } from 'primereact/tag';
|
||||
import { Button } from 'primereact/button';
|
||||
|
||||
import { mimeTypes } from '../../../../configData';
|
||||
import { defaultMaxFileSize, mimeTypes } from '../../../../configData';
|
||||
import getFormatedFileSizeText from '../../../../helpers/getFormatedFileSizeText';
|
||||
|
||||
const Fileupload = ({
|
||||
fieldName,
|
||||
@@ -27,7 +28,7 @@ const Fileupload = ({
|
||||
infoText = null,
|
||||
accept = ['image/*'],
|
||||
doctype = 'document',
|
||||
maxSize = 100000000,
|
||||
maxSize = defaultMaxFileSize,
|
||||
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||
chooseLabel = __('Aggiungi file', 'gepafin'),
|
||||
uploadLabel = __('Salva documento', 'gepafin'),
|
||||
@@ -162,19 +163,19 @@ const Fileupload = ({
|
||||
useEffect(() => {
|
||||
const properMime = accept.map
|
||||
? accept
|
||||
.map(v => {
|
||||
const found = head(mimeTypes.filter(o => o.code.includes(v)));
|
||||
let res = v;
|
||||
.map(v => {
|
||||
const found = head(mimeTypes.filter(o => o.code.includes(v)));
|
||||
let res = v;
|
||||
|
||||
if (found) {
|
||||
res = found.code;
|
||||
}
|
||||
if (found) {
|
||||
res = found.code;
|
||||
}
|
||||
|
||||
return res;
|
||||
}) : [];
|
||||
return res;
|
||||
}) : [];
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
setAcceptFormats(properMime.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||
setFormatsForInput(properMime.join(','))
|
||||
setFormatsForInput(properMime.join(','));
|
||||
}, [accept]);
|
||||
|
||||
return (
|
||||
@@ -184,6 +185,7 @@ const Fileupload = ({
|
||||
{label}{config.required || config.isRequired ?
|
||||
<span className="appForm__field--required">*</span> : null}
|
||||
{acceptFormats ? ' (' + getPropeMimeLabels(accept) + ')' : null}
|
||||
{` (max ${getFormatedFileSizeText(maxSize)})`}
|
||||
</label>
|
||||
<FileUpload
|
||||
ref={inputRef}
|
||||
|
||||
@@ -14,7 +14,8 @@ import { Tag } from 'primereact/tag';
|
||||
import { Button } from 'primereact/button';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
|
||||
import { mimeTypes } from '../../../../configData';
|
||||
import { defaultMaxFileSize, mimeTypes } from '../../../../configData';
|
||||
import getFormatedFileSizeText from '../../../../helpers/getFormatedFileSizeText';
|
||||
|
||||
const FileuploadAsync = ({
|
||||
fieldName,
|
||||
@@ -27,7 +28,7 @@ const FileuploadAsync = ({
|
||||
infoText = null,
|
||||
accept = ['image/*'],
|
||||
doctype = 'images',
|
||||
maxSize = 100000000,
|
||||
maxSize = defaultMaxFileSize,
|
||||
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||
chooseLabel = __('Aggiungi immagine', 'gepafin'),
|
||||
multiple = false,
|
||||
@@ -184,6 +185,7 @@ const FileuploadAsync = ({
|
||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||
{label}{config.required ? '*' : null}
|
||||
{acceptFormats ? ' (' + getPropeMimeLabels(accept) + ')' : null}
|
||||
{` (max ${getFormatedFileSizeText(maxSize)})`}
|
||||
</label>
|
||||
<FileUpload
|
||||
ref={inputRef}
|
||||
|
||||
Reference in New Issue
Block a user