feat: enhance role permissions and UI for clubs and training planning
- Updated role permissions to allow trainers and users to create clubs and training groups. - Modified database insertion logic to reflect the correct role for trainers during registration. - Enhanced frontend components to display appropriate messages and buttons based on user roles. - Improved user guidance in the Clubs and Training Planning pages, emphasizing the need for clubs and groups before planning training sessions.
This commit is contained in:
1 parent
1f2a4595cd
commit
69b26fc928
5 files changed
+136
-50
No files matched your search
@@ -18,6 +18,7 @@ function ClubsPage() {
|
||||
|
||||
const isAdmin = user?.role === 'admin' || user?.role === 'superadmin'
|
||||
const isTrainer = user?.role === 'trainer' || isAdmin
|
||||
const canCreateClub = ['admin', 'superadmin', 'trainer', 'user'].includes(user?.role)
|
||||
|
||||
useEffect(() => {
|
||||
loadData()
|
||||
@@ -61,7 +62,7 @@ function ClubsPage() {
|
||||
time_start: '',
|
||||
time_end: '',
|
||||
location: '',
|
||||
trainer_id: '',
|
||||
trainer_id: user?.id ?? '',
|
||||
co_trainer_ids: [],
|
||||
status: 'active'
|
||||
})
|
||||
@@ -144,7 +145,11 @@ function ClubsPage() {
|
||||
return (
|
||||
<div style={{ padding: '2rem' }}>
|
||||
<div style={{ maxWidth: '1200px', margin: '0 auto' }}>
|
||||
<h1 style={{ marginBottom: '1.5rem' }}>Vereinsverwaltung</h1>
|
||||
<h1 style={{ marginBottom: '0.75rem' }}>Vereinsverwaltung</h1>
|
||||
<p style={{ color: 'var(--text2)', marginBottom: '1.35rem', maxWidth: '46rem', lineHeight: 1.55 }}>
|
||||
Für die Trainingsplanung wird mindestens ein <strong>Verein</strong> und eine <strong>Trainingsgruppe</strong> gebraucht.
|
||||
Sparten sind optional — typische Eckdaten einer Gruppe (Wochentag, Zeit, Ort) kannst du schrittweise eintragen.
|
||||
</p>
|
||||
|
||||
{/* Tabs */}
|
||||
<div style={{
|
||||
@@ -179,7 +184,7 @@ function ClubsPage() {
|
||||
<>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '1rem' }}>
|
||||
<h2>Vereine</h2>
|
||||
{isAdmin && (
|
||||
{canCreateClub && (
|
||||
<button className="btn btn-primary" onClick={() => handleCreate('club')}>
|
||||
+ Neuer Verein
|
||||
</button>
|
||||
@@ -188,9 +193,17 @@ function ClubsPage() {
|
||||
|
||||
{clubs.length === 0 ? (
|
||||
<div className="card">
|
||||
<p style={{ color: 'var(--text2)', textAlign: 'center' }}>
|
||||
Keine Vereine gefunden
|
||||
<p style={{ color: 'var(--text2)', textAlign: 'center', marginBottom: canCreateClub ? '1rem' : 0 }}>
|
||||
Noch kein Verein angelegt.
|
||||
{canCreateClub
|
||||
? ' Nutze „+ Neuer Verein“ — ein Name reicht zum Start.'
|
||||
: ' Bitte einen Administrator oder Support um Anlage.'}
|
||||
</p>
|
||||
{canCreateClub && (
|
||||
<p style={{ color: 'var(--text2)', textAlign: 'center', fontSize: '0.9rem' }}>
|
||||
Danach im Tab Trainingsgruppen eine Gruppe diesem Verein zuordnen; Details sind optional.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'grid', gap: '1rem' }}>
|
||||
@@ -328,7 +341,7 @@ function ClubsPage() {
|
||||
<>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '1rem' }}>
|
||||
<h2>Trainingsgruppen</h2>
|
||||
{isTrainer && (
|
||||
{canCreateClub && (
|
||||
<button className="btn btn-primary" onClick={() => handleCreate('group')}>
|
||||
+ Neue Gruppe
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user