fix: re-resolve tenantId when org list is enriched by OrgResolver
All checks were successful
CI / build (push) Successful in 38s
CI / docker (push) Successful in 37s

TokenSync sets currentOrgId from fetchUserInfo (no tenantId).
OrgResolver later calls setOrganizations with enriched data including
tenantId. Now setOrganizations auto-resolves currentTenantId when
the org is already selected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-05 10:29:03 +02:00
parent 51c73d64a4
commit 1b42bd585d

View File

@@ -26,6 +26,14 @@ export const useOrgStore = create<OrgState>((set, get) => ({
const org = get().organizations.find((o) => o.id === orgId);
set({ currentOrgId: orgId, currentTenantId: org?.tenantId ?? null });
},
setOrganizations: (orgs) => set({ organizations: orgs }),
setOrganizations: (orgs) => {
const { currentOrgId } = get();
const match = currentOrgId ? orgs.find((o) => o.id === currentOrgId) : null;
set({
organizations: orgs,
// Re-resolve tenantId when org list is enriched (e.g., OrgResolver adds tenantId)
currentTenantId: match?.tenantId ?? get().currentTenantId,
});
},
setIsPlatformAdmin: (value) => set({ isPlatformAdmin: value }),
}));