text: import { useMoralisDapp } from "providers/MoralisDappProvider/MoralisDappProvider";
  import { useEffect, useState } from "react";
  import { useMoralisWeb3Api, useMoralisWeb3ApiCall } from "react-moralis";
  import { useIPFS } from "./useIPFS";
  
  export const useNFTTokenIds = (addr) => {
    const { token } = useMoralisWeb3Api();
    const { chainId } = useMoralisDapp();
    const { resolveLink } = useIPFS();
    const [NFTTokenIds, setNFTTokenIds] = useState([]);
    const [totalNFTs, setTotalNFTs] = useState();
    const [fetchSuccess, setFetchSuccess] = useState(true);
    const {
      fetch: getNFTTokenIds,
      data,
      error,
      isLoading,
    } = useMoralisWeb3ApiCall(token.getAllTokenIds, {
      chain: chainId,
      address: addr,
      limit: 10,
    });
  
    // eslint-disable-next-line react-hooks/exhaustive-deps
    useEffect(async () => {
      if (data?.result) {
        const NFTs = data.result;
        setTotalNFTs(data.total);
        setFetchSuccess(true);
        for (let NFT of NFTs) {
          if (NFT?.metadata) {
            NFT.metadata = JSON.parse(NFT.metadata);
            NFT.image = resolveLink(NFT.metadata?.image);
          } else if (NFT?.token_uri) {
            try {
              await fetch(NFT.token_uri)
                .then((response) => response.json())
                .then((data) => {
                  NFT.image = resolveLink(data.image);
                });
            } catch (error) {
              setFetchSuccess(false);
            }
          }
        }
        setNFTTokenIds(NFTs);
      }
      // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [data]);
  
    return {
      getNFTTokenIds,
      NFTTokenIds,
      totalNFTs,
      fetchSuccess,
      error,
      isLoading,
    };
  };
  