import { createRouter, createWebHistory } from 'vue-router'
import MainLayout from '@/layouts/MainLayout.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: MainLayout,
      children: [
        { path: '', name: 'home', component: () => import('@/views/HomeView.vue') },
        { path: 'category/:id', name: 'category', component: () => import('@/views/product/CategoryView.vue') },
        { path: 'product/:id', name: 'product-detail', component: () => import('@/views/product/ProductDetail.vue') },
        { path: 'cart', name: 'cart', component: () => import('@/views/cart/CartView.vue') },
        { path: 'order-confirm', name: 'order-confirm', component: () => import('@/views/order/OrderConfirm.vue') },
        { path: 'orders', name: 'orders', component: () => import('@/views/order/OrderList.vue') },
        { path: 'user', name: 'user', component: () => import('@/views/user/UserCenter.vue') },
        { path: 'address', name: 'address', component: () => import('@/views/user/AddressView.vue') },
        { path: 'favorites', name: 'favorites', component: () => import('@/views/user/FavoritesView.vue') },
        { path: 'coupons', name: 'coupons', component: () => import('@/views/user/CouponsView.vue') },
        { path: 'search', name: 'search', component: () => import('@/views/product/SearchView.vue') },
        { path: 'seckill', name: 'seckill', component: () => import('@/views/product/SeckillView.vue') },
        { path: 'notice', name: 'notice', component: () => import('@/views/NoticeView.vue') },
      ],
    },
    { path: '/login', name: 'login', component: () => import('@/views/user/LoginView.vue') },
    { path: '/register', name: 'register', component: () => import('@/views/user/RegisterView.vue') },
  ],
  scrollBehavior() {
    return { top: 0 }
  },
})

export default router
