Files
website/client/src/components/MaintenanceGate.jsx
2026-06-26 21:51:27 -05:00

23 lines
771 B
JavaScript

import { useAuth } from '../contexts/AuthContext.jsx'
import { useSite } from '../contexts/SiteContext.jsx'
import Maintenance from '../routes/public/Maintenance.jsx'
// Wraps the public site. When the shard is in maintenance, visitors see the
// coming-soon page; a logged-in admin sees the real site (live preview).
export default function MaintenanceGate({ children }) {
const { mode, loading } = useSite()
const { user, loading: authLoading } = useAuth()
if (loading || authLoading) {
return (
<div style={{ minHeight: '100vh', display: 'grid', placeItems: 'center', background: 'var(--bg-deep)' }}>
<span className="spin" />
</div>
)
}
if (mode === 'maintenance' && !user) {
return <Maintenance />
}
return children
}