UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

46 lines 1.76 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = require("react"); const useProject_1 = __importDefault(require("../projects/useProject")); const useAxiosPrivate_1 = __importDefault(require("../../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 } = (0, useProject_1.default)(); const axios = (0, useAxiosPrivate_1.default)(); const handleSpaceCommentReport = (0, react_1.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; } exports.default = useHandleSpaceCommentReport; //# sourceMappingURL=useHandleSpaceCommentReport.js.map