This commit is contained in:
IRBorisov 2023-08-11 12:44:40 +03:00
commit b5da4091d8
5 changed files with 16 additions and 20 deletions

1
.gitignore vendored
View File

@ -58,3 +58,4 @@ bower_components
# Environments # Environments
venv/ venv/
/GitExtensions.settings

View File

@ -77,7 +77,7 @@ export const UserProfileState = ({ children }: UserProfileStateProps) => {
onError: error => { setError(error); }, onError: error => { setError(error); },
onSuccess: () => { onSuccess: () => {
setUser(undefined); setUser(undefined);
auth.logout(); auth.reload();
if (callback) callback(); if (callback) callback();
}}); }});
}, [setUser, auth] }, [setUser, auth]

View File

@ -2,7 +2,6 @@ import { useLayoutEffect } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext'; import { useAuth } from '../context/AuthContext';
import { TIMEOUT_UI_REFRESH } from '../utils/constants';
function HomePage() { function HomePage() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -10,13 +9,9 @@ function HomePage() {
useLayoutEffect(() => { useLayoutEffect(() => {
if (!user) { if (!user) {
setTimeout(() => {
navigate('/library?filter=common'); navigate('/library?filter=common');
}, TIMEOUT_UI_REFRESH);
} else if(!user.is_staff) { } else if(!user.is_staff) {
setTimeout(() => {
navigate('/library?filter=personal'); navigate('/library?filter=personal');
}, TIMEOUT_UI_REFRESH);
} }
}, [navigate, user]) }, [navigate, user])

View File

@ -13,13 +13,13 @@ export function ChangePassword() {
const [old_password, setOldPassword] = useState(''); const [old_password, setOldPassword] = useState('');
const [new_password, setNewPassword] = useState(''); const [new_password, setNewPassword] = useState('');
const [new_password_repeat, setNewPasswordRepeat] = useState(''); const [new_password_repeat, setNewPasswordRepeat] = useState('');
const [password_equal, setPasswordEqual] = useState(true); const [new_pass_color, setNewPassColor] = useState('');
const navigate = useNavigate(); const navigate = useNavigate();
function handleSubmit(event: React.FormEvent<HTMLFormElement>) { function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault(); event.preventDefault();
if (new_password !== new_password_repeat) { if (new_password !== new_password_repeat) {
setPasswordEqual(false); setNewPassColor('bg-red-500');
toast.error('Пароли не совпадают'); toast.error('Пароли не совпадают');
} }
else { else {
@ -41,21 +41,21 @@ export function ChangePassword() {
onChange={event => setOldPassword(event.target.value)} onChange={event => setOldPassword(event.target.value)}
/> />
<TextInput id='new_password' <TextInput id='new_password'
colorClass={`${password_equal ? "" : "text-red-500"}`} colorClass={new_pass_color}
label="Введите новый пароль:" label="Введите новый пароль:"
value={new_password} value={new_password}
onChange={event => { onChange={event => {
setNewPassword(event.target.value); setNewPassword(event.target.value);
setPasswordEqual(true); setNewPassColor('');
}} }}
/> />
<TextInput id='new_password' <TextInput id='new_password_repeat'
colorClass={`${password_equal ? "" : "text-red-500"}`} colorClass={new_pass_color}
label="Повторите новый пароль:" label="Повторите новый пароль:"
value={new_password_repeat} value={new_password_repeat}
onChange={event => { onChange={event => {
setNewPasswordRepeat(event.target.value); setNewPasswordRepeat(event.target.value);
setPasswordEqual(true); setNewPassColor('');
}} }}
/> />
<div className='relative flex justify-center my-4 border'> <div className='relative flex justify-center my-4 border'>