<script setup lang="ts">
import MainLayout from "@/Layouts/MainLayout.vue";
import GlassBox from "@/Components/FlightsGoneBy/GlassBox.vue";
import { Head, Link, useForm } from "@inertiajs/vue3";
import { computed } from "vue";

defineOptions({ layout: MainLayout });

const props = defineProps<{
    status?: string;
}>();

const form = useForm({});

const submit = () => {
    form.post(route('verification.send'));
};

const verificationLinkSent = computed(() => props.status === 'verification-link-sent');
</script>

<template>
    <Head title="Email Verification" />
    <GlassBox>
        <h2>Verify Your Email</h2>
        <p>Thanks for signing up! Please verify your email address by clicking the link we sent you. If you didn't receive it, we can send another.</p>

        <v-alert v-if="verificationLinkSent" type="success" class="mb-2">
            A new verification link has been sent to your email address.
        </v-alert>

        <v-form style="width: 100%" @submit.prevent="submit">
            <v-container>
                <v-row>
                    <v-col cols="12" class="d-flex align-center justify-space-between">
                        <v-btn
                            size="large"
                            type="submit"
                            :loading="form.processing"
                            :disabled="form.processing"
                        >
                            Resend Verification Email
                        </v-btn>

                        <Link
                            :href="route('logout')"
                            method="post"
                            as="button"
                            style="opacity: 0.7; font-size: 0.9rem"
                        >
                            Log Out
                        </Link>
                    </v-col>
                </v-row>
            </v-container>
        </v-form>
    </GlassBox>
</template>

<style scoped>
h2 {
    font-size: 2rem;
    text-align: center;
}

p {
    text-align: center;
    width: 100%;
    opacity: 0.7;
    margin-bottom: 1rem;
}
</style>
