diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue
index cf364d6..8c422f8 100644
--- a/src/components/NavBar.vue
+++ b/src/components/NavBar.vue
@@ -3,11 +3,22 @@
Menu
-
-
-
-
-
+
+ Login
+
+
+ Logout
+
import trytonIcon from '../assets/icons/tryton-icon.svg';
+ import AuthService from '@/services/auth';
export default {
name: 'NavBar',
data: () => ({
drawer: false,
group: null,
showAdminMenu: false,
+ isAuthenticated: false,
menuItems: [
{ title: 'Inicio', route: '/', icon: 'mdi-home'},
{ title: 'Comprar', route:'/comprar', icon: 'mdi-cart'},
- { title: 'Salir', route:'/salir', icon: 'mdi-cart'},
],
menuAdminItems: [
{ title: 'Cuadrar tarro', route: '/cuadrar_tarro', icon: 'mdi-calculator'},
@@ -62,12 +74,18 @@
{ title: 'Actualizar Ventas Tryton', route: '/sincronizar_ventas_tryton', icon: 'trytonIcon'}
],
}),
+ mounted() {
+ this.checkAuth();
+ },
watch: {
group () {
this.drawer = false
},
},
methods: {
+ checkAuth() {
+ this.isAuthenticated = AuthService.isAuthenticated();
+ },
navigate(route) {
this.$router.push(route);
},
@@ -78,6 +96,11 @@
toggleAdminMenu() {
this.showAdminMenu = !this.showAdminMenu;
},
+ logout() {
+ AuthService.logout();
+ this.isAuthenticated = false;
+ this.$router.push('/');
+ },
}
}
-
+