import { Hall } from "@/app/[language]/hall/type"; import { useHallStore } from "@/state/Stores"; import { GetHallAPI } from "@/type/wwwAPI"; import { wwwAPI } from "@/utilities/wwwAPI"; import { useQuery } from "@tanstack/react-query"; import { useIsPath } from "taehui-lib/fe-utilities"; export default function useGetLevelHall() { const { tabItem } = useHallStore(); const isPath = useIsPath(); return useQuery<Hall[]>({ enabled: tabItem === "level" && isPath("/hall"), queryKey: ["levelHall"], queryFn: async () => { const { data } = await wwwAPI.get<GetHallAPI[]>("/hall/level"); return data.map((hall) => ({ ...hall, value: hall.value, text: `LV. ${hall.value}`, })); }, initialData: [], }); }