diff --git a/src/App.tsx b/src/App.tsx
index 78bf452b..46663509 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -277,31 +277,10 @@ export default function App() {
path="/gallery"
element={} />}
/>
- }
- fallback={}
- />
- }
- />
- } />}
- />
} />}
/>
- } />}
- />
- } />}
- />
} />}
@@ -333,6 +312,27 @@ export default function App() {
}
/>
))}
+ }
+ fallback={}
+ />
+ }
+ />
+ } />}
+ />
+ } />}
+ />
+ } />}
+ />
diff --git a/src/pages/Landing/HeaderLanding.tsx b/src/pages/Landing/HeaderLanding.tsx
index 0e4ef635..4d30cf6f 100644
--- a/src/pages/Landing/HeaderLanding.tsx
+++ b/src/pages/Landing/HeaderLanding.tsx
@@ -26,6 +26,12 @@ export default function Component() {
const userId = useUserStore((state) => state.userId);
const location = useLocation();
+ console.log("HeaderLanding debug:", {
+ userId,
+ location: location.pathname,
+ backgroundLocation: location.state?.backgroundLocation
+ });
+
return (
console.log("Signin button clicked")}
sx={{
color: "black",
border: "1px solid black",
diff --git a/src/stores/user.ts b/src/stores/user.ts
index 4de52d83..f626f241 100644
--- a/src/stores/user.ts
+++ b/src/stores/user.ts
@@ -66,7 +66,18 @@ export const setUser = (user: User) =>
}),
);
-export const clearUserData = () => useUserStore.setState({ ...initialState });
+export const clearUserData = () => {
+ console.log("clearUserData: Clearing user data");
+ console.log("clearUserData: Before clearing -", useUserStore.getState());
+
+ useUserStore.setState({ ...initialState });
+
+ console.log("clearUserData: After clearing -", useUserStore.getState());
+
+ // Также очищаем localStorage напрямую
+ localStorage.removeItem("user");
+ console.log("clearUserData: localStorage cleared");
+};
export const setUserAccount = (userAccount: OriginalUserAccount) =>
useUserStore.setState({ userAccount });
diff --git a/src/ui_kit/PrivateRoute.tsx b/src/ui_kit/PrivateRoute.tsx
index 558ea94e..27c4503d 100644
--- a/src/ui_kit/PrivateRoute.tsx
+++ b/src/ui_kit/PrivateRoute.tsx
@@ -1,8 +1,31 @@
import { useUserStore } from "@root/user";
import { Navigate, Outlet } from "react-router-dom";
+import { useEffect } from "react";
export default function PrivateRoute() {
const user = useUserStore((state) => state.user);
+ const userId = useUserStore((state) => state.userId);
- return user ? : ;
+ console.log("PrivateRoute debug:", {
+ user: user ? "exists" : "null",
+ userId: user?._id,
+ userIdFromStore: userId,
+ currentPath: window.location.pathname,
+ userObject: user
+ });
+
+ useEffect(() => {
+ if (!user) {
+ console.log("PrivateRoute: User is null, redirecting to / via useEffect");
+ window.location.href = "/";
+ }
+ }, [user]);
+
+ if (!user) {
+ console.log("PrivateRoute: User is null, showing fallback");
+ return <>>;
+ }
+
+ console.log("PrivateRoute: User exists, rendering Outlet");
+ return ;
}