diff --git a/src/App.tsx b/src/App.tsx index 2abd484..0a672d6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,20 +20,27 @@ import { ProfileDrawer } from './components/auth/ProfileDrawer'; import { PaymentSuccessModal } from './components/checkout/PaymentSuccessModal'; import { PasswordUpdatedModal } from './components/auth/PasswordUpdatedModal'; import { BillingPhoneModal } from './components/checkout/BillingPhoneModal'; +import { LoggedOutView } from './components/auth/LoggedOutView'; import { openMobileApp, DEFAULT_RETURN_ROUTE } from './utils/navigation'; -const getInitialTab = (): 'storefront' | 'subscriptions' => { +const getInitialTab = (): 'storefront' | 'subscriptions' | 'logged-out' => { if (typeof window !== 'undefined') { const path = window.location.pathname.toLowerCase(); + if (path.includes('/logged-out')) return 'logged-out'; if (path.includes('/subscriptions')) return 'subscriptions'; + + const params = new URLSearchParams(window.location.search); + if (params.get('logged_out') === 'true' || params.get('status') === 'logged-out') { + return 'logged-out'; + } } return 'storefront'; }; export default function App() { - const [activeTab, setActiveTab] = useState<'storefront' | 'subscriptions'>(getInitialTab); + const [activeTab, setActiveTab] = useState<'storefront' | 'subscriptions' | 'logged-out'>(getInitialTab); - const switchTab = (tab: 'storefront' | 'subscriptions') => { + const switchTab = (tab: 'storefront' | 'subscriptions' | 'logged-out') => { setActiveTab(tab); if (typeof window !== 'undefined') { const isStorePrefix = window.location.pathname.startsWith('/store'); @@ -251,6 +258,12 @@ export default function App() { const urlPlanCode = params.get('planCode'); const urlReturnRoute = params.get('returnRoute') || params.get('redirectPath') || params.get('redirect'); const urlScheme = params.get('scheme'); + const shouldOpenLogin = params.get('login') === 'true' || params.get('auth') === 'login'; + + if (shouldOpenLogin) { + setAuthMode('login'); + setShowAuthModal(true); + } if (urlReturnRoute) { setReturnRoute(urlReturnRoute); @@ -282,10 +295,15 @@ export default function App() { } } - if (urlToken || urlPlanCode) { + if (urlToken || urlPlanCode || shouldOpenLogin) { const isStorePrefix = window.location.pathname.startsWith('/store'); const basePath = isStorePrefix ? '/store/' : '/'; - const cleanPath = activeTab === 'subscriptions' ? `${basePath}subscriptions` : basePath; + const cleanPath = + activeTab === 'subscriptions' + ? `${basePath}subscriptions` + : activeTab === 'logged-out' + ? `${basePath}logged-out` + : basePath; window.history.replaceState({}, document.title, cleanPath); } @@ -354,13 +372,14 @@ export default function App() { setAppliedCoupon(null); setCouponCode(''); setPricingCalc(null); - switchTab('storefront'); setShowProfileDrawer(false); setProfileDisplayName(''); setProfilePhone(''); setProfileCountry('India'); setProfileError(null); setProfileSuccess(false); + setShowAuthModal(false); + switchTab('logged-out'); }; const handleUpdateProfile = async (e: React.FormEvent) => { @@ -509,6 +528,9 @@ export default function App() { setAuthEmail(''); setAuthDisplayName(''); setAuthPhone(''); + if (activeTab === 'logged-out') { + switchTab('storefront'); + } } catch (err: any) { setAuthError(err.response?.data?.detail || 'Authentication failed. Please check credentials.'); } finally { @@ -1063,6 +1085,14 @@ export default function App() { /> + ) : activeTab === 'logged-out' ? ( + { + switchTab('storefront'); + setAuthMode('login'); + setShowAuthModal(true); + }} + /> ) : ( /* 🧾 Tab: User Personal Subscriptions Ledger */ void; +} + +export const LoggedOutView: React.FC = ({ + onLoginAgain, +}) => { + const isStorePrefix = + typeof window !== 'undefined' && window.location.pathname.startsWith('/store'); + const basePath = isStorePrefix ? '/store/' : '/'; + const loginUrl = `${basePath}?login=true`; + const loginDisplayUrl = + typeof window !== 'undefined' + ? `${window.location.origin}${loginUrl}` + : loginUrl; + + return ( +
+
+ {/* Status Badge Icon */} +
+ +
+ + {/* Title & Description */} +

+ Successfully Logged Out +

+

+ You have been securely signed out of your AcuPedia session. Thank you for using our platform. +

+ + {/* Security Notice */} +
+ +

+ For security, please close your browser window if you are using a shared or public device. +

+
+ + {/* Actions */} + + + {/* Option to login in again via URL (explicit link for user / copy) */} + +
+
+ ); +}; + diff --git a/src/components/layout/StoreHeader.tsx b/src/components/layout/StoreHeader.tsx index d5c2547..b0194f0 100644 --- a/src/components/layout/StoreHeader.tsx +++ b/src/components/layout/StoreHeader.tsx @@ -3,8 +3,8 @@ import { Sparkles, LogIn, UserPlus, BookOpen, CheckCircle } from 'lucide-react'; import type { UserProfile } from '../../types'; interface StoreHeaderProps { - activeTab: 'storefront' | 'subscriptions'; - onSwitchTab: (tab: 'storefront' | 'subscriptions') => void; + activeTab: 'storefront' | 'subscriptions' | 'logged-out'; + onSwitchTab: (tab: 'storefront' | 'subscriptions' | 'logged-out') => void; loggedInUser: UserProfile | null; onOpenProfile: () => void; onOpenAuth: (mode: 'login' | 'register') => void;