- removed console log;
- added toast when switching companies;
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { intersection } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore, useTrackedStore } from '../../store';
|
||||
|
||||
// components
|
||||
import { Menu } from 'primereact/menu';
|
||||
import { intersection } from 'ramda';
|
||||
import { Toast } from 'primereact/toast';
|
||||
|
||||
const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
const navigate = useNavigate();
|
||||
@@ -26,6 +27,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
{item.label}
|
||||
</span>
|
||||
);
|
||||
const toast = useRef(null);
|
||||
let items = [
|
||||
{
|
||||
template: (item, options) => {
|
||||
@@ -84,6 +86,13 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
const switchCompany = (id) => {
|
||||
if (chosenCompanyId !== id) {
|
||||
storeSet.main.chosenCompanyId(id);
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('L\'azienda è stata cambiata')
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,10 +102,11 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
||||
companyId: o.id,
|
||||
template: renderCompanyItem
|
||||
}));
|
||||
setCompanyItems(items)
|
||||
setCompanyItems(items);
|
||||
}, [companies, chosenCompanyId])
|
||||
|
||||
return <>
|
||||
<Toast ref={toast}/>
|
||||
<Menu model={items} popup ref={menuLeftRef} id="topBar_profileMenu" className="topBar__menuProfile"/>
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ const BandoApplication = () => {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
return acc;
|
||||
}, {});
|
||||
console.log('formDataInitial', formDataInitial)
|
||||
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,15 +137,6 @@ const BandoViewBeneficiario = () => {
|
||||
}
|
||||
|
||||
const errCreateCallback = (data) => {
|
||||
/*if (bandoMsgs.current && data.message) {
|
||||
bandoMsgs.current.show([
|
||||
{
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.message,
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
}*/
|
||||
if (toast.current && data.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
@@ -163,15 +154,6 @@ const BandoViewBeneficiario = () => {
|
||||
}
|
||||
|
||||
const errGetBandoCallback = (data) => {
|
||||
/*if (bandoMsgs.current && data.message) {
|
||||
bandoMsgs.current.show([
|
||||
{
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.message,
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
}*/
|
||||
if (toast.current && data.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
|
||||
Reference in New Issue
Block a user