Add Notification and new mini desing
This commit is contained in:
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
|
||||
import { User, Lock, Server, MessageSquare, Shield, TrendingUp, Eye, EyeOff } from 'lucide-react';
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '../config';
|
||||
import { notify } from './NotificationSystem';
|
||||
|
||||
export default function Profile({ token, user, theme, onUsernameChange, viewingUsername }) {
|
||||
const [stats, setStats] = useState(null);
|
||||
@@ -66,6 +67,7 @@ export default function Profile({ token, user, theme, onUsernameChange, viewingU
|
||||
// Обновляем токен
|
||||
localStorage.setItem('token', data.access_token);
|
||||
|
||||
notify('success', 'Имя изменено', `Ваше новое имя: ${data.username}`);
|
||||
alert('Имя пользователя успешно изменено!');
|
||||
setUsernameForm({ new_username: '', password: '' });
|
||||
|
||||
@@ -76,6 +78,7 @@ export default function Profile({ token, user, theme, onUsernameChange, viewingU
|
||||
|
||||
loadStats();
|
||||
} catch (error) {
|
||||
notify('error', 'Ошибка изменения', error.response?.data?.detail || 'Не удалось изменить имя');
|
||||
alert(error.response?.data?.detail || 'Ошибка изменения имени пользователя');
|
||||
} finally {
|
||||
setUsernameLoading(false);
|
||||
@@ -111,9 +114,11 @@ export default function Profile({ token, user, theme, onUsernameChange, viewingU
|
||||
{ headers: { Authorization: `Bearer ${token}` } }
|
||||
);
|
||||
|
||||
notify('success', 'Пароль изменён', 'Ваш пароль успешно обновлен');
|
||||
alert('Пароль успешно изменён!');
|
||||
setPasswordForm({ old_password: '', new_password: '', confirm_password: '' });
|
||||
} catch (error) {
|
||||
notify('error', 'Ошибка изменения', error.response?.data?.detail || 'Не удалось изменить пароль');
|
||||
alert(error.response?.data?.detail || 'Ошибка изменения пароля');
|
||||
} finally {
|
||||
setPasswordLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user