|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { useEffect, useState } from 'react' |
| 4 | +import Link from 'next/link' |
| 5 | +import { Button } from '@/components/ui/button' |
| 6 | +import { useBrandConfig } from '@/lib/branding/branding' |
| 7 | +import AuthBackground from '@/app/(auth)/components/auth-background' |
| 8 | +import Nav from '@/app/(landing)/components/nav/nav' |
| 9 | + |
| 10 | +function isColorDark(hexColor: string): boolean { |
| 11 | + const hex = hexColor.replace('#', '') |
| 12 | + const r = Number.parseInt(hex.substring(0, 2), 16) |
| 13 | + const g = Number.parseInt(hex.substring(2, 4), 16) |
| 14 | + const b = Number.parseInt(hex.substring(4, 6), 16) |
| 15 | + const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255 |
| 16 | + return luminance < 0.5 |
| 17 | +} |
| 18 | + |
| 19 | +export default function NotFound() { |
| 20 | + const [buttonClass, setButtonClass] = useState('auth-button-gradient') |
| 21 | + const brandConfig = useBrandConfig() |
| 22 | + |
| 23 | + useEffect(() => { |
| 24 | + const rootStyle = getComputedStyle(document.documentElement) |
| 25 | + const brandBackground = rootStyle.getPropertyValue('--brand-background-hex').trim() |
| 26 | + |
| 27 | + if (brandBackground && isColorDark(brandBackground)) { |
| 28 | + document.body.classList.add('auth-dark-bg') |
| 29 | + } else { |
| 30 | + document.body.classList.remove('auth-dark-bg') |
| 31 | + } |
| 32 | + }, []) |
| 33 | + |
| 34 | + useEffect(() => { |
| 35 | + const checkCustomBrand = () => { |
| 36 | + const computedStyle = getComputedStyle(document.documentElement) |
| 37 | + const brandAccent = computedStyle.getPropertyValue('--brand-accent-hex').trim() |
| 38 | + if (brandAccent && brandAccent !== '#6f3dfa') { |
| 39 | + setButtonClass('auth-button-custom') |
| 40 | + } else { |
| 41 | + setButtonClass('auth-button-gradient') |
| 42 | + } |
| 43 | + } |
| 44 | + checkCustomBrand() |
| 45 | + window.addEventListener('resize', checkCustomBrand) |
| 46 | + const observer = new MutationObserver(checkCustomBrand) |
| 47 | + observer.observe(document.documentElement, { |
| 48 | + attributes: true, |
| 49 | + attributeFilter: ['style', 'class'], |
| 50 | + }) |
| 51 | + return () => { |
| 52 | + window.removeEventListener('resize', checkCustomBrand) |
| 53 | + observer.disconnect() |
| 54 | + } |
| 55 | + }, []) |
| 56 | + |
| 57 | + return ( |
| 58 | + <AuthBackground> |
| 59 | + <main className='relative flex min-h-screen flex-col font-geist-sans text-foreground'> |
| 60 | + {/* Header */} |
| 61 | + <Nav hideAuthButtons={true} variant='auth' /> |
| 62 | + |
| 63 | + {/* Content */} |
| 64 | + <div className='relative z-30 flex flex-1 items-center justify-center px-4 pb-24'> |
| 65 | + <div className='text-center'> |
| 66 | + <div className='mb-4 font-bold text-8xl text-foreground'>404</div> |
| 67 | + <div className='mb-8'> |
| 68 | + <Button |
| 69 | + asChild |
| 70 | + className={`${buttonClass} flex w-full items-center justify-center gap-2 rounded-[10px] border font-medium text-[15px] text-white transition-all duration-200`} |
| 71 | + > |
| 72 | + <Link href='/'>Back to Workspace</Link> |
| 73 | + </Button> |
| 74 | + </div> |
| 75 | + |
| 76 | + <div className='text-center text-muted-foreground text-sm'> |
| 77 | + Need help?{' '} |
| 78 | + <a |
| 79 | + href={`mailto:${brandConfig.supportEmail}`} |
| 80 | + className='underline-offset-4 transition hover:underline' |
| 81 | + > |
| 82 | + Contact support |
| 83 | + </a> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + </main> |
| 88 | + </AuthBackground> |
| 89 | + ) |
| 90 | +} |
0 commit comments