@@ -16,10 +16,6 @@ import evm from "providers/evm";
16
16
import { DetailsModalProps } from "./DetailsModal.types" ;
17
17
import styles from "./DetailsModal.module.scss" ;
18
18
19
- const handleOnSetTokenPriceSubmit = ( values : Record < string , string > ) => {
20
- console . log ( { values } ) ;
21
- } ;
22
-
23
19
export const DetailsModal : React . FC < DetailsModalProps > = ( { onClose, className, item } ) => {
24
20
const [ isSetForSale , setIsSetForSale ] = useState ( false ) ;
25
21
const tokenPriceInputRef = useRef < HTMLInputElement | undefined > ( ) ;
@@ -37,6 +33,11 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
37
33
}
38
34
} ;
39
35
36
+ const handleOnSetTokenPriceSubmit = async ( values : Record < string , string > ) => {
37
+ await ERC721 . setTokenForSale ( item . id ! , values . tokenPrice ) ;
38
+ setIsSetForSale ( false ) ;
39
+ } ;
40
+
40
41
const handleOnBuyNowClick = ( ) => {
41
42
ERC721 . buyToken ( item . id ! ) ;
42
43
} ;
@@ -53,7 +54,7 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
53
54
await ERC721 . ownerOf ( item . id ! ) ;
54
55
await ERC721 . getTokenPrice ( item . id ! ) ;
55
56
} ) ( ) ;
56
- } , [ item . id , ERC721 . actions . buyToken . isConfirmed ] ) ;
57
+ } , [ item . id , ERC721 . actions . buyToken . isConfirmed , ERC721 . actions . setTokenForSale . isConfirmed ] ) ;
57
58
58
59
useEffect ( ( ) => {
59
60
if ( ! ERC721 . tokenPrice ?. rawValue ) return ;
@@ -117,10 +118,17 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
117
118
</ div >
118
119
< div >
119
120
< Typography . Text flat truncate className = { styles [ "details-modal__price-block--owner-pill" ] } >
120
- < span > Owned by:</ span > < Typography . Anchor > { ensName || ERC721 . owner } </ Typography . Anchor >
121
+ < span > Owned by:</ span > { " " }
122
+ < Typography . Anchor
123
+ href = { `${ evm . getBlockExplorerUrl ( ) } /address/${ ensName || ERC721 . owner } ` }
124
+ target = "_blank"
125
+ >
126
+ { ensName || ERC721 . owner }
127
+ </ Typography . Anchor >
121
128
</ Typography . Text >
122
129
</ div >
123
130
</ div >
131
+
124
132
{ ! isConnected && (
125
133
< div className = { styles [ "details-modal__price-block--connect-wallet" ] } >
126
134
< Button fullWidth variant = "outlined" onClick = { handleOnDisplayWidgetClick } >
@@ -158,22 +166,44 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
158
166
< Typography . Text flat >
159
167
Purchase confirmed! Check your transaction{ " " }
160
168
< Typography . Anchor
169
+ target = "_blank"
161
170
href = { `${ evm . getBlockExplorerUrl ( ) } /tx/${ ERC721 . actions . buyToken . transactionHash } ` }
162
171
>
163
172
here < Icon name = "icon-exit-up2" />
164
173
</ Typography . Anchor >
165
174
</ Typography . Text >
166
175
</ div >
167
176
) }
177
+
178
+ { ERC721 . actions . setTokenForSale . isConfirmed && (
179
+ < div
180
+ className = { clsx (
181
+ styles [ "details-modal__price-block--success-setTokenForSale" ] ,
182
+ styles [ "details-modal__price-block--success" ] ,
183
+ ) }
184
+ >
185
+ < Typography . Text flat >
186
+ New price set! < br />
187
+ This token is now for sale.
188
+ < br /> Check your transaction{ " " }
189
+ < Typography . Anchor
190
+ target = "_blank"
191
+ href = { `${ evm . getBlockExplorerUrl ( ) } /tx/${ ERC721 . actions . setTokenForSale . transactionHash } ` }
192
+ >
193
+ here < Icon name = "icon-exit-up2" />
194
+ </ Typography . Anchor >
195
+ </ Typography . Text >
196
+ </ div >
197
+ ) }
168
198
</ Card . Content >
169
199
170
200
{ ERC721 . tokenPrice && ! ERC721 . connectedAccountIsOwner ( ) && (
171
201
< Card . Actions >
172
202
< Button
173
203
fullWidth
174
204
disabled = { ! isConnected || ERC721 . actions . buyToken . isPending }
175
- onClick = { handleOnBuyNowClick }
176
205
isLoading = { ERC721 . actions . buyToken . isPending }
206
+ onClick = { handleOnBuyNowClick }
177
207
>
178
208
Buy for: { ERC721 . tokenPrice ?. formattedValue } ETH
179
209
</ Button >
@@ -188,7 +218,7 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
188
218
onClick = { handleSetForSaleToggle }
189
219
isLoading = { ERC721 . actions . buyToken . isPending }
190
220
>
191
- Set For Sale
221
+ { ERC721 . tokenPrice ? " Set A New Price" : "Set For Sale" }
192
222
</ Button >
193
223
</ Card . Actions >
194
224
) }
@@ -198,20 +228,20 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
198
228
< Button
199
229
variant = "outlined"
200
230
color = "secondary"
201
- disabled = { ! isConnected }
231
+ disabled = { ! isConnected || ERC721 . actions . setTokenForSale . isPending }
202
232
onClick = { handleSetForSaleToggle }
203
233
isLoading = { ERC721 . actions . buyToken . isPending }
204
234
>
205
235
Cancel
206
236
</ Button >
207
237
< Button
208
238
color = "primary"
209
- disabled = { ! isConnected }
210
- isLoading = { ERC721 . actions . buyToken . isPending }
211
239
type = "submit"
212
240
onClick = { handleSubmit }
241
+ disabled = { ! isConnected || ERC721 . actions . setTokenForSale . isPending }
242
+ isLoading = { ERC721 . actions . setTokenForSale . isPending }
213
243
>
214
- Set For Sale
244
+ { ERC721 . tokenPrice ? "Confirm New Price" : " Set For Sale" }
215
245
</ Button >
216
246
</ Card . Actions >
217
247
) }
@@ -220,7 +250,10 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
220
250
/>
221
251
< Card className = { styles [ "details-modal__forge-card" ] } >
222
252
< Card . Content >
223
- < Typography . Headline5 > Forge This Item</ Typography . Headline5 >
253
+ < Typography . Headline5 flat = { ! ERC721 . connectedAccountIsOwner ( ) } > Forge This Item</ Typography . Headline5 >
254
+ { ! ERC721 . connectedAccountIsOwner ( ) && (
255
+ < Typography . TextLead > (Only the current owner can forge this item)</ Typography . TextLead >
256
+ ) }
224
257
< Typography . Text flat > Extend this item's story, exclusively for you by Lars Kristo.</ Typography . Text >
225
258
< Typography . Description >
226
259
* Each forge is also registered in the Ethereum blockchain tied to the original NFT.
@@ -239,7 +272,7 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
239
272
</ div >
240
273
</ Grid . Col >
241
274
< Grid . Col className = { styles [ "details-modal__forge-card--row-button" ] } lg = { 4 } >
242
- < Button variant = "outlined" color = "secondary" >
275
+ < Button variant = "outlined" color = "secondary" disabled = { ! ERC721 . connectedAccountIsOwner ( ) } >
243
276
Forge
244
277
</ Button >
245
278
</ Grid . Col >
@@ -258,7 +291,7 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
258
291
</ div >
259
292
</ Grid . Col >
260
293
< Grid . Col className = { styles [ "details-modal__forge-card--row-button" ] } lg = { 4 } >
261
- < Button variant = "outlined" color = "secondary" >
294
+ < Button variant = "outlined" color = "secondary" disabled = { ! ERC721 . connectedAccountIsOwner ( ) } >
262
295
Forge
263
296
</ Button >
264
297
</ Grid . Col >
@@ -277,7 +310,7 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
277
310
</ div >
278
311
</ Grid . Col >
279
312
< Grid . Col className = { styles [ "details-modal__forge-card--row-button" ] } lg = { 4 } >
280
- < Button variant = "outlined" color = "secondary" >
313
+ < Button variant = "outlined" color = "secondary" disabled = { ! ERC721 . connectedAccountIsOwner ( ) } >
281
314
Forge
282
315
</ Button >
283
316
</ Grid . Col >
@@ -318,27 +351,44 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
318
351
< Typography . Headline5 > Details</ Typography . Headline5 >
319
352
< div className = { styles [ "details-modal__details-card--row" ] } >
320
353
< Typography . Text flat > Contract Address</ Typography . Text >
321
- < Typography . Anchor truncate > { ERC721 . contractAddress } </ Typography . Anchor >
354
+ < Typography . Anchor
355
+ truncate
356
+ href = { `${ evm . getBlockExplorerUrl ( ) } /token/${ ERC721 . contractAddress } ` }
357
+ target = "_blank"
358
+ >
359
+ { ERC721 . contractAddress }
360
+ </ Typography . Anchor >
322
361
</ div >
323
362
< div className = { styles [ "details-modal__details-card--row" ] } >
324
363
< Typography . Text flat > Token ID</ Typography . Text >
325
- < Typography . Anchor > #{ item . id ! } </ Typography . Anchor >
364
+ < Typography . Anchor
365
+ href = { `${ evm . getBlockExplorerUrl ( ) } /nft/${ ERC721 . contractAddress } /${ item . id ! } ` }
366
+ target = "_blank"
367
+ >
368
+ #{ item . id ! }
369
+ </ Typography . Anchor >
326
370
</ div >
327
371
< div className = { styles [ "details-modal__details-card--row" ] } >
328
372
< Typography . Text flat > Token Standard</ Typography . Text >
329
373
< Typography . Anchor > ERC721</ Typography . Anchor >
330
374
</ div >
331
375
< div className = { styles [ "details-modal__details-card--row" ] } >
332
376
< Typography . Text flat > Owner</ Typography . Text >
333
- < Typography . Anchor truncate > { ensName || ERC721 . owner } </ Typography . Anchor >
377
+ < Typography . Anchor
378
+ truncate
379
+ href = { `${ evm . getBlockExplorerUrl ( ) } /address/${ ensName || ERC721 . owner } ` }
380
+ target = "_blank"
381
+ >
382
+ { ensName || ERC721 . owner }
383
+ </ Typography . Anchor >
334
384
</ div >
335
385
< div className = { styles [ "details-modal__details-card--row" ] } >
336
386
< Typography . Text flat > Royalty</ Typography . Text >
337
- < Typography . Anchor > { ERC721 . royalty ?. percentageFormatted } </ Typography . Anchor >
387
+ < Typography . Text flat > { ERC721 . royalty ?. percentageFormatted } </ Typography . Text >
338
388
</ div >
339
389
< div className = { styles [ "details-modal__details-card--row" ] } >
340
390
< Typography . Text flat > Chain</ Typography . Text >
341
- < Typography . Anchor > Ethereum</ Typography . Anchor >
391
+ < Typography . Text flat > Ethereum</ Typography . Text >
342
392
</ div >
343
393
</ Card . Content >
344
394
</ Card >
0 commit comments