доабвление поле города при регистрации
This commit is contained in:
parent
e3a60ccb55
commit
679c1f20e2
@ -14,7 +14,7 @@ const generateToken = (id) => {
|
||||
// @access Public
|
||||
const registerUser = async (req, res, next) => {
|
||||
try {
|
||||
const { name, email, password, dateOfBirth, gender } = req.body;
|
||||
const { name, email, password, dateOfBirth, gender, city } = req.body;
|
||||
|
||||
console.log('Начало регистрации пользователя с email:', email);
|
||||
|
||||
@ -22,6 +22,12 @@ const registerUser = async (req, res, next) => {
|
||||
res.status(400);
|
||||
throw new Error('Пожалуйста, заполните все обязательные поля: имя, email, пароль и дату рождения.');
|
||||
}
|
||||
|
||||
// Проверяем наличие города
|
||||
if (!city) {
|
||||
res.status(400);
|
||||
throw new Error('Пожалуйста, выберите город.');
|
||||
}
|
||||
|
||||
// Проверка возраста (минимум 14 лет)
|
||||
const birthDate = new Date(dateOfBirth);
|
||||
@ -56,6 +62,10 @@ const registerUser = async (req, res, next) => {
|
||||
password,
|
||||
dateOfBirth,
|
||||
gender,
|
||||
location: {
|
||||
city: city,
|
||||
country: 'Россия' // Устанавливаем страну по умолчанию
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Пользователь создан успешно:', user ? 'Да' : 'Нет', 'ID:', user ? user._id : 'N/A');
|
||||
|
@ -67,6 +67,26 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="city">
|
||||
<i class="bi-geo-alt"></i>
|
||||
Город
|
||||
</label>
|
||||
<div class="custom-select">
|
||||
<select
|
||||
id="city"
|
||||
v-model="city"
|
||||
required
|
||||
:disabled="loading"
|
||||
>
|
||||
<option value="" disabled selected>Выберите город</option>
|
||||
<option v-for="cityItem in cities" :key="cityItem.name" :value="cityItem.name">
|
||||
{{ cityItem.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">
|
||||
<i class="bi-shield-lock"></i>
|
||||
@ -132,15 +152,18 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, computed } from 'vue';
|
||||
import { useAuth } from '@/auth';
|
||||
import russianCities from '@/assets/russian-cities.json';
|
||||
|
||||
const name = ref('');
|
||||
const email = ref('');
|
||||
const birthdate = ref('');
|
||||
const city = ref('');
|
||||
const password = ref('');
|
||||
const confirmPassword = ref('');
|
||||
const errorMessage = ref('');
|
||||
const loading = ref(false);
|
||||
const birthdateInput = ref(null);
|
||||
const cities = ref([]);
|
||||
|
||||
// Функция для открытия календаря при клике на поле
|
||||
const openDatePicker = () => {
|
||||
@ -176,6 +199,13 @@ const enableScroll = () => {
|
||||
|
||||
onMounted(() => {
|
||||
preventScroll(); // Блокируем прокрутку при монтировании компонента
|
||||
|
||||
// Сортируем города по алфавиту
|
||||
cities.value = russianCities.sort((a, b) => {
|
||||
if (a.name < b.name) return -1;
|
||||
if (a.name > b.name) return 1;
|
||||
return 0;
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
@ -187,7 +217,7 @@ const handleRegister = async () => {
|
||||
loading.value = true;
|
||||
|
||||
// Простая валидация на клиенте
|
||||
if (!name.value || !email.value || !birthdate.value || !password.value || !confirmPassword.value) {
|
||||
if (!name.value || !email.value || !birthdate.value || !city.value || !password.value || !confirmPassword.value) {
|
||||
errorMessage.value = 'Пожалуйста, заполните все обязательные поля.';
|
||||
loading.value = false;
|
||||
return;
|
||||
@ -224,6 +254,7 @@ const handleRegister = async () => {
|
||||
name: name.value,
|
||||
email: email.value,
|
||||
dateOfBirth: birthdate.value, // Изменено с birthdate на dateOfBirth для соответствия бэкенду
|
||||
city: city.value, // Добавлено поле города
|
||||
password: password.value
|
||||
};
|
||||
|
||||
@ -406,6 +437,44 @@ const handleRegister = async () => {
|
||||
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.custom-select {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.custom-select select {
|
||||
width: 100%;
|
||||
padding: 0.9rem 1rem;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.custom-select:after {
|
||||
content: '▼';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 10px;
|
||||
transform: translateY(-50%);
|
||||
font-size: 0.8rem;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.custom-select select:focus {
|
||||
outline: none;
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
border-color: rgba(255, 255, 255, 0.5);
|
||||
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.action-button {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
|
Loading…
x
Reference in New Issue
Block a user