fix(web): unmount CustomerPortal when navigating to /login

When a user was logged in as one client and switched to another via the
dev login selector, the portal pages (Home, My Pets, Appointments,
Billing) continued showing the original user's data.

Root cause: CustomerPortal was rendered unconditionally for all
non-/admin routes (including /login). Since CustomerPortal uses a
ref (initDone) to skip re-initialization on re-renders, navigating to
/login and back did not trigger session re-creation — the old session
remained in state.

Fix: make CustomerPortal conditional on pathname not being /login, so
it properly unmounts when the user switches. On re-navigation to /,
a fresh CustomerPortal mounts and creates a new session for the
selected dev user.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
groombook-engineer[bot]
2026-04-02 01:22:45 +00:00
parent 15fdd1cb5d
commit 22475ae8e2
+5 -2
View File
@@ -262,6 +262,9 @@ export function App() {
return <Navigate to="/setup" replace />;
}
// Don't render portal chrome at /login — DevLoginSelector is shown instead
const showCustomerPortal = !location.pathname.startsWith("/admin") && location.pathname !== "/login";
return (
<BrandingProvider>
{location.pathname.startsWith("/admin") ? (
@@ -271,12 +274,12 @@ export function App() {
</Routes>
{authDisabled && <DevSessionIndicator />}
</>
) : (
) : showCustomerPortal ? (
<>
<CustomerPortal />
{authDisabled && <DevSessionIndicator />}
</>
)}
) : null}
</BrandingProvider>
);
}