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('');
async function handleLogin() {
errorMsg.value = '';
try {
await authStore.login({ email: email.value, password: password.value }),
await authStore.login({ email: email.value, password: password.value });
router.push('/recipes');
} catch (error) {
errorMsg.value = error.message;
......
<script setup>
import SignLayout from '@/components/SignLayout.vue';
</script>
<template>
<SignLayout>
<div class="form-signin w-100 p-5 shadow rounded bg-white form-card">
<h2 class="mb-4 text-center">Registrarse</h2>
<form>
<form @submit.prevent="handleRegister">
<div class="form-floating mb-4">
<input
type="text"
class="form-control"
id="inputName"
placeholder="Nombre"
v-model="name"
required
>
<label for="inputName">Nombre</label>
......@@ -25,6 +22,7 @@ import SignLayout from '@/components/SignLayout.vue';
class="form-control"
id="inputSurname"
placeholder="Apellidos"
v-model="surname"
required
>
<label for="inputSurname">Apellidos</label>
......@@ -36,6 +34,7 @@ import SignLayout from '@/components/SignLayout.vue';
class="form-control"
id="inputEmail"
placeholder="Correo electrónico"
v-model="email"
required
>
<label for="inputEmail">Correo electrónico</label>
......@@ -47,6 +46,7 @@ import SignLayout from '@/components/SignLayout.vue';
class="form-control"
id="inputPassword"
placeholder="Contraseña"
v-model="password"
required
>
<label for="inputPassword">Contraseña</label>
......@@ -65,6 +65,38 @@ import SignLayout from '@/components/SignLayout.vue';
</SignLayout>
</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>
.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