@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
29 lines • 1.08 kB
JavaScript
import { useCallback } from "react";
import useAxiosPrivate from "../../../config/useAxiosPrivate";
import useProject from "../../projects/useProject";
import { useUser } from "../../user";
function useFetchConnectionStatus() {
const axios = useAxiosPrivate();
const { projectId } = useProject();
const { user } = useUser();
const getConnectionStatus = 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 check connection status with yourself");
}
const response = await axios.get(`/users/${userId}/connection`);
return response.data;
}, [axios, projectId, user]);
return getConnectionStatus;
}
export default useFetchConnectionStatus;
//# sourceMappingURL=useFetchConnectionStatus.js.map