diff --git a/src/components/layout/layout.jsx b/src/components/layout/layout.jsx index 73374db..caca754 100644 --- a/src/components/layout/layout.jsx +++ b/src/components/layout/layout.jsx @@ -42,7 +42,7 @@ export default function Layout() { {/* Main Content Area */}
diff --git a/src/pages/Login/Login.jsx b/src/pages/Login/Login.jsx index 393a84f..671e0ce 100644 --- a/src/pages/Login/Login.jsx +++ b/src/pages/Login/Login.jsx @@ -15,184 +15,243 @@ import { setProfile } from "../../redux/slices/profileSlice"; // Services import authService from "../../services/auth"; +import toggleTheme from "../../components/ToggleTheme"; + export default function Login() { - const navigate = useNavigate(); - const dispatch = useDispatch(); + const navigate = useNavigate(); + const dispatch = useDispatch(); - // State Management - const [userName, setUserName] = useState(""); - const [password, setPassword] = useState(""); - const [loading, setLoading] = useState(false); - const [error, setError] = useState(""); - const [isMobile, setIsMobile] = useState(window.innerWidth < 768); + // State Management + const [userName, setUserName] = useState(""); + const [password, setPassword] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(""); + const [isMobile, setIsMobile] = useState(window.innerWidth < 768); - useEffect(() => { - const handleResize = () => { - setIsMobile(window.innerWidth < 768); - }; - - window.addEventListener('resize', handleResize); - return () => window.removeEventListener('resize', handleResize); - }, []); - - // Handle Login - const handleLogin = async (e) => { - e.preventDefault(); - setError(""); - setLoading(true); - - try { - const res = await authService.login({ userName, password }); - if (res.data.success && res.data.data?.tokens?.accessToken) { - dispatch(setToken(res.data.data.tokens.accessToken)); - dispatch(setProfile(res.data.data.admin)); - console.log("✅ Login successful:", res.data.data.admin); - navigate("/dashboard"); - } else { - setError("اطلاعات دریافتی معتبر نیست"); - } - } catch (error) { - console.error("❌ Login error:", error); - const errorMessage = - error.response?.data?.message || - (error.request ? "خطا در برقراری ارتباط با سرور" : "خطای نامشخص رخ داده است"); - setError(errorMessage); - } finally { - setLoading(false); - } + useEffect(() => { + const handleResize = () => { + setIsMobile(window.innerWidth < 768); }; - return ( -
- {/* Header */} -
-
- {/* Left Section */} -
- Logo -
- - - - -
-
+ window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); - {/* Center Links (Hidden on Mobile) */} - + // Handle Login + const handleLogin = async (e) => { + e.preventDefault(); + setError(""); + setLoading(true); - {/* Right Section */} - -
-
+ try { + const res = await authService.login({ userName, password }); + if (res.data.success && res.data.data?.tokens?.accessToken) { + dispatch(setToken(res.data.data.tokens.accessToken)); + dispatch(setProfile(res.data.data.admin)); + console.log("✅ Login successful:", res.data.data.admin); + navigate("/dashboard"); + } else { + setError("اطلاعات دریافتی معتبر نیست"); + } + } catch (error) { + console.error("❌ Login error:", error); + const errorMessage = + error.response?.data?.message || + (error.request + ? "خطا در برقراری ارتباط با سرور" + : "خطای نامشخص رخ داده است"); + setError(errorMessage); + } finally { + setLoading(false); + } + }; - {/* Main Content */} -
- {/* Left Side - Login Form */} -
- {/* Dark Overlay */} -
-
- {/* Breadcrumb */} -
- ورود - > - خانه -
- - {/* Header */} -
-

ورود ادمین

-

دسترسی ویژه برای مدیریت و گزارش‌ها

-
- - {/* Login Form */} -
- {/* Error Message */} - {error && ( -
- {error} -
- )} - - {/* Username Field */} -
- -
- setUserName(e.target.value)} - placeholder="userName" - className="w-full pl-12 pr-4 py-3 border-2 bg-background border-gray-300 rounded-xl focus:outline-none focus:border-button1 transition-colors text-sm" - dir="ltr" - required - /> - -
-
- - {/* Password Field */} -
- -
- setPassword(e.target.value)} - placeholder="password" - className="w-full pl-12 pr-4 py-3 border-2 bg-background border-gray-300 rounded-xl focus:outline-none focus:border-button1 transition-colors text-sm" - dir="ltr" - required - /> - -
-
- - {/* Forgot Password */} - - - {/* Submit Button */} - -
-
-
- - {/* Right Side - Image (Hidden on Mobile) */} -
- Coffee workspace -
+ return ( +
+ {/* Header */} +
+
+ {/* Left Section */} +
+ Logo +
+ + + +
+
+ + {/* Center Links (Hidden on Mobile) */} + + + {/* Right Section */} +
- ); -} \ No newline at end of file +
+ + {/* Main Content */} +
+ {/* Left Side - Login Form */} +
+ {/* Dark Overlay */} +
+
+ {/* Breadcrumb */} +
+ ورود + > + خانه +
+ + {/* Header */} +
+

+ ورود ادمین +

+

+ دسترسی ویژه برای مدیریت و گزارش‌ها +

+
+ + {/* Login Form */} +
+ {/* Error Message */} + {error && ( +
+ {error} +
+ )} + + {/* Username Field */} +
+ +
+ setUserName(e.target.value)} + placeholder="userName" + className="w-full pl-12 pr-4 py-3 border-2 bg-background border-gray-300 dark:text-white rounded-xl focus:outline-none focus:border-button1 transition-colors text-sm" + dir="ltr" + required + /> + +
+
+ + {/* Password Field */} +
+ +
+ setPassword(e.target.value)} + placeholder="password" + className="w-full pl-12 pr-4 py-3 border-2 bg-background border-gray-300 dark:text-white rounded-xl focus:outline-none focus:border-button1 transition-colors text-sm" + dir="ltr" + required + /> + +
+
+ + {/* Forgot Password */} + + + {/* Submit Button */} + +
+
+
+ + {/* Right Side - Image (Hidden on Mobile) */} +
+ Coffee workspace +
+
+
+ ); +} diff --git a/src/styles/index.css b/src/styles/index.css index 1863831..e2bc351 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -14,6 +14,7 @@ --font-sans: "Vazirmatn", system-ui, sans-serif; + } .dark { @@ -28,6 +29,35 @@ --color-background: #272322; } +/* Chrome / Edge / Safari autofill FIX (light + dark, no color) */ + +input:-webkit-autofill, +input:-webkit-autofill:hover, +input:-webkit-autofill:focus, +textarea:-webkit-autofill, +textarea:-webkit-autofill:focus, +select:-webkit-autofill { + -webkit-box-shadow: 0 0 0 1000px #fdf8f4 inset !important; + box-shadow: 0 0 0 1000px #fdf8f4 inset !important; + -webkit-text-fill-color: inherit !important; +} + +.dark input:-webkit-autofill, +.dark input:-webkit-autofill:hover, +.dark input:-webkit-autofill:focus, +.dark textarea:-webkit-autofill, +.dark textarea:-webkit-autofill:focus, +.dark select:-webkit-autofill { + -webkit-box-shadow: 0 0 0 1000px #272322 inset !important; + box-shadow: 0 0 0 1000px #272322 inset !important; + -webkit-text-fill-color: inherit !important; +} + + + + + + html { font-family: var(--font-sans); }