import { Hall } from "@/app/[language]/hall/type";
import { useHallStore } from "@/state/Stores";
import { GetHallAPI } from "@/type/wwwAPI";
import { formatText } from "@/utilities/Utility";
import { wwwAPI } from "@/utilities/wwwAPI";
import { useQuery } from "@tanstack/react-query";
import { useIsPath } from "taehui-lib/fe-utilities";

export default function useGetAbility6KHall() {
  const { tabItem, abilityTabItem } = useHallStore();

  const isPath = useIsPath();

  return useQuery<Hall[]>({
    enabled:
      tabItem === "ability" && abilityTabItem === "6K" && isPath("/hall"),
    queryKey: ["ability6KHall"],
    queryFn: async () => {
      const { data } = await wwwAPI.get<GetHallAPI[]>("/hall/ability/6K");
      return data.map((hall) => ({
        ...hall,
        value: hall.value,
        text: `${formatText(hall.value)} Point`,
      }));
    },
    initialData: [],
  });
}
