
This commit introduces a comprehensive chore management system, allowing users to create, manage, and track both personal and group chores. Key changes include: - Addition of new API endpoints for personal and group chores in `be/app/api/v1/endpoints/chores.py`. - Implementation of chore models and schemas to support the new functionality in `be/app/models.py` and `be/app/schemas/chore.py`. - Integration of chore services in the frontend to handle API interactions for chore management. - Creation of new Vue components for displaying and managing chores, including `ChoresPage.vue` and `PersonalChoresPage.vue`. - Updates to the router to include chore-related routes and navigation. This feature enhances user collaboration and organization within shared living environments, aligning with the project's goal of streamlining household management.
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
// src/router/index.ts
|
|
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
|
|
import routes from './routes'
|
|
import { useAuthStore } from '../stores/auth'
|
|
|
|
const history =
|
|
import.meta.env.VITE_ROUTER_MODE === 'history'
|
|
? createWebHistory(import.meta.env.BASE_URL)
|
|
: createWebHashHistory(import.meta.env.BASE_URL)
|
|
|
|
const router = createRouter({
|
|
history,
|
|
routes,
|
|
scrollBehavior: () => ({ left: 0, top: 0 }),
|
|
})
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
// Auth guard logic
|
|
const authStore = useAuthStore()
|
|
const isAuthenticated = authStore.isAuthenticated
|
|
const publicRoutes = ['/auth/login', '/auth/signup', '/auth/callback'] // Added callback route
|
|
const requiresAuth = !publicRoutes.includes(to.path)
|
|
|
|
if (requiresAuth && !isAuthenticated) {
|
|
next({ path: '/auth/login', query: { redirect: to.fullPath } }) // Fixed login path with leading slash
|
|
} else if (!requiresAuth && isAuthenticated) {
|
|
next({ path: '/' })
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|