diff --git a/components/NftdataCard.tsx b/components/NftdataCard.tsx index e474366..68311b1 100644 --- a/components/NftdataCard.tsx +++ b/components/NftdataCard.tsx @@ -171,18 +171,11 @@ const NftdataCard: React.FC = ({
- {metaData.current_token_data.token_name} { - console.error( - "Image failed to load:", - (e.target as HTMLImageElement).src - ); - (e.target as HTMLImageElement).src = - "/path/to/placeholder/image.png"; - }} + />
diff --git a/components/UserNFTs.tsx b/components/UserNFTs.tsx index b27fb91..6f24000 100644 --- a/components/UserNFTs.tsx +++ b/components/UserNFTs.tsx @@ -61,36 +61,36 @@ const fetchUserNFTs = async (chainSymbol: string) => { return filteredNFTs; } else if (chainSymbol === 'apt') { - const APTOS_GRAPHQL_ENDPOINT = process.env.NEXT_PUBLIC_APTOS_GRAPHQL_ENDPOINT; + const APTOS_GRAPHQL_ENDPOINT = process.env.NEXT_PUBLIC_GRAPHQL_APTOS; const query = ` - query GetAccountNfts($address: String) { - current_token_ownerships_v2( - where: {owner_address: {_eq: $address}, amount: {_gt: "0"}} - ) { - current_token_data { - collection_id - largest_property_version_v1 - current_collection { - collection_id - collection_name - description - creator_address - uri - __typename - } - description - token_name - token_data_id - token_standard - token_uri - __typename - } - owner_address - amount - __typename - } - } + query GetAccountNfts($address: String) { +current_token_ownerships_v2( + where: {owner_address: {_eq: $address}, amount: {_gt: "0"}} +) { + current_token_data { + collection_id + largest_property_version_v1 + current_collection { + collection_id + collection_name + description + creator_address + uri + __typename + } + description + token_name + token_data_id + token_standard + token_uri + __typename + } + owner_address + amount + __typename +} +} `; const variables = { address: userAddress }; @@ -114,9 +114,8 @@ const fetchUserNFTs = async (chainSymbol: string) => { cdn_asset_uris: { cdn_image_uri: nft.current_token_data.token_uri, }, - collection: nft.current_token_data.current_collection.collection_name, - symbol: '', current_collection: nft.current_token_data.current_collection, + symbol: '', }, })); diff --git a/pages/subscription.tsx b/pages/subscription.tsx index c81ebed..c7c2a3f 100644 --- a/pages/subscription.tsx +++ b/pages/subscription.tsx @@ -168,12 +168,11 @@ const Subscription = () => { }); if (loggedin && !loading && isDataChecked && !nftLoading) { - if (((nftdata && nftdata.length === 0) || !nftdata) && !trialsubscriptiondata && !nftError) { - console.log("Conditions met for redirection to /plans"); + if ((!nftdata || nftdata.length === 0) && !trialsubscriptiondata && !nftError) { + console.log("No NFTs found, redirecting to /plans"); const redirectTimer = setTimeout(() => { - console.log("Redirecting to /plans"); router.push("/plans"); - }, 1000); // 1 second delay + }, 1000); return () => clearTimeout(redirectTimer); } else { @@ -183,7 +182,6 @@ const Subscription = () => { }, [loggedin, loading, isDataChecked, nftLoading, nftdata, trialsubscriptiondata, nftError]); - const handleSubmit = async (e: FormEvent) => { e.preventDefault(); @@ -451,8 +449,9 @@ const Subscription = () => { setNftError(null); try { const chainSymbol = Cookies.get("Chain_symbol") || "sol"; // Default to "sol" if not set - const nfts = await fetchUserNFTs(wallet); + const nfts = await fetchUserNFTs(chainSymbol); setnftdata(nfts); + console.log("Fetched NFTs:", nfts); } catch (error) { console.error("Error fetching NFTs:", error); setNftError("Failed to fetch NFTs"); @@ -461,7 +460,7 @@ const Subscription = () => { } } }; - + fetchNFTs(); }, [wallet]);