Add delete button for draft rounds with confirmation dialog
Build and Push Docker Image / build (push) Successful in 8m26s Details

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt 2026-02-02 19:37:54 +01:00
parent 46694154dc
commit 86d38ba743
1 changed files with 60 additions and 0 deletions

View File

@ -16,6 +16,17 @@ import { Badge } from '@/components/ui/badge'
import { Skeleton } from '@/components/ui/skeleton'
import { Progress } from '@/components/ui/progress'
import { Separator } from '@/components/ui/separator'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog'
import {
ArrowLeft,
Edit,
@ -31,7 +42,10 @@ import {
BarChart3,
Upload,
Filter,
Trash2,
Loader2,
} from 'lucide-react'
import { toast } from 'sonner'
import { format, formatDistanceToNow, isPast, isFuture } from 'date-fns'
interface PageProps {
@ -50,6 +64,15 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
utils.round.get.invalidate({ id: roundId })
},
})
const deleteRound = trpc.round.delete.useMutation({
onSuccess: () => {
toast.success('Round deleted')
router.push('/admin/rounds')
},
onError: () => {
toast.error('Failed to delete round')
},
})
if (isLoading) {
return <RoundDetailSkeleton />
@ -162,6 +185,43 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
Close Round
</Button>
)}
{round.status === 'DRAFT' && (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive">
<Trash2 className="mr-2 h-4 w-4" />
Delete
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete Round</AlertDialogTitle>
<AlertDialogDescription>
This will permanently delete &ldquo;{round.name}&rdquo; and all
associated projects, assignments, and evaluations. This action
cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={() => deleteRound.mutate({ id: round.id })}
disabled={deleteRound.isPending}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deleteRound.isPending ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Deleting...
</>
) : (
'Delete Round'
)}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)}
</div>
</div>