<template>
    <div class="row">
        <div class="col">
            <div class="row m-r-0 m-l-0 m-b-20 animated fadeInUpBig fast" v-if="error">
                <div class="col p-l-50">
                    <small class="bold fs-10 text-danger">{{error}}</small>
                </div>
            </div>
            <div class="row m-l-0 animated fadeInUpBig">
                <div class="col b-t b-b b-grey animated" :class="[{'shake': $v.parameters.email.$error}]"  :style="[$v.parameters.email.$error ? {'border-bottom': 'solid 2px red !important'} : {}]">
                    <div class="row align-items-center">
                        <div class="col no-padding bg-white ">
                            <div class="input-group transparent">
                                <span class="input-group-addon no-border">
                                    <i class="fa fa-envelope-o fa-fw p-l-15 p-t-20" style="padding-right: 18px;"></i>
                                </span>
                                <input v-model="parameters.email" placeholder="Email Address" class="form-control no-border bg-white p-t-35 p-b-35 p-l-0 p-r-0">
                                <validation-error-component :validator="$v.parameters.email" class="absolute fs-12" style=" top: 10px; right: 15px; z-index: 99;"></validation-error-component>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row m-t-30 align-items-center">
                <div class="col-auto animated fadeInLeftBig slower">
                    <div class="b-t b-b b-r b-grey all-caps muted p-t-15 p-b-15 p-l-30 p-r-20 font-lato pointer fs-12" @click="$store.dispatch('toggleSection', {name: 'forgetPassword', status: false})" style="letter-spacing: 2px;"><i class="fa fa-angle-left" style="padding-right: 18px;"></i>Back to login</div>
                </div>
                <div class="col-auto ml-auto p-r-0 animated fadeInRightBig slow">
                    <div class="bg-success all-caps text-white p-t-15 p-b-15 p-l-50 p-r-20 bold font-lato pointer fs-12" style="letter-spacing: 4px;" @click="submit(route('api.account.authentication.password.forget'), 'post', section, false , false)">Request Reset Link</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>

    import { required, email } from "vuelidate/lib/validators";
    import request from '../../../mixins/requestMixin'
    export default {
        props: {
            section:{
                type: String,
                required: true
            }
        },
        data() {
            return {
                error: '',
                parameters: {
                    email: ''
                }
            };
        },
        validations: {
            parameters: {
                email: { required, email }
            }
        },
        methods:{
            successHandler(){
                this.$store.dispatch('toggleSection', {name: 'forgetPasswordSuccess', status: true})
                this.$store.dispatch('passwordResetEmail', {email: this.parameters.email})
            },
            errorHandler(error){
                this.error = error.message;
            }
        },
        mixins: [request]
    }

</script>