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

defineOptions({ layout: MainLayout });

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

const form = useForm({
    email: '',
});

const submit = () => {
    form.post(route('password.email'));
};
</script>

<template>
    <Head title="Forgot Password" />
    <GlassBox title="Forgot Your Password?" blurb="No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.">
        <v-alert v-if="status" type="success" class="mb-2">{{ status }}</v-alert>

        <v-form style="width: 100%" @submit.prevent="submit" v-if="!status">
            <v-container>
                <v-row>
                    <v-col cols="12">
                        <v-text-field
                            v-model="form.email"
                            label="Email"
                            type="email"
                            autocomplete="username"
                            autofocus
                            :error-messages="form.errors.email"
                        />
                    </v-col>
                </v-row>

                <v-row>
                    <v-col cols="12" class="d-flex justify-end">
                        <v-btn
                            variant="elevated"
                            size="large"
                            block
                            type="submit"
                            :loading="form.processing"
                            :disabled="form.processing"
                        >
                            Email Password Reset Link
                        </v-btn>
                    </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>
