UNPKG

@replyke/core

Version:

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

31 lines 1.11 kB
import { useCallback } from "react"; import useAxiosPrivate from "../../config/useAxiosPrivate"; import useProject from "../projects/useProject"; import useEntity from "./useEntity"; function useUpdateEntity() { const axios = useAxiosPrivate(); const { projectId } = useProject(); const { setEntity } = useEntity(); const updateEntity = useCallback(async (props) => { const { entityId, update } = props; const { title, content, attachments, keywords, location, metadata, mentions, } = update; if (!projectId) { throw new Error("No projectId available."); } const response = await axios.patch(`/${projectId}/entities/${entityId}`, { title, content, attachments, keywords, location, metadata, mentions, }); const updatedEntity = response.data; setEntity?.(updatedEntity); return updatedEntity; }, [projectId, axios]); return updateEntity; } export default useUpdateEntity; //# sourceMappingURL=useUpdateEntity.js.map