import Vue from 'vue'
import VueRouter from 'vue-router'
import FrontOffice from '../layouts/FrontOffice.vue'
import BackOffice from '../layouts/BackOffice.vue'

import Index from '../views/Index.vue'
import Login from '../views/Login.vue'
import AdminLogin from '../views/AdminLogin.vue'
import Register from '../views/Register.vue'
import AboutUs from '../views/AboutUs.vue'
import JobDetail from '../views/JobDetail.vue'
import JobList from '../views/JobList.vue'
import BookmarkList from '../views/BookmarkList.vue'
import JobApply from '../views/JobApply.vue'

import AdminIndex from '../views/admin/AdminIndex.vue'
import AdminAddJob from '../views/admin/AdminAddJob.vue'
import AdminEditJob from '../views/admin/AdminEditJob.vue'
import AdminApplicantDetail from '../views/admin/AdminApplicantDetail'
Vue.use(VueRouter)

const routes = [
  { 
    path: "/",
    component: FrontOffice,
    children: [
      {
        name: 'index',
        path: '',
        component: Index,
      },
      {
        name: 'login',
        path: '/login',
        component: Login,
      },
      {
        name: 'admin-login',
        path: '/admin/login',
        component: AdminLogin,
      },
      {
        name: 'register',
        path: '/register',
        component: Register,
      },
      {
        name: 'about-us',
        path: 'about',
        component: AboutUs,
      },
      {
        name: 'job-detail',
        path: '/job/:id',
        component: JobDetail,
      },
      {
        name: 'job-apply',
        path: '/job/apply/:id',
        component: JobApply,
      },
      {
        name: 'job-list',
        path: '/jobs',
        component: JobList,
      },
      {
        name: 'bookmark-list',
        path: '/bookmarks',
        component: BookmarkList,
      },
    ],
  },
  {
    path: '/admin',
    component: BackOffice,
    children: [
      { 
        name: 'admin-index',
        path: '',
        component: AdminIndex,
      },
      {
        name: 'admin-job-new',
        path: 'job/new',
        component: AdminAddJob,
      },
      {
        name: 'admin-job-edit',
        path: 'job/edit/:id',
        component: AdminEditJob,
      },
      {
        name: 'admin-job-applicants',
        path: 'applicants/:id',
        component: AdminApplicantDetail
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
