- 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

@@ -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}/>