| 1 | import { ArrowRight } from 'lucide-react' |
| 2 | import type { Metadata |
| 3 | import Link from 'next/link |
| 4 | import { buttonVariants } |
| 5 | import { createMetadata } |
| 6 | |
| 7 | const ERROR_CODES = { |
| 8 | '400': { |
| 9 | title: 'Bad request', |
| 10 | accent: 'something was off.', |
| 11 | message: 'The request was malformed or invalid.', |
| 12 | }, |
| 13 | '401': { |
| 14 | title: 'Unauthorized', |
| 15 | accent: 'sign in to continue.', |
| 16 | message: 'You need to sign in to view this page.', |
| 17 | }, |
| 18 | '403': { |
| 19 | title: 'Forbidden', |
| 20 | accent: "you can't go in there.", |
| 21 | message: 'You do not have permission to view this page.', |
| 22 | }, |
| 23 | '404': { |
| 24 | title: 'Not found', |
| 25 | accent: 'nothing lives here.', |
| 26 | message: "The page you're looking for doesn't exist.", |
| 27 | }, |
| 28 | '408': { |
| 29 | title: 'Request timeout', |
| 30 | accent: 'we ran out of time.', |
| 31 | message: 'The request took too long to complete.', |
| 32 | }, |
| 33 | '410': { |
| 34 | title: 'Gone', |
| 35 | accent: 'this is no longer here.', |
| 36 | message: 'This resource is no longer available.', |
| 37 | }, |
| 38 | '429': { |
| 39 | title: 'Too many requests', |
| 40 | accent: 'slow down a moment.', |
| 41 | message: 'You are being rate limited. Please try again later.', |
| 42 | }, |
| 43 | '500': { |
| 44 | title: 'Internal server error', |
| 45 | accent: 'something broke on our end.', |
| 46 | message: 'Something went wrong on our end.', |
| 47 | }, |
| 48 | '502': { |
| 49 | title: 'Bad gateway', |
| 50 | accent: 'the wires got crossed.', |
| 51 | message: 'The server received an invalid response.', |
| 52 | }, |
| 53 | '503': { |
| 54 | title: 'Service unavailable', |
| 55 | accent: 'be back in a moment.', |
| 56 | message: 'The service is temporarily unavailable.', |
| 57 | }, |
| 58 | '504': { |
| 59 | title: 'Gateway timeout', |
| 60 | accent: 'the upstream is napping.', |
| 61 | message: 'The upstream server took too long to respond.', |
| 62 | }, |
| 63 | } as const |
| 64 | |
| 65 | export const dynamicParams = |
| 66 | |
| 67 | export function generateStaticParams() |
| 68 | return Object.keys |
| 69 | } |
| 70 | |
| 71 | export const metadata: |
| 72 | title: 'Error', |
| 73 | description: 'Something went wrong.', |
| 74 | }) |
| 75 | |
| 76 | export default async function |
| 77 | params, |
| 78 | searchParams, |
| 79 | }: PageProps< |
| 80 | const { code |
| 81 | const sp = |
| 82 | const messageParam = |
| 83 | const message = |
| 84 | |
| 85 | const known = |
| 86 | const title = |
| 87 | const accent = |
| 88 | const description = |
| 89 | |
| 90 | return ( |
| 91 | <main className='relative flex w-full flex-1 items-center justify-center overflow-hidden bg-background px-6 py-24 text-foreground |
| 92 | <div |
| 93 | aria-hidden |
| 94 | className='pointer-events-none absolute top-1/2 left-1/2 -z-10 h-72 w-[60%] -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary/15 blur-3xl' |
| 95 | /> |
| 96 | <div className='relative mx-auto w-full max-w-2xl |
| 97 | <div className='inline-flex items-center gap-2 font-mono text-[11px] text-muted-foreground uppercase tracking-[0.18em] |
| 98 | <span className='h-px w-6 bg-muted-foreground/40 |
| 99 | Error / {code} |
| 100 | </div> |
| 101 | <h1 className='mt-6 font-semibold text-5xl text-foreground leading-[0.98] tracking-[-0.04em] sm:text-6xl |
| 102 | {title}. |
| 103 | <br /> |
| 104 | <span className='text-muted-foreground/80 italic |
| 105 | </h1> |
| 106 | <p className='mt-8 max-w-xl text-lg text-muted-foreground leading-relaxed |
| 107 | {description} |
| 108 | </p> |
| 109 | <div className='mt-10 flex items-center gap-3 |
| 110 | <Link className={ |
| 111 | Back to dashboard |
| 112 | <ArrowRight className=' |
| 113 | </Link> |
| 114 | <Link |
| 115 | className='inline-flex items-center gap-1.5 text-foreground/80 text-sm hover:text-foreground' |
| 116 | href='/' |
| 117 | > |
| 118 | Go home |
| 119 | </Link> |
| 120 | </div> |
| 121 | </div> |
| 122 | </main> |
| 123 | ) |
| 124 | } |