MCPcopy Create free account
hub / github.com/code100x/cms / CommentDeleteForm

Function CommentDeleteForm

src/components/comment/CommentDeleteForm.tsx:10–41  ·  view source on GitHub ↗
({ commentId }: { commentId: number })

Source from the content-addressed store, hash-verified

8import { toast } from 'sonner';
9
10const 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
43export default CommentDeleteForm;

Callers

nothing calls this directly

Calls 1

useActionFunction · 0.90

Tested by

no test coverage detected