Source

apis/Dashboard.js

import { useQuery } from "@tanstack/react-query";
import Axios from "../utils/ApiConfiguration";
/**
 * Fetches chart data for a company's share history.
 *
 * This function makes an API call to retrieve chart data for a specific company's share history.
 *
 * @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 } = useGetCompanyChartData();
 * if (isLoading) {
 *   return <div>Loading chart data...</div>;
 * }
 * if (isError) {
 *   return <div>Error loading chart data</div>;
 * }
 * return (
 *   <div>
 *     * Render chart data here
 *   </div>
 * );
 */
export const useGetCompanyChartData = () =>
  useQuery({
    queryKey: ["company_chart_data"],
    queryFn: () => Axios.get("sharehistory/"),
  });