({
commentId,
contentId,
}: {
commentId: number;
contentId: number;
})
| 8 | import { toast } from 'sonner'; |
| 9 | |
| 10 | const 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 | |
| 47 | export default CommentPinForm; |
nothing calls this directly
no test coverage detected