import type { RouteRecordRaw } from 'vue-router';
import { RouteNames } from './router-constants';
import { ModuleNames } from 'src/modules/shared/models/user.models';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('src/layouts/main-layout.vue'),
    meta: { requires_auth: true },
    children: [
      {
        path: '',
        name: RouteNames.DASHBOARD,
        component: () => import('src/pages/dashboard-page.vue'),
        meta: { required_module: ModuleNames.DASHBOARD }
      },
      {
        path: 'timesheet-approvals',
        name: RouteNames.TIMESHEET_APPROVALS,
        component: () => import('src/pages/timesheet-approval-page.vue'),
        meta: { required_module: ModuleNames.TIMESHEETS_APPROVAL }
      },
      {
        path: 'employees',
        name: RouteNames.EMPLOYEE_LIST,
        component: () => import('src/pages/employee-list-page.vue'),
        meta: { required_module: ModuleNames.EMPLOYEE_LIST }
      },
      {
        path: 'timesheet',
        name: RouteNames.TIMESHEET,
        component: () => import('src/pages/timesheet-page.vue'),
        meta: { required_module: ModuleNames.TIMESHEETS },
      },
      {
        path: 'profile',
        name: RouteNames.PROFILE,
        component: () => import('src/pages/profile-page.vue'),
        meta: { required_module: ModuleNames.PERSONAL_PROFILE },
      },
      {
        path: 'help',
        name: RouteNames.HELP,
        component: () => import('src/pages/help-page.vue'),
      },
    ],
  },

  {
    path: '/v1/login',
    name: RouteNames.LOGIN,
    component: () => import('src/pages/login-page.vue'),
    meta: { requires_auth: false },
  },

  {
    path: '/login-success',
    name: RouteNames.LOGIN_SUCCESS,
    component: () => import('src/modules/auth/pages/auth-login-popup-success.vue'),
    meta: { requires_auth: false },
  },

  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    name: RouteNames.ERROR,
    component: () => import('src/pages/error-page.vue'),
    meta: { requires_auth: false },
  },
];

export default routes;
