Bug fix pay invoice flow
This commit is contained in:
parent
eaab2e3e5d
commit
8230c99c80
@ -37,14 +37,14 @@ export default function Invoice(props) {
|
|||||||
<>
|
<>
|
||||||
<h4>⚡️ Invoice for {info?.amount?.toLocaleString()} sats</h4>
|
<h4>⚡️ Invoice for {info?.amount?.toLocaleString()} sats</h4>
|
||||||
<p>{info?.description}</p>
|
<p>{info?.description}</p>
|
||||||
{showInvoice && <LNURLTip lnInvoice={invoice} show={true} /> }
|
<LNURLTip invoice={invoice} show={showInvoice} onClose={() => setShowInvoice(false)} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h4>⚡️ Invoice for {info?.amount?.toLocaleString()} sats</h4>
|
<h4>⚡️ Invoice for {info?.amount?.toLocaleString()} sats</h4>
|
||||||
{showInvoice && <LNURLTip lnInvoice={invoice} show={true} /> }
|
<LNURLTip invoice={invoice} show={showInvoice} onClose={() => setShowInvoice(false)} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ export default function Invoice(props) {
|
|||||||
{info?.expire ? <small>{info?.expired ? "Expired" : "Expires"} <NoteTime from={info.expire * 1000} /></small> : null}
|
{info?.expire ? <small>{info?.expired ? "Expired" : "Expires"} <NoteTime from={info.expire * 1000} /></small> : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{info?.expired ? <div className="btn">Expired</div> : <div className="btn" onClick={(e) => setShowInvoice(true)}>Pay</div> }
|
{info?.expired ? <div className="btn">Expired</div> : <div className="btn" onClick={(e) => { e.stopPropagation(); setShowInvoice(true); }}>Pay</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
|
@ -9,25 +9,24 @@ export default function LNURLTip(props) {
|
|||||||
const onClose = props.onClose || (() => { });
|
const onClose = props.onClose || (() => { });
|
||||||
const service = props.svc;
|
const service = props.svc;
|
||||||
const show = props.show || false;
|
const show = props.show || false;
|
||||||
const lnInvoice = props.lnInvoice
|
|
||||||
const amounts = [50, 100, 500, 1_000, 5_000, 10_000];
|
const amounts = [50, 100, 500, 1_000, 5_000, 10_000];
|
||||||
const [payService, setPayService] = useState("");
|
const [payService, setPayService] = useState("");
|
||||||
const [amount, setAmount] = useState(0);
|
const [amount, setAmount] = useState(0);
|
||||||
const [customAmount, setCustomAmount] = useState(0);
|
const [customAmount, setCustomAmount] = useState(0);
|
||||||
const [invoice, setInvoice] = useState("");
|
const [invoice, setInvoice] = useState(null);
|
||||||
const [comment, setComment] = useState("");
|
const [comment, setComment] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [success, setSuccess] = useState(null);
|
const [success, setSuccess] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (show && !lnInvoice) {
|
if (show && invoice === null) {
|
||||||
loadService()
|
loadService()
|
||||||
.then(a => setPayService(a))
|
.then(a => setPayService(a))
|
||||||
.catch(() => setError("Failed to load LNURL service"));
|
.catch(() => setError("Failed to load LNURL service"));
|
||||||
} else {
|
} else {
|
||||||
setPayService("");
|
setPayService("");
|
||||||
setError("");
|
setError("");
|
||||||
setInvoice("");
|
setInvoice(props.invoice ? { pr: props.invoice } : null);
|
||||||
setAmount(0);
|
setAmount(0);
|
||||||
setComment("");
|
setComment("");
|
||||||
setSuccess(null);
|
setSuccess(null);
|
||||||
@ -58,7 +57,7 @@ export default function LNURLTip(props) {
|
|||||||
|
|
||||||
const selectAmount = (a) => {
|
const selectAmount = (a) => {
|
||||||
setError("");
|
setError("");
|
||||||
setInvoice("");
|
setInvoice(null);
|
||||||
setAmount(a);
|
setAmount(a);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -166,7 +165,7 @@ export default function LNURLTip(props) {
|
|||||||
|
|
||||||
function payInvoice() {
|
function payInvoice() {
|
||||||
if (success) return null;
|
if (success) return null;
|
||||||
const pr = lnInvoice ? lnInvoice : invoice.pr;
|
const pr = invoice?.pr;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="invoice">
|
<div className="invoice">
|
||||||
|
@ -10,7 +10,7 @@ export default function Modal(props) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal" onClick={(e) => onClose(e)}>
|
<div className="modal" onClick={(e) => { e.stopPropagation(); onClose(e); }}>
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user