summaryrefslogtreecommitdiff
path: root/src/main.tsx
blob: 6e36c31c3cd00447e02bca45d74fd0407b24580e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react'
import ReactDOM from 'react-dom/client'
import { BrowserRouter, createBrowserRouter, Navigate, RouterProvider } from 'react-router-dom'
import Products from "./routes/products/products";
import Product from "./routes/products/product";
import Companies from "./routes/companies/companies";
import Layout from "./components/layout";
import { loader, productLoader } from "./clients/loaders"; 
import './index.css';

const routes = [
  {
    path: '/products',
    loader: loader,
    element: <Products/>
  },
  {
    path: "products/:productId",
    loader: productLoader,
    element: <Product/>
  },
  {
    path: "/companies",
    loader: loader,
    element: <Companies/>
  },
  {
    path: '/',
    element: <Navigate to='/products'/>
  }
];

const router = createBrowserRouter(routes);

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