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

Function CommentPinForm

src/components/comment/CommentPinForm.tsx:10–45  ·  view source on GitHub ↗
({
  commentId,
  contentId,
}: {
  commentId: number;
  contentId: number;
})

Source from the content-addressed store, hash-verified

8import { toast } from 'sonner';
9
10const CommentPinForm = ({
11 commentId,
12 contentId,
13}: {
14 commentId: number;
15 contentId: number;
16}) => {
17 const currentPath = usePathname();
18
19 const { execute, isLoading } = useAction(pinComment, {
20 onSuccess: () => {
21 toast('Comment Pinned');
22 },
23 onError: (error) => {
24 toast.error(error);
25 },
26 });
27 const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
28 e.preventDefault();
29
30 execute({
31 commentId,
32 contentId,
33 currentPath,
34 });
35 };
36 return (
37 <form className="w-full" onSubmit={handleFormSubmit}>
38 <button className="w-full" type="submit" disabled={isLoading}>
39 <div className="flex items-center gap-1">
40 Pin <PinIcon className="h-4 w-4" />
41 </div>
42 </button>
43 </form>
44 );
45};
46
47export default CommentPinForm;

Callers

nothing calls this directly

Calls 1

useActionFunction · 0.90

Tested by

no test coverage detected