// Libs
// -----------------------------------------------------------------------------
import { FC } from 'react';
import { useLocation, Routes, Route } from 'react-router-dom';

// App
// -----------------------------------------------------------------------------
import { useRoutes } from './routes';
import './AppRoutes.module.scss';

// Props
// -----------------------------------------------------------------------------
type AppRoutesProps = {
  isLicenseActivated: boolean | null;
};

export const AppRoutes: FC<AppRoutesProps> = ({ isLicenseActivated }) => {
  const { pathname } = useLocation();
  const routes = useRoutes(isLicenseActivated);

  return (
    <Routes location={pathname}>
      {routes.map((route) => {
        return (
          <Route key={route.path} path={route.path} element={route.component} />
        );
      })}
    </Routes>
  );
};
