- updated https url;
This commit is contained in:
@@ -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 {
|
.appForm__repeaterItem {
|
||||||
padding: 0.5rem 0.5rem 0.5rem 1rem;
|
padding: 0.5rem 0.5rem 0.5rem 1rem;
|
||||||
border-left: 3px solid #dadada;
|
border-left: 3px solid #dadada;
|
||||||
@@ -279,4 +293,11 @@
|
|||||||
|
|
||||||
.appForm__delegaFormHeader {
|
.appForm__delegaFormHeader {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appForm__delegaFormActions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
gap: 0.5em;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
167
src/components/FileuploadStandalone/index.js
Normal file
167
src/components/FileuploadStandalone/index.js
Normal file
@@ -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 (
|
||||||
|
<div className="appForm__fileUploadItem">
|
||||||
|
<div>
|
||||||
|
<span className="appForm__fileUploadItemName">
|
||||||
|
{file.name}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{file.id ? <Tag value={__('Caricato', 'gepafin')} severity="success"></Tag> : null}
|
||||||
|
{!file.id ? <Tag value={__('In attesa', 'gepafin')} severity="warning"></Tag> : null}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={disabled}
|
||||||
|
icon="pi pi-times"
|
||||||
|
severity="danger"
|
||||||
|
aria-label={__('Anulla', 'gepafin')}
|
||||||
|
onClick={() => onTemplateRemove(file)}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onTemplateRemove = (file) => {
|
||||||
|
if (file.id) {
|
||||||
|
FileUploadService.deleteFile(
|
||||||
|
{},
|
||||||
|
(data) => dCallback(data, file.id),
|
||||||
|
dErrorCallback,
|
||||||
|
[['id', file.id]]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const files = inputRef.current.getFiles()
|
||||||
|
const newFiles = files.filter(o => o.lastModified !== file.lastModified && o.name !== file.name);
|
||||||
|
inputRef.current.setFiles(newFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dCallback = (data, id) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
setStateFieldData(prevState => {
|
||||||
|
const newFiles = prevState.filter(o => o.id !== id);
|
||||||
|
inputRef.current.setUploadedFiles(newFiles);
|
||||||
|
return newFiles;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dErrorCallback = (err) => {
|
||||||
|
console.log('err', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const onBeforeDrop = (e) => {
|
||||||
|
return !isEmpty(e.dataTransfer.files) ? validateFileInputType(e.dataTransfer.files) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onBeforeSelect = (e) => {
|
||||||
|
if (e.originalEvent.target.files) {
|
||||||
|
return !isEmpty(e.originalEvent.target.files)
|
||||||
|
? validateFileInputType(e.originalEvent.target.files)
|
||||||
|
: false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const validateFileInputType = (files) => {
|
||||||
|
const MIMEtype = new RegExp(acceptFormats);
|
||||||
|
|
||||||
|
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
||||||
|
return MIMEtype.test(file.type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setStateFieldData(defaultValue);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
|
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||||
|
}, [accept]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.setUploadedFiles(stateFieldData);
|
||||||
|
}
|
||||||
|
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
||||||
|
}, [stateFieldData])
|
||||||
|
|
||||||
|
return (
|
||||||
|
sourceId && sourceId !== 0
|
||||||
|
? <FileUpload
|
||||||
|
ref={inputRef}
|
||||||
|
disabled={disabled}
|
||||||
|
id={fieldName}
|
||||||
|
name={fieldName}
|
||||||
|
url={'/document/uploadFile'}
|
||||||
|
multiple={multiple}
|
||||||
|
accept={accept}
|
||||||
|
maxFileSize={maxSize}
|
||||||
|
emptyTemplate={<p>{emptyText}</p>}
|
||||||
|
chooseLabel={chooseLabel}
|
||||||
|
cancelLabel={__('Cancella', 'gepafin')}
|
||||||
|
uploadLabel={__('Carica', 'gepafin')}
|
||||||
|
itemTemplate={itemTemplate}
|
||||||
|
customUpload
|
||||||
|
onBeforeDrop={onBeforeDrop}
|
||||||
|
onBeforeSelect={onBeforeSelect}
|
||||||
|
uploadHandler={customBase64Uploader}/>
|
||||||
|
: null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FileuploadStandalone;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState, useRef } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import { classNames } from 'primereact/utils';
|
import { classNames } from 'primereact/utils';
|
||||||
import { head } from 'ramda'
|
import { head, isEmpty } from 'ramda'
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
import FileUploadService from '../../../../service/file-upload-service';
|
import FileUploadService from '../../../../service/file-upload-service';
|
||||||
@@ -111,7 +111,15 @@ const Fileupload = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onBeforeDrop = (e) => {
|
const onBeforeDrop = (e) => {
|
||||||
return validateFileInputType(e.dataTransfer.files);
|
return !isEmpty(e.dataTransfer.files) ? validateFileInputType(e.dataTransfer.files) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onBeforeSelect = (e) => {
|
||||||
|
if (e.originalEvent.target.files) {
|
||||||
|
return !isEmpty(e.originalEvent.target.files)
|
||||||
|
? validateFileInputType(e.originalEvent.target.files)
|
||||||
|
: false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const validateFileInputType = (files) => {
|
const validateFileInputType = (files) => {
|
||||||
@@ -178,6 +186,7 @@ const Fileupload = ({
|
|||||||
itemTemplate={itemTemplate}
|
itemTemplate={itemTemplate}
|
||||||
customUpload
|
customUpload
|
||||||
onBeforeDrop={onBeforeDrop}
|
onBeforeDrop={onBeforeDrop}
|
||||||
|
onBeforeSelect={onBeforeSelect}
|
||||||
uploadHandler={customBase64Uploader}/>
|
uploadHandler={customBase64Uploader}/>
|
||||||
{infoText ? <small>{infoText}</small> : null}
|
{infoText ? <small>{infoText}</small> : null}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import FileUploadService from '../../../../service/file-upload-service';
|
|||||||
import { FileUpload } from 'primereact/fileupload';
|
import { FileUpload } from 'primereact/fileupload';
|
||||||
import { Tag } from 'primereact/tag';
|
import { Tag } from 'primereact/tag';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { head } from 'ramda';
|
import { head, isEmpty } from 'ramda';
|
||||||
import { mimeTypes } from '../../../../configData';
|
import { mimeTypes } from '../../../../configData';
|
||||||
|
|
||||||
const FileuploadAsync = ({
|
const FileuploadAsync = ({
|
||||||
@@ -112,7 +112,15 @@ const FileuploadAsync = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onBeforeDrop = (e) => {
|
const onBeforeDrop = (e) => {
|
||||||
return validateFileInputType(e.dataTransfer.files);
|
return !isEmpty(e.dataTransfer.files) ? validateFileInputType(e.dataTransfer.files) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onBeforeSelect = (e) => {
|
||||||
|
if (e.originalEvent.target.files) {
|
||||||
|
return !isEmpty(e.originalEvent.target.files)
|
||||||
|
? validateFileInputType(e.originalEvent.target.files)
|
||||||
|
: false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const validateFileInputType = (files) => {
|
const validateFileInputType = (files) => {
|
||||||
@@ -179,6 +187,7 @@ const FileuploadAsync = ({
|
|||||||
itemTemplate={itemTemplate}
|
itemTemplate={itemTemplate}
|
||||||
customUpload
|
customUpload
|
||||||
onBeforeDrop={onBeforeDrop}
|
onBeforeDrop={onBeforeDrop}
|
||||||
|
onBeforeSelect={onBeforeSelect}
|
||||||
uploadHandler={customBase64Uploader}/>
|
uploadHandler={customBase64Uploader}/>
|
||||||
{infoText ? <small>{infoText}</small> : null}
|
{infoText ? <small>{infoText}</small> : null}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const NumberInput = ({
|
|||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
useGrouping = false
|
useGrouping = true
|
||||||
}) => {
|
}) => {
|
||||||
const input = <Controller
|
const input = <Controller
|
||||||
name={fieldName}
|
name={fieldName}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
|||||||
const renderCompanyItem = (item) => (
|
const renderCompanyItem = (item) => (
|
||||||
<span className="topBar__menuCompanyItem"
|
<span className="topBar__menuCompanyItem"
|
||||||
onClick={chosenCompanyId === item.companyId ? () => {
|
onClick={chosenCompanyId === item.companyId ? () => {
|
||||||
} : switchCompany(item.companyId)}
|
} : () => switchCompany(item.companyId)}
|
||||||
data-id={item.companyId}
|
data-id={item.companyId}
|
||||||
data-active={chosenCompanyId === item.companyId}>
|
data-active={chosenCompanyId === item.companyId}>
|
||||||
<i className="pi pi-building-columns"></i>
|
<i className="pi pi-building-columns"></i>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const mimeTypes = [
|
export const mimeTypes = [
|
||||||
{ name: 'PDF', code: 'application/pdf' },
|
{ name: 'PDF', code: 'application/pdf' },
|
||||||
{ name: 'Firmato PDF o Word', code: 'application/pkcs7-mime' },
|
/*{ name: 'Firmato PDF o Word', code: 'application/pkcs7-mime' },*/
|
||||||
{ name: 'ZIP', code: 'application/zip' },
|
{ name: 'ZIP', code: 'application/zip' },
|
||||||
{ name: 'Immagine', code: 'image/*' },
|
{ name: 'Immagine', code: 'image/*' },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const Profile = () => {
|
|||||||
infoMsgs.current.clear();
|
infoMsgs.current.clear();
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
|
|
||||||
UserService.updateUser(formData, updateCallback, updateError);
|
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateCallback = (data) => {
|
const updateCallback = (data) => {
|
||||||
@@ -121,6 +121,55 @@ const Profile = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="appPageSection">
|
||||||
|
<h2>{__('Consensi', 'gepafin')}</h2>
|
||||||
|
|
||||||
|
<div className="appForm__switchFieldWrapper">
|
||||||
|
<FormField
|
||||||
|
type="switch"
|
||||||
|
fieldName="marketing"
|
||||||
|
label={''}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
onLabel={''}
|
||||||
|
offLabel={''}
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
{__('Invio di materiale pubblicitario, vendita diretta, compimento di ricerche di mercato o comunicazione commerciale riguardanti promozione e vendita di prodotti e servizi della Gepafin, mediante modalità di contatto automatizzate (posta elettronica, PEC, messaggi tramite canali informatici, network ed applicazioni web) e tradizionali (come posta cartacea e chiamate telefoniche con operatore)', 'gepafin')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__switchFieldWrapper">
|
||||||
|
<FormField
|
||||||
|
type="switch"
|
||||||
|
fieldName="offers"
|
||||||
|
label={''}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
onLabel={''}
|
||||||
|
offLabel={''}
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
{__('Elaborazione, in forma elettronica, dei dati relativi ai rapporti e servizi forniti, per l’analisi di comportamenti e preferenze della clientela, da utilizzare a scopo commerciale, per la individuazione ed offerta di prodotti e servizi di suo interesse', 'gepafin')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__switchFieldWrapper">
|
||||||
|
<FormField
|
||||||
|
type="switch"
|
||||||
|
fieldName="thirdParty"
|
||||||
|
label={''}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
onLabel={''}
|
||||||
|
offLabel={''}
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
{__('Comunicazione dei miei dati ad altre società in ambito bancario, finanziario od assicurativo e enti pubblici che li tratteranno per invio di materiale pubblicitario, vendita diretta, compimento di ricerche di mercato o comunicazione commerciale riguardanti loro prodotti o servizi, mediante le modalità automatizzate e tradizionali di comunicazione sopra indicate', 'gepafin')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Utenti Associati', 'gepafin')}</h2>
|
<h2>{__('Utenti Associati', 'gepafin')}</h2>
|
||||||
<div className="appForm__cols">
|
<div className="appForm__cols">
|
||||||
@@ -141,59 +190,59 @@ const Profile = () => {
|
|||||||
<FormField
|
<FormField
|
||||||
type="select"
|
type="select"
|
||||||
disabled={true}
|
disabled={true}
|
||||||
fieldName="timezone"
|
fieldName="timezone"
|
||||||
defaultValue={'Europe/Rome'}
|
defaultValue={'Europe/Rome'}
|
||||||
label={__('Fuso Orario', 'gepafin')}
|
label={__('Fuso Orario', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
options={[
|
options={[
|
||||||
{ label: __('Europe/Rome', 'gepafin'), name: 'Europe/Rome' }
|
{ label: __('Europe/Rome', 'gepafin'), name: 'Europe/Rome' }
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
type="select"
|
type="select"
|
||||||
disabled={true}
|
disabled={true}
|
||||||
fieldName="dateformat"
|
fieldName="dateformat"
|
||||||
defaultValue={'DD/MM/YY'}
|
defaultValue={'DD/MM/YY'}
|
||||||
label={__('Formato Data', 'gepafin')}
|
label={__('Formato Data', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
options={[
|
options={[
|
||||||
{ label: __('DD/MM/YY', 'gepafin'), name: 'DD/MM/YY' }
|
{ label: __('DD/MM/YY', 'gepafin'), name: 'DD/MM/YY' }
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Sicurezza', 'gepafin')}</h2>
|
<h2>{__('Sicurezza', 'gepafin')}</h2>
|
||||||
<div className="appForm__row">
|
<div className="appForm__row">
|
||||||
<label>{__('Ultimo accesso', 'gepafin')}</label>
|
<label>{__('Ultimo accesso', 'gepafin')}</label>
|
||||||
<span>{getDateFromISOstring(userData.lastLogin)}</span>
|
<span>{getDateFromISOstring(userData.lastLogin)}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
<div className="appPageSection__hr">
|
<div className="appPageSection__hr">
|
||||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<div className="appPageSection__actions">
|
<div className="appPageSection__actions">
|
||||||
<Button
|
<Button
|
||||||
disabled={isAsyncRequest}
|
disabled={isAsyncRequest}
|
||||||
label={__('Salva modifiche', 'gepafin')}
|
label={__('Salva modifiche', 'gepafin')}
|
||||||
icon="pi pi-check" iconPos="right"/>
|
icon="pi pi-check" iconPos="right"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { isEmpty, isNil, pathOr, head } from 'ramda';
|
import { isEmpty, isNil, pathOr, head } from 'ramda';
|
||||||
import { klona } from 'klona';
|
import { klona } from 'klona';
|
||||||
|
import { wrap } from 'object-path-immutable';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore, storeGet } from '../../store';
|
import { storeSet, useStore, storeGet } from '../../store';
|
||||||
@@ -12,19 +13,24 @@ import FormField from '../../components/FormField';
|
|||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||||
|
import { InputText } from 'primereact/inputtext';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import CompanyService from '../../service/company-service';
|
import CompanyService from '../../service/company-service';
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
import { isPIVA, isCodiceFiscale } from '../../helpers/validators';
|
import { isPIVA, isCodiceFiscale, isEmail, isEmailPEC } from '../../helpers/validators';
|
||||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||||
|
import FileuploadStandalone from '../../components/FileuploadStandalone';
|
||||||
|
|
||||||
const ProfileCompany = () => {
|
const ProfileCompany = () => {
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
const companies = useStore().main.companies();
|
const companies = useStore().main.companies();
|
||||||
const infoMsgs = useRef(null);
|
const infoMsgs = useRef(null);
|
||||||
const [formInitialData, setFormInitialData] = useState({});
|
const [formInitialData, setFormInitialData] = useState({});
|
||||||
|
const [delegaData, setDelegaData] = useState({});
|
||||||
|
const [delega, setDelega] = useState({});
|
||||||
|
const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@@ -137,6 +143,16 @@ const ProfileCompany = () => {
|
|||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setDelegaFieldValue = (value, name) => {
|
||||||
|
const newDelegaData = wrap(delegaData).set([name], value).value();
|
||||||
|
setDelegaData(newDelegaData)
|
||||||
|
}
|
||||||
|
|
||||||
|
const setDelegaFile = (data) => {
|
||||||
|
console.log('setDelegaFile', data)
|
||||||
|
setDelega(data);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const newFormData = klona(formInitialData);
|
const newFormData = klona(formInitialData);
|
||||||
Object.keys(newFormData).map(v => setValue(v, newFormData[v]));
|
Object.keys(newFormData).map(v => setValue(v, newFormData[v]));
|
||||||
@@ -204,7 +220,12 @@ const ProfileCompany = () => {
|
|||||||
label={__('Email PEC', 'gepafin')}
|
label={__('Email PEC', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
config={{
|
||||||
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
|
validate: {
|
||||||
|
isEmailPEC
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
@@ -214,7 +235,12 @@ const ProfileCompany = () => {
|
|||||||
label={__('Email', 'gepafin')}
|
label={__('Email', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
config={{
|
||||||
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
|
validate: {
|
||||||
|
isEmail
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/*<FormField
|
{/*<FormField
|
||||||
@@ -258,6 +284,41 @@ const ProfileCompany = () => {
|
|||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__cols">
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
disabled={isNil(formInitialData.id)}
|
||||||
|
fieldName="contactName"
|
||||||
|
label={__('Nome di referente aziendale', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
fieldName="contactEmail"
|
||||||
|
label={__('Email di referente aziendale', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{
|
||||||
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
|
validate: {
|
||||||
|
isEmail
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/*<FormField
|
||||||
|
type="textinput"
|
||||||
|
fieldName="phoneNumber"
|
||||||
|
label={__('Telefono', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>*/}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
@@ -273,101 +334,105 @@ const ProfileCompany = () => {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{!isLegalRepresentant
|
{!isLegalRepresentant
|
||||||
? <div className="appForm__delegaForm">
|
? <div className="appForm__delegaForm">
|
||||||
<div className="appForm__delegaFormHeader">
|
<div className="appForm__delegaFormHeader">
|
||||||
<legend>{__('Compilazione Delega', 'gepafin')}</legend>
|
<legend>{__('Compilazione Delega', 'gepafin')}</legend>
|
||||||
<p className="appForm__delegaFormText">{__('Per procedere come delegato, compila il form seguente, scarica il documento della delega, fallo firmare dal rappresentante legale e ricaricalo.', 'gepafin')}</p>
|
<p className="appForm__delegaFormText">{__('Per procedere come delegato, compila il form seguente, scarica il documento della delega, fallo firmare dal rappresentante legale e ricaricalo.', 'gepafin')}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__cols">
|
||||||
|
<div className="appForm__field">
|
||||||
|
<label htmlFor="delegaFirstName">
|
||||||
|
{__('Nome del rappresentante legale', 'gepafin')}
|
||||||
|
<span className="appForm__field--required">*</span>
|
||||||
|
</label>
|
||||||
|
<InputText
|
||||||
|
id="delegaFirstName"
|
||||||
|
value={delegaFirstName}
|
||||||
|
onChange={(e) => setDelegaFieldValue(e.target.value, 'delegaFirstName')}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appForm__cols">
|
<div className="appForm__field">
|
||||||
<FormField
|
<label htmlFor="delegaLastName">
|
||||||
type="textinput"
|
{__('Cognome del rappresentante legale', 'gepafin')}
|
||||||
fieldName="delegaFirstName"
|
<span className="appForm__field--required">*</span>
|
||||||
label={__('Nome del rappresentante legale', 'gepafin')}
|
</label>
|
||||||
control={control}
|
<InputText
|
||||||
errors={errors}
|
id="delegaLastName"
|
||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
value={delegaLastName}
|
||||||
/>
|
onChange={(e) => setDelegaFieldValue(e.target.value, 'delegaLastName')}/>
|
||||||
|
|
||||||
<FormField
|
|
||||||
type="textinput"
|
|
||||||
fieldName="delegaLastName"
|
|
||||||
label={__('Cognome del rappresentante legale', 'gepafin')}
|
|
||||||
control={control}
|
|
||||||
errors={errors}
|
|
||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
type="textinput"
|
|
||||||
fieldName="delegaCodiceFiscale"
|
|
||||||
label={__('Codice fiscale del rappresentante legale', 'gepafin')}
|
|
||||||
control={control}
|
|
||||||
errors={errors}
|
|
||||||
config={{
|
|
||||||
required: __('È obbligatorio', 'gepafin'),
|
|
||||||
isCodiceFiscale
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div className="appForm__field">
|
||||||
<Button
|
<label htmlFor="delegaCodiceFiscale">
|
||||||
type="button"
|
{__('Codice fiscale del rappresentante legale', 'gepafin')}
|
||||||
label={__('Genera documento Delega', 'gepafin')}
|
<span className="appForm__field--required">*</span>
|
||||||
icon="pi pi-check" iconPos="right"/>
|
</label>
|
||||||
|
<InputText
|
||||||
|
id="delegaCodiceFiscale"
|
||||||
|
value={delegaCodiceFiscale}
|
||||||
|
onChange={(e) => setDelegaFieldValue(e.target.value, 'delegaCodiceFiscale')}/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<FormField
|
<div>
|
||||||
type="fileuploadasync"
|
|
||||||
setDataFn={setValue}
|
|
||||||
fieldName="docs"
|
|
||||||
label={__('Carica documento Delega Firmato', 'gepafin')}
|
|
||||||
control={control}
|
|
||||||
errors={errors}
|
|
||||||
defaultValue={values['docs']}
|
|
||||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
|
||||||
accept={['application/pkcs7-mime']}
|
|
||||||
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
|
||||||
multiple={true}
|
|
||||||
doctype="document"
|
|
||||||
register={register}
|
|
||||||
sourceId={values.id}
|
|
||||||
source="call"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
disabled={true}
|
|
||||||
outlined
|
|
||||||
onClick={() => {
|
|
||||||
}}
|
|
||||||
label={__('Visualizza delega', 'gepafin')} icon="pi pi-eye" iconPos="right"/>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
disabled={true}
|
|
||||||
outlined
|
|
||||||
onClick={() => {
|
|
||||||
}}
|
|
||||||
label={__('Sostituisci delega', 'gepafin')} icon="pi pi-sync" iconPos="right"/>
|
|
||||||
</div>
|
|
||||||
</div> : null}
|
|
||||||
|
|
||||||
<div className="appPageSection__hr">
|
|
||||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="appPageSection">
|
|
||||||
<div className="appPageSection__actions">
|
|
||||||
<Button
|
<Button
|
||||||
form="companyForm"
|
disabled={isEmpty(delegaCodiceFiscale) || isEmpty(delegaFirstName) || isEmpty(delegaLastName)}
|
||||||
/*disabled={isAsyncRequest || emptyValues || values.id}*/
|
type="button"
|
||||||
label={__('Salva modifiche', 'gepafin')}
|
label={__('Genera documento Delega', 'gepafin')}
|
||||||
icon="pi pi-check" iconPos="right"/>
|
icon="pi pi-check" iconPos="right"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__field">
|
||||||
|
<label htmlFor="delega">
|
||||||
|
{__('Carica documento Delega Firmato', 'gepafin')}
|
||||||
|
<span className="appForm__field--required">*</span>
|
||||||
|
</label>
|
||||||
|
<FileuploadStandalone
|
||||||
|
setDataFn={setDelegaFile}
|
||||||
|
fieldName="delega"
|
||||||
|
defaultValue={[delega]}
|
||||||
|
accept={['']}
|
||||||
|
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
||||||
|
multiple={false}
|
||||||
|
doctype="document"
|
||||||
|
sourceId={formInitialData.id}
|
||||||
|
source="call"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__delegaFormActions">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={true}
|
||||||
|
outlined
|
||||||
|
onClick={() => {
|
||||||
|
}}
|
||||||
|
label={__('Visualizza delega', 'gepafin')} icon="pi pi-eye" iconPos="right"/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={true}
|
||||||
|
outlined
|
||||||
|
onClick={() => {
|
||||||
|
}}
|
||||||
|
label={__('Sostituisci delega', 'gepafin')} icon="pi pi-sync" iconPos="right"/>
|
||||||
|
</div>
|
||||||
|
</div> : <div className="appPage__spacer"></div>}
|
||||||
|
|
||||||
|
<div className="appPageSection__hr">
|
||||||
|
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appPageSection">
|
||||||
|
<div className="appPageSection__actions">
|
||||||
|
<Button
|
||||||
|
form="companyForm"
|
||||||
|
/*disabled={isAsyncRequest || emptyValues || values.id}*/
|
||||||
|
label={__('Salva modifiche', 'gepafin')}
|
||||||
|
icon="pi pi-check" iconPos="right"/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -106,15 +106,15 @@ const Registration = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const disableAllChecks = () => {
|
const disableAllChecks = () => {
|
||||||
setValue('marketing1', false);
|
setValue('marketing', false);
|
||||||
setValue('marketing2', false);
|
setValue('offers', false);
|
||||||
setValue('marketing3', false);
|
setValue('thirdparty', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const enableAllChecks = () => {
|
const enableAllChecks = () => {
|
||||||
setValue('marketing1', true);
|
setValue('marketing', true);
|
||||||
setValue('marketing2', true);
|
setValue('offers', true);
|
||||||
setValue('marketing3', true);
|
setValue('thirdparty', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -320,11 +320,11 @@ const Registration = () => {
|
|||||||
<div className={classNames(['appForm__row', 'reverseSwitchField'])}>
|
<div className={classNames(['appForm__row', 'reverseSwitchField'])}>
|
||||||
<FormField
|
<FormField
|
||||||
type="switch"
|
type="switch"
|
||||||
fieldName="thirdparty"
|
fieldName="thirdParty"
|
||||||
label={''}
|
label={''}
|
||||||
control={control}
|
control={control}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
defaultValue={values['thirdparty']}
|
defaultValue={values['thirdParty']}
|
||||||
onLabel={''}
|
onLabel={''}
|
||||||
offLabel={''}
|
offLabel={''}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user