import { useHOFStore } from "@/Stores"; import { formatText } from "@/Utility"; import { wwwAXIOS } from "@/Www"; import { GetHOFAPI } from "@/wwwAPI"; import { useQuery } from "@tanstack/react-query"; import { useTranslations } from "next-intl"; import { useIsPath } from "taehui-ts/fe-utility"; export default function useGetAtHighestHOF() { const { tabPosition, atTabPosition } = useHOFStore(); const t = useTranslations(); const isPath = useIsPath(); return useQuery< { avatarID: string; avatarName: string; text: string; }[] >({ enabled: tabPosition === 1 && atTabPosition === 1 && isPath("/hof"), queryKey: ["atHighestHOF"], queryFn: async () => { const { data } = await wwwAXIOS.get<GetHOFAPI[]>("/hof/atHighest"); return data.map((hof) => ({ ...hof, text: t("textCount", { value: formatText(hof.value) }), })); }, initialData: [], }); }