import Main from './components/Main.jsx';
import React from "react";
import { useRoutes, Outlet, BrowserRouter } from 'react-router-dom';

function Router(props) {
    return useRoutes(props.rootRoute);
  }
  
  function App() {
    const routes = [
      { index: true, element: <Main /> },
      { path: '/', element: <Main />, label: 'ГЛАВНОЕ' },
    ];
    const links = routes.filter(route => route.hasOwnProperty('label'));
    const rootRoute = [
      { path: '/', element: render(links), children: routes }
    ];
    function render(links) {
      return (
        <div className="App">         
          <div className="w-100">
            <Outlet />
          </div>        
      </div>
    );
  }
  
    return (
      <BrowserRouter>
        <Router rootRoute={ rootRoute } />
      </BrowserRouter>
    );
  }
  
  export default App;