'use client' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Button } from '@/components/ui/button' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select' import { Textarea } from '@/components/ui/textarea' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog' import { Plus, Trash2, Trophy } from 'lucide-react' import { defaultAwardTrack } from '@/lib/pipeline-defaults' import type { WizardTrackConfig } from '@/types/pipeline-wizard' import type { RoutingMode, DecisionMode, AwardScoringMode } from '@prisma/client' type AwardsSectionProps = { tracks: WizardTrackConfig[] onChange: (tracks: WizardTrackConfig[]) => void isActive?: boolean } function slugify(name: string): string { return name .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/^-|-$/g, '') } export function AwardsSection({ tracks, onChange, isActive }: AwardsSectionProps) { const awardTracks = tracks.filter((t) => t.kind === 'AWARD') const nonAwardTracks = tracks.filter((t) => t.kind !== 'AWARD') const addAward = () => { const newTrack = defaultAwardTrack(awardTracks.length) newTrack.sortOrder = tracks.length onChange([...tracks, newTrack]) } const updateAward = (index: number, updates: Partial) => { const updated = [...tracks] const awardIndex = tracks.findIndex( (t) => t.kind === 'AWARD' && awardTracks.indexOf(t) === index ) if (awardIndex >= 0) { updated[awardIndex] = { ...updated[awardIndex], ...updates } onChange(updated) } } const removeAward = (index: number) => { const toRemove = awardTracks[index] onChange(tracks.filter((t) => t !== toRemove)) } return (

Configure special award tracks that run alongside the main competition.

{awardTracks.length === 0 && (
No award tracks configured. Awards are optional.
)} {awardTracks.map((track, index) => (
Award Track {index + 1} Remove Award Track? This will remove the "{track.name}" award track and all its stages. This action cannot be undone. Cancel removeAward(index)}> Remove
{ const name = e.target.value updateAward(index, { name, slug: slugify(name), awardConfig: { ...track.awardConfig, name, }, }) }} />