auth + groups invite
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
// src/views/home/auth/Login.tsx
|
||||
import { useState, useEffect } from 'react';
|
||||
import { PrimaryButton } from '../../../components/button/PrimaryButton';
|
||||
import { Input } from '../../../components/input/Input';
|
||||
import { useAppDispatch, useAppSelector } from '../../../redux/hooks';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||
import { loginUser } from '../../../redux/slices/auth';
|
||||
// import { cn } from "../../../lib/cn";
|
||||
import { setMenuActivePage } from '../../../redux/slices/store';
|
||||
@@ -13,6 +14,7 @@ import { googleLogo } from '../../../assets/icons/input';
|
||||
const Login = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const [username, setUsername] = useState<string>('');
|
||||
const [password, setPassword] = useState<string>('');
|
||||
@@ -30,7 +32,9 @@ const Login = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (jwt) {
|
||||
navigate('/home/account'); // или другая страница после входа
|
||||
const from = location.state?.from;
|
||||
const path = from ? from.pathname + from.search : '/home/account';
|
||||
navigate(path, { replace: true });
|
||||
}
|
||||
}, [jwt]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user