diff --git a/src/element/Invoice.js b/src/element/Invoice.js index f96a7b0ba..cba16ab87 100644 --- a/src/element/Invoice.js +++ b/src/element/Invoice.js @@ -1,15 +1,18 @@ import "./Invoice.css"; +import { useState } from "react"; import { decode as invoiceDecode } from "light-bolt11-decoder"; import { useMemo } from "react"; import NoteTime from "./NoteTime"; +import QrCode from "./QrCode"; export default function Invoice(props) { const invoice = props.invoice; + const [showLnQr, setShowLnQr] = useState(false); const info = useMemo(() => { try { let parsed = invoiceDecode(invoice); - + let amount = parseInt(parsed.sections.find(a => a.name === "amount")?.value); let timestamp = parseInt(parsed.sections.find(a => a.name === "timestamp")?.value); let expire = parseInt(parsed.sections.find(a => a.name === "expiry")?.value); @@ -34,15 +37,28 @@ export default function Invoice(props) { <>

⚡️ Invoice for {info?.amount?.toLocaleString()} sats

{info?.description}

+ { showLnQr ?

: null } ) } else { return ( + <>

⚡️ Invoice for {info?.amount?.toLocaleString()} sats

+ { showLnQr ?

: null } + ) } } + function pay(){ + return ( + <> + { showLnQr ?
window.open(`lightning:${invoice}`)}>Pay
: +
setShowLnQr(true)}>Pay
} + + ) + } + return (
@@ -51,8 +67,7 @@ export default function Invoice(props) { {info?.expire ? {info?.expired ? "Expired" : "Expires"} : null}
- {info?.expired ?
Expired
: -
window.open(`lightning:${invoice}`)}>Pay
} + {info?.expired ?
Expired
: pay() } ) } \ No newline at end of file