import { Head, usePage } from '@inertiajs/react';
import { AlertTriangle } from 'lucide-react';

interface PageProps {
    reason: 'not_found' | 'cancelled' | 'expired';
}

const MESSAGES: Record<PageProps['reason'], { title: string; text: string }> = {
    not_found: {
        title: 'Lien invalide',
        text: 'Ce document est introuvable ou le lien est incorrect.',
    },
    cancelled: {
        title: 'Document annulé',
        text: 'Ce document a été annulé par son expéditeur.',
    },
    expired: {
        title: 'Lien expiré',
        text: 'Le lien de signature a expiré. Veuillez contacter l\'expéditeur pour en obtenir un nouveau.',
    },
};

export default function PublicDocumentNotFound() {
    const { reason } = usePage<PageProps>().props;
    const msg = MESSAGES[reason] ?? MESSAGES.not_found;
    return (
        <>
            <Head title={msg.title} />
            <div className="flex min-h-screen items-center justify-center bg-slate-100 p-6">
                <div className="max-w-md rounded-md border border-rose-200 bg-white p-6 text-center shadow-sm">
                    <AlertTriangle className="mx-auto mb-3 h-10 w-10 text-rose-500" />
                    <h1 className="text-lg font-semibold">{msg.title}</h1>
                    <p className="mt-2 text-sm text-muted-foreground">{msg.text}</p>
                </div>
            </div>
        </>
    );
}
