@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
41 lines • 1.45 kB
JavaScript
import { useCallback } from "react";
import useProject from "../projects/useProject";
import useAxiosPrivate from "../../config/useAxiosPrivate";
/**
* Hook to handle comment reports at the space level
* Space moderators can: remove comment, ban user from space, dismiss
*
* @example
* const handleSpaceCommentReport = useHandleSpaceCommentReport();
*
* await handleSpaceCommentReport({
* spaceId: "space-uuid",
* reportId: "report-uuid",
* commentId: "comment-uuid",
* actions: ["remove-comment"],
* summary: "Removed inappropriate comment"
* });
*/
function useHandleSpaceCommentReport() {
const { projectId } = useProject();
const axios = useAxiosPrivate();
const handleSpaceCommentReport = useCallback(async ({ spaceId, reportId, commentId, actions, summary, userId, reason, }) => {
if (!projectId) {
throw new Error("No projectId available.");
}
if (!spaceId || !reportId) {
throw new Error("spaceId and reportId are required");
}
const response = await axios.patch(`/${projectId}/spaces/${spaceId}/reports/comment/${reportId}`, {
commentId,
actions,
summary,
userId,
reason,
});
return response.data;
}, [projectId, axios]);
return handleSpaceCommentReport;
}
export default useHandleSpaceCommentReport;
//# sourceMappingURL=useHandleSpaceCommentReport.js.map