import 'bootstrap/dist/css/bootstrap.min.css';
import React from 'react';
import ReactDOM from 'react-dom/client';
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import App from './App.jsx';
import './index.css';
import ErrorPage from './pages/ErrorPage.jsx';
import MainPage from './pages/MainPage.jsx';
import Chanel from './pages/Chanel.jsx';
import Login from './pages/Login.jsx';
import Register from './pages/Register.jsx';
import Admin from './pages/Admin.jsx';
import Repair from './pages/Repair.jsx';
import Search from './pages/Search.jsx';
import Watch from './pages/Watch.jsx';
import Redact from './pages/Redact.jsx';

const routes = [
  {
    index: true,
    path: '/',
    element: <MainPage />,
    title: 'Главная страница',
  },
  {
    path: '/chanel/:id?',
    element: <Chanel />,
    title: 'Канал',
  },
  {
    path: '/login',
    element: <Login />,
    title: 'Вход',
  },
  {
    path: '/regist',
    element: <Register />,
    title: 'Регистрация',
  },
  {
    path: '/admin',
    element: <Admin />,
    title: 'Админ Панель',
  },
  {
    path: '/account',
    element: <Repair />,
    title: 'Аккаунт',
  },
  {
    path: '/search',
    element: <Search />,
    title: 'Поиск',
  },
  {
    path: '/watch/:id?',
    element: <Watch />,
    title: 'Видео',
  },
  {
    path: '/redact/:id?',
    element: <Redact />,
  },
];

const router = createBrowserRouter([
  {
    path: '/',
    element: <App routes={routes} />,
    children: routes,
    errorElement: <ErrorPage />,
  },
]);

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <RouterProvider router={router} />
  </React.StrictMode>,
);
