@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
29 lines • 1.24 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"));
function useFetchUserSpaces() {
const { projectId } = (0, useProject_1.default)();
const axios = (0, useAxiosPrivate_1.default)();
const fetchUserSpaces = (0, react_1.useCallback)(async (params = {}) => {
if (!projectId) {
throw new Error("No projectId available.");
}
const { include, role, ...rest } = params;
const response = await axios.get(`/${projectId}/spaces/user-spaces`, {
params: {
...rest,
include: Array.isArray(include) ? include.join(",") : include,
role: Array.isArray(role) ? role.join(",") : role,
},
});
return response.data;
}, [projectId, axios]);
return fetchUserSpaces;
}
exports.default = useFetchUserSpaces;
//# sourceMappingURL=useFetchUserSpaces.js.map