All checks were successful
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 25s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 23s
- Introduced a new utility function to filter and return only active club memberships, improving role management and access control. - Updated various components and pages to utilize the new active club memberships function, ensuring only relevant memberships are considered. - Enhanced user interface elements to reflect the status of club memberships, including visual indicators for inactive memberships. - Improved backend logic for resolving tenant contexts and managing club roles based on active memberships.
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import { useAuth } from '../context/AuthContext'
|
|
import { activeClubMemberships, getResolvedActiveClubIdForUi } from '../utils/activeClub'
|
|
|
|
/**
|
|
* Zeigt einen Vereins-Umschalter, wenn der Nutzer mehreren Vereinen zugeordnet ist.
|
|
* Steuert den Mandanten-Kontext (Header X-Active-Club-Id + Profilfeld active_club_id).
|
|
*/
|
|
export default function ActiveClubSwitcher({ variant = 'sidebar' }) {
|
|
const { user, setActiveClub } = useAuth()
|
|
const clubs = activeClubMemberships(user?.clubs)
|
|
if (clubs.length <= 1) return null
|
|
|
|
const selectClubId = getResolvedActiveClubIdForUi(user)
|
|
|
|
const isMobile = variant === 'mobile'
|
|
|
|
return (
|
|
<label
|
|
className={
|
|
'active-club-switch' +
|
|
(isMobile ? ' active-club-switch--mobile' : ' active-club-switch--sidebar')
|
|
}
|
|
>
|
|
<span className="active-club-switch__label">Aktiver Verein</span>
|
|
<select
|
|
className="form-input active-club-switch__select"
|
|
aria-label="Aktiven Verein wählen"
|
|
value={selectClubId ?? ''}
|
|
onChange={(e) => {
|
|
const v = e.target.value
|
|
if (v) setActiveClub(Number(v))
|
|
}}
|
|
>
|
|
{clubs.map((c) => (
|
|
<option key={c.id} value={c.id}>
|
|
{c.name || `Verein #${c.id}`}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
)
|
|
}
|