UNPKG

@replyke/core

Version:

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

39 lines 1.53 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 moderate a comment within a space (approve or remove). * Requires space moderator permissions. * * @example * const moderateSpaceComment = useModerateSpaceComment(); * * await moderateSpaceComment({ * spaceId: "space-uuid", * commentId: "comment-uuid", * action: "remove", * reason: "Spam content" * }); */ function useModerateSpaceComment() { const { projectId } = (0, useProject_1.default)(); const axios = (0, useAxiosPrivate_1.default)(); const moderateSpaceComment = (0, react_1.useCallback)(async ({ spaceId, commentId, action, reason, }) => { if (!projectId) { throw new Error("No projectId available."); } if (!spaceId || !commentId) { throw new Error("spaceId and commentId are required."); } const response = await axios.patch(`/${projectId}/spaces/${spaceId}/comments/${commentId}/moderation`, { action, reason }); return response.data; }, [projectId, axios]); return moderateSpaceComment; } exports.default = useModerateSpaceComment; //# sourceMappingURL=useModerateSpaceComment.js.map