2022-08-13 00:40:26 +00:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2022-07-06 04:15:11 +00:00
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import classNames from 'classnames';
|
2022-08-11 06:55:45 +00:00
|
|
|
import Cookies from 'universal-cookie';
|
2022-08-13 00:40:26 +00:00
|
|
|
import { Button } from 'primereact/button';
|
|
|
|
import { Menubar } from 'primereact/menubar';
|
2022-08-11 06:55:45 +00:00
|
|
|
|
|
|
|
const cookies = new Cookies();
|
2022-07-06 04:15:11 +00:00
|
|
|
|
|
|
|
export const AppTopbar = (props) => {
|
2022-08-13 00:40:26 +00:00
|
|
|
const [logged, setLogged] = useState(null);
|
2022-07-06 04:15:11 +00:00
|
|
|
|
2022-08-13 00:40:26 +00:00
|
|
|
|
|
|
|
function cerrarSesion() {
|
2022-08-11 06:55:45 +00:00
|
|
|
cookies.remove('id', { path: "/" });
|
|
|
|
cookies.remove('email', { path: "/" });
|
|
|
|
cookies.remove('name', { path: "/" });
|
|
|
|
cookies.remove('type', { path: "/" });
|
|
|
|
cookies.remove('community_id', { path: "/" });
|
|
|
|
window.location.href = '/login';
|
|
|
|
}
|
|
|
|
|
2022-08-13 00:40:26 +00:00
|
|
|
useEffect(() => {
|
|
|
|
if (cookies.get('email')) {
|
|
|
|
setLogged(true);
|
|
|
|
} else {
|
|
|
|
setLogged(false);
|
|
|
|
};
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
const buttonLogout = () => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="my-2">
|
|
|
|
<Button label="Cerrar Sesión"
|
|
|
|
className="p-button-danger"
|
|
|
|
onClick={cerrarSesion}
|
|
|
|
disabled={logged} />
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const menuProfile = [
|
|
|
|
{
|
|
|
|
label: 'Perfil',
|
|
|
|
icon: 'pi pi-user',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
label: 'Cerrar Sesion',
|
|
|
|
icon: 'pi pi-fw pi-lock',
|
|
|
|
}
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-07-06 04:15:11 +00:00
|
|
|
return (
|
|
|
|
<div className="layout-topbar">
|
|
|
|
<Link to="/" className="layout-topbar-logo">
|
2022-08-13 00:40:26 +00:00
|
|
|
<img src={'images/Logo_Katoikia.svg'} alt="logo" />
|
2022-07-06 04:15:11 +00:00
|
|
|
<span>KATOIKIA</span>
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
{/* <button type="button" className="p-link layout-menu-button layout-topbar-button" onClick={props.onToggleMenuClick}>
|
|
|
|
<i className="pi pi-bars"/>
|
|
|
|
</button> */}
|
|
|
|
|
2022-08-13 00:40:26 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="p-link layout-topbar-menu-button layout-topbar-button"
|
|
|
|
>
|
|
|
|
<i className="pi pi-ellipsis-v" />
|
|
|
|
</button>
|
2022-07-06 04:15:11 +00:00
|
|
|
|
2022-08-13 00:40:26 +00:00
|
|
|
<ul className="layout-topbar-menu lg:flex origin-top">
|
|
|
|
{/* <li>
|
2022-07-06 04:15:11 +00:00
|
|
|
<button className="p-link layout-topbar-button" onClick={props.onMobileSubTopbarMenuClick}>
|
|
|
|
<i className="pi pi-calendar"/>
|
|
|
|
<span>Events</span>
|
|
|
|
</button>
|
|
|
|
</li> */}
|
2022-08-13 00:40:26 +00:00
|
|
|
{/* <li>
|
2022-07-06 04:15:11 +00:00
|
|
|
<button className="p-link layout-topbar-button" onClick={props.onMobileSubTopbarMenuClick}>
|
|
|
|
<i className="pi pi-cog"/>
|
|
|
|
<span>Settings</span>
|
|
|
|
</button>
|
|
|
|
</li> */}
|
2022-08-13 00:40:26 +00:00
|
|
|
<li className='mx-2' hidden={!logged}>
|
2022-07-14 21:03:52 +00:00
|
|
|
<button className="p-link layout-topbar-button" >
|
|
|
|
<i className="pi pi-user" />
|
2022-08-13 00:40:26 +00:00
|
|
|
<span>Perfil</span>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li className='mx-2' hidden={!logged}>
|
|
|
|
<button className="p-link layout-topbar-button" onClick={cerrarSesion} >
|
|
|
|
<i className="pi pi-sign-out" />
|
|
|
|
<span>Cerrar Sesión</span>
|
2022-07-14 21:03:52 +00:00
|
|
|
</button>
|
|
|
|
</li>
|
2022-08-13 00:40:26 +00:00
|
|
|
{/*
|
|
|
|
<Menubar model={menuProfile} ></Menubar>
|
|
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li hidden={!logged}>
|
|
|
|
<div className="my-2" >
|
|
|
|
<Button label="Cerrar Sesión"
|
|
|
|
className="p-button-danger"
|
|
|
|
onClick={cerrarSesion}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</li>*/}
|
2022-07-14 21:03:52 +00:00
|
|
|
</ul>
|
2022-07-06 04:15:11 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|