@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
40 lines • 1.42 kB
JavaScript
import { useCallback } from "react";
import useProject from "../projects/useProject";
import useAxiosPrivate from "../../config/useAxiosPrivate";
/**
* Hook to fetch reports for spaces the user can moderate
*
* If spaceId is provided, returns reports for that specific space
* If spaceId is omitted, returns reports from ALL spaces the user moderates
*
* @example
* const fetchModeratedReports = useFetchModeratedReports();
*
* // Fetch reports for a specific space
* const reports = await fetchModeratedReports({
* spaceId: "space-uuid",
* targetType: "entity",
* page: 1,
* limit: 20
* });
*
* // Fetch reports from ALL spaces the user moderates
* const allReports = await fetchModeratedReports({
* page: 1,
* limit: 20
* });
*/
function useFetchModeratedReports() {
const { projectId } = useProject();
const axios = useAxiosPrivate();
const fetchModeratedReports = useCallback(async ({ spaceId, targetType, status, sortBy, page, limit, }) => {
if (!projectId) {
throw new Error("No projectId available.");
}
const response = await axios.get(`/${projectId}/reports/moderated`, { params: { spaceId, targetType, status, sortBy, page, limit } });
return response.data;
}, [projectId, axios]);
return fetchModeratedReports;
}
export default useFetchModeratedReports;
//# sourceMappingURL=useFetchModeratedReports.js.map