e.stopPropagation()}>
-
⚡️ Send sats
+ function invoiceForm() {
+ if (invoice) return null;
+ return (
+ <>
{metadata?.description ?? service}
{payService?.commentAllowed > 0 ?
@@ -133,8 +157,51 @@ export default function LNURLTip(props) {
: null}
{amount === -1 ? custom() : null}
+ {amount > 0 ?
loadInvoice()}>Get Invoice
: null}
+ >
+ )
+ }
+
+ function payInvoice() {
+ if(success) return null;
+ const pr = invoice.pr;
+ return (
+ <>
+
+
+
+
+
+ {pr ? <>
+ {webLn()}
+
window.open(`lightning:${pr}`)}>Open Wallet
+
navigator.clipboard.writeText(pr)}>Copy Invoice
+ > : null}
+
+
+ >
+ )
+ }
+
+ function successAction() {
+ if(!success) return null;
+ return (
+ <>
+
{success?.description ?? "Paid!"}
+ {success.url ?
{success.url} : null}
+ >
+ )
+ }
+
+ if (!show) return null;
+ return (
+
onClose()}>
+ e.stopPropagation()}>
+
⚡️ Send sats
+ {invoiceForm()}
{error ?
{error}
: null}
-
+ {payInvoice()}
+ {successAction()}
)
diff --git a/src/element/QrCode.js b/src/element/QrCode.js
index 50727b93..4654a1fe 100644
--- a/src/element/QrCode.js
+++ b/src/element/QrCode.js
@@ -1,17 +1,15 @@
import QRCodeStyling from "qr-code-styling";
-import {useEffect, useRef} from "react";
+import { useEffect, useRef } from "react";
export default function QrCode(props) {
const qrRef = useRef();
- const link = props.link;
-
+
useEffect(() => {
- console.log("Showing QR: ", link);
- if (link?.length > 0) {
+ if (props.data?.length > 0) {
let qr = new QRCodeStyling({
width: props.width || 256,
height: props.height || 256,
- data: link,
+ data: props.data,
margin: 5,
type: 'canvas',
image: props.avatar,
@@ -27,15 +25,17 @@ export default function QrCode(props) {
});
qrRef.current.innerHTML = "";
qr.append(qrRef.current);
- qrRef.current.onclick = function (e) {
- let elm = document.createElement("a");
- elm.href = `lightning:${link}`;
- elm.click();
+ if (props.link) {
+ qrRef.current.onclick = function (e) {
+ let elm = document.createElement("a");
+ elm.href = props.link;
+ elm.click();
+ }
}
} else {
qrRef.current.innerHTML = "";
}
- }, [link]);
+ }, [props.data, props.link]);
return (