import React, { useState, useEffect } from 'react'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import { AuthProvider, useAuth } from './contexts/AuthContext'; import Navbar from './components/Navbar'; import Footer from './components/Footer'; import AuthModal from './components/AuthModal'; import AlphaGate from './components/AlphaGate'; import Home from './pages/Home'; import GoogleCallback from './pages/GoogleCallback'; import VerifyEmail from './pages/VerifyEmail'; import ResetPassword from './pages/ResetPassword'; import ItemList from './pages/ItemList'; import ItemDetail from './pages/ItemDetail'; import EditItem from './pages/EditItem'; import RentItem from './pages/RentItem'; import CreateItem from './pages/CreateItem'; import MyRentals from './pages/MyRentals'; import MyListings from './pages/MyListings'; import Profile from './pages/Profile'; import PublicProfile from './pages/PublicProfile'; import Messages from './pages/Messages'; import MessageDetail from './pages/MessageDetail'; import ItemRequests from './pages/ItemRequests'; import ItemRequestDetail from './pages/ItemRequestDetail'; import CreateItemRequest from './pages/CreateItemRequest'; import MyRequests from './pages/MyRequests'; import EarningsDashboard from './pages/EarningsDashboard'; import PrivateRoute from './components/PrivateRoute'; import axios from 'axios'; import './App.css'; const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:5001'; const AppContent: React.FC = () => { const { showAuthModal, authModalMode, closeAuthModal } = useAuth(); const [hasAlphaAccess, setHasAlphaAccess] = useState(null); const [checkingAccess, setCheckingAccess] = useState(true); useEffect(() => { const checkAlphaAccess = async () => { try { const response = await axios.get(`${API_URL}/alpha/verify-session`, { withCredentials: true, }); setHasAlphaAccess(response.data.hasAccess); } catch (error) { console.error('Error checking alpha access:', error); setHasAlphaAccess(false); } finally { setCheckingAccess(false); } }; checkAlphaAccess(); }, []); // Show loading state while checking if (checkingAccess) { return (
Loading...
); } // Show alpha gate if no access if (!hasAlphaAccess) { return ; } return ( <>
} /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } />
); }; function App() { return ( ); } export default App;