Files
MOPC-Portal/src/app/(admin)/error.tsx
Matt b5425e705e
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m33s
Apply full refactor updates plus pipeline/email UX confirmations
2026-02-14 15:26:42 +01:00

73 lines
2.5 KiB
TypeScript

'use client'
import { useEffect } from 'react'
import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { AlertTriangle, RefreshCw, LayoutDashboard } from 'lucide-react'
import { isChunkLoadError, attemptChunkErrorRecovery } from '@/lib/chunk-error-recovery'
export default function AdminError({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
useEffect(() => {
console.error('Admin section error:', error)
if (isChunkLoadError(error)) {
attemptChunkErrorRecovery('admin')
}
}, [error])
const isChunk = isChunkLoadError(error)
return (
<div className="flex min-h-[50vh] items-center justify-center p-4">
<Card className="max-w-md">
<CardHeader className="text-center">
<div className="mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10">
<AlertTriangle className="h-6 w-6 text-destructive" />
</div>
<CardTitle>Something went wrong</CardTitle>
</CardHeader>
<CardContent className="space-y-4 text-center">
<p className="text-muted-foreground">
{isChunk
? 'A new version of the platform may have been deployed. Please reload the page.'
: 'An error occurred while loading this admin page. Please try again or return to the dashboard.'}
</p>
{!isChunk && (error.message || error.digest) && (
<p className="text-xs text-muted-foreground bg-muted rounded px-3 py-2 font-mono break-all">
{error.message || `Error ID: ${error.digest}`}
</p>
)}
<div className="flex justify-center gap-2">
{isChunk ? (
<Button onClick={() => window.location.reload()}>
<RefreshCw className="mr-2 h-4 w-4" />
Reload Page
</Button>
) : (
<>
<Button onClick={reset} variant="outline">
<RefreshCw className="mr-2 h-4 w-4" />
Try Again
</Button>
<Button asChild>
<Link href="/admin">
<LayoutDashboard className="mr-2 h-4 w-4" />
Dashboard
</Link>
</Button>
</>
)}
</div>
</CardContent>
</Card>
</div>
)
}