Files
consumocuidado/pages/login/restablecer.vue
2025-09-15 14:37:26 +02:00

106 lines
2.3 KiB
Vue

<template>
<div class="container-fluid">
<BModal
id="modal-center"
v-model="active"
centered
title="consumo-cuidado"
ok-variant="success"> Email enviado, revisa tu bandeja de entrada. </BModal>
<div class="row">
<FormHeader
title="Restablecer Contraseña"
subtitle="Introduce la dirección de correo asociada a tu cuenta y te enviaremos un
email con tu nueva contraseña.<br />Recuerda que siempre puedes cambiarla dentro del menú de edición."
class="col-12" />
</div>
<form class="form" align="center" @submit.prevent="sendEmail">
<FormInput
v-model="email"
required
type="email"
label-text="Email"
@input="email = $event"
/>
<p v-if="error" class="error">
{{ error }}
</p>
<SubmitButton :text="sending ? `Enviando...` : `Enviar`" image-url="" :disabled="sending" />
</form>
</div>
</template>
<script>
export default {
// setup() {
// definePageMeta({
// layout: 'main',
// })
// },
data() {
return {
email: '',
error: '',
sending: false,
active: false,
}
},
methods: {
async sendEmail() {
this.sending = true
this.error = null
const config = useRuntimeConfig()
try {
await $fetch('/forgotten_password/', {
baseURL: config.public.baseURL,
method: 'POST',
body: { email: this.email },
})
this.active = true
} catch (err) {
this.error = 'Error al enviar el email. Por favor, inténtalo de nuevo.'
console.error('Error al enviar el email:', err)
}
this.sending = false
},
},
}
</script>
<style lang="scss" scoped>
.container-fluid {
margin-top: 5rem;
margin-bottom: 5rem;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
background: linear-gradient($color-consumo-base-light, $color-bg-light);
border-radius: 1rem;
padding: 2rem;
gap: 3rem;
color: $color-primary;
@include mobile {
margin-top: 7rem;
}
}
.form {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 40px;
width: 100%;
}
.help {
color: $color-navy;
}
.error {
color: $color-error;
}
</style>