From 781945b358fc6ca8487785f1b013f272a398847b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D1=82=D0=B0=D0=BB=D0=B8=D0=B9=20=D0=9B=D0=B0?= =?UTF-8?q?=D0=B2=D1=88=D0=BE=D0=BD=D0=BE=D0=BA?= <114582703+valavshonok@users.noreply.github.com> Date: Sun, 14 Dec 2025 17:24:02 +0300 Subject: [PATCH] fix --- index.html | 4 ++-- public/logo.svg | 5 +++++ public/vite.svg | 1 - src/redux/slices/auth.ts | 8 +++++++- src/views/home/auth/Login.tsx | 13 +++---------- src/views/home/auth/Register.tsx | 15 ++++++++------- src/views/home/contests/Contests.tsx | 7 +++++++ src/views/home/missions/Missions.tsx | 7 +++++++ 8 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 public/logo.svg delete mode 100644 public/vite.svg diff --git a/index.html b/index.html index 7edb050..aa2abfd 100644 --- a/index.html +++ b/index.html @@ -2,9 +2,9 @@ - + - Vite + React + TS + LiquidCode diff --git a/public/logo.svg b/public/logo.svg new file mode 100644 index 0000000..45fd0a1 --- /dev/null +++ b/public/logo.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/public/vite.svg b/public/vite.svg deleted file mode 100644 index e7b8dfb..0000000 --- a/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/redux/slices/auth.ts b/src/redux/slices/auth.ts index 0aebac2..f9f6a26 100644 --- a/src/redux/slices/auth.ts +++ b/src/redux/slices/auth.ts @@ -1,5 +1,6 @@ import { createSlice, createAsyncThunk, PayloadAction } from '@reduxjs/toolkit'; import axios from '../../axios'; +import { toastError } from '../../lib/toastNotification'; type Status = 'idle' | 'loading' | 'successful' | 'failed'; @@ -85,7 +86,7 @@ export const registerUser = createAsyncThunk( }); return response.data; } catch (err: any) { - return rejectWithValue(err.response?.data?.errors); + return rejectWithValue(err.response?.data?.errors ? err.response?.data?.errors : {"error" : [err.response?.data]}); } }, ); @@ -216,6 +217,11 @@ const authSlice = createSlice({ builder.addCase(registerUser.rejected, (state, action) => { state.status = 'failed'; state.register.errors = action.payload as Record; + Object.values(state.register.errors).forEach((messages) => { + messages.forEach((msg) => { + toastError(msg); + }); + }); }); // ----------------- Login ----------------- diff --git a/src/views/home/auth/Login.tsx b/src/views/home/auth/Login.tsx index 6ed61d1..8ad9c0c 100644 --- a/src/views/home/auth/Login.tsx +++ b/src/views/home/auth/Login.tsx @@ -67,7 +67,7 @@ const Login = () => {
-
+
С возвращением
@@ -100,15 +100,8 @@ const Login = () => { error={getErrorPasswordMessage()} /> -
- - Забыли пароль? - +
+
diff --git a/src/views/home/auth/Register.tsx b/src/views/home/auth/Register.tsx index 1b5f1c5..4c4729f 100644 --- a/src/views/home/auth/Register.tsx +++ b/src/views/home/auth/Register.tsx @@ -9,7 +9,7 @@ import { registerUser } from '../../../redux/slices/auth'; import { setMenuActivePage } from '../../../redux/slices/store'; import { Balloon } from '../../../assets/icons/auth'; import { Link } from 'react-router-dom'; -import { Checkbox } from '../../../components/checkbox/Checkbox'; +// import { Checkbox } from '../../../components/checkbox/Checkbox'; function isValidEmail(email: string): boolean { const pattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; @@ -52,12 +52,13 @@ const Register = () => { const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [submitClicked, setSubmitClicked] = useState(false); - const [politicChecked, setPoliticChecked] = useState(false); + const [politicChecked, setPoliticChecked] = useState(true); const { status, jwt } = useAppSelector((state) => state.auth); // const { errors } = useAppSelector((state) => state.auth.register); useEffect(() => { + setPoliticChecked(true); dispatch(setMenuActivePage('account')); }, []); @@ -142,7 +143,7 @@ const Register = () => {
-
+
Добро пожаловать
@@ -200,7 +201,7 @@ const Register = () => { />
- { setPoliticChecked(value); }} @@ -215,13 +216,13 @@ const Register = () => { /> Я принимаю{' '} - {/* + политику конфиденциальности - */} + политику конфиденциальности - + */}
diff --git a/src/views/home/contests/Contests.tsx b/src/views/home/contests/Contests.tsx index d6b4892..c259445 100644 --- a/src/views/home/contests/Contests.tsx +++ b/src/views/home/contests/Contests.tsx @@ -14,12 +14,15 @@ import { } from '../../../redux/slices/contests'; import ModalCreateContest from './ModalCreate'; import Filters from './Filter'; +import { toastWarning } from '../../../lib/toastNotification'; const Contests = () => { const dispatch = useAppDispatch(); const [modalActive, setModalActive] = useState(false); + const jwt = useAppSelector((state) => state.auth.jwt); + const { contests, status } = useAppSelector( (state) => state.contests.fetchContests, ); @@ -49,6 +52,10 @@ const Contests = () => {
{ + if (!jwt){ + toastWarning("Для создания контеста необходимо авторизоваться") + return; + } setModalActive(true); }} text="Создать контест" diff --git a/src/views/home/missions/Missions.tsx b/src/views/home/missions/Missions.tsx index 1770cce..862afcb 100644 --- a/src/views/home/missions/Missions.tsx +++ b/src/views/home/missions/Missions.tsx @@ -10,6 +10,7 @@ import { import { fetchMissions } from '../../../redux/slices/missions'; import ModalCreate from './ModalCreate'; import Filters from './Filter'; +import { toastWarning } from '../../../lib/toastNotification'; export interface Mission { id: number; @@ -29,6 +30,7 @@ const Missions = () => { const missions = useAppSelector((state) => state.missions.missions); + const jwt = useAppSelector((state) => state.auth.jwt); const nameFilter = useAppSelector( (state) => state.store.missions.filterName, ); @@ -60,6 +62,11 @@ const Missions = () => {
{ + + if (!jwt){ + toastWarning("Для загрузки задачи необходимо авторизоваться") + return; + } setModalActive(true); }} text="Добавить задачу"