feat(views): añadida funcionalidad a la vista Register

parent f15a2d2f
Showing with 38 additions and 6 deletions
...@@ -62,7 +62,7 @@ const errorMsg = ref(''); ...@@ -62,7 +62,7 @@ const errorMsg = ref('');
async function handleLogin() { async function handleLogin() {
errorMsg.value = ''; errorMsg.value = '';
try { try {
await authStore.login({ email: email.value, password: password.value }), await authStore.login({ email: email.value, password: password.value });
router.push('/recipes'); router.push('/recipes');
} catch (error) { } catch (error) {
errorMsg.value = error.message; errorMsg.value = error.message;
......
<script setup>
import SignLayout from '@/components/SignLayout.vue';
</script>
<template> <template>
<SignLayout> <SignLayout>
<div class="form-signin w-100 p-5 shadow rounded bg-white form-card"> <div class="form-signin w-100 p-5 shadow rounded bg-white form-card">
<h2 class="mb-4 text-center">Registrarse</h2> <h2 class="mb-4 text-center">Registrarse</h2>
<form> <form @submit.prevent="handleRegister">
<div class="form-floating mb-4"> <div class="form-floating mb-4">
<input <input
type="text" type="text"
class="form-control" class="form-control"
id="inputName" id="inputName"
placeholder="Nombre" placeholder="Nombre"
v-model="name"
required required
> >
<label for="inputName">Nombre</label> <label for="inputName">Nombre</label>
...@@ -25,6 +22,7 @@ import SignLayout from '@/components/SignLayout.vue'; ...@@ -25,6 +22,7 @@ import SignLayout from '@/components/SignLayout.vue';
class="form-control" class="form-control"
id="inputSurname" id="inputSurname"
placeholder="Apellidos" placeholder="Apellidos"
v-model="surname"
required required
> >
<label for="inputSurname">Apellidos</label> <label for="inputSurname">Apellidos</label>
...@@ -36,6 +34,7 @@ import SignLayout from '@/components/SignLayout.vue'; ...@@ -36,6 +34,7 @@ import SignLayout from '@/components/SignLayout.vue';
class="form-control" class="form-control"
id="inputEmail" id="inputEmail"
placeholder="Correo electrónico" placeholder="Correo electrónico"
v-model="email"
required required
> >
<label for="inputEmail">Correo electrónico</label> <label for="inputEmail">Correo electrónico</label>
...@@ -47,6 +46,7 @@ import SignLayout from '@/components/SignLayout.vue'; ...@@ -47,6 +46,7 @@ import SignLayout from '@/components/SignLayout.vue';
class="form-control" class="form-control"
id="inputPassword" id="inputPassword"
placeholder="Contraseña" placeholder="Contraseña"
v-model="password"
required required
> >
<label for="inputPassword">Contraseña</label> <label for="inputPassword">Contraseña</label>
...@@ -65,6 +65,38 @@ import SignLayout from '@/components/SignLayout.vue'; ...@@ -65,6 +65,38 @@ import SignLayout from '@/components/SignLayout.vue';
</SignLayout> </SignLayout>
</template> </template>
<script setup>
import SignLayout from '@/components/SignLayout.vue';
import { useAuthStore } from '@/stores/authStore';
import { useRouter } from 'vue-router';
import { ref } from 'vue';
const authStore = useAuthStore();
const router = useRouter();
const name = ref('');
const surname = ref('');
const email = ref('');
const password = ref('');
const errorMsg = ref('');
async function handleRegister() {
errorMsg.value = '';
try {
await authStore.register({
name: name.value,
surname: surname.value,
email: email.value,
password: password.value
});
router.push('/recipes');
} catch (error) {
errorMsg.value = error.message;
}
}
</script>
<style scope> <style scope>
.form-card .btn-style { .form-card .btn-style {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment