import { GetAvatarFavoritesAPI } from "@/type/wwwAPI";

import { wwwAPI } from "@/utilities/wwwAPI";
import { useQuery } from "@tanstack/react-query";
import { useTranslations } from "next-intl";
import { useIsPath } from "taehui-lib/fe-utilities";

export default function useGetAvatarFavorites(
  favoritesTabItem: string,
  avatarID?: string,
) {
  const isPath = useIsPath();

  const t = useTranslations();

  return useQuery({
    enabled: !!avatarID && isPath("/avatar"),
    queryKey: ["avatarFavorites", favoritesTabItem, avatarID],
    queryFn: async () => {
      const { data } = await wwwAPI.get<GetAvatarFavoritesAPI>(
        `/avatar/favorites/${favoritesTabItem}`,
        {
          params: { avatarID },
        },
      );
      return data;
    },
    initialData: [],
  });
}
