import { Routes, Route, Navigate } from 'react-router-dom';
import Login from './pages/LoginPage/Index';
import BookingPage from './pages/BookingPage/Index';
import { getItem } from './lib/sessionStorage';
function App() {
  const RequireAuth = ({ children }) => {
    const isAuthenticated = getItem('user') ? true : false;
    return isAuthenticated ? children : <Navigate to="/login" replace />;
  };

  return (
    <Routes>
      <Route path="/login" element={<Login />} />
      <Route
        path="/"
        element={
          <RequireAuth>
            <BookingPage />
          </RequireAuth>
        }
      />
    </Routes>
  );
}

export default App;
