import GuestLayout from '@/Layouts/GuestLayout';
import { Head, Link, useForm } from '@inertiajs/react';
import { FormEventHandler } from 'react';
import { Button } from '@/Components/ui/button';
import { Card } from '@/Components/ui/card';

export default function VerifyEmail({ status }: { status?: string }) {
    const { post, processing } = useForm({});

    const submit: FormEventHandler = (e) => {
        e.preventDefault();

        post(route('verification.send'));
    };

    return (
        <GuestLayout>
            <Head title="Email Verification" />

            <div className="flex flex-col items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
                <Card className="w-full max-w-md rounded-3xl overflow-hidden p-8 text-center">
                    <div className="mb-6 text-sm text-gray-600 dark:text-gray-400">
                        Thanks for signing up! Before getting started, could you verify
                        your email address by clicking on the link we just emailed to
                        you? If you didn't receive the email, we will gladly send you
                        another.
                    </div>

                    {status === 'verification-link-sent' && (
                        <div className="mb-6 text-sm font-medium text-green-600 dark:text-green-400">
                            A new verification link has been sent to the email address
                            you provided during registration.
                        </div>
                    )}

                    <form onSubmit={submit} className="space-y-4">
                        <button className="btn btn-primary w-full h-auto py-3 rounded-xl shadow-sm font-bold text-white" disabled={processing}>
                            Resend Verification Email
                        </button>

                        <Link
                            href={route('logout')}
                            method="post"
                            as="button"
                            className="text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:text-gray-400 dark:hover:text-gray-100"
                        >
                            Log Out
                        </Link>
                    </form>
                </Card>
            </div>
        </GuestLayout>
    );
}
