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
venv/
/GitExtensions.settings

View File

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

View File

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

View File

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