import { createRouter, createWebHistory } from 'vue-router';
import { authGuard } from '@/core/auth/auth.guard';
import { authRoutes } from '@/modules/auth/auth.routes';
import { dashboardRoutes } from '@/modules/dashboard/dashboard.routes';
import { userRoutes } from '@/modules/user/user.routes';
import { projectRoutes } from '@/modules/project/project.routes';
import { wbsRoutes } from '@/modules/wbs/wbs.routes';
import { tealRoutes } from '@/modules/teal/teal.routes';
import { timesheetRoutes } from '@/modules/timesheet/timesheet.routes';
import { approvalRoutes } from '@/modules/approval/approval.routes';
import { reportRoutes } from '@/modules/report/report.routes';
import { settingsRoutes } from '@/modules/settings/settings.routes';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    ...authRoutes,
    {
      path: '/',
      component: () => import('@/core/components/AppLayout.vue'),
      beforeEnter: authGuard,
      redirect: '/dashboard',
      children: [
        ...dashboardRoutes,
        ...userRoutes,
        ...projectRoutes,
        ...wbsRoutes,
        ...tealRoutes,
        ...timesheetRoutes,
        ...approvalRoutes,
        ...reportRoutes,
        ...settingsRoutes,
      ],
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'not-found',
      component: () => import('@/core/components/NotFoundView.vue'),
    },
  ],
});

export default router;
