import { GetAvatarWwwLevelsAPI } from "@/type/wwwAPI";
import { wwwAPI } from "@/utilities/wwwAPI";
import { useQuery } from "@tanstack/react-query";
import { useIsPath } from "taehui-lib/fe-utilities";

export default function useGetAvatarWwwLevels(avatarID?: string) {
  const isPath = useIsPath();

  return useQuery({
    enabled: !!avatarID && isPath("/avatar"),
    queryKey: ["avatarWwwLevels", avatarID],
    queryFn: async () => {
      const { data } = await wwwAPI.get<GetAvatarWwwLevelsAPI>(
        "/avatar/wwwLevels",
        {
          params: { avatarID },
        },
      );
      return data;
    },
    initialData: [],
  });
}
