File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,20 @@ export function Pay() {
1111 const { provider } = useStore ( ) ;
1212 const [ amount , setAmount ] = useState ( 0 ) ;
1313 const [ description , setDescription ] = useState ( "" ) ;
14+ const [ hasCopied , setCopied ] = useState ( false ) ;
15+
16+ function copyQr ( ) {
17+ try {
18+ if ( ! invoice ) {
19+ return ;
20+ }
21+ window . navigator . clipboard . writeText ( invoice ) ;
22+ setCopied ( true ) ;
23+ setTimeout ( ( ) => setCopied ( false ) , 1000 ) ;
24+ } catch ( error ) {
25+ console . error ( error ) ;
26+ }
27+ }
1428
1529 useEffect ( ( ) => {
1630 if ( ! provider ) {
@@ -49,12 +63,12 @@ export function Pay() {
4963 < div className = "flex grow flex-col items-center justify-center gap-5" >
5064 < span className = "text-4xl font-bold" > { new Intl . NumberFormat ( ) . format ( amount ) } sats</ span >
5165 < span className = "font-semibold" > { description } </ span >
52- < div className = "relative flex items-center justify-center" >
66+ < div className = "relative flex items-center justify-center" onClick = { copyQr } >
5367 < QRCodeSVG value = { invoice } size = { 256 } />
5468 </ div >
5569 < p className = "mb-4 flex flex-row items-center justify-center gap-2" >
56- < span className = "loading loading-spinner text-primary" > </ span >
57- Waiting for payment...
70+ { ! hasCopied && < span className = "loading loading-spinner text-primary" > </ span > }
71+ { hasCopied ? "✅ Invoice Copied!" : " Waiting for payment..." }
5872 </ p >
5973 < button
6074 onClick = { ( ) => {
You can’t perform that action at this time.
0 commit comments