({ commentId }: { commentId: number })
| 8 | import { toast } from 'sonner'; |
| 9 | |
| 10 | const CommentDeleteForm = ({ commentId }: { commentId: number }) => { |
| 11 | const currentPath = usePathname(); |
| 12 | |
| 13 | const { execute, isLoading } = useAction(deleteMessage, { |
| 14 | onSuccess: () => { |
| 15 | toast('Comment deleted'); |
| 16 | }, |
| 17 | onError: (error) => { |
| 18 | toast.error(error); |
| 19 | }, |
| 20 | }); |
| 21 | const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => { |
| 22 | e.preventDefault(); |
| 23 | |
| 24 | execute({ |
| 25 | commentId, |
| 26 | currentPath, |
| 27 | }); |
| 28 | }; |
| 29 | return ( |
| 30 | <form className="w-full" onSubmit={handleFormSubmit}> |
| 31 | <button |
| 32 | className="flex w-full items-center gap-2" |
| 33 | type="submit" |
| 34 | disabled={isLoading} |
| 35 | > |
| 36 | <Trash2Icon className="size-4" /> |
| 37 | Delete |
| 38 | </button> |
| 39 | </form> |
| 40 | ); |
| 41 | }; |
| 42 | |
| 43 | export default CommentDeleteForm; |
nothing calls this directly
no test coverage detected