68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import HomeView from '@/views/HomeView.vue'
|
|
import LoginView from '@/views/LoginView.vue'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import MyAccountView from '@/views/MyAccountView.vue'
|
|
|
|
function enforceAuth() {
|
|
const authStore = useAuthStore()
|
|
if (!authStore.state) return '/login'
|
|
return true
|
|
}
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
component: HomeView,
|
|
},
|
|
{
|
|
path: '/login',
|
|
component: LoginView,
|
|
},
|
|
{
|
|
path: '/my-account',
|
|
component: MyAccountView,
|
|
beforeEnter: [enforceAuth],
|
|
},
|
|
{
|
|
path: '/classroom-compliance',
|
|
component: () => import('@/apps/classroom_compliance/MainView.vue'),
|
|
beforeEnter: [enforceAuth],
|
|
children: [
|
|
{
|
|
path: '',
|
|
component: () => import('@/apps/classroom_compliance/ClassesView.vue'),
|
|
},
|
|
{
|
|
path: 'classes/:id',
|
|
component: () => import('@/apps/classroom_compliance/ClassView.vue'),
|
|
props: true,
|
|
},
|
|
{
|
|
path: 'edit-class',
|
|
component: () => import('@/apps/classroom_compliance/EditClassView.vue'),
|
|
},
|
|
{
|
|
path: 'classes/:classId/students/:studentId',
|
|
component: () => import('@/apps/classroom_compliance/StudentView.vue'),
|
|
props: true,
|
|
},
|
|
{
|
|
path: 'classes/:classId/edit-student',
|
|
component: () => import('@/apps/classroom_compliance/EditStudentView.vue'),
|
|
props: true,
|
|
},
|
|
{
|
|
path: 'classes/:classId/import-students',
|
|
component: () => import('@/apps/classroom_compliance/ImportStudentsView.vue'),
|
|
props: true,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
})
|
|
|
|
export default router
|