import { useState } from 'react'; import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'; import { AuthProvider, useAuth } from './contexts/AuthContext.jsx'; import { SocketProvider } from './contexts/SocketContext.jsx'; import { ToastProvider } from './contexts/ToastContext.jsx'; import Login from './pages/Login.jsx'; import Chat from './pages/Chat.jsx'; import ChangePassword from './pages/ChangePassword.jsx'; // ── iOS "Add to Home Screen" banner ─────────────────────────────────────────── // iOS Safari does not fire beforeinstallprompt. Push notifications require the // app to be installed as a PWA. This banner is shown to any iOS Safari user who // has not yet added the app to their Home Screen. const IOS_BANNER_KEY = 'rc_ios_install_dismissed'; function IOSInstallBanner() { const isIOS = /iphone|ipad|ipod/i.test(navigator.userAgent); const isStandalone = window.navigator.standalone === true; const [dismissed, setDismissed] = useState(() => localStorage.getItem(IOS_BANNER_KEY) === '1'); if (!isIOS || isStandalone || dismissed) return null; const dismiss = () => { localStorage.setItem(IOS_BANNER_KEY, '1'); setDismissed(true); }; return (
Add to Home Screen
To receive push notifications, tap the{' '} {' '}Share button, then select "Add to Home Screen".
); } function ProtectedRoute({ children }) { const { user, loading, mustChangePassword } = useAuth(); if (loading) return (
); if (!user) return ; if (mustChangePassword) return ; return children; } function AuthRoute({ children }) { const { user, loading, mustChangePassword } = useAuth(); document.documentElement.setAttribute('data-theme', 'light'); if (loading) return null; if (user && !mustChangePassword) return ; return children; } function RestoreTheme() { const saved = localStorage.getItem('rosterchirp-theme') || 'light'; document.documentElement.setAttribute('data-theme', saved); return null; } export default function App() { return ( {/* All routes go through jama auth */} } /> } /> } /> } /> } /> ); }