1
1
// import React, { useCallback, useEffect, useRef } from 'react';
2
2
import React , { useEffect } from 'react' ;
3
3
// import { useNFTsByOwner } from '@web3-ui/hooks';
4
+ import { useNFTMetadata } from 'ankr-react' ;
4
5
5
6
export type NFTProps = {
6
7
/**
@@ -15,10 +16,6 @@ export type NFTProps = {
15
16
* The size of the NFT card.
16
17
*/
17
18
size ?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' ;
18
- /**
19
- * Use testnet API (Rinkeby) instead of mainnet
20
- */
21
- isTestnet ?: boolean ;
22
19
} ;
23
20
24
21
export interface NFTData {
@@ -37,16 +34,14 @@ export const NFT = ({
37
34
// contractAddress,
38
35
// tokenId,
39
36
size = 'xs' ,
40
- } : // isTestnet = false,
41
- NFTProps ) => {
42
- // const _isMounted = useRef(true);
43
- const [ nftData , setNftData ] = React . useState < NFTData > ( ) ;
44
- const [ errorMessage , setErrorMessage ] = React . useState < string > ( ) ;
37
+ } : NFTProps ) => {
38
+ // const { data, error, isLoading } = useNFTMetadata({
39
+ // blockchain: 'eth',
40
+ // contractAddress: '0xEdB61f74B0d09B2558F1eeb79B247c1F363Ae452',
41
+ // tokenId: '2276'
42
+ // });
45
43
46
- useEffect ( ( ) => {
47
- setNftData ( undefined ) ;
48
- setErrorMessage ( '' ) ;
49
- } , [ ] ) ;
44
+ // console.log('data', data);
50
45
51
46
// working ankr api hook for nfts by owner
52
47
// const { data, error, isLoading } = useNFTsByOwner({
@@ -57,89 +52,5 @@ NFTProps) => {
57
52
// console.log('error', error);
58
53
// console.log(data);
59
54
60
- return < NFTCard data = { nftData } errorMessage = { errorMessage } size = { size } /> ;
61
- } ;
62
-
63
- /**
64
- * Private component to display an NFT given the data
65
- */
66
- export const NFTCard = ( {
67
- data,
68
- errorMessage = '' ,
69
- size,
70
- hideIfError = false ,
71
- } : {
72
- data : NFTData | undefined | null ;
73
- errorMessage ?: string | undefined ;
74
- size : 'xs' | 'sm' | 'md' | 'lg' | 'xl' ;
75
- hideIfError ?: boolean ;
76
- } ) => {
77
- console . log ( data ) ;
78
- console . log ( errorMessage ) ;
79
- console . log ( size ) ;
80
- console . log ( hideIfError ) ;
81
- // const [error, setError] = useState(false);
82
- // const name = data?.name;
83
- // const imageUrl = data?.imageUrl;
84
- // const assetContractName = data?.assetContractName;
85
- // const assetContractSymbol = data?.assetContractSymbol;
86
- // const animationUrl = data?.animationUrl;
87
- // const tokenId = data?.tokenId;
88
- // const displayName = name || `${assetContractSymbol} #${tokenId}`;
89
-
90
- // if (errorMessage || error || imageUrl === '(unknown)' || !imageUrl) {
91
- // if (hideIfError) return null;
92
- // return (
93
- // <>{errorMessage}</>
94
- // // <Alert status="error">
95
- // // <AlertIcon />
96
- // // {errorMessage}
97
- // // </Alert>
98
- // );
99
- // }
100
-
101
- return (
102
- < div > nft here</ div >
103
- // <Skeleton isLoaded={!!data} maxW={size} h="md">
104
- // <Box maxW={size} borderRadius="lg" borderWidth="1px" overflow="hidden">
105
- // {animationUrl ? (
106
- // animationUrl.endsWith('.mp3') ? (
107
- // <VStack>
108
- // <Image
109
- // src={imageUrl}
110
- // alt={displayName}
111
- // borderRadius="lg"
112
- // w={size}
113
- // onError={() => setError(true)}
114
- // />
115
- // <audio
116
- // src={animationUrl}
117
- // controls
118
- // autoPlay
119
- // muted
120
- // style={{ borderRadius: '7px' }}
121
- // />
122
- // </VStack>
123
- // ) : (
124
- // <Flex w={size} h={size} bg="black" justifyContent="center">
125
- // <video src={animationUrl} controls autoPlay muted />
126
- // </Flex>
127
- // )
128
- // ) : (
129
- // <Image src={imageUrl} alt={displayName} borderRadius="lg" w={size} />
130
- // )}
131
- // <Box p="6">
132
- // <Flex alignItems="center" justifyContent="space-between" pb="2">
133
- // <Heading as="h3" size="sm" style={{ overflowWrap: 'anywhere' }}>
134
- // {displayName}
135
- // </Heading>
136
- // {assetContractSymbol && <Tag size="sm">{assetContractSymbol}</Tag> }
137
- // </Flex>
138
- // <Text fontSize="xs">
139
- // {assetContractName} #{tokenId}
140
- // </Text>
141
- // </Box>
142
- // </Box>
143
- // </Skeleton>
144
- ) ;
55
+ return < div > nft here</ div > ;
145
56
} ;
0 commit comments