From af151f254b329923b12a445f3116b6740f7f0d57 Mon Sep 17 00:00:00 2001 From: "MH.Dmitrii" Date: Thu, 1 Oct 2026 10:45:51 +0300 Subject: [PATCH] fix layout for dashboard, add dashboard, save rememberme state in localstorage --- frontend/src/App.css | 4 ---- frontend/src/App.tsx | 2 ++ frontend/src/features/auth/components/AuthComponent.tsx | 9 ++++++--- frontend/src/layouts/AuthLayout.css | 3 +++ frontend/src/pages/Dashboard.tsx | 9 +++++++++ frontend/src/utils/rememberMe.ts | 9 +++++++++ 6 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 frontend/src/pages/Dashboard.tsx create mode 100644 frontend/src/utils/rememberMe.ts diff --git a/frontend/src/App.css b/frontend/src/App.css index 3fc8113..ba3535a 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -1,7 +1,3 @@ #root { height: 100%; - box-shadow: 1px 1px 20px 1px rgba(68, 68, 68, 0.5); - border-radius: 40px; - border: 1px solid #444; - overflow: hidden; } \ No newline at end of file diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 411f6b1..f1abb1b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2,12 +2,14 @@ import './App.css' import { Route, Routes } from "react-router-dom"; import { LoginPage } from "./pages/LoginPage"; import { ForgotPasswordPage } from "./pages/ForgotPasswordPage"; +import { DashboardPage } from './pages/Dashboard'; function App() { return ( } /> } /> + } /> ); } diff --git a/frontend/src/features/auth/components/AuthComponent.tsx b/frontend/src/features/auth/components/AuthComponent.tsx index cfbd8f7..f36d79b 100644 --- a/frontend/src/features/auth/components/AuthComponent.tsx +++ b/frontend/src/features/auth/components/AuthComponent.tsx @@ -1,7 +1,8 @@ import { useState, type SubmitEvent, type ReactElement } from "react"; -import { Link } from "react-router-dom"; +import { Link, useNavigate } from "react-router-dom"; import styles from "./AuthComponent.module.css"; import { login } from "../../../api/LoginAPI/Auth"; +import { persistRememberMe } from "../../../utils/rememberMe"; export function Auth():ReactElement { const [email, setEmail] = useState(""); @@ -9,6 +10,7 @@ export function Auth():ReactElement { const [rememberMe, setRememberMe] = useState(false); const [showPassword, setShowPassword] = useState(false); const [errors, setErrors] = useState<{ email?: string; password?: string }>({}); + const navigate = useNavigate(); const validateEmail = (value: string) => { if (!value) return "Введите email"; @@ -26,12 +28,13 @@ export function Auth():ReactElement { try { await login(email, password); - window.location.href = "http://localhost:8000/docs"; + persistRememberMe(rememberMe); + navigate("/dashboard"); } catch (err) { console.error(err); setErrors({ password: "Неверный email или пароль" }); } - }; + }; return ( <> diff --git a/frontend/src/layouts/AuthLayout.css b/frontend/src/layouts/AuthLayout.css index 1cfbfec..60bdf9e 100644 --- a/frontend/src/layouts/AuthLayout.css +++ b/frontend/src/layouts/AuthLayout.css @@ -5,6 +5,9 @@ width: 100%; overflow: hidden; height: 100%; + box-shadow: 1px 1px 20px 1px rgba(68, 68, 68, 0.5); + border-radius: 40px; + border: 1px solid #444; } .left_side { width: 60%; diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx new file mode 100644 index 0000000..ae80c62 --- /dev/null +++ b/frontend/src/pages/Dashboard.tsx @@ -0,0 +1,9 @@ + + +export function DashboardPage() { + return ( + <> +

test

+ + ); +} \ No newline at end of file diff --git a/frontend/src/utils/rememberMe.ts b/frontend/src/utils/rememberMe.ts new file mode 100644 index 0000000..839b2d5 --- /dev/null +++ b/frontend/src/utils/rememberMe.ts @@ -0,0 +1,9 @@ + + +export function persistRememberMe(value:boolean):void { + if (value) { + localStorage.setItem("rememberMe", "True"); + } else{ + localStorage.removeItem("rememberMe"); + } +}; \ No newline at end of file