From fa29164fedee54433708cd208005271e5bbc5338 Mon Sep 17 00:00:00 2001
From: Vitalii Kiiko
Date: Tue, 8 Oct 2024 17:13:18 +0200
Subject: [PATCH] - updated https url;
---
src/assets/scss/components/appForm.scss | 21 ++
src/components/FileuploadStandalone/index.js | 167 ++++++++++++
.../FormField/components/Fileupload/index.js | 13 +-
.../components/FileuploadAsync/index.js | 13 +-
.../FormField/components/NumberInput/index.js | 2 +-
src/components/TopBarProfileMenu/index.js | 2 +-
src/configData.js | 2 +-
src/pages/Profile/index.js | 137 ++++++----
src/pages/ProfileCompany/index.js | 241 +++++++++++-------
src/pages/Registration/index.js | 16 +-
10 files changed, 467 insertions(+), 147 deletions(-)
create mode 100644 src/components/FileuploadStandalone/index.js
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 (
+
+
+
+ {file.name}
+
+
+
+ {file.id ? : null}
+ {!file.id ? : null}
+
+
+ onTemplateRemove(file)}/>
+
+
+ );
+ };
+
+ 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
+ ? {emptyText}
}
+ chooseLabel={chooseLabel}
+ cancelLabel={__('Cancella', 'gepafin')}
+ uploadLabel={__('Carica', 'gepafin')}
+ itemTemplate={itemTemplate}
+ customUpload
+ onBeforeDrop={onBeforeDrop}
+ onBeforeSelect={onBeforeSelect}
+ uploadHandler={customBase64Uploader}/>
+ : null
+ )
+}
+
+export default FileuploadStandalone;
\ No newline at end of file
diff --git a/src/components/FormField/components/Fileupload/index.js b/src/components/FormField/components/Fileupload/index.js
index 1dee52a..5b52a35 100644
--- a/src/components/FormField/components/Fileupload/index.js
+++ b/src/components/FormField/components/Fileupload/index.js
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useRef } from 'react';
import { classNames } from 'primereact/utils';
-import { head } from 'ramda'
+import { head, isEmpty } from 'ramda'
import { __ } from '@wordpress/i18n';
import FileUploadService from '../../../../service/file-upload-service';
@@ -111,7 +111,15 @@ const Fileupload = ({
}
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) => {
@@ -178,6 +186,7 @@ const Fileupload = ({
itemTemplate={itemTemplate}
customUpload
onBeforeDrop={onBeforeDrop}
+ onBeforeSelect={onBeforeSelect}
uploadHandler={customBase64Uploader}/>
{infoText ? {infoText} : null}
>
diff --git a/src/components/FormField/components/FileuploadAsync/index.js b/src/components/FormField/components/FileuploadAsync/index.js
index 9b879b8..ff32881 100644
--- a/src/components/FormField/components/FileuploadAsync/index.js
+++ b/src/components/FormField/components/FileuploadAsync/index.js
@@ -7,7 +7,7 @@ import FileUploadService from '../../../../service/file-upload-service';
import { FileUpload } from 'primereact/fileupload';
import { Tag } from 'primereact/tag';
import { Button } from 'primereact/button';
-import { head } from 'ramda';
+import { head, isEmpty } from 'ramda';
import { mimeTypes } from '../../../../configData';
const FileuploadAsync = ({
@@ -112,7 +112,15 @@ const FileuploadAsync = ({
}
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) => {
@@ -179,6 +187,7 @@ const FileuploadAsync = ({
itemTemplate={itemTemplate}
customUpload
onBeforeDrop={onBeforeDrop}
+ onBeforeSelect={onBeforeSelect}
uploadHandler={customBase64Uploader}/>
{infoText ? {infoText} : null}
>
diff --git a/src/components/FormField/components/NumberInput/index.js b/src/components/FormField/components/NumberInput/index.js
index 484ec3c..896fc32 100644
--- a/src/components/FormField/components/NumberInput/index.js
+++ b/src/components/FormField/components/NumberInput/index.js
@@ -20,7 +20,7 @@ const NumberInput = ({
min,
max,
disabled = false,
- useGrouping = false
+ useGrouping = true
}) => {
const input = {
const renderCompanyItem = (item) => (
{
- } : switchCompany(item.companyId)}
+ } : () => switchCompany(item.companyId)}
data-id={item.companyId}
data-active={chosenCompanyId === item.companyId}>
diff --git a/src/configData.js b/src/configData.js
index 8a4ad6e..c1d903d 100644
--- a/src/configData.js
+++ b/src/configData.js
@@ -1,6 +1,6 @@
export const mimeTypes = [
{ 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: 'Immagine', code: 'image/*' },
{
diff --git a/src/pages/Profile/index.js b/src/pages/Profile/index.js
index d9ddcca..3f35c05 100644
--- a/src/pages/Profile/index.js
+++ b/src/pages/Profile/index.js
@@ -36,7 +36,7 @@ const Profile = () => {
infoMsgs.current.clear();
storeSet.main.setAsyncRequest();
- UserService.updateUser(formData, updateCallback, updateError);
+ UserService.updateUser(userData.id, formData, updateCallback, updateError);
};
const updateCallback = (data) => {
@@ -121,6 +121,55 @@ const Profile = () => {
+
+
{__('Consensi', 'gepafin')}
+
+
+
+
+ {__('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')}
+
+
+
+
+
+
+ {__('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')}
+
+
+
+
+
+
+ {__('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')}
+
+
+
+
{__('Utenti Associati', 'gepafin')}
@@ -141,59 +190,59 @@ const Profile = () => {
+ fieldName="timezone"
+ defaultValue={'Europe/Rome'}
+ label={__('Fuso Orario', 'gepafin')}
+ control={control}
+ errors={errors}
+ config={{ required: __('È obbligatorio', 'gepafin') }}
+ options={[
+ { label: __('Europe/Rome', 'gepafin'), name: 'Europe/Rome' }
+ ]}
+ />
-
+
+
-
-
-
{__('Sicurezza', 'gepafin')}
-
-
{__('Ultimo accesso', 'gepafin')}
-
{getDateFromISOstring(userData.lastLogin)}
+
+
{__('Sicurezza', 'gepafin')}
+
+ {__('Ultimo accesso', 'gepafin')}
+ {getDateFromISOstring(userData.lastLogin)}
+
-
-
+
-
- {__('Azioni rapide', 'gepafin')}
-
-
-
-
-
+
+ {__('Azioni rapide', 'gepafin')}
+
+
+
-
- )
+)
}
diff --git a/src/pages/ProfileCompany/index.js b/src/pages/ProfileCompany/index.js
index f10968b..a286a6a 100644
--- a/src/pages/ProfileCompany/index.js
+++ b/src/pages/ProfileCompany/index.js
@@ -2,6 +2,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import { __ } from '@wordpress/i18n';
import { isEmpty, isNil, pathOr, head } from 'ramda';
import { klona } from 'klona';
+import { wrap } from 'object-path-immutable';
// store
import { storeSet, useStore, storeGet } from '../../store';
@@ -12,19 +13,24 @@ import FormField from '../../components/FormField';
import { Button } from 'primereact/button';
import { useForm } from 'react-hook-form';
import BlockingOverlay from '../../components/BlockingOverlay';
+import { InputText } from 'primereact/inputtext';
// api
import CompanyService from '../../service/company-service';
// tools
-import { isPIVA, isCodiceFiscale } from '../../helpers/validators';
+import { isPIVA, isCodiceFiscale, isEmail, isEmailPEC } from '../../helpers/validators';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
+import FileuploadStandalone from '../../components/FileuploadStandalone';
const ProfileCompany = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
const companies = useStore().main.companies();
const infoMsgs = useRef(null);
const [formInitialData, setFormInitialData] = useState({});
+ const [delegaData, setDelegaData] = useState({});
+ const [delega, setDelega] = useState({});
+ const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
const {
control,
@@ -137,6 +143,16 @@ const ProfileCompany = () => {
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(() => {
const newFormData = klona(formInitialData);
Object.keys(newFormData).map(v => setValue(v, newFormData[v]));
@@ -204,7 +220,12 @@ const ProfileCompany = () => {
label={__('Email PEC', 'gepafin')}
control={control}
errors={errors}
- config={{ required: __('È obbligatorio', 'gepafin') }}
+ config={{
+ required: __('È obbligatorio', 'gepafin'),
+ validate: {
+ isEmailPEC
+ }
+ }}
/>
{
label={__('Email', 'gepafin')}
control={control}
errors={errors}
- config={{ required: __('È obbligatorio', 'gepafin') }}
+ config={{
+ required: __('È obbligatorio', 'gepafin'),
+ validate: {
+ isEmail
+ }
+ }}
/>
{/* {
config={{ required: __('È obbligatorio', 'gepafin') }}
/>
+
+
+
+
+
+
+ {/* */}
+
@@ -273,101 +334,105 @@ const ProfileCompany = () => {
- {!isLegalRepresentant
- ?
-
-
{__('Compilazione Delega', 'gepafin')}
-
{__('Per procedere come delegato, compila il form seguente, scarica il documento della delega, fallo firmare dal rappresentante legale e ricaricalo.', 'gepafin')}
+ {!isLegalRepresentant
+ ?
+
+
{__('Compilazione Delega', 'gepafin')}
+
{__('Per procedere come delegato, compila il form seguente, scarica il documento della delega, fallo firmare dal rappresentante legale e ricaricalo.', 'gepafin')}
+
+
+
+
+
+ {__('Nome del rappresentante legale', 'gepafin')}
+ *
+
+ setDelegaFieldValue(e.target.value, 'delegaFirstName')}/>
-
-
-
-
-
-
+
+
+ {__('Cognome del rappresentante legale', 'gepafin')}
+ *
+
+ setDelegaFieldValue(e.target.value, 'delegaLastName')}/>
-
-
+
+
+ {__('Codice fiscale del rappresentante legale', 'gepafin')}
+ *
+
+ setDelegaFieldValue(e.target.value, 'delegaCodiceFiscale')}/>
+
-
-
-
- {
- }}
- label={__('Visualizza delega', 'gepafin')} icon="pi pi-eye" iconPos="right"/>
- {
- }}
- label={__('Sostituisci delega', 'gepafin')} icon="pi pi-sync" iconPos="right"/>
-
-
: null}
-
-
- {__('Azioni rapide', 'gepafin')}
-
-
-
-
+
+
+
+
+ {__('Carica documento Delega Firmato', 'gepafin')}
+ *
+
+
+
+
+
+ {
+ }}
+ label={__('Visualizza delega', 'gepafin')} icon="pi pi-eye" iconPos="right"/>
+ {
+ }}
+ label={__('Sostituisci delega', 'gepafin')} icon="pi pi-sync" iconPos="right"/>
+
+
:
}
+
+
+ {__('Azioni rapide', 'gepafin')}
+
+
+
)
diff --git a/src/pages/Registration/index.js b/src/pages/Registration/index.js
index 6a103ed..6bb24d1 100644
--- a/src/pages/Registration/index.js
+++ b/src/pages/Registration/index.js
@@ -106,15 +106,15 @@ const Registration = () => {
}
const disableAllChecks = () => {
- setValue('marketing1', false);
- setValue('marketing2', false);
- setValue('marketing3', false);
+ setValue('marketing', false);
+ setValue('offers', false);
+ setValue('thirdparty', false);
}
const enableAllChecks = () => {
- setValue('marketing1', true);
- setValue('marketing2', true);
- setValue('marketing3', true);
+ setValue('marketing', true);
+ setValue('offers', true);
+ setValue('thirdparty', true);
}
useEffect(() => {
@@ -320,11 +320,11 @@ const Registration = () => {