From 5d023b8785c21eb0b753568255318283df2f3f0d Mon Sep 17 00:00:00 2001 From: genzof Date: Sun, 15 Feb 2026 21:16:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8F=20=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D1=81=D1=82=D1=83=D0=BF=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлено модальное окно для добавления описание профиля с счётчиком символов и размером до 500 символов, добавлен отступ между изменением пароля и выходом из аккаунта, перекрашена кнопка удаления аккаунта. --- src/Profile.js | 107 ++++++++++++++++++++++++++++++++++++++++++++++-- src/css/App.css | 32 ++++++++++++++- 2 files changed, 134 insertions(+), 5 deletions(-) diff --git a/src/Profile.js b/src/Profile.js index 75ce354..9cf03cf 100644 --- a/src/Profile.js +++ b/src/Profile.js @@ -19,6 +19,10 @@ const Profile = () => { const [new_password, setnew_password] = useState(''); const [new_password_confirm, setnew_password_confirm] = useState(''); const [passwordError, setPasswordError] = useState(''); + const [showDescriptionModal, setShowDescriptionModal] = useState(false); + const [profileDescription, setProfileDescription] = useState(''); + const [descriptionError, setDescriptionError] = useState(''); + useEffect(() => { const checkSession = async () => { try { @@ -117,6 +121,36 @@ const Profile = () => { } }; + const saveProfileDescription = async (e) => { + e.preventDefault(); + setDescriptionError(''); + + try { + await axios.put('/api/users/change_description', + { new_description: profileDescription }, + { withCredentials: true } + ); + try { + const response = await axios.get('/api/users/me'); + setUser(response.data.display_name); + setUserName(response.data.username); + // Обновляем описание, если оно есть в ответе + if (response.data.description) { + setProfileDescription(response.data.description); + } + } catch (err) { + setError('Ошибка обновления данных профиля'); + } + + setShowDescriptionModal(false); // Закрываем модальное окно + + } catch (err) { + setDescriptionError( + err.response?.data?.detail || 'Ошибка при сохранении описания' + ); + } + }; + const OpenWindowDelete = () => { setShowConfirm(true); // Показываем окно подтверждения @@ -141,7 +175,23 @@ const Profile = () => { const closeWindowUserName = () => { setShowConfirmUserName(false); // Показываем окно подтверждения }; - + + const openDescriptionModal = async () => { + setDescriptionError(''); + try { + const response = await axios.get('/api/users/me'); + setProfileDescription(response.data.description || ''); + setShowDescriptionModal(true); + } catch (err) { + setError('Не удалось загрузить данные профиля'); + console.error('Ошибка загрузки данных пользователя:', err); + } + }; + + const closeDescriptionModal = () => { + setShowDescriptionModal(false); + setDescriptionError(''); + }; const deleteAccount = async () => { try { await axios.delete('/api/users/me', { withCredentials: true }); @@ -171,6 +221,13 @@ const Profile = () => {

{user}

+

Описание профиля

+
+ Добавьте краткое описание о себе, которое увидят другие пользователи. +
+
Логин

{userName}

@@ -178,9 +235,9 @@ const Profile = () => {

Изменить пароль

В целях безопасности мы рекомендуем выбрать пароль, который ещё не использовался вами в других учётных записях.
- - - + + + )} @@ -284,6 +341,48 @@ const Profile = () => { )} + {showDescriptionModal && ( +
+
+

{profileDescription ? 'Редактировать описание профиля' : 'Добавить описание профиля'}

+ + {descriptionError && ( +
+ {descriptionError} +
+ )} + +
+
+ +