import React from 'react'; import { BrowserRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom'; import { ThemeProvider } from './hooks/useTheme'; import { AuthProvider, useAuth } from './hooks/useAuth.tsx'; import LandingPage from './pages/Landing/LandingPage'; import DashboardPage from './pages/Dashboard/DashboardPage'; import TextLabPage from './pages/TextLab/TextLabPage'; import AudioLabPage from './pages/AudioLab/AudioLabPage'; import ImageLabPage from './pages/ImageLab/ImageLabPage'; import VideoLabPage from './pages/VideoLab/VideoLabPage'; import AboutPage from './pages/About/AboutPage'; import ContactPage from './pages/Contact/ContactPage'; import SubscriptionPage from './pages/Subscription/SubscriptionPage'; import LoginPage from './pages/Auth/LoginPage'; import SignupPage from './pages/Auth/SignupPage'; import SettingsPage from './pages/Settings/SettingsPage'; import PrivacyPage from './pages/Legal/PrivacyPage'; import TermsPage from './pages/Legal/TermsPage'; import FAQPage from './pages/Legal/FAQPage'; import './App.css'; // Protected Route Component const ProtectedRoute = ({ children }: { children: React.ReactNode }) => { const { isAuthenticated, isLoading } = useAuth(); const location = useLocation(); if (isLoading) { return (
); } if (!isAuthenticated) { return ; } return <>{children}; }; // Paid Route Component const PaidRoute = ({ children }: { children: React.ReactNode }) => { const { user, isAuthenticated, isLoading } = useAuth(); if (isLoading) return null; if (!isAuthenticated) return ; if (user?.subscription_tier !== 'paid') return ; return <>{children}; }; function App() { return ( } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); } export default App;