<template lang="pug">
  div
    app-menu
    br
    br
    h1 Recuperar Contraseña
    .row
        .col-6.offset-3
            p Introduzca su email para recuperar su contraseña {{ title }}
            p {{ title }}
            .input-group
                input.form-control(type='text' v-model="correo" placeholder="Correo" aria-label="Recipient's username with two button addons" aria-describedby='button-addon4')
                #button-addon4.input-group-append
                button.btn.btn-primary(type='button' v-on:click="recupera") Enviar
    br
    br
    br
    br

</template>

<script>
import webMenu from '../estetica/menu.vue'
import Swal from 'sweetalert2'
import axios from 'axios'
import config from '../config/config.js'
export default {
    data() {
        return {
            title: process.env.API,
            correo: '',
        }
    },
    methods: {
        recupera: function() {
            axios
                .get(
                    `${config.api}/enviar_email?correo=${this.correo}`
                )
                .then(res => {
                    // eslint-disable-next-line
                    console.log(res.data)
                    Swal.fire({
                        title: 'Éxito',
                        text: 'Se envio un correo con la nueva contraseña',
                        icon: 'success',
                        confirmButtonText: 'Aceptar',
                    })
                })
                .catch(error => {
                    // eslint-disable-next-line
                    console.log(error)
                    Swal.fire({
                        title: 'Error',
                        icon: 'error',
                        text: error.response.data.msj,
                        confirmButtonText: 'Aceptar',
                    })
                })
        },
    },
    components: {
        appMenu: webMenu,
    },
}
</script>

<style>
</style>