2026-03-04 17:00:19 +01:00
|
|
|
import { redirect } from 'next/navigation'
|
|
|
|
|
import { prisma } from '@/lib/prisma'
|
2026-01-30 13:41:32 +01:00
|
|
|
import { requireRole } from '@/lib/auth-redirect'
|
|
|
|
|
import { ObserverNav } from '@/components/layouts/observer-nav'
|
2026-02-20 22:45:56 +01:00
|
|
|
import { EditionProvider } from '@/components/observer/observer-edition-context'
|
2026-01-30 13:41:32 +01:00
|
|
|
|
2026-03-04 17:00:19 +01:00
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
|
|
2026-01-30 13:41:32 +01:00
|
|
|
export default async function ObserverLayout({
|
|
|
|
|
children,
|
|
|
|
|
}: {
|
|
|
|
|
children: React.ReactNode
|
|
|
|
|
}) {
|
|
|
|
|
const session = await requireRole('OBSERVER')
|
feat: impersonation system, semi-finalist detail page, tRPC resilience
- Add super-admin impersonation: "Login As" from user list, red banner
with "Return to Admin", audit logged start/end, nested impersonation
blocked, onboarding gate skipped during impersonation
- Fix semi-finalist stats: check latest terminal state (not any PASSED),
use passwordHash OR status=ACTIVE for activation check
- Add /admin/semi-finalists detail page with search, category/status filters
- Add account_reminder_days setting to notifications tab
- Add tRPC resilience: retry on 503/HTML responses, custom fetch detects
nginx error pages, exponential backoff (2s/4s/8s)
- Reduce dashboard polling intervals (60s stats, 30s activity, 120s semi)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:55:44 +01:00
|
|
|
const isImpersonating = !!session.user.impersonating
|
2026-01-30 13:41:32 +01:00
|
|
|
|
feat: impersonation system, semi-finalist detail page, tRPC resilience
- Add super-admin impersonation: "Login As" from user list, red banner
with "Return to Admin", audit logged start/end, nested impersonation
blocked, onboarding gate skipped during impersonation
- Fix semi-finalist stats: check latest terminal state (not any PASSED),
use passwordHash OR status=ACTIVE for activation check
- Add /admin/semi-finalists detail page with search, category/status filters
- Add account_reminder_days setting to notifications tab
- Add tRPC resilience: retry on 503/HTML responses, custom fetch detects
nginx error pages, exponential backoff (2s/4s/8s)
- Reduce dashboard polling intervals (60s stats, 30s activity, 120s semi)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:55:44 +01:00
|
|
|
// Check if user has completed onboarding (skip during impersonation)
|
|
|
|
|
if (!isImpersonating) {
|
|
|
|
|
const user = await prisma.user.findUnique({
|
|
|
|
|
where: { id: session.user.id },
|
|
|
|
|
select: { onboardingCompletedAt: true },
|
|
|
|
|
})
|
2026-03-04 17:00:19 +01:00
|
|
|
|
feat: impersonation system, semi-finalist detail page, tRPC resilience
- Add super-admin impersonation: "Login As" from user list, red banner
with "Return to Admin", audit logged start/end, nested impersonation
blocked, onboarding gate skipped during impersonation
- Fix semi-finalist stats: check latest terminal state (not any PASSED),
use passwordHash OR status=ACTIVE for activation check
- Add /admin/semi-finalists detail page with search, category/status filters
- Add account_reminder_days setting to notifications tab
- Add tRPC resilience: retry on 503/HTML responses, custom fetch detects
nginx error pages, exponential backoff (2s/4s/8s)
- Reduce dashboard polling intervals (60s stats, 30s activity, 120s semi)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:55:44 +01:00
|
|
|
if (!user) {
|
|
|
|
|
redirect('/login')
|
|
|
|
|
}
|
2026-03-04 17:00:19 +01:00
|
|
|
|
feat: impersonation system, semi-finalist detail page, tRPC resilience
- Add super-admin impersonation: "Login As" from user list, red banner
with "Return to Admin", audit logged start/end, nested impersonation
blocked, onboarding gate skipped during impersonation
- Fix semi-finalist stats: check latest terminal state (not any PASSED),
use passwordHash OR status=ACTIVE for activation check
- Add /admin/semi-finalists detail page with search, category/status filters
- Add account_reminder_days setting to notifications tab
- Add tRPC resilience: retry on 503/HTML responses, custom fetch detects
nginx error pages, exponential backoff (2s/4s/8s)
- Reduce dashboard polling intervals (60s stats, 30s activity, 120s semi)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:55:44 +01:00
|
|
|
if (!user.onboardingCompletedAt) {
|
|
|
|
|
redirect('/onboarding')
|
|
|
|
|
}
|
2026-03-04 17:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 13:41:32 +01:00
|
|
|
return (
|
|
|
|
|
<div className="min-h-screen bg-background">
|
2026-02-20 22:45:56 +01:00
|
|
|
<EditionProvider>
|
|
|
|
|
<ObserverNav
|
|
|
|
|
user={{
|
|
|
|
|
name: session.user.name,
|
|
|
|
|
email: session.user.email,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<main className="container-app py-6">{children}</main>
|
|
|
|
|
</EditionProvider>
|
2026-01-30 13:41:32 +01:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|