1- import { useSelector } from 'react-redux' ;
1+ import { useDispatch , useSelector } from 'react-redux' ;
22
3+ import { copyAddressToClipboard } from '@suite/address' ;
34import { Translation } from '@suite/intl' ;
45import { type AccountsRootState , selectAccountByKey } from '@suite-common/wallet-core' ;
56import { type AccountKey } from '@suite-common/wallet-types' ;
@@ -10,8 +11,8 @@ import { belowBreakpoint, breakpoints } from '@trezor/theme';
1011
1112import { AddressLabeling } from './AddressLabeling' ;
1213import { CoinQrCode } from './CoinQrCode' ;
13- import { type ReceiveAddressItem } from './receiveTypes ' ;
14- import { canShareAddress , shareAddress } from './share' ;
14+ import { type ReceiveAddressItem } from './receive ' ;
15+ import { canShareAddress , shareAddress } from './sharing/ share' ;
1516
1617const QR_SIZE = 148 ;
1718
@@ -21,7 +22,7 @@ type AddressCardDetailProps = {
2122 disabled : boolean ;
2223 isVerifyLoading : boolean ;
2324 isVerifyDisabled : boolean ;
24- onCopy : ( path : string , address : string ) => void ;
25+ onCopied : ( path : string ) => void ;
2526 onVerify : ( path : string ) => void ;
2627} ;
2728
@@ -31,14 +32,20 @@ export const AddressCardDetail = ({
3132 disabled,
3233 isVerifyLoading,
3334 isVerifyDisabled,
34- onCopy ,
35+ onCopied ,
3536 onVerify,
3637} : AddressCardDetailProps ) => {
38+ const dispatch = useDispatch ( ) ;
3739 const account = useSelector ( ( state : AccountsRootState ) =>
3840 selectAccountByKey ( state , accountKey ) ,
3941 ) ;
4042 const isBelowTablet = useMediaQuery ( belowBreakpoint ( breakpoints . tablet ) ) ;
4143
44+ const handleCopy = ( ) => {
45+ dispatch ( copyAddressToClipboard ( item . address ) ) ;
46+ onCopied ( item . path ) ;
47+ } ;
48+
4249 if ( ! account ) {
4350 return null ;
4451 }
@@ -81,11 +88,7 @@ export const AddressCardDetail = ({
8188 </ Text >
8289 </ Column >
8390 < Row gap = { 12 } flexWrap = "wrap" >
84- < Button
85- size = "large"
86- iconLeft = { CopyIcon }
87- onClick = { ( ) => onCopy ( item . path , item . address ) }
88- >
91+ < Button size = "large" iconLeft = { CopyIcon } onClick = { handleCopy } >
8992 < Translation id = "TR_COPY_TO_CLIPBOARD" />
9093 </ Button >
9194 { canShareAddress ( ) && (
0 commit comments