alpha
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import React from 'react';
|
||||
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';
|
||||
@@ -25,10 +26,49 @@ 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<boolean | null>(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 (
|
||||
<div className="d-flex align-items-center justify-content-center min-vh-100">
|
||||
<div className="spinner-border text-primary" role="status">
|
||||
<span className="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Show alpha gate if no access
|
||||
if (!hasAlphaAccess) {
|
||||
return <AlphaGate />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user