diff --git a/app/(root)/page.tsx b/app/(root)/page.tsx index 4804323..b344224 100644 --- a/app/(root)/page.tsx +++ b/app/(root)/page.tsx @@ -29,6 +29,9 @@ const SubscriptionTracker: FC = () => { // Timestamp used to trigger data refresh const [lastUpdated, setLastUpdated] = useState(Date.now()); + // Logout loading state + const [logoutLoading, setLogoutLoading] = useState(false); + /** * Fetch user data when component mounts or lastUpdated changes */ @@ -95,20 +98,23 @@ const SubscriptionTracker: FC = () => { * Handle user logout */ const handleSignOut = async () => { - try { - const response = await fetch("/api/auth/logout", { - method: "POST", - }); - - if (response.ok) { - window.location.href = "/"; - } else { - console.error("Failed to sign out"); + try { + setLogoutLoading(true); + const response = await fetch("/api/auth/logout", { + method: "POST", + }); + + if (response.ok) { + window.location.href = "/"; + } else { + console.error("Failed to sign out"); + } + } catch (error) { + console.error("Error signing out:", error); + }finally{ + setLogoutLoading(false); } - } catch (error) { - console.error("Error signing out:", error); - } - }; + }; /** * Renders the appropriate component based on active tab @@ -144,11 +150,37 @@ const SubscriptionTracker: FC = () => { {/* Sign Out button */} {/* User information display (Name and Account Money) */}