<template>
    <div class="row">
        <div class="col p-r-0">
            <transition-component key="2" group enter-class="animated fadeInRightBig faster" leave-class="animated fadeOutUpBig" v-show="!$store.getters.isLoading('loginSection')">
                <div class="row" key="1" v-show="!$store.getters.isShowing('loginForm') && !$store.getters.isShowing('registrationForm')">
                    <div class="col p-r-0">
                        <div class="row m-l-0">
                            <div class="col p-l-50">
                                <h5 class="font-lato light animated fadeInRightBig slow" style=" line-height: 50px; letter-spacing: 5px; ">Hi There!</h5>
                            </div>
                        </div>
                        <div class="row  m-l-0 m-b-20  animated fadeInRightBig slow">
                            <div class="col p-l-50">
                                <p class="muted font-lato light lh-25" style="letter-spacing: 2px; ">Enter your email address to <b>register</b>/<b>login</b>.</p>
                            </div>
                        </div>
                        <div class="row no-margin">
                            <div class="col">
                                <div class="row 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 animated fadeInDownBig">
                                    <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 pl-md-0 pr-md-0  bg-white">
                                                <div class="input-group transparent b-grey b-t b-b">
                                                    <span class="input-group-addon no-border">
                                                        <i class="fa fa-user-o fa-fw p-l-15 p-t-20" style="padding-right: 18px;"></i>
                                                    </span>
                                                    <input placeholder="My Email Address" v-model.trim="parameters.email" 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>
                        </div>
                        <div class="row m-t-30 align-items-center">
                            <div class="col-auto animated fadeInLeftBig slow">
                                <div class="b-t b-b b-r b-primary bg-transparent all-caps text-primary p-t-15 p-b-15 p-l-50 p-r-50 bold font-lato pointer" style="letter-spacing: 8px;" @click="submit(route('api.account.authentication.authenticate.email.check'), 'post', section, false, false)">Next <i class="fa fa-chevron-right fs-13"></i></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row" key="2" v-show="$store.getters.isShowing('loginForm')" >
                    <div class="col all-caps">
                        <div class="row  m-l-0">
                            <div class="col p-l-50">
                                <h5 class="font-lato light lh-40 animated fadeInLeftBig slow" style="letter-spacing: 5px; ">Welcome Back!</h5>
                            </div>
                        </div>
                        <div class="row  m-l-0 m-b-20  animated fadeInRightBig slow">
                            <div class="col p-l-50">
                                <p class="muted font-lato light lh-25" style="letter-spacing: 2px; ">Looks like you already have an account with us.</p>
                            </div>
                        </div>
                        <login-form-component section="loginSection" :email="parameters.email"></login-form-component>
                    </div>
                </div>
                <div class="row m-t-30" key="3" v-show="$store.getters.isShowing('registrationForm')" >
                    <div class="col all-caps">
                        <div class="row m-b-20">
                            <div class="col p-l-50">
                                <div class="row  m-l-0 align-items-center justify-content-center">
                                    <div class="col">
                                        <h5 class="font-lato light lh-40 animated fadeInLeftBig slow" style="letter-spacing: 5px; ">Create Account</h5>
                                    </div>
                                </div>
                                <div class="row m-l-0 animated fadeInRightBig slow">
                                    <div class="col">
                                        <p class="muted font-lato light lh-25" style="letter-spacing: 2px; ">Looks like you are a new user.<br>Let's create a fresh new izyim profile for you.</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <registration-form-component ref="registration" :email="parameters.email" section="loginSection"></registration-form-component>
                    </div>
                </div>
            </transition-component>
        </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: 'loginForm', status: true})
            },
            errorHandler(){
                this.$store.dispatch('toggleSection', {name: 'registrationForm', status: true})
            }
        },
        mixins: [request]
    }

</script>