initial commit

This commit is contained in:
2025-11-20 14:06:59 -05:00
commit cb0f972a5f
77 changed files with 11579 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
import { createRouter, createWebHistory } from 'vue-router'
import { isParentAuthenticated } from '../stores/auth'
import ChildLayout from '../layout/ChildLayout.vue'
import ChildrenList from '../components/ChildrenList.vue'
import ChildView from '../components/ChildView.vue'
import ParentView from '../components/ParentView.vue'
import ParentLayout from '../layout/ParentLayout.vue'
const routes = [
{
path: '/child',
name: 'ChildLayout',
component: ChildLayout,
children: [
{
path: '', // /child
name: 'ChildrenList',
component: ChildrenList,
},
{
path: ':id', // /child/:id
name: 'ChildDetailView',
component: ChildView,
props: true,
},
],
},
{
path: '/parent',
name: 'ParentLayout',
component: ParentLayout,
meta: { requiresAuth: true },
children: [
{
path: '', // /parent
name: 'ParentChildrenList',
component: ChildrenList,
},
{
path: ':id',
name: 'ParentChildDetailView',
component: ParentView,
props: true,
},
],
},
{
path: '/',
redirect: '/child',
},
]
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
})
// Auth guard
router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth && !isParentAuthenticated.value) {
// Redirect to /child if trying to access /parent without auth
next('/child')
} else {
next()
}
})
export default router