<template>
    <div>
        <div class="box">
            <div class="flex justify-between">
                <h1 class="page-title">Administration</h1>
                <a href="#" @click.prevent="logout" class="btn">
                    <svg-vue icon="logout" /> Déconnexion
                </a>
            </div>
            <UserAdmin />
        </div>
    </div>
</template>

<script>
import UserAdmin from './User/UserAdmin'

export default {
    name: 'DashBoard',
    components: {
        UserAdmin
    },
    methods: {
        logout: function () {
            // eslint-disable-next-line no-undef
            axios.post('logout')
                .then(res => {
                    // eslint-disable-next-line no-constant-condition
                    if(res.status === 302 || 401) {
                        window.location.href = '/login'
                    }
                }).catch(() => {

                })
        }
    }
}
</script>
