fix: remove duplicate tournament variable definitions in admin pages
This commit is contained in:
@@ -2,7 +2,7 @@ import { prisma } from "@/lib/prisma"
|
|||||||
import Navigation from "@/components/Navigation"
|
import Navigation from "@/components/Navigation"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { notFound, redirect } from "next/navigation"
|
import { notFound, redirect } from "next/navigation"
|
||||||
import { getSession } from "@/lib/auth-simple"
|
import { canManageTournament } from "@/lib/permissions"
|
||||||
import EditTournamentForm from "@/components/EditTournamentForm"
|
import EditTournamentForm from "@/components/EditTournamentForm"
|
||||||
|
|
||||||
interface PageProps {
|
interface PageProps {
|
||||||
@@ -12,14 +12,14 @@ interface PageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function EditTournamentPage({ params }: PageProps) {
|
export default async function EditTournamentPage({ params }: PageProps) {
|
||||||
const session = await getSession()
|
const tournamentId = parseInt(params.id)
|
||||||
|
|
||||||
if (!session || session.user?.role !== "club_admin") {
|
// Check if user can manage this tournament
|
||||||
|
const permission = await canManageTournament(tournamentId)
|
||||||
|
if (!permission.allowed) {
|
||||||
redirect("/auth/login")
|
redirect("/auth/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
const tournamentId = parseInt(params.id)
|
|
||||||
|
|
||||||
const tournament = await prisma.event.findUnique({
|
const tournament = await prisma.event.findUnique({
|
||||||
where: { id: tournamentId },
|
where: { id: tournamentId },
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { prisma } from "@/lib/prisma"
|
|||||||
import Navigation from "@/components/Navigation"
|
import Navigation from "@/components/Navigation"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { notFound, redirect } from "next/navigation"
|
import { notFound, redirect } from "next/navigation"
|
||||||
import { getSession } from "@/lib/auth-simple"
|
import { canManageTournament } from "@/lib/permissions"
|
||||||
import MatchEditor from "@/components/MatchEditor"
|
import MatchEditor from "@/components/MatchEditor"
|
||||||
|
|
||||||
interface PageProps {
|
interface PageProps {
|
||||||
@@ -12,14 +12,14 @@ interface PageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function TournamentResultsPage({ params }: PageProps) {
|
export default async function TournamentResultsPage({ params }: PageProps) {
|
||||||
const session = await getSession()
|
const tournamentId = parseInt(params.id)
|
||||||
|
|
||||||
if (!session || session.user?.role !== "club_admin") {
|
// Check if user can manage this tournament
|
||||||
|
const permission = await canManageTournament(tournamentId)
|
||||||
|
if (!permission.allowed) {
|
||||||
redirect("/auth/login")
|
redirect("/auth/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
const tournamentId = parseInt(params.id)
|
|
||||||
|
|
||||||
const tournament = await prisma.event.findUnique({
|
const tournament = await prisma.event.findUnique({
|
||||||
where: { id: tournamentId },
|
where: { id: tournamentId },
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user