feat: add admin login
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
<script setup>
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import Button from 'primevue/button';
|
||||
import Menubar from 'primevue/menubar';
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const router = useRouter();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const navItems = ref([
|
||||
{
|
||||
@@ -39,10 +41,18 @@ const navItems = ref([
|
||||
}
|
||||
]);
|
||||
|
||||
const handleLogout = () => {
|
||||
authStore.logout();
|
||||
router.push('/login');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col min-h-screen">
|
||||
<div v-if="!authStore.isAuthenticated">
|
||||
<router-view />
|
||||
</div>
|
||||
|
||||
<div v-else class="flex flex-col min-h-screen">
|
||||
<header class="sticky top-0 z-50 shadow-md">
|
||||
<Menubar :model="navItems" class="!rounded-none">
|
||||
<template #start>
|
||||
@@ -51,7 +61,7 @@ const navItems = ref([
|
||||
</div>
|
||||
</template>
|
||||
<template #end>
|
||||
<Button label="Logout" icon="pi pi-power-off" severity="secondary" text />
|
||||
<Button label="Logout" icon="pi pi-power-off" severity="secondary" text @click="handleLogout" />
|
||||
</template>
|
||||
</Menubar>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user