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 CartPage from './pages/CartPage.jsx';
import ErrorPage from './pages/ErrorPage.jsx';
import Page1 from './pages/Page1.jsx';
import Page3 from './pages/Page3.jsx';
import Page4 from './pages/Page4.jsx';
import PageEdit from './pages/PageEdit.jsx';
import Admin from './pages/Admin.jsx';
import Login from './pages/Login.jsx';
import Search from './pages/Search.jsx';

const routes = [
  {
    index: true,
    path: '/',
    element: <Page1 />,
  },
  {
    path: '/page2',
    element: <CartPage />,
    title: 'Favourite',
  },
  {
    path: '/page3',
    element: <Page3 />,
    title: 'Audio',
  },
  {
    path: '/page4',
    element: <Page4 />,
    title: 'Comics',
  },
  {
    path: '/page-edit/:id',
    element: <PageEdit />,
  },
  {
    path: '/cart',
    element: <CartPage />,
  },
  {
    path: '/admin',
    element: <Admin />,
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '/search',
    element: <Search />,
  },
];

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>,
);
