@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
22 lines • 877 B
JavaScript
import { useCallback } from "react";
import useAxiosPrivate from "../../config/useAxiosPrivate";
import useProject from "../projects/useProject";
import { handleError } from "../../utils/handleError";
function useReportMessage() {
const { projectId } = useProject();
const axios = useAxiosPrivate();
const report = useCallback(async ({ conversationId, messageId, reason, details, }) => {
if (!projectId)
throw new Error("No projectId available.");
try {
await axios.post(`/${projectId}/chat/conversations/${conversationId}/messages/${messageId}/report`, { reason, details });
}
catch (err) {
handleError(err, "Failed to report message");
throw err;
}
}, [projectId, axios]);
return report;
}
export default useReportMessage;
//# sourceMappingURL=useReportMessage.js.map