import { useMutation, useQuery } from "@tanstack/react-query";
import Axios from "../utils/ApiConfiguration";
/**
* Custom hook to fetch a "karnama" (assuming it's a specific entity) by its ID.
*
* This hook fetches a "karnama" by its ID from the server using the `useQuery` hook from "@tanstack/react-query."
*
* @param {string} id - The ID of the "karnama" to fetch.
* @returns {Object} The query result object containing the "karnama" data, loading status, and possible errors.
* @throws {Error} If there's an issue with fetching the "karnama" data.
*
* @example
* // Usage of useGetKarnama hook
* const { data, isLoading, error } = useGetKarnama("karnama_id_here");
* if (isLoading) {
* return <p>Loading...</p>;
* }
* if (error) {
* return <p>Error: {error.message}</p>;
* }
* // Render "karnama" data
* return (
* <div>
* <h1>Karnama Details</h1>
* Render data here
* </div>
* );
*/
export const useGetKarnama = (id) =>
useQuery({
queryKey: ["karnama"],
queryFn: () => Axios.get(`karanama/${id}/`),
refetchOnWindowFocus: false,
});
Source