UNPKG

@replyke/core

Version:

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

26 lines 919 B
import { useCallback } from "react"; import useProject from "../../projects/useProject"; import useAxiosPrivate from "../../../config/useAxiosPrivate"; function useCreateRule() { const { projectId } = useProject(); const axios = useAxiosPrivate(); const createRule = useCallback(async ({ spaceId, title, description }) => { if (!projectId) { throw new Error("No projectId available."); } if (!spaceId) { throw new Error("Please pass a spaceId"); } if (!title) { throw new Error("Rule title is required"); } const response = await axios.post(`/${projectId}/spaces/${spaceId}/rules`, { title, description: description || null, }); return response.data; }, [projectId, axios]); return createRule; } export default useCreateRule; //# sourceMappingURL=useCreateRule.js.map