1
- import { useAssetInfo , useRedirection } from '@hooks' ;
1
+ import { useAssetInfo , useRedirection , useWalletAvatar } from '@hooks' ;
2
2
import { walletRoutePaths } from '@routes' ;
3
3
import React , { useMemo } from 'react' ;
4
4
import { useParams } from 'react-router-dom' ;
5
5
import styles from './Nfts.module.scss' ;
6
- import { Button , Drawer , DrawerNavigation , useObservable } from '@lace/common' ;
6
+ import { Button , Drawer , DrawerNavigation , toast , useObservable } from '@lace/common' ;
7
7
import { useWalletStore } from '@src/stores' ;
8
8
import { nftDetailSelector } from '@src/views/browser-view/features/nfts/selectors' ;
9
9
import { NftDetail as NftDetailView } from '@lace/core' ;
@@ -23,6 +23,7 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
23
23
} = useWalletStore ( ) ;
24
24
const { t } = useTranslation ( ) ;
25
25
const analytics = useAnalyticsContext ( ) ;
26
+ const { setAvatar } = useWalletAvatar ( ) ;
26
27
27
28
const redirectToNfts = useRedirection ( walletRoutePaths . nfts ) ;
28
29
const redirectToSend = useRedirection < { params : { id ?: string } } > ( walletRoutePaths . send ) ;
@@ -44,6 +45,12 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
44
45
redirectToSend ( { params : { id } } ) ;
45
46
} ;
46
47
48
+ const handleSetAsAvatar = ( image : string ) => {
49
+ setAvatar ( image ) ;
50
+ toast . notify ( { text : t ( 'core.nftDetail.avatarUpdated' ) } ) ;
51
+ void analytics . sendEventToPostHog ( PostHogAction . NFTDetailSetAsAvatarClick ) ;
52
+ } ;
53
+
47
54
return (
48
55
< Drawer
49
56
popupView
@@ -65,6 +72,7 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
65
72
isPopup = { appMode === APP_MODE_POPUP }
66
73
amount = { amount }
67
74
title = { < h2 className = { styles . secondaryTitle } > { assetInfo . nftMetadata ?. name ?? assetInfo . fingerprint } </ h2 > }
75
+ onSetAsAvatar = { handleSetAsAvatar }
68
76
/>
69
77
) }
70
78
</ Drawer >
0 commit comments