@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
29 lines • 1.09 kB
JavaScript
import { useCallback } from "react";
import useAxiosPrivate from "../../../config/useAxiosPrivate";
import useProject from "../../projects/useProject";
import { useUser } from "../../user";
function useRemoveConnectionByUserId() {
const axios = useAxiosPrivate();
const { projectId } = useProject();
const { user } = useUser();
const removeConnectionByUserId = useCallback(async (props) => {
const { userId } = props;
if (!projectId) {
throw new Error("No project specified");
}
if (!user) {
throw new Error("No user is logged in");
}
if (!userId) {
throw new Error("No user ID was provided");
}
if (userId === user.id) {
throw new Error("Cannot disconnect from yourself");
}
const response = await axios.delete(`/users/${userId}/connection`);
return response.data;
}, [axios, projectId, user]);
return removeConnectionByUserId;
}
export default useRemoveConnectionByUserId;
//# sourceMappingURL=useRemoveConnectionByUserId.js.map