fix: re-resolve tenantId when org list is enriched by OrgResolver
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:
@@ -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 }),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user