|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import Link from "next/link"; |
| 4 | +import { usePathname } from "next/navigation"; |
| 5 | +import { cn } from "@/lib/utils"; |
| 6 | +import { |
| 7 | + Settings, |
| 8 | + Users, |
| 9 | + FileText, |
| 10 | + Trophy, |
| 11 | + Wallet, |
| 12 | + AlertTriangle, |
| 13 | + CheckCircle, |
| 14 | + BarChart3, |
| 15 | +} from "lucide-react"; |
| 16 | + |
| 17 | +interface BountyManageNavProps { |
| 18 | + bountyId: string; |
| 19 | + bountyStatus: "draft" | "active" | "submissions" | "judging" | "payout" | "completed" | "cancelled"; |
| 20 | + hasDisputes?: boolean; |
| 21 | + pendingPayouts?: number; |
| 22 | +} |
| 23 | + |
| 24 | +export function BountyManageNav({ |
| 25 | + bountyId, |
| 26 | + bountyStatus, |
| 27 | + hasDisputes = false, |
| 28 | + pendingPayouts = 0, |
| 29 | +}: BountyManageNavProps) { |
| 30 | + const pathname = usePathname(); |
| 31 | + const baseUrl = `/me/bounties/${bountyId}/manage`; |
| 32 | + |
| 33 | + const navItems = [ |
| 34 | + { |
| 35 | + label: "Overview", |
| 36 | + href: baseUrl, |
| 37 | + icon: BarChart3, |
| 38 | + enabled: true, |
| 39 | + }, |
| 40 | + { |
| 41 | + label: "Configure", |
| 42 | + href: `${baseUrl}/configure`, |
| 43 | + icon: Settings, |
| 44 | + enabled: ["draft", "active"].includes(bountyStatus), |
| 45 | + }, |
| 46 | + { |
| 47 | + label: "Applications", |
| 48 | + href: `${baseUrl}/applications`, |
| 49 | + icon: Users, |
| 50 | + enabled: true, |
| 51 | + badge: bountyStatus === "active" ? "Review" : undefined, |
| 52 | + }, |
| 53 | + { |
| 54 | + label: "Submissions", |
| 55 | + href: `${baseUrl}/submissions`, |
| 56 | + icon: FileText, |
| 57 | + enabled: ["submissions", "judging", "payout", "completed"].includes(bountyStatus), |
| 58 | + }, |
| 59 | + { |
| 60 | + label: "Select Winners", |
| 61 | + href: `${baseUrl}/winners`, |
| 62 | + icon: Trophy, |
| 63 | + enabled: ["judging", "payout"].includes(bountyStatus), |
| 64 | + highlight: bountyStatus === "judging", |
| 65 | + }, |
| 66 | + { |
| 67 | + label: "Payout", |
| 68 | + href: `${baseUrl}/payout`, |
| 69 | + icon: Wallet, |
| 70 | + enabled: ["payout", "completed"].includes(bountyStatus), |
| 71 | + badge: pendingPayouts > 0 ? `${pendingPayouts} pending` : undefined, |
| 72 | + }, |
| 73 | + { |
| 74 | + label: "Disputes", |
| 75 | + href: `${baseUrl}/disputes`, |
| 76 | + icon: AlertTriangle, |
| 77 | + enabled: true, |
| 78 | + badge: hasDisputes ? "Action needed" : undefined, |
| 79 | + badgeVariant: hasDisputes ? "destructive" : "default", |
| 80 | + }, |
| 81 | + { |
| 82 | + label: "Results", |
| 83 | + href: `${baseUrl}/results`, |
| 84 | + icon: CheckCircle, |
| 85 | + enabled: bountyStatus === "completed", |
| 86 | + }, |
| 87 | + ]; |
| 88 | + |
| 89 | + return ( |
| 90 | + <nav className="flex flex-col space-y-1"> |
| 91 | + {navItems.map((item) => { |
| 92 | + const isActive = pathname === item.href; |
| 93 | + const Icon = item.icon; |
| 94 | + |
| 95 | + if (!item.enabled) { |
| 96 | + return ( |
| 97 | + <div |
| 98 | + key={item.href} |
| 99 | + className="flex items-center gap-3 px-3 py-2 text-sm text-muted-foreground/50 cursor-not-allowed" |
| 100 | + > |
| 101 | + <Icon className="h-4 w-4" /> |
| 102 | + <span>{item.label}</span> |
| 103 | + </div> |
| 104 | + ); |
| 105 | + } |
| 106 | + |
| 107 | + return ( |
| 108 | + <Link |
| 109 | + key={item.href} |
| 110 | + href={item.href} |
| 111 | + className={cn( |
| 112 | + "flex items-center justify-between gap-3 px-3 py-2 text-sm rounded-md transition-colors", |
| 113 | + isActive |
| 114 | + ? "bg-primary text-primary-foreground" |
| 115 | + : "text-muted-foreground hover:bg-muted hover:text-foreground", |
| 116 | + item.highlight && !isActive && "border-l-2 border-yellow-500" |
| 117 | + )} |
| 118 | + > |
| 119 | + <div className="flex items-center gap-3"> |
| 120 | + <Icon className="h-4 w-4" /> |
| 121 | + <span>{item.label}</span> |
| 122 | + </div> |
| 123 | + {item.badge && ( |
| 124 | + <span |
| 125 | + className={cn( |
| 126 | + "text-xs px-2 py-0.5 rounded-full", |
| 127 | + item.badgeVariant === "destructive" |
| 128 | + ? "bg-destructive text-destructive-foreground" |
| 129 | + : "bg-muted-foreground/20" |
| 130 | + )} |
| 131 | + > |
| 132 | + {item.badge} |
| 133 | + </span> |
| 134 | + )} |
| 135 | + </Link> |
| 136 | + ); |
| 137 | + })} |
| 138 | + </nav> |
| 139 | + ); |
| 140 | +} |
| 141 | + |
| 142 | +// Management CTA button for the bounty list |
| 143 | +export function ManageBountyCTA({ bountyId }: { bountyId: string }) { |
| 144 | + return ( |
| 145 | + <Link |
| 146 | + href={`/me/bounties/${bountyId}/manage`} |
| 147 | + className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors" |
| 148 | + > |
| 149 | + <Settings className="h-4 w-4" /> |
| 150 | + Manage |
| 151 | + </Link> |
| 152 | + ); |
| 153 | +} |
| 154 | + |
| 155 | +export default BountyManageNav; |
0 commit comments