1+ import { useEffect } from 'react' ;
12import { Link } from '@/core/base/components/Link' ;
23import { ModalBody } from '@/core/base/components/Modal/ModalBody' ;
34import { ModalFooter } from '@/core/base/components/Modal/ModalFooter' ;
45import { ModalHeader } from '@/core/base/components/Modal/ModalHeader' ;
56import { ForwardIcon } from '@/core/base/icons/ForwardIcon' ;
7+ import { CopyIcon } from '@/core/base/icons/CopyIcon' ;
8+ import { SuccessIcon } from '@/core/base/icons/SuccessIcon' ;
69import { cx } from '@/core/base/utils/css' ;
710import { CustomQRCode } from '@/core/components/CustomQRCode' ;
11+ import { useClipboard } from '@/core/base/hooks/useClipboard' ;
812import { useWalletLogos } from '@/core/hooks/useWalletLogos' ;
913import { useWalletKit } from '@/core/providers/WalletKitProvider/context' ;
10- import { clsContainer , clsOfficialButton } from './styles.css' ;
14+ import { clsContainer , clsOfficialButton , clsCopyButton , clsFooter } from './styles.css' ;
1115import { useAutoCloseConnectModal } from '@/core/hooks/useAutoCloseConnectModal' ;
1216import { BaseWallet } from '@/core/configs/types' ;
1317
@@ -25,9 +29,18 @@ export function TemplateQRCodeView(props: TemplateQRCodeViewProps) {
2529
2630 const { options } = useWalletKit ( ) ;
2731 const logos = useWalletLogos ( wallet ?. logos ) ;
32+ const { onCopy, hasCopied, setValue } = useClipboard ( qrCodeUri ?? '' ) ;
33+
34+ useEffect ( ( ) => {
35+ if ( qrCodeUri ) {
36+ setValue ( qrCodeUri ) ;
37+ }
38+ } , [ qrCodeUri , setValue ] ) ;
2839
2940 useAutoCloseConnectModal ( isConnected , address ) ;
3041
42+ const showFooter = ! ! qrCodeUri || ( isWalletConnect && ! options ?. hideOfficialWalletConnectCTA ) ;
43+
3144 return (
3245 < >
3346 < ModalHeader > Scan with your phone</ ModalHeader >
@@ -36,15 +49,32 @@ export function TemplateQRCodeView(props: TemplateQRCodeViewProps) {
3649 < CustomQRCode value = { qrCodeUri } logo = { logos . default } />
3750 </ ModalBody >
3851
39- { isWalletConnect && ! options ?. hideOfficialWalletConnectCTA && (
40- < ModalFooter >
41- < Link
42- className = { cx ( 'wk-official-wc-button' , clsOfficialButton ) }
43- onClick = { onClickOpenWcModal }
44- >
45- Open the official WalletConnect modal
46- < ForwardIcon />
47- </ Link >
52+ { showFooter && (
53+ < ModalFooter className = { clsFooter } >
54+ { ! ! qrCodeUri && (
55+ < button className = { cx ( 'wk-copy-link-button' , clsCopyButton ) } onClick = { onCopy } >
56+ { hasCopied ? (
57+ < >
58+ < SuccessIcon width = { 16 } height = { 16 } />
59+ Copied
60+ </ >
61+ ) : (
62+ < >
63+ < CopyIcon width = { 16 } height = { 16 } />
64+ Copy Link
65+ </ >
66+ ) }
67+ </ button >
68+ ) }
69+ { isWalletConnect && ! options ?. hideOfficialWalletConnectCTA && (
70+ < Link
71+ className = { cx ( 'wk-official-wc-button' , clsOfficialButton ) }
72+ onClick = { onClickOpenWcModal }
73+ >
74+ Open the official WalletConnect modal
75+ < ForwardIcon />
76+ </ Link >
77+ ) }
4878 </ ModalFooter >
4979 ) }
5080 </ >
0 commit comments