fix(portal): prevent Dashboard redirect during impersonation session load

When navigating to /?sessionId=xxx, Dashboard would immediately
redirect to /login because sessionId was null before the fetch
completed. The impersonation banner never rendered.

Add isImpersonating state: true while impersonation fetch is in-flight,
prevents Dashboard from redirecting until session loads.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Barkley Trimsworth
2026-03-31 17:43:00 +00:00
parent fdc324d445
commit 991660405d
2 changed files with 10 additions and 3 deletions
+4 -1
View File
@@ -8,6 +8,8 @@ interface DashboardProps {
onNavigate: (section: "appointments" | "pets" | "billing" | "reports") => void;
readOnly: boolean;
onReschedule: (appointmentId: string) => void;
/** True when a sessionId param was in the URL and the session is still loading */
isImpersonating?: boolean;
}
interface Appointment {
@@ -73,6 +75,7 @@ export function Dashboard({
onNavigate,
readOnly,
onReschedule,
isImpersonating,
}: DashboardProps) {
const [appointments, setAppointments] = useState<Appointment[]>([]);
const [pets, setPets] = useState<Pet[]>([]);
@@ -183,7 +186,7 @@ export function Dashboard({
);
}
if (!sessionId) {
if (!sessionId && !isImpersonating) {
return <Navigate to="/login" replace />;
}