fix(portal): fix isInitializing race condition causing premature redirect
setIsInitializing(false) was in .finally() which fires BEFORE the outer .then() chain completes, causing redirect to fire before setSession was called. Now setIsInitializing(false) is called explicitly inside success/error handlers after setSession completes. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -86,6 +86,7 @@ export function CustomerPortal() {
|
||||
.then((r) => {
|
||||
if (!r.ok) {
|
||||
setSessionError("Failed to create portal session. Please try again.");
|
||||
setIsInitializing(false);
|
||||
return null;
|
||||
}
|
||||
return r.json() as Promise<ImpersonationSession>;
|
||||
@@ -96,11 +97,12 @@ export function CustomerPortal() {
|
||||
setClientName(devUser.name);
|
||||
setSessionError(null);
|
||||
}
|
||||
setIsInitializing(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSessionError("Failed to connect. Please check your connection and try again.");
|
||||
})
|
||||
.finally(() => setIsInitializing(false));
|
||||
setIsInitializing(false);
|
||||
});
|
||||
} else {
|
||||
// No sessionId param and no dev user — init is complete with no session
|
||||
setIsInitializing(false);
|
||||
|
||||
Reference in New Issue
Block a user