@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
45 lines • 1.72 kB
JavaScript
;
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 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 } = (0, useProject_1.default)();
const axios = (0, useAxiosPrivate_1.default)();
const fetchModeratedReports = (0, react_1.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;
}
exports.default = useFetchModeratedReports;
//# sourceMappingURL=useFetchModeratedReports.js.map