- 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:
20855
package-lock.json
generated
20855
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -4,24 +4,24 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
|
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
|
||||||
"@babel/preset-react": "7.24.7",
|
"@babel/preset-react": "7.25.7",
|
||||||
"@date-fns/tz": "1.1.2",
|
"@date-fns/tz": "1.1.2",
|
||||||
"@emotion/styled": "11.13.0",
|
"@emotion/styled": "11.13.0",
|
||||||
"@tanstack/react-table": "^8.20.5",
|
"@tanstack/react-table": "^8.20.5",
|
||||||
"@wordpress/i18n": "5.8.0",
|
"@wordpress/i18n": "5.9.0",
|
||||||
"@wordpress/react-i18n": "4.8.0",
|
"@wordpress/react-i18n": "4.9.0",
|
||||||
"@xyflow/react": "12.3.1",
|
"@xyflow/react": "12.3.1",
|
||||||
"codice-fiscale-js": "2.3.22",
|
"codice-fiscale-js": "2.3.22",
|
||||||
"deep-object-diff": "1.1.9",
|
"deep-object-diff": "1.1.9",
|
||||||
"dompurify": "3.1.7",
|
"dompurify": "3.1.7",
|
||||||
"fast-deep-equal": "3.1.3",
|
"fast-deep-equal": "3.1.3",
|
||||||
"html-react-parser": "5.1.16",
|
"html-react-parser": "5.1.18",
|
||||||
"jwt-decode": "4.0.0",
|
"jwt-decode": "4.0.0",
|
||||||
"klona": "2.0.6",
|
"klona": "2.0.6",
|
||||||
"luxon": "3.5.0",
|
"luxon": "3.5.0",
|
||||||
"object-path-immutable": "^4.1.2",
|
"object-path-immutable": "^4.1.2",
|
||||||
"primeicons": "7.0.0",
|
"primeicons": "7.0.0",
|
||||||
"primereact": "10.8.3",
|
"primereact": "10.8.4",
|
||||||
"quill": "2.0.2",
|
"quill": "2.0.2",
|
||||||
"ramda": "0.30.1",
|
"ramda": "0.30.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
@@ -30,27 +30,27 @@
|
|||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-hook-form": "7.53.0",
|
"react-hook-form": "7.53.0",
|
||||||
"react-router-dom": "6.26.2",
|
"react-router-dom": "6.26.2",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "^3.0.1",
|
||||||
"validate.js": "0.13.1",
|
"validate.js": "0.13.1",
|
||||||
"zustand": "4.5.4",
|
"zustand": "4.5.4",
|
||||||
"zustand-x": "3.0.4"
|
"zustand-x": "3.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "7.25.6",
|
"@babel/cli": "7.25.7",
|
||||||
"@babel/core": "7.25.2",
|
"@babel/core": "7.25.7",
|
||||||
"@babel/plugin-syntax-jsx": "7.24.7",
|
"@babel/plugin-syntax-jsx": "7.25.7",
|
||||||
"@wordpress/babel-plugin-makepot": "6.8.0",
|
"@wordpress/babel-plugin-makepot": "6.9.0",
|
||||||
"babel-plugin-macros": "3.1.0",
|
"babel-plugin-macros": "3.1.0",
|
||||||
"sass": "1.79.3",
|
"sass": "1.79.4",
|
||||||
"sass-loader": "16.0.2"
|
"sass-loader": "16.0.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "GENERATE_SOURCEMAP=false react-scripts start",
|
"start": "GENERATE_SOURCEMAP=false react-scripts start",
|
||||||
"start:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && PORT=8000 react-scripts start",
|
"start:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && PORT=8000 react-scripts start --mode development",
|
||||||
"start:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts start",
|
"start:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts start --mode production",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"build:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && react-scripts build",
|
"build:dev": "cp environments/dev/* public/loaded-files && rm public/loaded-files/dev.env && cp environments/dev/dev.env .env && react-scripts build --mode development",
|
||||||
"build:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts build",
|
"build:prod": "cp environments/prod/* public/loaded-files && rm public/loaded-files/prod.env && cp environments/prod/prod.env .env && react-scripts build --mode production",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
},
|
},
|
||||||
|
|||||||
17
src/App.js
17
src/App.js
@@ -17,7 +17,6 @@ function App() {
|
|||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
|
||||||
const callback = (data) => {
|
const callback = (data) => {
|
||||||
//console.log('app /me', data);
|
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
storeSet.main.userData(data.data);
|
storeSet.main.userData(data.data);
|
||||||
} else {
|
} else {
|
||||||
@@ -27,36 +26,20 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const errCallback = (data) => {
|
const errCallback = (data) => {
|
||||||
//storeSet.main.doLogout();
|
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*const companyCallback = (data) => {
|
|
||||||
if (data.status === 'SUCCESS') {
|
|
||||||
storeSet.main.companies(data.data);
|
|
||||||
}
|
|
||||||
storeSet.main.unsetAsyncRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
const errCompanyCallback = (data) => {
|
|
||||||
storeSet.main.doLogout();
|
|
||||||
storeSet.main.unsetAsyncRequest();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (role === 'ROLE_BENEFICIARY') {
|
if (role === 'ROLE_BENEFICIARY') {
|
||||||
//storeSet.main.setAsyncRequest();
|
|
||||||
const userData = storeGet.main.userData();
|
const userData = storeGet.main.userData();
|
||||||
if (userData.companies) {
|
if (userData.companies) {
|
||||||
storeSet.main.companies(userData.companies);
|
storeSet.main.companies(userData.companies);
|
||||||
}
|
}
|
||||||
//CompanyService.getCompanyForUser(userData.id, companyCallback, errCompanyCallback)
|
|
||||||
}
|
}
|
||||||
}, [role])
|
}, [role])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
//console.log('app loaded, initiate call to /me');
|
|
||||||
AuthenticationService.me(callback, errCallback);
|
AuthenticationService.me(callback, errCallback);
|
||||||
|
|
||||||
fetch('/languages/en_US.json')
|
fetch('/languages/en_US.json')
|
||||||
|
|||||||
@@ -177,6 +177,7 @@
|
|||||||
.appForm__switchFieldWrapper {
|
.appForm__switchFieldWrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
.appForm__field.switch {
|
.appForm__field.switch {
|
||||||
width: 90px;
|
width: 90px;
|
||||||
@@ -184,7 +185,9 @@
|
|||||||
|
|
||||||
> div:nth-of-type(2) {
|
> div:nth-of-type(2) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-bottom: 20px;
|
justify-content: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,12 @@
|
|||||||
&[data-active="true"] {
|
&[data-active="true"] {
|
||||||
color: var(--primary-text);
|
color: var(--primary-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[data-active="false"] {
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
i {
|
i {
|
||||||
margin-right: 7px;
|
margin-right: 7px;
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ const FileuploadDelega = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const itemTemplate = (file) => {
|
const itemTemplate = (file) => {
|
||||||
console.log('file', file)
|
|
||||||
return (
|
return (
|
||||||
<div className="appForm__fileUploadItem">
|
<div className="appForm__fileUploadItem">
|
||||||
<div>
|
<div>
|
||||||
@@ -128,8 +127,10 @@ const FileuploadDelega = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (inputRef.current) {
|
if (inputRef.current) {
|
||||||
inputRef.current.setUploadedFiles(multiple ? defaultValue : [defaultValue]);
|
const properValue = multiple
|
||||||
console.log('inputRef.current', inputRef.current, multiple ? defaultValue : [defaultValue])
|
? defaultValue
|
||||||
|
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
||||||
|
inputRef.current.setUploadedFiles(properValue);
|
||||||
}
|
}
|
||||||
}, [defaultValue]);
|
}, [defaultValue]);
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,15 @@ const Fileupload = ({
|
|||||||
register(fieldName, config)
|
register(fieldName, config)
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
const properValue = multiple
|
||||||
|
? defaultValue
|
||||||
|
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
||||||
|
inputRef.current.setUploadedFiles(properValue);
|
||||||
|
}
|
||||||
|
}, [defaultValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// eslint-disable-next-line no-useless-escape
|
// eslint-disable-next-line no-useless-escape
|
||||||
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||||
|
|||||||
@@ -153,6 +153,15 @@ const FileuploadAsync = ({
|
|||||||
register(fieldName, config)
|
register(fieldName, config)
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
const properValue = multiple
|
||||||
|
? defaultValue
|
||||||
|
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
||||||
|
inputRef.current.setUploadedFiles(properValue);
|
||||||
|
}
|
||||||
|
}, [defaultValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// eslint-disable-next-line no-useless-escape
|
// eslint-disable-next-line no-useless-escape
|
||||||
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
|||||||
const [companyItems, setCompanyItems] = useState([]);
|
const [companyItems, setCompanyItems] = useState([]);
|
||||||
const renderCompanyItem = (item) => (
|
const renderCompanyItem = (item) => (
|
||||||
<span className="topBar__menuCompanyItem"
|
<span className="topBar__menuCompanyItem"
|
||||||
onClick={chosenCompanyId === item.companyId ? () => {
|
onClick={() => 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>
|
||||||
@@ -83,7 +82,9 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
|||||||
].filter(o => o.enable);
|
].filter(o => o.enable);
|
||||||
|
|
||||||
const switchCompany = (id) => {
|
const switchCompany = (id) => {
|
||||||
console.log('switchCompany');
|
if (chosenCompanyId !== id) {
|
||||||
|
storeSet.main.chosenCompanyId(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -93,7 +94,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
|||||||
template: renderCompanyItem
|
template: renderCompanyItem
|
||||||
}));
|
}));
|
||||||
setCompanyItems(items)
|
setCompanyItems(items)
|
||||||
}, [companies])
|
}, [companies, chosenCompanyId])
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Menu model={items} popup ref={menuLeftRef} id="topBar_profileMenu" className="topBar__menuProfile"/>
|
<Menu model={items} popup ref={menuLeftRef} id="topBar_profileMenu" className="topBar__menuProfile"/>
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
import React, { useMemo, useRef } from 'react';
|
import React, { useMemo, useRef } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore } from '../../store';
|
import { storeSet, useStore } from '../../store';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { Messages } from 'primereact/messages';
|
|
||||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||||
import FormField from '../../components/FormField';
|
import FormField from '../../components/FormField';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { useForm } from 'react-hook-form';
|
import { Toast } from 'primereact/toast';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import UserService from '../../service/user-service';
|
import UserService from '../../service/user-service';
|
||||||
|
|
||||||
|
// tools
|
||||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
const userData = useStore().main.userData();
|
const userData = useStore().main.userData();
|
||||||
const infoMsgs = useRef(null);
|
const toast = useRef(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors }
|
||||||
setValue
|
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: useMemo(() => {
|
defaultValues: useMemo(() => {
|
||||||
return userData;
|
return userData;
|
||||||
@@ -33,7 +34,6 @@ const Profile = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
infoMsgs.current.clear();
|
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
|
|
||||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
||||||
@@ -41,7 +41,14 @@ const Profile = () => {
|
|||||||
|
|
||||||
const updateCallback = (data) => {
|
const updateCallback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
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();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
@@ -58,7 +65,7 @@ const Profile = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
<Messages ref={infoMsgs}/>
|
<Toast ref={toast}/>
|
||||||
|
|
||||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
|
||||||
@@ -124,6 +131,38 @@ const Profile = () => {
|
|||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Consensi', 'gepafin')}</h2>
|
<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">
|
<div className="appForm__switchFieldWrapper">
|
||||||
<FormField
|
<FormField
|
||||||
type="switch"
|
type="switch"
|
||||||
@@ -190,7 +229,7 @@ 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}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { __ } from '@wordpress/i18n';
|
|||||||
import { isEmpty, pathOr, head } from 'ramda';
|
import { isEmpty, pathOr, head } from 'ramda';
|
||||||
import { klona } from 'klona';
|
import { klona } from 'klona';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore, storeGet } from '../../store';
|
import { storeSet, useStore, storeGet } from '../../store';
|
||||||
@@ -18,10 +19,10 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
|||||||
import { Messages } from 'primereact/messages';
|
import { Messages } from 'primereact/messages';
|
||||||
import FormField from '../../components/FormField';
|
import FormField from '../../components/FormField';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||||
import { InputText } from 'primereact/inputtext';
|
import { InputText } from 'primereact/inputtext';
|
||||||
import FileuploadDelega from '../../components/FileuploadDelega';
|
import FileuploadDelega from '../../components/FileuploadDelega';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
|
||||||
const ProfileCompany = () => {
|
const ProfileCompany = () => {
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
@@ -32,6 +33,7 @@ const ProfileCompany = () => {
|
|||||||
const [delegaData, setDelegaData] = useState({});
|
const [delegaData, setDelegaData] = useState({});
|
||||||
const [delega, setDelega] = useState({});
|
const [delega, setDelega] = useState({});
|
||||||
const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
|
const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
|
||||||
|
const toast = useRef(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@@ -39,6 +41,7 @@ const ProfileCompany = () => {
|
|||||||
formState: { errors },
|
formState: { errors },
|
||||||
setValue,
|
setValue,
|
||||||
watch,
|
watch,
|
||||||
|
reset
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: useMemo(() => {
|
defaultValues: useMemo(() => {
|
||||||
return formInitialData;
|
return formInitialData;
|
||||||
@@ -82,6 +85,14 @@ const ProfileCompany = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
storeSet.main.companies(newCompanies);
|
storeSet.main.companies(newCompanies);
|
||||||
|
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'success',
|
||||||
|
summary: '',
|
||||||
|
detail: __('L\'azienda è stata aggiornata!', 'gepafin')
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
@@ -142,12 +153,10 @@ const ProfileCompany = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const setDelegaFile = (name, value) => {
|
const setDelegaFile = (name, value) => {
|
||||||
console.log('setDelegaFile', value)
|
|
||||||
setDelega(value);
|
setDelega(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDellegaCallback = (data) => {
|
const getDellegaCallback = (data) => {
|
||||||
console.log(data)
|
|
||||||
if (data.data) {
|
if (data.data) {
|
||||||
setDelega(data.data);
|
setDelega(data.data);
|
||||||
}
|
}
|
||||||
@@ -155,6 +164,7 @@ const ProfileCompany = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const errDellegaCallback = () => {
|
const errDellegaCallback = () => {
|
||||||
|
setDelega({});
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +200,7 @@ const ProfileCompany = () => {
|
|||||||
}, [formInitialData]);
|
}, [formInitialData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
reset();
|
||||||
let chosenCompany = {};
|
let chosenCompany = {};
|
||||||
|
|
||||||
if (chosenCompanyId) {
|
if (chosenCompanyId) {
|
||||||
@@ -218,6 +229,7 @@ const ProfileCompany = () => {
|
|||||||
contactEmail,
|
contactEmail,
|
||||||
isLegalRepresentant
|
isLegalRepresentant
|
||||||
}
|
}
|
||||||
|
|
||||||
setFormInitialData(companyData);
|
setFormInitialData(companyData);
|
||||||
}, [chosenCompanyId, companies]);
|
}, [chosenCompanyId, companies]);
|
||||||
|
|
||||||
@@ -236,6 +248,7 @@ const ProfileCompany = () => {
|
|||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
<Messages ref={infoMsgs}/>
|
<Messages ref={infoMsgs}/>
|
||||||
|
<Toast ref={toast}/>
|
||||||
|
|
||||||
<form id="companyForm" className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
<form id="companyForm" className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
||||||
|
|||||||
@@ -108,13 +108,13 @@ const Registration = () => {
|
|||||||
const disableAllChecks = () => {
|
const disableAllChecks = () => {
|
||||||
setValue('marketing', false);
|
setValue('marketing', false);
|
||||||
setValue('offers', false);
|
setValue('offers', false);
|
||||||
setValue('thirdparty', false);
|
setValue('thirdParty', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const enableAllChecks = () => {
|
const enableAllChecks = () => {
|
||||||
setValue('marketing', true);
|
setValue('marketing', true);
|
||||||
setValue('offers', true);
|
setValue('offers', true);
|
||||||
setValue('thirdparty', true);
|
setValue('thirdParty', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const zustandXOpts = {
|
const zustandXOpts = {
|
||||||
devtools: {
|
devtools: {
|
||||||
enabled: true
|
enabled: process.env.NODE_ENV !== 'production'
|
||||||
},
|
},
|
||||||
persist: {
|
persist: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user