diff --git a/src/App.tsx b/src/App.tsx
index 52e942c..94e5e3d 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -27,7 +27,6 @@ const PrivateRoute = () => {
const [checked, setChecked] = useState(false);
const [isValid, setIsValid] = useState(false);
-
useEffect(() => {
const checkAuth = async () => {
if (!token) {
@@ -85,7 +84,7 @@ function App() {
} />
- 404} />
+ 404
Not Found} />
>
diff --git a/src/index.css b/src/index.css
index b5a4566..7227235 100644
--- a/src/index.css
+++ b/src/index.css
@@ -31,3 +31,10 @@ body {
max-width: 100%;
max-height: 100%;
}
+
+.not-found {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+}
diff --git a/src/pages/login/login.tsx b/src/pages/login/login.tsx
index 904a574..a86ee34 100644
--- a/src/pages/login/login.tsx
+++ b/src/pages/login/login.tsx
@@ -13,14 +13,15 @@ const Login = () => {
const { setToken } = useAuth();
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
+
const navigate = useNavigate();
const location = useLocation();
+ const searchPath = new URLSearchParams(location.search);
+ const redirectPath = searchPath.get('to') || "/";
const [usernameEmpty, setUsernameEmpty] = useState(false);
const [passwordEmpty, setPasswordEmpty] = useState(false);
- const from = location.state?.from?.pathname || "/";
-
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
@@ -35,7 +36,7 @@ const Login = () => {
if ((username === "admin" && password === "1234") || (username === "a" && password === "a")) {
const token = "todo.jwt.token";
setToken(token);
- navigate(from, { replace: true });
+ navigate(redirectPath, { replace: true });
} else {
toast.error("Wrong login or password");
}