import { useQuery } from "@tanstack/react-query";
import {
    getMarketplacesOptions,
    getMarketplacesQueryKey,
} from "@/lib/client/@tanstack/react-query.gen";

type Props = {
    clientId: number;
};

const useMarketplacesList = ({ clientId }: Props) => {
    const { data, refetch } = useQuery(
        getMarketplacesOptions({ path: { clientId } })
    );

    const queryKey = getMarketplacesQueryKey({ path: { clientId } });

    return { marketplaces: data?.items ?? [], refetch, queryKey };
};

export default useMarketplacesList;
