- removed console log;

- added toast when switching companies;
This commit is contained in:
Vitalii Kiiko
2024-10-10 15:23:25 +02:00
parent 156aac3d20
commit 374f60da97
3 changed files with 14 additions and 22 deletions

View File

@@ -1,13 +1,14 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { intersection } from 'ramda';
// store // store
import { storeSet, useStore, useTrackedStore } from '../../store'; import { storeSet, useStore, useTrackedStore } from '../../store';
// components // components
import { Menu } from 'primereact/menu'; import { Menu } from 'primereact/menu';
import { intersection } from 'ramda'; import { Toast } from 'primereact/toast';
const TopBarProfileMenu = ({ menuLeftRef }) => { const TopBarProfileMenu = ({ menuLeftRef }) => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -26,6 +27,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
{item.label} {item.label}
</span> </span>
); );
const toast = useRef(null);
let items = [ let items = [
{ {
template: (item, options) => { template: (item, options) => {
@@ -84,6 +86,13 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
const switchCompany = (id) => { const switchCompany = (id) => {
if (chosenCompanyId !== id) { if (chosenCompanyId !== id) {
storeSet.main.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, companyId: o.id,
template: renderCompanyItem template: renderCompanyItem
})); }));
setCompanyItems(items) setCompanyItems(items);
}, [companies, chosenCompanyId]) }, [companies, chosenCompanyId])
return <> return <>
<Toast ref={toast}/>
<Menu model={items} popup ref={menuLeftRef} id="topBar_profileMenu" className="topBar__menuProfile"/> <Menu model={items} popup ref={menuLeftRef} id="topBar_profileMenu" className="topBar__menuProfile"/>
</> </>
} }

View File

@@ -254,7 +254,7 @@ const BandoApplication = () => {
acc[cur.fieldId] = cur.fieldValue; acc[cur.fieldId] = cur.fieldValue;
return acc; return acc;
}, {}); }, {});
console.log('formDataInitial', formDataInitial)
setFormInitialData(formDataInitial); setFormInitialData(formDataInitial);
} }
} }

View File

@@ -137,15 +137,6 @@ const BandoViewBeneficiario = () => {
} }
const errCreateCallback = (data) => { 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) { if (toast.current && data.message) {
toast.current.show({ toast.current.show({
severity: 'error', severity: 'error',
@@ -163,15 +154,6 @@ const BandoViewBeneficiario = () => {
} }
const errGetBandoCallback = (data) => { 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) { if (toast.current && data.message) {
toast.current.show({ toast.current.show({
severity: 'error', severity: 'error',