auth + groups invite

This commit is contained in:
Виталий Лавшонок
2025-11-15 17:37:47 +03:00
parent ded41ba7f0
commit dfc2985209
16 changed files with 673 additions and 225 deletions

View File

@@ -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]);

View File

@@ -1,8 +1,9 @@
// src/views/home/auth/Register.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 { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { registerUser } from '../../../redux/slices/auth';
// import { cn } from "../../../lib/cn";
import { setMenuActivePage } from '../../../redux/slices/store';
@@ -15,6 +16,7 @@ import { googleLogo } from '../../../assets/icons/input';
const Register = () => {
const dispatch = useAppDispatch();
const navigate = useNavigate();
const location = useLocation();
const [username, setUsername] = useState<string>('');
const [email, setEmail] = useState<string>('');
@@ -32,7 +34,9 @@ const Register = () => {
useEffect(() => {
if (jwt) {
navigate('/home/account');
const from = location.state?.from;
const path = from ? from.pathname + from.search : '/home/account';
navigate(path, { replace: true });
}
console.log(submitClicked);
}, [jwt]);