import { useQuery } from "@tanstack/react-query";
import * as api from "../service/AboutService";
import { useParams } from "next/navigation";

export const useGetAbout = () => {
  const { name } = useParams<{ name: string }>();
  return useQuery({
    queryKey: ["about", name],
    queryFn: () => api.getAbout(name),
    enabled: !!name,
    retry: false,
    staleTime: 5 * 60_000,
    refetchOnMount: false,
  });
};

export const useGetReviews = () => {
  const { name } = useParams<{ name: string }>();
  return useQuery({
    queryKey: ["reviews", name],
    queryFn: () => api.getReviews(name),
    enabled: !!name,
    retry: false,
  });
};

export const useGetSchedules = () => {
  const { name } = useParams<{ name: string }>();
  return useQuery({
    queryKey: ["schedules", name],
    queryFn: () => api.getSchedules(name),
    enabled: !!name,
    retry: false,
  });
};
