From 00a035653f7c4aa3906e991bc8a14ad00aecd5b8 Mon Sep 17 00:00:00 2001 From: MoonTestUse1 Date: Wed, 1 Jan 2025 22:53:45 +0600 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D0=BD=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA=D0=B8=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E1=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/layouts/AdminLayout.vue | 62 +++++++++++++++++ frontend/src/router/index.ts | 67 ++++++++---------- frontend/src/views/admin/EmployeesView.vue | 81 ++++++++++++++++++++++ frontend/src/views/admin/RequestsView.vue | 47 +++++++++++++ 4 files changed, 220 insertions(+), 37 deletions(-) create mode 100644 frontend/src/layouts/AdminLayout.vue create mode 100644 frontend/src/views/admin/EmployeesView.vue create mode 100644 frontend/src/views/admin/RequestsView.vue diff --git a/frontend/src/layouts/AdminLayout.vue b/frontend/src/layouts/AdminLayout.vue new file mode 100644 index 0000000..f6e2271 --- /dev/null +++ b/frontend/src/layouts/AdminLayout.vue @@ -0,0 +1,62 @@ + + + \ No newline at end of file diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 2ffac53..97638ed 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -1,51 +1,44 @@ import { createRouter, createWebHistory } from 'vue-router'; -import { useAuthStore } from '@/stores/auth'; -import LoginView from '../views/LoginView.vue'; const router = createRouter({ history: createWebHistory(), routes: [ - { - path: '/', - name: 'login', - component: LoginView - }, - { - path: '/support', - name: 'support', - component: () => import('../views/SupportView.vue'), - meta: { requiresAuth: true } - }, { path: '/admin', - name: 'admin-login', - component: () => import('../views/admin/AdminLoginView.vue') + component: () => import('@/layouts/AdminLayout.vue'), + children: [ + { + path: '', + redirect: '/admin/dashboard' + }, + { + path: 'dashboard', + name: 'AdminDashboard', + component: () => import('@/views/admin/DashboardView.vue') + }, + { + path: 'requests', + name: 'AdminRequests', + component: () => import('@/views/admin/RequestsView.vue') + }, + { + path: 'employees', + name: 'AdminEmployees', + component: () => import('@/views/admin/EmployeesView.vue') + }, + { + path: 'employees/add', + name: 'AdminEmployeeAdd', + component: () => import('@/views/admin/AddEmployeeView.vue') + } + ] }, { - path: '/admin/dashboard', - name: 'admin-dashboard', - component: () => import('../views/admin/DashboardView.vue'), - meta: { requiresAdmin: true } - }, - { - path: '/admin/employees/add', - name: 'add-employee', - component: () => import('../views/admin/AddEmployeeView.vue'), - meta: { requiresAdmin: true } + path: '/admin/login', + name: 'AdminLogin', + component: () => import('@/views/admin/AdminLoginView.vue') } ] }); -router.beforeEach((to, _, next) => { - const authStore = useAuthStore(); - - if (to.meta.requiresAuth && !authStore.isAuthenticated) { - next({ name: 'login' }); - } else if (to.meta.requiresAdmin && !authStore.isAdmin) { - next({ name: 'admin-login' }); - } else { - next(); - } -}); - export default router; \ No newline at end of file diff --git a/frontend/src/views/admin/EmployeesView.vue b/frontend/src/views/admin/EmployeesView.vue new file mode 100644 index 0000000..a4c6bfc --- /dev/null +++ b/frontend/src/views/admin/EmployeesView.vue @@ -0,0 +1,81 @@ + + + \ No newline at end of file diff --git a/frontend/src/views/admin/RequestsView.vue b/frontend/src/views/admin/RequestsView.vue new file mode 100644 index 0000000..26956d7 --- /dev/null +++ b/frontend/src/views/admin/RequestsView.vue @@ -0,0 +1,47 @@ + + + \ No newline at end of file