- updated dependencies;

- fixed displaying delega;
- fixed switching companies;
- added toast for profile and company profile;
- fixed registration 'deby/allow all' func;
This commit is contained in:
Vitalii Kiiko
2024-10-10 10:33:21 +02:00
parent 8cac4ea23e
commit cc8597b529
14 changed files with 18215 additions and 15834 deletions

View File

@@ -1,30 +1,31 @@
import React, { useMemo, useRef } from 'react';
import { __ } from '@wordpress/i18n';
import { useForm } from 'react-hook-form';
// store
import { storeSet, useStore } from '../../store';
// components
import { Messages } from 'primereact/messages';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import FormField from '../../components/FormField';
import { Button } from 'primereact/button';
import { useForm } from 'react-hook-form';
import { Toast } from 'primereact/toast';
// api
import UserService from '../../service/user-service';
// tools
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
const Profile = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
const userData = useStore().main.userData();
const infoMsgs = useRef(null);
const toast = useRef(null);
const {
control,
handleSubmit,
formState: { errors },
setValue
formState: { errors }
} = useForm({
defaultValues: useMemo(() => {
return userData;
@@ -33,7 +34,6 @@ const Profile = () => {
});
const onSubmit = (formData) => {
infoMsgs.current.clear();
storeSet.main.setAsyncRequest();
UserService.updateUser(userData.id, formData, updateCallback, updateError);
@@ -41,7 +41,14 @@ const Profile = () => {
const updateCallback = (data) => {
if (data.status === 'SUCCESS') {
//setData(getFormattedBandiData(data.data));
storeSet.main.userData(data.data);
if (toast.current) {
toast.current.show({
severity: 'success',
summary: '',
detail: __('L\'utente è stato aggiornato!', 'gepafin')
});
}
}
storeSet.main.unsetAsyncRequest();
}
@@ -58,7 +65,7 @@ const Profile = () => {
</div>
<div className="appPage__spacer"></div>
<Messages ref={infoMsgs}/>
<Toast ref={toast}/>
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
@@ -124,6 +131,38 @@ const Profile = () => {
<div className="appPageSection">
<h2>{__('Consensi', 'gepafin')}</h2>
<div className="appForm__switchFieldWrapper">
<FormField
type="switch"
disabled={true}
fieldName="privacy"
label={''}
control={control}
errors={errors}
onLabel={''}
offLabel={''}
/>
<div>
{__('Dichiaro di aver preso visione, prima dell\'accesso al portale https://bandi.gepafin.it, dell\' "Informativa Privacy" all\'interno dell\'Appendice 10 dell\'Avviso secondo il Regolamento UE 2016/679 relativo alla protezione delle persone fisiche con riguardo al trattamento dei dati personale, nonché alla libera circolazione di tali dati e che abroga la Direttiva 95/46 CE.', 'gepafin')}
</div>
</div>
<div className="appForm__switchFieldWrapper">
<FormField
type="switch"
disabled={true}
fieldName="terms"
label={''}
control={control}
errors={errors}
onLabel={''}
offLabel={''}
/>
<div>
{__('Termini e condizioni', 'gepafin')}
</div>
</div>
<div className="appForm__switchFieldWrapper">
<FormField
type="switch"
@@ -190,7 +229,7 @@ const Profile = () => {
<FormField
type="select"
disabled={true}
fieldName="timezone"
fieldName="timezone"
defaultValue={'Europe/Rome'}
label={__('Fuso Orario', 'gepafin')}
control={control}

View File

@@ -3,6 +3,7 @@ import { __ } from '@wordpress/i18n';
import { isEmpty, pathOr, head } from 'ramda';
import { klona } from 'klona';
import { wrap } from 'object-path-immutable';
import { useForm } from 'react-hook-form';
// store
import { storeSet, useStore, storeGet } from '../../store';
@@ -18,10 +19,10 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import { Messages } from 'primereact/messages';
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';
import FileuploadDelega from '../../components/FileuploadDelega';
import { Toast } from 'primereact/toast';
const ProfileCompany = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
@@ -32,6 +33,7 @@ const ProfileCompany = () => {
const [delegaData, setDelegaData] = useState({});
const [delega, setDelega] = useState({});
const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
const toast = useRef(null);
const {
control,
@@ -39,6 +41,7 @@ const ProfileCompany = () => {
formState: { errors },
setValue,
watch,
reset
} = useForm({
defaultValues: useMemo(() => {
return formInitialData;
@@ -82,6 +85,14 @@ const ProfileCompany = () => {
}
storeSet.main.companies(newCompanies);
if (toast.current) {
toast.current.show({
severity: 'success',
summary: '',
detail: __('L\'azienda è stata aggiornata!', 'gepafin')
});
}
}
storeSet.main.unsetAsyncRequest();
}
@@ -142,12 +153,10 @@ const ProfileCompany = () => {
}
const setDelegaFile = (name, value) => {
console.log('setDelegaFile', value)
setDelega(value);
}
const getDellegaCallback = (data) => {
console.log(data)
if (data.data) {
setDelega(data.data);
}
@@ -155,6 +164,7 @@ const ProfileCompany = () => {
}
const errDellegaCallback = () => {
setDelega({});
storeSet.main.unsetAsyncRequest();
}
@@ -190,6 +200,7 @@ const ProfileCompany = () => {
}, [formInitialData]);
useEffect(() => {
reset();
let chosenCompany = {};
if (chosenCompanyId) {
@@ -218,6 +229,7 @@ const ProfileCompany = () => {
contactEmail,
isLegalRepresentant
}
setFormInitialData(companyData);
}, [chosenCompanyId, companies]);
@@ -236,6 +248,7 @@ const ProfileCompany = () => {
<div className="appPage__spacer"></div>
<Messages ref={infoMsgs}/>
<Toast ref={toast}/>
<form id="companyForm" className="appForm" onSubmit={handleSubmit(onSubmit)}>
<BlockingOverlay shouldDisplay={isAsyncRequest}/>

View File

@@ -108,13 +108,13 @@ const Registration = () => {
const disableAllChecks = () => {
setValue('marketing', false);
setValue('offers', false);
setValue('thirdparty', false);
setValue('thirdParty', false);
}
const enableAllChecks = () => {
setValue('marketing', true);
setValue('offers', true);
setValue('thirdparty', true);
setValue('thirdParty', true);
}
useEffect(() => {