import React from 'react'; import ReactDOM from 'react-dom/client'; import { createBrowserRouter, RouterProvider, Outlet, Navigate } from 'react-router-dom'; import RootApp from '@/App'; import AdminPage from '@/pages/AdminPage'; import LoginPage from '@/pages/LoginPage'; import ManageProfilePage from '@/pages/ManageProfilePage'; import AuthCallbackPage from '@/pages/AuthCallbackPage'; import { AuthProvider, useAuth } from '@/contexts/AuthContext'; import { DataProvider, useData as useDataContextData } from '@/contexts/DataContext'; // Import useData directly import '@/index.css'; // Toaster is rendered within RootApp, so no need to import here unless specifically needed outside // import { Toaster } from '@/components/ui/toaster'; import { SearchSection } from '@/components/SearchSection'; import { useState as ReactUseState, useEffect as ReactUseEffect } from 'react'; import { Loader2 } from 'lucide-react'; function HomePageContent() { const { barbershops, barbers, loadingData } = useDataContextData(); const [currentUserPosition, setCurrentUserPosition] = ReactUseState(null); ReactUseEffect(() => { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( (position) => { setCurrentUserPosition({ latitude: position.coords.latitude, longitude: position.coords.longitude, }); }, (error) => { console.error("Error getting user location:", error); } ); } }, []); if (loadingData && (barbershops.length === 0 && barbers.length === 0) ) { return (

Carregando barbearias e barbeiros...

); } if (!loadingData && barbershops.length === 0 && barbers.length === 0) { return (

Nenhum resultado encontrado

Ainda não há barbearias ou barbeiros cadastrados. Seja o primeiro!

); } return ( ); } const ProtectedRoute = ({ children }) => { const { session, loading } = useAuth(); if (loading) { return (

Verificando Autenticação...

Aguarde um momento.

); } if (!session) { return ; } return children; }; const router = createBrowserRouter([ { path: "/", element: , children: [ { index: true, element: , } ] }, { path: "/login", element: , }, { path: "/auth/callback", element: , }, { path: "/admin", element: ( ), children: [ { index: true, element: , }, { path: "profile", element: , } ], }, { path: "*", element: } ]); ReactDOM.createRoot(document.getElementById('root')).render( );