Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 176 additions & 55 deletions app/action/[userId]/page.tsx

Large diffs are not rendered by default.

1,003 changes: 1,003 additions & 0 deletions app/action/[userId]/subactions/[subactionId]/page.tsx

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions app/logout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { useAuthToken } from "@/hooks/use-auth-token";
import { socketService } from "@/services/socketService";
import { apiSlice } from "@/states/apiSlice";
import { useDispatch } from "react-redux";

const LogoutPage = () => {
const router = useRouter();
const { removeToken } = useAuthToken();
const dispatch = useDispatch();

useEffect(() => {
const performLogout = () => {
const performLogout = async () => {
try {
// 1. Clear authentication tokens
// 1. Clear authentication tokens first
removeToken();

// 2. Force disconnect socket (this will also clear chat state)
Expand Down Expand Up @@ -42,18 +40,28 @@ const LogoutPage = () => {
if (preservedItems.sidebarExpanded) {
localStorage.setItem('sidebarExpanded', preservedItems.sidebarExpanded);
}

// Small delay to ensure state is cleared
await new Promise(resolve => setTimeout(resolve, 100));
} catch (error) {
console.error('Error during logout:', error);
} finally {
// 6. Always redirect to home page, even if there's an error
window.location.replace("/");
Comment on lines +44 to +50
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logout page now uses window.location.replace("/") instead of window.location.href = "/". While both work, replace is better as it prevents the logout page from appearing in browser history. However, the delay on line 45 (setTimeout(resolve, 100)) seems arbitrary. Consider documenting why this delay is necessary or removing it if it's not required for the logout flow to work correctly.

Copilot uses AI. Check for mistakes.
}

// 6. Immediate redirect using window.location for guaranteed navigation
window.location.href = "/";
};

performLogout();
}, []); // Empty deps - only run once on mount
}, [removeToken, dispatch]);

return null;
return (
<div className="flex items-center justify-center min-h-screen bg-gray-50 dark:bg-darkBg-main">
<div className="text-center">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-[#D4AF37] mx-auto mb-4"></div>
<p className="text-[#00313A] dark:text-white font-medium">Logging out...</p>
</div>
</div>
);
};

export default LogoutPage;
Loading