From 7731b2fbd67e7b8a8b9e0656bb50268a3b49282d Mon Sep 17 00:00:00 2001 From: mono Date: Sat, 7 Mar 2026 16:12:17 -0500 Subject: [PATCH] #28 feat(auth): add login/logout buttons in NavBar --- src/components/NavBar.vue | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) 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('/'); + }, } } - +