1- import { useAssetInfo , useRedirection } from '@hooks' ;
1+ import { useAssetInfo , useRedirection , useWalletAvatar } from '@hooks' ;
22import { walletRoutePaths } from '@routes' ;
33import React , { useMemo } from 'react' ;
44import { useParams } from 'react-router-dom' ;
55import styles from './Nfts.module.scss' ;
6- import { Button , Drawer , DrawerNavigation , useObservable } from '@lace/common' ;
6+ import { Button , Drawer , DrawerNavigation , toast , useObservable } from '@lace/common' ;
77import { useWalletStore } from '@src/stores' ;
88import { nftDetailSelector } from '@src/views/browser-view/features/nfts/selectors' ;
99import { NftDetail as NftDetailView } from '@lace/core' ;
@@ -23,6 +23,7 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
2323 } = useWalletStore ( ) ;
2424 const { t } = useTranslation ( ) ;
2525 const analytics = useAnalyticsContext ( ) ;
26+ const { setAvatar } = useWalletAvatar ( ) ;
2627
2728 const redirectToNfts = useRedirection ( walletRoutePaths . nfts ) ;
2829 const redirectToSend = useRedirection < { params : { id ?: string } } > ( walletRoutePaths . send ) ;
@@ -44,6 +45,12 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
4445 redirectToSend ( { params : { id } } ) ;
4546 } ;
4647
48+ const handleSetAsAvatar = ( image : string ) => {
49+ setAvatar ( image ) ;
50+ toast . notify ( { text : t ( 'core.nftDetail.avatarUpdated' ) } ) ;
51+ void analytics . sendEventToPostHog ( PostHogAction . NFTDetailSetAsAvatarClick ) ;
52+ } ;
53+
4754 return (
4855 < Drawer
4956 popupView
@@ -65,6 +72,7 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
6572 isPopup = { appMode === APP_MODE_POPUP }
6673 amount = { amount }
6774 title = { < h2 className = { styles . secondaryTitle } > { assetInfo . nftMetadata ?. name ?? assetInfo . fingerprint } </ h2 > }
75+ onSetAsAvatar = { handleSetAsAvatar }
6876 />
6977 ) }
7078 </ Drawer >
0 commit comments