Add delete button for draft rounds with confirmation dialog
Build and Push Docker Image / build (push) Successful in 8m26s
Details
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:
parent
46694154dc
commit
86d38ba743
|
|
@ -16,6 +16,17 @@ import { Badge } from '@/components/ui/badge'
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
import { Progress } from '@/components/ui/progress'
|
import { Progress } from '@/components/ui/progress'
|
||||||
import { Separator } from '@/components/ui/separator'
|
import { Separator } from '@/components/ui/separator'
|
||||||
|
import {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogAction,
|
||||||
|
AlertDialogCancel,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogTitle,
|
||||||
|
AlertDialogTrigger,
|
||||||
|
} from '@/components/ui/alert-dialog'
|
||||||
import {
|
import {
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
Edit,
|
Edit,
|
||||||
|
|
@ -31,7 +42,10 @@ import {
|
||||||
BarChart3,
|
BarChart3,
|
||||||
Upload,
|
Upload,
|
||||||
Filter,
|
Filter,
|
||||||
|
Trash2,
|
||||||
|
Loader2,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
|
import { toast } from 'sonner'
|
||||||
import { format, formatDistanceToNow, isPast, isFuture } from 'date-fns'
|
import { format, formatDistanceToNow, isPast, isFuture } from 'date-fns'
|
||||||
|
|
||||||
interface PageProps {
|
interface PageProps {
|
||||||
|
|
@ -50,6 +64,15 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
|
||||||
utils.round.get.invalidate({ id: roundId })
|
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) {
|
if (isLoading) {
|
||||||
return <RoundDetailSkeleton />
|
return <RoundDetailSkeleton />
|
||||||
|
|
@ -162,6 +185,43 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
|
||||||
Close Round
|
Close Round
|
||||||
</Button>
|
</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 “{round.name}” 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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue