import { useCreateReport } from "@replyke/react-js";
function CommentReportButton({ commentId }: { commentId: string }) {
const createCommentReport = useCreateReport({ type: "comment" });
const handleReport = async () => {
try {
await createCommentReport({
targetId: commentId,
reason: "spam",
details: "This comment contains spam links."
});
console.log("Comment report created successfully.");
} catch (error) {
console.error("Failed to create report:", error.message);
}
};
return <button onClick={handleReport}>Report Comment</button>;
}
function EntityReportButton({ entityId }: { entityId: string }) {
const createEntityReport = useCreateReport({ type: "entity" });
const handleReport = async () => {
try {
await createEntityReport({
targetId: entityId,
reason: "harassment",
details: "This entity contains inappropriate content."
});
console.log("Entity report created successfully.");
} catch (error) {
console.error("Failed to create report:", error.message);
}
};
return <button onClick={handleReport}>Report Entity</button>;
}