@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
25 lines • 981 B
JavaScript
import { useCallback } from "react";
import useAxiosPrivate from "../../config/useAxiosPrivate";
import useProject from "../projects/useProject";
function useRemoveReaction() {
const axios = useAxiosPrivate();
const { projectId } = useProject();
const removeReaction = useCallback(async (props) => {
const { targetType, targetId } = props;
if (!targetId) {
throw new Error("No target ID provided");
}
if (!projectId) {
throw new Error("No project specified");
}
// Determine endpoint based on targetType
const endpoint = targetType === "entity"
? `/${projectId}/entities/${targetId}/reactions`
: `/${projectId}/comments/${targetId}/reactions`;
const response = await axios.delete(endpoint);
return response.data;
}, [axios, projectId]);
return removeReaction;
}
export default useRemoveReaction;
//# sourceMappingURL=useRemoveReaction.js.map