feat: add site_admin role, casual match support, and tournament deletion
This commit is contained in:
@@ -2,8 +2,9 @@ import { prisma } from "@/lib/prisma"
|
||||
import Navigation from "@/components/Navigation"
|
||||
import Link from "next/link"
|
||||
import { notFound, redirect } from "next/navigation"
|
||||
import { canManageTournament, hasRole } from "@/lib/permissions"
|
||||
import { canManageTournament, canDeleteTournament } from "@/lib/permissions"
|
||||
import { getTournamentStatus } from "@/lib/tournamentUtils"
|
||||
import { DeleteTournamentButton } from "@/components/DeleteTournamentButton"
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
@@ -20,8 +21,8 @@ export default async function TournamentDetailPage({ params }: PageProps) {
|
||||
redirect("/auth/login")
|
||||
}
|
||||
|
||||
// Check if user can create tournaments (tournament_admin or club_admin)
|
||||
const canCreate = await hasRole('tournament_admin')
|
||||
// Check if user can delete this tournament
|
||||
const deletePermission = await canDeleteTournament(tournamentId)
|
||||
|
||||
let tournament = await prisma.event.findUnique({
|
||||
where: { id: tournamentId },
|
||||
@@ -119,6 +120,8 @@ export default async function TournamentDetailPage({ params }: PageProps) {
|
||||
orderBy: { playedAt: "desc" },
|
||||
})
|
||||
|
||||
const matchCount = matches.length
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50">
|
||||
<Navigation />
|
||||
@@ -173,6 +176,13 @@ export default async function TournamentDetailPage({ params }: PageProps) {
|
||||
>
|
||||
Export CSV
|
||||
</a>
|
||||
{deletePermission.allowed && (
|
||||
<DeleteTournamentButton
|
||||
tournamentId={tournament.id}
|
||||
tournamentName={tournament.name}
|
||||
matchCount={matchCount}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user