import { useMutation, useQuery } from "@tanstack/react-query";
import Axios from "../utils/ApiConfiguration";
/**
* Custom hook to fetch a list of documents related to shareholders.
*
* This function makes an API call to retrieve documents associated with shareholders.
*
* @returns {import("@tanstack/react-query").UseQueryResult} The query result object.
*
* @throws {Error} If the API call fails or encounters an error.
*
* @example
* const { data, isLoading, isError } = useGetDocuments();
* if (isLoading) {
* return <div>Loading documents...</div>;
* }
* if (isError) {
* return <div>Error loading documents</div>;
* }
* return (
* <div>
* * Render the list of documents here
* </div>
* );
*/
export const useGetDocuments = () =>
useQuery({
queryKey: ["documents"],
queryFn: () => Axios.get("shareholderdocument/"),
refetchOnWindowFocus: false,
});
Source