Add Club Creation Request Management Features
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Failing after 1m14s
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Failing after 1m14s
- Introduced endpoints for managing club creation requests, including fetching, creating, and withdrawing requests. - Updated the onboarding page to allow users to submit new club creation requests and view their existing requests. - Enhanced the admin interface with navigation and routing for club creation requests management. - Incremented version to 0.8.191 to reflect these new features and updates in the application.
This commit is contained in:
1 parent
8718cf5c70
commit
8ee8f52e0f
11 files changed
+836
-9
No files matched your search
@@ -55,6 +55,7 @@ const AdminMaturityModelsPage = lazy(() => import('./pages/AdminMaturityModelsPa
|
||||
const TrainerContextsPage = lazy(() => import('./pages/TrainerContextsPage'))
|
||||
const MediaWikiImportPage = lazy(() => import('./pages/MediaWikiImportPage'))
|
||||
const AdminUsersPage = lazy(() => import('./pages/AdminUsersPage'))
|
||||
const AdminClubCreationRequestsPage = lazy(() => import('./pages/AdminClubCreationRequestsPage'))
|
||||
const MediaLibraryPage = lazy(() => import('./pages/MediaLibraryPage'))
|
||||
const LegalPage = lazy(() => import('./pages/LegalPage'))
|
||||
const AdminLegalDocumentsPage = lazy(() => import('./pages/AdminLegalDocumentsPage'))
|
||||
@@ -282,6 +283,14 @@ const appRouter = createBrowserRouter([
|
||||
</PlatformAdminRoute>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'admin/club-creation-requests',
|
||||
element: (
|
||||
<PlatformAdminRoute>
|
||||
<AdminClubCreationRequestsPage />
|
||||
</PlatformAdminRoute>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'admin/hierarchy',
|
||||
element: (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { TreePine, FolderTree, Download, Grid3x3, Users, Scale, Sparkles, Wand2, Activity } from 'lucide-react'
|
||||
import { TreePine, FolderTree, Download, Grid3x3, Users, Scale, Sparkles, Wand2, Activity, Building2 } from 'lucide-react'
|
||||
|
||||
/**
|
||||
* Admin-Seiten-Navigation (horizontal) — nur für Super-Admins (globaler Portal-Mandant).
|
||||
@@ -8,6 +8,7 @@ export default function AdminPageNav() {
|
||||
const pages = [
|
||||
{ to: '/admin/hierarchy', label: 'Hierarchie', icon: TreePine },
|
||||
{ to: '/admin/users', label: 'Nutzer', icon: Users },
|
||||
{ to: '/admin/club-creation-requests', label: 'Vereinsgründungen', icon: Building2 },
|
||||
{ to: '/admin/user-content', label: 'Nutzer-Inhalte', icon: Activity },
|
||||
{ to: '/admin/maturity-models', label: 'Fähigkeitsmatrix', icon: Grid3x3 },
|
||||
{ to: '/admin/catalogs', label: 'Kataloge', icon: FolderTree },
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Navigate } from 'react-router-dom'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import api from '../utils/api'
|
||||
import AdminPageNav from '../components/AdminPageNav'
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value) return '—'
|
||||
try {
|
||||
return new Date(value).toLocaleString('de-DE', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})
|
||||
} catch {
|
||||
return String(value)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Superadmin: offene Anträge auf Vereinsgründung freigeben oder ablehnen.
|
||||
*/
|
||||
export default function AdminClubCreationRequestsPage() {
|
||||
const { user } = useAuth()
|
||||
const isSuperadmin = user?.role === 'superadmin'
|
||||
|
||||
const [requests, setRequests] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
const [busyId, setBusyId] = useState(null)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
const rows = await api.listAdminClubCreationRequests()
|
||||
setRequests(Array.isArray(rows) ? rows : [])
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isSuperadmin) return
|
||||
let cancelled = false
|
||||
;(async () => {
|
||||
setError('')
|
||||
setLoading(true)
|
||||
try {
|
||||
await load()
|
||||
} catch (e) {
|
||||
if (!cancelled) setError(e.message || String(e))
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false)
|
||||
}
|
||||
})()
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [isSuperadmin, load])
|
||||
|
||||
if (!isSuperadmin) return <Navigate to="/" replace />
|
||||
|
||||
const handleApprove = async (id) => {
|
||||
if (!confirm('Verein anlegen und Antragsteller als Hauptverwalter eintragen?')) return
|
||||
setBusyId(id)
|
||||
setError('')
|
||||
try {
|
||||
await api.approveClubCreationRequest(id)
|
||||
await load()
|
||||
} catch (e) {
|
||||
setError(e.message || String(e))
|
||||
} finally {
|
||||
setBusyId(null)
|
||||
}
|
||||
}
|
||||
|
||||
const handleReject = async (id) => {
|
||||
if (!confirm('Gründungsantrag wirklich ablehnen?')) return
|
||||
setBusyId(id)
|
||||
setError('')
|
||||
try {
|
||||
await api.rejectClubCreationRequest(id)
|
||||
await load()
|
||||
} catch (e) {
|
||||
setError(e.message || String(e))
|
||||
} finally {
|
||||
setBusyId(null)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page-padding app-page">
|
||||
<AdminPageNav />
|
||||
<h1 style={{ marginTop: '1rem', fontSize: '1.35rem' }}>Vereinsgründungen</h1>
|
||||
<p style={{ color: 'var(--text2)', maxWidth: '42rem', lineHeight: 1.5 }}>
|
||||
Offene Anträge von verifizierten Nutzern ohne Vereinsmitgliedschaft. Bei Freigabe wird ein
|
||||
neuer Verein mit Free-Abo angelegt; der Antragsteller wird Vereinsadmin und Trainer.
|
||||
</p>
|
||||
|
||||
{error ? (
|
||||
<p role="alert" style={{ color: 'var(--danger)' }}>
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{loading ? (
|
||||
<p className="spinner" style={{ marginTop: '1rem' }}>
|
||||
Laden…
|
||||
</p>
|
||||
) : requests.length === 0 ? (
|
||||
<div className="card" style={{ marginTop: '1rem' }}>
|
||||
<p style={{ margin: 0, color: 'var(--text2)' }}>Keine offenen Gründungsanträge.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem', marginTop: '1rem' }}>
|
||||
{requests.map((r) => (
|
||||
<div key={r.id} className="card">
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem 1rem', marginBottom: '0.5rem' }}>
|
||||
<strong>{r.proposed_name}</strong>
|
||||
{r.proposed_abbreviation ? (
|
||||
<span style={{ color: 'var(--text2)' }}>({r.proposed_abbreviation})</span>
|
||||
) : null}
|
||||
</div>
|
||||
<p style={{ margin: '0 0 0.35rem', fontSize: '0.9rem', color: 'var(--text2)' }}>
|
||||
Antragsteller: {r.applicant_name || '—'}{' '}
|
||||
{r.applicant_email ? `· ${r.applicant_email}` : ''}
|
||||
</p>
|
||||
<p style={{ margin: '0 0 0.35rem', fontSize: '0.85rem', color: 'var(--text3)' }}>
|
||||
Eingereicht: {formatDate(r.created_at)}
|
||||
</p>
|
||||
{r.proposed_description ? (
|
||||
<p style={{ margin: '0.5rem 0', fontSize: '0.9rem', whiteSpace: 'pre-wrap' }}>
|
||||
{r.proposed_description}
|
||||
</p>
|
||||
) : null}
|
||||
{r.message ? (
|
||||
<p
|
||||
style={{
|
||||
margin: '0.5rem 0 0',
|
||||
fontSize: '0.875rem',
|
||||
color: 'var(--text2)',
|
||||
fontStyle: 'italic',
|
||||
}}
|
||||
>
|
||||
Nachricht: {r.message}
|
||||
</p>
|
||||
) : null}
|
||||
<div style={{ display: 'flex', gap: '0.5rem', marginTop: '0.85rem', flexWrap: 'wrap' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
disabled={busyId === r.id}
|
||||
onClick={() => handleApprove(r.id)}
|
||||
>
|
||||
{busyId === r.id ? '…' : 'Freigeben'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={busyId === r.id}
|
||||
onClick={() => handleReject(r.id)}
|
||||
>
|
||||
Ablehnen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -13,6 +13,14 @@ const joinStatusLabel = (s) =>
|
||||
withdrawn: 'zurückgezogen',
|
||||
})[s] || s
|
||||
|
||||
const creationStatusLabel = (s) =>
|
||||
({
|
||||
pending: 'ausstehend',
|
||||
approved: 'freigegeben',
|
||||
rejected: 'abgelehnt',
|
||||
withdrawn: 'zurückgezogen',
|
||||
})[s] || s
|
||||
|
||||
/**
|
||||
* Onboarding für Nutzer ohne aktive Vereinsmitgliedschaft (Phase A).
|
||||
*/
|
||||
@@ -23,6 +31,12 @@ export default function OnboardingPage() {
|
||||
const [joinClubId, setJoinClubId] = useState('')
|
||||
const [joinMessage, setJoinMessage] = useState('')
|
||||
const [joinBusy, setJoinBusy] = useState(false)
|
||||
const [myCreationRequests, setMyCreationRequests] = useState([])
|
||||
const [createName, setCreateName] = useState('')
|
||||
const [createAbbr, setCreateAbbr] = useState('')
|
||||
const [createDesc, setCreateDesc] = useState('')
|
||||
const [createMessage, setCreateMessage] = useState('')
|
||||
const [createBusy, setCreateBusy] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
const [ok, setOk] = useState('')
|
||||
|
||||
@@ -34,9 +48,15 @@ export default function OnboardingPage() {
|
||||
api.getMyClubJoinRequests().then(setMyJoinRequests).catch(() => {})
|
||||
}
|
||||
|
||||
const refreshCreationRequests = () => {
|
||||
if (!emailOk) return
|
||||
api.getMyClubCreationRequests().then(setMyCreationRequests).catch(() => {})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
api.listPublicClubsDirectory().then(setPublicClubs).catch(() => {})
|
||||
refreshJoinRequests()
|
||||
refreshCreationRequests()
|
||||
}, [user?.id, emailOk])
|
||||
|
||||
const memberClubIds = new Set((user?.clubs || []).map((c) => c.id))
|
||||
@@ -47,6 +67,40 @@ export default function OnboardingPage() {
|
||||
(c) => !memberClubIds.has(c.id) && !pendingClubIds.has(c.id)
|
||||
)
|
||||
|
||||
const hasPendingCreation = myCreationRequests.some((r) => r.status === 'pending')
|
||||
|
||||
const handleCreateClub = async (e) => {
|
||||
e.preventDefault()
|
||||
setError('')
|
||||
setOk('')
|
||||
const name = (createName || '').trim()
|
||||
if (!name) {
|
||||
setError('Bitte einen Vereinsnamen angeben.')
|
||||
return
|
||||
}
|
||||
setCreateBusy(true)
|
||||
try {
|
||||
await api.createClubCreationRequest({
|
||||
proposed_name: name,
|
||||
proposed_abbreviation: (createAbbr || '').trim() || undefined,
|
||||
proposed_description: (createDesc || '').trim() || undefined,
|
||||
message: (createMessage || '').trim() || undefined,
|
||||
})
|
||||
setCreateName('')
|
||||
setCreateAbbr('')
|
||||
setCreateDesc('')
|
||||
setCreateMessage('')
|
||||
refreshCreationRequests()
|
||||
setOk(
|
||||
'Gründungsantrag gesendet. Nach Freigabe durch den Plattform-Administrator wird dein Verein angelegt.'
|
||||
)
|
||||
} catch (err) {
|
||||
setError(err.message || 'Antrag fehlgeschlagen.')
|
||||
} finally {
|
||||
setCreateBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleJoin = async (e) => {
|
||||
e.preventDefault()
|
||||
setError('')
|
||||
@@ -191,11 +245,126 @@ export default function OnboardingPage() {
|
||||
|
||||
<div className="card">
|
||||
<h2 style={{ margin: '0 0 0.75rem', fontSize: '1.1rem' }}>Neuen Verein gründen</h2>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.875rem', margin: 0, lineHeight: 1.5 }}>
|
||||
Die Beantragung einer neuen Vereinsgründung wird als Nächstes freigeschaltet (Freigabe durch
|
||||
den Plattform-Administrator). Bis dahin wende dich an{' '}
|
||||
<a href="mailto:support@jinkendo.de">support@jinkendo.de</a> oder tritt einem bestehenden Verein bei.
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.875rem', marginBottom: '1rem', lineHeight: 1.5 }}>
|
||||
Stelle einen Antrag auf Vereinsgründung. Nach Freigabe durch den Plattform-Administrator
|
||||
wird der Verein mit Free-Abo angelegt und du wirst Hauptverwalter.
|
||||
</p>
|
||||
|
||||
{myCreationRequests.length > 0 ? (
|
||||
<div style={{ marginBottom: '1rem' }}>
|
||||
<strong style={{ fontSize: '0.9rem' }}>Meine Gründungsanträge</strong>
|
||||
<ul
|
||||
style={{
|
||||
margin: '0.5rem 0 0',
|
||||
paddingLeft: '1.25rem',
|
||||
color: 'var(--text2)',
|
||||
fontSize: '0.9rem',
|
||||
}}
|
||||
>
|
||||
{myCreationRequests.map((r) => (
|
||||
<li key={r.id} style={{ marginBottom: '0.35rem' }}>
|
||||
{r.proposed_name} — {creationStatusLabel(r.status)}
|
||||
{r.status === 'approved' && r.created_club_name
|
||||
? ` (${r.created_club_name})`
|
||||
: null}
|
||||
{r.status === 'pending' ? (
|
||||
<>
|
||||
{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '0.75rem', padding: '0.15rem 0.45rem' }}
|
||||
onClick={async () => {
|
||||
if (!confirm('Antrag wirklich zurückziehen?')) return
|
||||
try {
|
||||
await api.withdrawClubCreationRequest(r.id)
|
||||
refreshCreationRequests()
|
||||
} catch (err) {
|
||||
setError(err.message || 'Zurückziehen fehlgeschlagen.')
|
||||
}
|
||||
}}
|
||||
>
|
||||
zurückziehen
|
||||
</button>
|
||||
</>
|
||||
) : null}
|
||||
{r.status === 'approved' ? (
|
||||
<>
|
||||
{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
style={{ fontSize: '0.75rem', padding: '0.15rem 0.45rem' }}
|
||||
onClick={() => checkAuth()}
|
||||
>
|
||||
App aktualisieren
|
||||
</button>
|
||||
</>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{hasPendingCreation ? (
|
||||
<p style={{ margin: 0, color: 'var(--text2)', fontSize: '0.875rem' }}>
|
||||
Du hast bereits einen offenen Gründungsantrag. Bitte warte auf die Freigabe oder ziehe
|
||||
den Antrag zurück.
|
||||
</p>
|
||||
) : (
|
||||
<form onSubmit={handleCreateClub}>
|
||||
<label className="form-label" htmlFor="onb-create-name">
|
||||
Vereinsname
|
||||
</label>
|
||||
<input
|
||||
id="onb-create-name"
|
||||
className="form-input"
|
||||
value={createName}
|
||||
onChange={(e) => setCreateName(e.target.value)}
|
||||
maxLength={200}
|
||||
required
|
||||
/>
|
||||
<label className="form-label" htmlFor="onb-create-abbr" style={{ marginTop: '0.75rem' }}>
|
||||
Kürzel (optional)
|
||||
</label>
|
||||
<input
|
||||
id="onb-create-abbr"
|
||||
className="form-input"
|
||||
value={createAbbr}
|
||||
onChange={(e) => setCreateAbbr(e.target.value)}
|
||||
maxLength={50}
|
||||
/>
|
||||
<label className="form-label" htmlFor="onb-create-desc" style={{ marginTop: '0.75rem' }}>
|
||||
Beschreibung (optional)
|
||||
</label>
|
||||
<textarea
|
||||
id="onb-create-desc"
|
||||
className="form-input"
|
||||
rows={2}
|
||||
value={createDesc}
|
||||
onChange={(e) => setCreateDesc(e.target.value)}
|
||||
/>
|
||||
<label className="form-label" htmlFor="onb-create-msg" style={{ marginTop: '0.75rem' }}>
|
||||
Nachricht an den Administrator (optional)
|
||||
</label>
|
||||
<textarea
|
||||
id="onb-create-msg"
|
||||
className="form-input"
|
||||
rows={2}
|
||||
value={createMessage}
|
||||
onChange={(e) => setCreateMessage(e.target.value)}
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-primary"
|
||||
disabled={createBusy}
|
||||
style={{ marginTop: '0.85rem' }}
|
||||
>
|
||||
{createBusy ? 'Senden…' : 'Gründung beantragen'}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -232,6 +232,35 @@ export async function withdrawClubJoinRequest(requestId) {
|
||||
return request(`/api/me/club-join-requests/${requestId}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
/** Eigene Anträge auf Vereinsgründung. */
|
||||
export async function getMyClubCreationRequests() {
|
||||
return request('/api/me/club-creation-requests')
|
||||
}
|
||||
|
||||
export async function createClubCreationRequest(payload) {
|
||||
return request('/api/me/club-creation-requests', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function withdrawClubCreationRequest(requestId) {
|
||||
return request(`/api/me/club-creation-requests/${requestId}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
/** Offene Gründungsanträge — Plattform-Admin. */
|
||||
export async function listAdminClubCreationRequests() {
|
||||
return request('/api/admin/club-creation-requests')
|
||||
}
|
||||
|
||||
export async function approveClubCreationRequest(requestId) {
|
||||
return request(`/api/admin/club-creation-requests/${requestId}/approve`, { method: 'POST' })
|
||||
}
|
||||
|
||||
export async function rejectClubCreationRequest(requestId) {
|
||||
return request(`/api/admin/club-creation-requests/${requestId}/reject`, { method: 'POST' })
|
||||
}
|
||||
|
||||
/** Offene Anträge (Vereins-/Plattform-Admin). */
|
||||
export async function listClubJoinRequests(clubId) {
|
||||
return request(`/api/clubs/${clubId}/join-requests`)
|
||||
@@ -889,6 +918,12 @@ export const api = {
|
||||
getMyClubJoinRequests,
|
||||
createClubJoinRequest,
|
||||
withdrawClubJoinRequest,
|
||||
getMyClubCreationRequests,
|
||||
createClubCreationRequest,
|
||||
withdrawClubCreationRequest,
|
||||
listAdminClubCreationRequests,
|
||||
approveClubCreationRequest,
|
||||
rejectClubCreationRequest,
|
||||
listClubJoinRequests,
|
||||
acceptClubJoinRequest,
|
||||
rejectClubJoinRequest,
|
||||
|
||||
Reference in new issue
Block a user