import React from 'react';
import {
    createBrowserRouter,
    RouterProvider,
} from 'react-router-dom';

//import root route
import Root from './routes/root';

//import error route
//TODO Why is this page not working?
import ErrorPage from './error-page';

//import contact route
//TODO Why is this page not working?
import Contact from './routes/contact';

//create Browser Router and configure route
const router=createBrowserRouter([
    {
	path:"/",
	element:<Root />,
	errorElement:<ErrorPage />,
    },
    {
	path:"contacts/:contactId",
	element:<Contact />,
    },
]);

//TODO remove debugging
if (process.env.NODE_ENV !== 'production') {
    console.log('development mode');
}

//since react 18
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById("root"));
//render root app
root.render(
    <React.StrictMode>
	<RouterProvider router={router} />
    </React.StrictMode>
);
