import { useHallStore } from "@/Stores"; import { formatText } from "@/Utility"; import { wwwAXIOS } from "@/Www"; import { GetHallAPI } from "@/wwwAPI"; import { useQuery } from "@tanstack/react-query"; import { useIsPath } from "taehui-ts/fe-utility"; export default function useGetLevelHall() { const { tabPosition } = useHallStore(); const isPath = useIsPath(); return useQuery< { avatarID: string; avatarName: string; text: string; }[] >({ enabled: tabPosition === 3 && isPath("/hall"), queryKey: ["levelHall"], queryFn: async () => { const { data } = await wwwAXIOS.get<GetHallAPI[]>("/hall/level"); return data.map((hall) => ({ ...hall, text: `LV.${formatText(hall.value)}`, })); }, initialData: [], }); }