From fd4f4f3db9ecb2183965a0510b0e54d39dedb730 Mon Sep 17 00:00:00 2001 From: Olajcodes Date: Sat, 27 Jun 2026 10:22:51 +0100 Subject: [PATCH 1/3] feat:Replace NEXT_PUBLIC_MOCK_MAINTAINER env flag with useUserRole hook --- components/bounty/bounty-sidebar.tsx | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/components/bounty/bounty-sidebar.tsx b/components/bounty/bounty-sidebar.tsx index 83312078..2b3a3e80 100644 --- a/components/bounty/bounty-sidebar.tsx +++ b/components/bounty/bounty-sidebar.tsx @@ -3,6 +3,7 @@ import { useMemo, useState } from "react"; import { RatingModal } from "../rating/rating-modal"; import { useClaimBounty } from "@/hooks/use-bounty-mutations"; +import { useUserRole } from "@/hooks/use-user-role"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import type { @@ -28,17 +29,8 @@ export function BountySidebar({ bounty }: BountySidebarProps) { const claimBounty = useClaimBounty(); const [loading, setLoading] = useState(false); - // Mock maintainer check for now - in real app this comes from auth context - const IS_MAINTAINER = process.env.NEXT_PUBLIC_MOCK_MAINTAINER === "true"; - - if ( - typeof window !== "undefined" && - process.env.NEXT_PUBLIC_MOCK_MAINTAINER === "true" - ) { - console.warn( - "DEV: Mock maintainer enabled in components/bounty/bounty-sidebar.tsx — do NOT enable in production", - ); - } + const role = useUserRole(); + const isSponsor = role === "sponsor"; const createdTimeAgo = useMemo( () => formatDistanceToNow(new Date(bounty.createdAt), { addSuffix: true }), @@ -90,7 +82,7 @@ export function BountySidebar({ bounty }: BountySidebarProps) { } | null>(null); const handleMarkCompleted = async () => { - if (!IS_MAINTAINER) { + if (!isSponsor) { alert("Only maintainers can mark as completed."); return; } @@ -121,7 +113,7 @@ export function BountySidebar({ bounty }: BountySidebarProps) { alert("You have already rated this contributor."); return; } - if (!IS_MAINTAINER) { + if (!isSponsor) { alert("Only maintainers can rate contributors."); return; } @@ -142,7 +134,7 @@ export function BountySidebar({ bounty }: BountySidebarProps) { }; const renderActionButton = () => { - if (bounty.status === "IN_PROGRESS" && IS_MAINTAINER && !completed) { + if (bounty.status === "IN_PROGRESS" && isSponsor && !completed) { return ( ); -} +} \ No newline at end of file From de5d6ab4e0704e0552b7e5c6f2a58a9a0f929e57 Mon Sep 17 00:00:00 2001 From: Olajcodes Date: Sat, 27 Jun 2026 10:41:02 +0100 Subject: [PATCH 2/3] feat:Implemented CodeRabbit feedback --- components/bounty/bounty-sidebar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/bounty/bounty-sidebar.tsx b/components/bounty/bounty-sidebar.tsx index 2b3a3e80..806883d1 100644 --- a/components/bounty/bounty-sidebar.tsx +++ b/components/bounty/bounty-sidebar.tsx @@ -83,7 +83,7 @@ export function BountySidebar({ bounty }: BountySidebarProps) { const handleMarkCompleted = async () => { if (!isSponsor) { - alert("Only maintainers can mark as completed."); + alert("Only sponsors can mark as completed."); return; } setLoading(true); @@ -114,7 +114,7 @@ export function BountySidebar({ bounty }: BountySidebarProps) { return; } if (!isSponsor) { - alert("Only maintainers can rate contributors."); + alert("Only sponsors can rate contributors."); return; } if (!completed) { From dfd90fd4e884ae08ba0fa83e45b049635fada53b Mon Sep 17 00:00:00 2001 From: Olajcodes Date: Sat, 27 Jun 2026 16:31:10 +0100 Subject: [PATCH 3/3] fix: add trailing newline to bounty-sidebar.tsx --- components/bounty/bounty-sidebar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bounty/bounty-sidebar.tsx b/components/bounty/bounty-sidebar.tsx index 806883d1..28fca510 100644 --- a/components/bounty/bounty-sidebar.tsx +++ b/components/bounty/bounty-sidebar.tsx @@ -251,4 +251,5 @@ export function BountySidebar({ bounty }: BountySidebarProps) { ); -} \ No newline at end of file +} +