import { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('src/layouts/MainLayout.vue'),
    // If we get so big we need lazy loading, we can use imports again
    // component: () => import('layouts/MainLayout.vue'),
    children: [
      {
        path: '',
        // If we get so big we need lazy loading, we can use imports again
        // component: () => import('pages/IndexPage.vue'),
        component: () => import('src/pages/IndexPage.vue'),
        name: 'index',
        meta: { title: 'OYS Borrow a Boat' },
      },
      {
        path: '/boat',
        component: () => import('src/pages/BoatPage.vue'),
        name: 'boat',
        meta: { title: 'Boats' },
      },
      {
        path: '/schedule',
        component: () => import('pages/schedule/SchedulePageView.vue'),
        name: 'schedule',
        meta: { title: 'Schedule' },
        children: [
          {
            path: '',
            component: () => import('pages/schedule/ScheduleIndexPage.vue'),
            name: 'schedule-index',
          },
          {
            path: 'book',
            component: () =>
              import('src/pages/schedule/BoatReservationPage.vue'),
            name: 'reserve-boat',
          },
          {
            path: 'view',
            component: () => import('src/pages/schedule/BoatScheduleView.vue'),
            name: 'boat-schedule',
          },
          {
            path: 'list',
            component: () =>
              import('src/pages/schedule/ListReservationsPage.vue'),
            name: 'list-reservations',
          },
          {
            path: 'edit/:id',
            component: () =>
              import('src/pages/schedule/ModifyBoatReservation.vue'),
            name: 'edit-reservation',
          },
          {
            path: 'manage',
            component: () => import('src/pages/schedule/ManageCalendar.vue'),
            name: 'manage-schedule',
            meta: { requiredRoles: ['Schedule Admins'] },
          },
        ],
      },
      {
        path: '/certification',
        component: () => import('src/pages/CertificationPage.vue'),
        name: 'certification',
        meta: { title: 'Certifications' },
      },
      {
        path: '/task',
        name: 'task',
        meta: { title: 'Tasks' },
        children: [
          {
            path: '',
            component: () => import('src/pages/task/TaskPage.vue'),
            name: 'task-index',
          },
          {
            path: '/:id/edit',
            component: () => import('pages/task/TaskEditPage.vue'),
            name: 'edit-task',
          },
        ],
      },
      {
        path: '/checklist',
        component: () => import('pages/ChecklistPage.vue'),
        name: 'checklist',
        meta: { title: 'Checklist' },
      },
      {
        path: '/profile',
        component: () => import('src/pages/ProfilePage.vue'),
        name: 'profile',
        meta: { title: 'Member Profile' },
      },
      {
        path: '/reference',
        component: () => import('src/pages/reference/ReferencePage.vue'),
        name: 'reference',
        meta: { title: 'Reference' },
        children: [
          {
            path: '',
            component: () =>
              import('src/pages/reference/ReferenceIndexPage.vue'),
            name: 'reference-index',
          },
          {
            path: 'reference/:id/view',
            component: () =>
              import('src/pages/reference/ReferenceItemPage.vue'),
          },
        ],
      },
    ],
  },
  {
    path: '/admin',
    component: () => import('layouts/AdminLayout.vue'),
    meta: { requiredRoles: ['admin'] },
    children: [
      {
        path: 'user',
        component: () => import('pages/admin/UserAdminPage.vue'),
        name: 'useradmin',
      },
      {
        path: 'boat',
        component: () => import('pages/admin/BoatAdminPage.vue'),
        name: 'boatadmin',
      },
    ],
  },
  {
    path: '/login',
    component: () => import('pages/LoginPage.vue'),
    name: 'login',
    meta: {
      publicRoute: true,
    },
  },
  {
    path: '/pwreset',
    component: () => import('pages/ResetPassword.vue'),
    name: 'pwreset',
    meta: {
      publicRoute: true,
    },
  },
  {
    path: '/terms-of-service',
    component: () => import('pages/TermsOfServicePage.vue'),
    name: 'tospage',
    meta: {
      publicRoute: true,
    },
  },
  {
    path: '/privacy-policy',
    component: () => import('pages/PrivacyPolicyPage.vue'),
    name: 'privacy-policy',
    meta: {
      publicRoute: true,
    },
  },
  {
    path: '/signup',
    component: () => import('pages/SignupPage.vue'),
    name: 'signup',
    meta: {
      publicRoute: true,
    },
  },
  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/ErrorNotFound.vue'),
  },
];

export default routes;
