import { Hall } from "@/app/[language]/hall/type"; import { useHallStore } from "@/store/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-ts/fe-utilities"; export default function useGetLevelHall() { const { tabPosition } = useHallStore(); const isPath = useIsPath(); return useQuery<Hall[]>({ enabled: tabPosition === 3 && isPath("/hall"), queryKey: ["levelHall"], queryFn: async () => { const { data } = await wwwAPI.get<GetHallAPI[]>("/hall/level"); return data.map((hall) => ({ ...hall, text: `LV.${formatText(hall.value)}`, })); }, initialData: [], }); }