modified: main_dc/yalarba/easySite/easySite/app/pages/auth/register.vue

add first and last names for forms and change logic as
fullName=firstName+lastName
This commit is contained in:
2025-11-14 04:01:11 +05:00
parent 6b13e77bb6
commit 76b2aae44c
@@ -9,32 +9,32 @@
<div class="card-body"> <div class="card-body">
<form @submit.prevent="handleSubmit" class="auth-form"> <form @submit.prevent="handleSubmit" class="auth-form">
<!-- Имя -->
<div class="form-group"> <div class="form-group">
<label class="form-label">Полное имя</label> <label class="form-label">Имя</label>
<input v-model="form.full_name" type="text" class="form-input" placeholder="Ваше полное имя" required> <input v-model="form.first_name" type="text" class="form-input" placeholder="Ваше имя" required>
</div> </div>
<!-- Фамилия -->
<div class="form-group">
<label class="form-label">Фамилия</label>
<input v-model="form.last_name" type="text" class="form-input" placeholder="Ваша фамилия" required>
</div>
<!-- Email -->
<div class="form-group"> <div class="form-group">
<label class="form-label">Email</label> <label class="form-label">Email</label>
<input v-model="form.email" type="email" class="form-input" placeholder="your@email.com" required> <input v-model="form.email" type="email" class="form-input" placeholder="your@email.com" required>
</div> </div>
<div class="form-group"> <!-- Пароль -->
<label class="form-label">Телефон</label>
<input v-model="form.phone" type="tel" class="form-input" placeholder="Ваш телефон">
</div>
<div class="form-group">
<label class="form-label">Город</label>
<input v-model="form.city" type="text" class="form-input" placeholder="Ваш город">
</div>
<div class="form-group"> <div class="form-group">
<label class="form-label">Пароль</label> <label class="form-label">Пароль</label>
<input v-model="form.password" type="password" class="form-input" <input v-model="form.password" type="password" class="form-input"
placeholder="Придумайте пароль (минимум 6 символов)" required minlength="6"> placeholder="Придумайте пароль (минимум 6 символов)" required minlength="6">
</div> </div>
<!-- Подтверждение пароля -->
<div class="form-group"> <div class="form-group">
<label class="form-label">Подтверждение пароля</label> <label class="form-label">Подтверждение пароля</label>
<input v-model="form.passwordConfirm" type="password" class="form-input" placeholder="Повторите пароль" <input v-model="form.passwordConfirm" type="password" class="form-input" placeholder="Повторите пароль"
@@ -66,12 +66,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const config = useRuntimeConfig()
const loading = ref(false) const loading = ref(false)
// Форма регистрации согласно UserRegisterRequest // Форма регистрации — теперь с отдельными полями имени и фамилии
const form = ref({ const form = ref({
full_name: '', first_name: '',
last_name: '',
email: '', email: '',
password: '', password: '',
passwordConfirm: '', passwordConfirm: '',
@@ -95,15 +95,16 @@ const handleSubmit = async () => {
loading.value = true loading.value = true
try { try {
// Формируем full_name из имени и фамилии
const full_name = `${form.value.first_name.trim()} ${form.value.last_name.trim()}`
// Отправка данных на бэкенд // Отправка данных на бэкенд
const response = await $fetch(`https://easysite102.ru/auth/register`, { const response = await $fetch(`https://easysite102.ru/auth/register`, {
method: 'POST', method: 'POST',
body: { body: {
email: form.value.email, email: form.value.email,
password: form.value.password, password: form.value.password,
full_name: form.value.full_name, full_name // = first_name + last_name
phone: form.value.phone || '', // optional field
city: form.value.city || '' // optional field
} }
}) })
@@ -112,7 +113,7 @@ const handleSubmit = async () => {
// Успешная регистрация // Успешная регистрация
alert('Регистрация выполнена успешно!') alert('Регистрация выполнена успешно!')
// Автоматический вход после регистрации или переход на страницу входа // Переход на страницу входа
navigateTo('/auth/login') navigateTo('/auth/login')
} catch (error: unknown) { } catch (error: unknown) {
@@ -129,7 +130,6 @@ const handleSubmit = async () => {
return return
} }
} }
// Общее сообщение об ошибке
alert(`Ошибка: ${error.message}`) alert(`Ошибка: ${error.message}`)
} else { } else {
alert('Неизвестная ошибка при регистрации. Попробуйте позже.') alert('Неизвестная ошибка при регистрации. Попробуйте позже.')
@@ -140,6 +140,7 @@ const handleSubmit = async () => {
} }
</script> </script>
<style scoped> <style scoped>
.auth-page { .auth-page {
min-height: 100vh; min-height: 100vh;