Skip to content

Commit

Permalink
Merge pull request #165 from NetSepio/main
Browse files Browse the repository at this point in the history
Merging main with prod
  • Loading branch information
Rushikeshnimkar authored Oct 15, 2024
2 parents 4fcb5a2 + b192dd2 commit 3b2cc46
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 47 deletions.
13 changes: 3 additions & 10 deletions components/NftdataCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,11 @@ const NftdataCard: React.FC<ReviewCardProps> = ({
<div>
<div className="flex flex-col">
<div className="">
<img
<img
alt={metaData.current_token_data.token_name}
src={imageSrc || "/path/to/placeholder/image.png"}
src={imageSrc}
className="w-full h-48 object-cover rounded-lg"
onError={(e) => {
console.error(
"Image failed to load:",
(e.target as HTMLImageElement).src
);
(e.target as HTMLImageElement).src =
"/path/to/placeholder/image.png";
}}

/>
</div>
<div className="w-full">
Expand Down
59 changes: 29 additions & 30 deletions components/UserNFTs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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: '',
},
}));

Expand Down
13 changes: 6 additions & 7 deletions pages/subscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -183,7 +182,6 @@ const Subscription = () => {
}, [loggedin, loading, isDataChecked, nftLoading, nftdata, trialsubscriptiondata, nftError]);



const handleSubmit = async (e: FormEvent) => {
e.preventDefault();

Expand Down Expand Up @@ -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");
Expand All @@ -461,7 +460,7 @@ const Subscription = () => {
}
}
};

fetchNFTs();
}, [wallet]);

Expand Down

0 comments on commit 3b2cc46

Please sign in to comment.