import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

import LayoutView from '../views/layout/index.vue'
import LoginView from '../views/login/index.vue'
import MenuView from '../views/menu/index.vue'
import OrderView from '../views/order/index.vue'
import orderDetail from '../views/order/orderDetail.vue'
import ExitView from '../views/exit/index.vue'
import GoodsView from '../views/goods/index.vue'

const routes: RouteRecordRaw[] = [
  { path: '/login', component: LoginView },
  {
    path: '/',
    component: LayoutView,
    redirect: '/menu',
    children: [
      { path: '/menu', component: MenuView },
      {
        path: '/order',
        children: [
          {
            path: 'orderList',
            component: OrderView,
          },
          {
            path: 'orderDetail',
            component: orderDetail,
          },
        ],
      },
      { path: '/exit', component: ExitView },
      { path: '/goods', component: GoodsView },
    ],
  },
  {
    path: '/test',
    name: 'Test',
    component: () => import('@/views/test/index.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router
