@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
27 lines • 968 B
JavaScript
import { useCallback } from "react";
import useAxiosPrivate from "../../config/useAxiosPrivate";
import useProject from "../projects/useProject";
import { useUser } from "../user";
function useIsEntitySaved() {
const axios = useAxiosPrivate();
const { projectId } = useProject();
const { user } = useUser();
const checkIfEntityIsSaved = useCallback(async ({ entityId }) => {
if (!user) {
throw new Error("No user authenticated.");
}
if (!entityId) {
throw new Error("No entity ID passed.");
}
if (!projectId) {
throw new Error("No projectId available.");
}
const response = await axios.get(`/${projectId}/entities/is-entity-saved`, {
params: { entityId },
});
return response.data;
}, [user, axios, projectId]);
return { checkIfEntityIsSaved };
}
export default useIsEntitySaved;
//# sourceMappingURL=useIsEntitySaved.js.map