DeleteTaskDialog.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import React from "react"
  2. import {
  3. AlertDialog,
  4. AlertDialogAction,
  5. AlertDialogCancel,
  6. AlertDialogContent,
  7. AlertDialogDescription,
  8. AlertDialogFooter,
  9. AlertDialogHeader,
  10. AlertDialogTitle,
  11. } from "@/components/ui/alert-dialog"
  12. import { Button } from "@/components/ui"
  13. import { vscode } from "@/utils/vscode"
  14. interface DeleteTaskDialogProps {
  15. taskId: string
  16. open: boolean
  17. onOpenChange: (open: boolean) => void
  18. }
  19. export const DeleteTaskDialog = ({ taskId, open, onOpenChange }: DeleteTaskDialogProps) => {
  20. const handleDelete = () => {
  21. vscode.postMessage({ type: "deleteTaskWithId", text: taskId })
  22. onOpenChange(false)
  23. }
  24. return (
  25. <AlertDialog open={open} onOpenChange={onOpenChange}>
  26. <AlertDialogContent>
  27. <AlertDialogHeader>
  28. <AlertDialogTitle>Delete Task</AlertDialogTitle>
  29. <AlertDialogDescription>
  30. Are you sure you want to delete this task? This action cannot be undone.
  31. </AlertDialogDescription>
  32. </AlertDialogHeader>
  33. <AlertDialogFooter>
  34. <AlertDialogCancel asChild>
  35. <Button variant="secondary">Cancel</Button>
  36. </AlertDialogCancel>
  37. <AlertDialogAction asChild>
  38. <Button variant="destructive" onClick={handleDelete}>
  39. Delete
  40. </Button>
  41. </AlertDialogAction>
  42. </AlertDialogFooter>
  43. </AlertDialogContent>
  44. </AlertDialog>
  45. )
  46. }