Frontend update
This commit is contained in:
22
client/src/components/MaintenanceGate.jsx
Normal file
22
client/src/components/MaintenanceGate.jsx
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user