Add frontend/src/views/RegisterView.vue
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<div class="register">
|
||||||
|
<h2>Register</h2>
|
||||||
|
<form @submit.prevent="handleRegister">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Email</label>
|
||||||
|
<input v-model="email" type="email" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Username</label>
|
||||||
|
<input v-model="username" type="text" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Full Name</label>
|
||||||
|
<input v-model="fullName" type="text" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Password</label>
|
||||||
|
<input v-model="password" type="password" required />
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Register</button>
|
||||||
|
</form>
|
||||||
|
<p>Already have an account? <router-link to="/login">Login</router-link></p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { useAuthStore } from '../stores/auth'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
const email = ref('')
|
||||||
|
const username = ref('')
|
||||||
|
const fullName = ref('')
|
||||||
|
const password = ref('')
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const handleRegister = async () => {
|
||||||
|
const success = await authStore.register(email.value, username.value, password.value, fullName.value)
|
||||||
|
if (success) {
|
||||||
|
router.push('/login')
|
||||||
|
} else {
|
||||||
|
alert('Registration failed')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user