From 620d251c5e176bb06dcb0f17da04febe1b0282e5 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 24 Apr 2026 17:28:24 +0000 Subject: [PATCH] Allow competition admins to edit props from the competition prop page The prop update server action already permits competition admins via RLS, but the competition prop view only rendered the edit dialog for system admins and never exposed a button to open it. Add a visible Edit button in the prop header and broaden the isAdmin check to include users with the "admin" role in the competition. --- .../props/[propId]/competition-prop-view.tsx | 13 ++++++++- .../[competitionId]/props/[propId]/page.tsx | 29 +++++++++---------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/competitions/[competitionId]/props/[propId]/competition-prop-view.tsx b/app/competitions/[competitionId]/props/[propId]/competition-prop-view.tsx index 1dd1dde..1e27598 100644 --- a/app/competitions/[competitionId]/props/[propId]/competition-prop-view.tsx +++ b/app/competitions/[competitionId]/props/[propId]/competition-prop-view.tsx @@ -3,7 +3,7 @@ import { useState, useRef } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; -import { ChevronRight, Calendar, CalendarClock, Lock } from "lucide-react"; +import { ChevronRight, Calendar, CalendarClock, Lock, Pencil } from "lucide-react"; import { PropWithUserForecast } from "@/types/db_types"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; @@ -253,6 +253,17 @@ export function CompetitionPropView({

)} + {isAdmin && ( + + )} {/* Deadline info */} diff --git a/app/competitions/[competitionId]/props/[propId]/page.tsx b/app/competitions/[competitionId]/props/[propId]/page.tsx index 1907a4b..ea9d6f9 100644 --- a/app/competitions/[competitionId]/props/[propId]/page.tsx +++ b/app/competitions/[competitionId]/props/[propId]/page.tsx @@ -58,21 +58,20 @@ async function CompetitionPropPageContent({ } const competition = competitionResult.data; - // For private competitions, verify membership - if (competition.is_private) { - const roleResult = await getCurrentUserRole(competitionId); - if (!roleResult.success) { - return ; - } + const roleResult = await getCurrentUserRole(competitionId); + if (!roleResult.success) { + return ; + } + const userRole = roleResult.data; - if (roleResult.data === null) { - return ( - - ); - } + // For private competitions, verify membership + if (competition.is_private && userRole === null) { + return ( + + ); } // Get the prop with user's forecast @@ -102,7 +101,7 @@ async function CompetitionPropPageContent({ competitionId={competitionId} competitionName={competition.name} isForecastingOpen={isForecastingOpen} - isAdmin={user.is_admin} + isAdmin={user.is_admin || userRole === "admin"} /> ); }