<template>
    <div id="login_form">
        <div class="holder">
            <div class="logo">
                <img src="assets/images/cms_logo_white.png" alt="">
            </div>

            <div class="content">
                <p class="intro_text">Bitte melde dich mit deinen Benutzerdaten an.</p>

                <my-form :elements="elements" :buttons="buttons" :submitHandler="login"></my-form>

                <div style="clear:both;"></div>
            </div>
        </div>
    </div>
</template>

<script>
import MyForm from "components/my-form";

export default {
    name: "LoginForm",
    components: {
        MyForm
    },
    data() {
        return {
            username: "",
            password: "",
            elements: {
                username: {
                    placeholder: "Benutzername",
                    icon: "icon-user",
                    type: "text",
                    required: true
                },
                password: {
                    placeholder: "Passwort",
                    icon: "icon-key",
                    type: "password",
                    required: true
                }
            },
            buttons: [{
                label: "login",
                type: "submit"
            }]
        }
    },
    methods: {
        login(formData) {
            this.$store.dispatch("login", formData)
                .then(user => {
                    console.log("---- user login --------");
                    console.log(user);
                    this.$router.go(-1);
                })
                .catch(error => {
                    console.log("---- login error -------");
                    console.log(error);
                });
        }
    }
}
</script>

<style lang="less">
@import "~mixins";

/*--------------------------------------------------------------
# LOGINBOX
--------------------------------------------------------------*/
#login_form{
    /* Disply on top */
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 3000;
    top:0px; left:0px; bottom:0px; right:0px;

    /* Center vertically */
    display: flex;
    justify-content: center;
    align-items: center;


    background: @cms_brand_primary;

    &>.holder {
        position: relative;
        display: block;
        max-width: 380px;
        width: 90%;
        height: auto;
        margin: 0px;
        border-radius: 2px;
        padding: 20px;
    }

    .logo{
        .clearfix();
        line-height:0; margin-bottom:15px; text-align:center;
        img {width:100%; max-width:72px;}
    }

    .content{
        p {text-align:center; color: white; font-size:15px; line-height:1.2;}
    }

    .intro_text{
        font-size:14px!important; margin-bottom:20px; line-height:1.5;
    }

    form{
        text-align: center;
    }

    input{
        height: 40px;
        padding: 0px 15px;
        border-color: transparent;

        &:focus {
            border: solid 1px @gray_dark;
            background: white;
        }
    }
}
</style>