/**
 * 路由配置
 */

import React from 'react'
import { createBrowserRouter, Navigate } from 'react-router-dom'
import MainLayout from '@layout/MainLayout'
import Home from '@pages/Home'
import HeritageList from '@pages/Heritage/List'
import HeritageDetail from '@pages/Heritage/Detail'
import InheritorsList from '@pages/Inheritors/List'
import InheritorDetail from '@pages/Inheritor/Detail'
import NewsPage from '@pages/News'
import NewsDetail from '@pages/News/Detail'
import EventDetail from '@pages/News/EventDetail'
import Login from '@pages/User/Login'
import Register from '@pages/User/Register'
import UserCenter from '@pages/User/Center'
import SearchPage from '@pages/Search'
import DataVisualization from '@pages/Data'
import About from '@pages/About'

const router = createBrowserRouter([
  {
    path: '/',
    element: <MainLayout />,
    children: [
      {
        index: true,
        element: <Home />,
      },
      {
        path: 'heritage',
        element: <HeritageList />,
      },
      {
        path: 'heritage/categories/:category',
        element: <HeritageList />,
      },
      {
        path: 'heritage/:id',
        element: <HeritageDetail />,
      },
      {
        path: 'inheritors',
        element: <InheritorsList />,
      },
      {
        path: 'inheritor/:id',
        element: <InheritorDetail />,
      },
      {
        path: 'search',
        element: <SearchPage />,
      },
      {
        path: 'data',
        element: <DataVisualization />,
      },
      {
        path: 'user/center',
        element: <UserCenter />,
      },
      {
        path: 'about',
        element: <About />,
      },
      {
        path: 'news',
        element: <NewsPage />,
      },
      {
        path: 'news/:id',
        element: <NewsDetail />,
      },
      {
        path: 'events/:id',
        element: <EventDetail />,
      },
      {
        path: '*',
        element: <Navigate to="/" replace />,
      },
    ],
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '/register',
    element: <Register />,
  },
])

export default router
