All checks were successful
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 24s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 31s
- Updated resolve_tenant_context to use stored active_club_id if the club exists when no header is provided. - Adjusted comments for clarity regarding platform admin behavior. - Added unit tests to verify new behavior for platform admins in test_access_layer.py. version bump to 1.0.5 for tenant_context module.
33 lines
873 B
JavaScript
33 lines
873 B
JavaScript
import { ACTIVE_CLUB_STORAGE_KEY } from './api'
|
|
|
|
/**
|
|
* Einheitliche Anzeige des aktiven Vereins: Abgleich mit effective_club_id, active_club_id,
|
|
* LocalStorage (Request-Header-Quelle), sonst erster Verein der Liste.
|
|
*/
|
|
export function getResolvedActiveClubIdForUi(user) {
|
|
const clubs = user?.clubs || []
|
|
if (!clubs.length) return null
|
|
|
|
const idInClubs = (id) =>
|
|
id != null &&
|
|
id !== '' &&
|
|
clubs.some((c) => Number(c.id) === Number(id))
|
|
|
|
const eff = user?.effective_club_id
|
|
if (idInClubs(eff)) return Number(eff)
|
|
|
|
const ac = user?.active_club_id
|
|
if (idInClubs(ac)) return Number(ac)
|
|
|
|
try {
|
|
const ls = localStorage.getItem(ACTIVE_CLUB_STORAGE_KEY)
|
|
if (ls && /^\d+$/.test(ls.trim()) && clubs.some((c) => String(c.id) === ls.trim())) {
|
|
return Number(ls.trim())
|
|
}
|
|
} catch {
|
|
/* ignore */
|
|
}
|
|
|
|
return Number(clubs[0].id)
|
|
}
|