import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {
  createHashRouter,
  createRoutesFromElements,
  Navigate,
  Route,
  RouterProvider,
} from 'react-router-dom';
import Measure from './pages/Measure';
import Setting from './pages/Setting';
import Bluetooth from './pages/Bluetooth';
import Mine from './pages/Mine';
import MeasureSave from './pages/MeasureSave';
import MeasureRecord from './pages/MeasureRecord';

const router = createHashRouter(
  createRoutesFromElements(
    <Route path="/">
      <Route index element={<Navigate to="home/measure" replace />} />
      <Route path="home" element={<App />}>
        <Route path="measure" element={<Measure />} ></Route>
        <Route path="setting" element={<Setting />}></Route>
        <Route path="bluetooth" element={<Bluetooth />}></Route>
        <Route path="mine" element={<Mine />}></Route>
      </Route>
      <Route path="measure">
        <Route path="save" element={<MeasureSave />}></Route>
        <Route path="record/:recordId" element={<MeasureRecord />}></Route>
      </Route>
    </Route>
  )
);

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

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
