import { useHallStore } from "@/Stores"; import { formatText } from "@/Utility"; import { wwwAXIOS } from "@/Www"; import { GetHallAPI } from "@/wwwAPI"; import { useQuery } from "@tanstack/react-query"; import { useTranslations } from "next-intl"; import { useIsPath } from "taehui-ts/fe-utility"; export default function useGetTotalTotalHall() { const { tabPosition, totalTabPosition } = useHallStore(); const t = useTranslations(); const isPath = useIsPath(); return useQuery< { avatarID: string; avatarName: string; text: string; }[] >({ enabled: tabPosition === 0 && totalTabPosition === 0 && isPath("/hall"), queryKey: ["totalTotalHall"], queryFn: async () => { const { data } = await wwwAXIOS.get<GetHallAPI[]>("/hall/totalTotal"); return data.map((hall) => ({ ...hall, text: t("textHandled", { value: formatText(hall.value) }), })); }, initialData: [], }); }