Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/app/screens/ConfirmPayment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,26 @@ function ConfirmPayment() {
const paymentRequest = navState.args?.paymentRequest as string;
const invoice = lightningPayReq.decode(paymentRequest);

const amountSat =
invoice.satoshis || Number(invoice.millisatoshis) / 1000 || 0;

const navigate = useNavigate();
const auth = useAccount();

const [budget, setBudget] = useState(
((invoice.satoshis || 0) * 10).toString()
);
const [budget, setBudget] = useState((amountSat * 10).toString());
const [fiatAmount, setFiatAmount] = useState("");
const [fiatBudgetAmount, setFiatBudgetAmount] = useState("");

const formattedInvoiceSats = getFormattedSats(invoice.satoshis || 0);
const formattedInvoiceSats = getFormattedSats(amountSat);

useEffect(() => {
(async () => {
if (showFiat && invoice.satoshis) {
const res = await getFormattedFiat(invoice.satoshis);
if (showFiat && amountSat !== 0) {
const res = await getFormattedFiat(amountSat);
setFiatAmount(res);
}
})();
}, [invoice.satoshis, showFiat, getFormattedFiat]);
}, [amountSat, showFiat, getFormattedFiat]);

useEffect(() => {
(async () => {
Expand Down Expand Up @@ -150,7 +151,7 @@ function ConfirmPayment() {
<div className="my-4">
<div className="mb-4 p-4 shadow bg-white dark:bg-surface-02dp rounded-lg">
<PaymentSummary
amount={invoice.satoshis || "0"} // TODO: allow entering amount or do not allow zero-amount invoices
amount={amountSat} // TODO: allow entering amount or do not allow zero-amount invoices
fiatAmount={fiatAmount}
description={invoice.tagsObject.description}
/>
Expand Down
11 changes: 6 additions & 5 deletions src/app/screens/ConfirmPaymentAsync/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@ function ConfirmPaymentAsync() {
const navState = useNavigationState();
const paymentRequest = navState.args?.paymentRequest as string;
const invoice = lightningPayReq.decode(paymentRequest);

const amountSat =
invoice.satoshis || Number(invoice.millisatoshis) / 1000 || 0;
const navigate = useNavigate();

const [fiatAmount, setFiatAmount] = useState("");

useEffect(() => {
(async () => {
if (showFiat && invoice.satoshis) {
const res = await getFormattedFiat(invoice.satoshis);
if (showFiat && amountSat !== 0) {
const res = await getFormattedFiat(amountSat);
setFiatAmount(res);
}
})();
}, [invoice.satoshis, showFiat, getFormattedFiat]);
}, [amountSat, showFiat, getFormattedFiat]);

const [loading, setLoading] = useState(false);

Expand Down Expand Up @@ -99,7 +100,7 @@ function ConfirmPaymentAsync() {
<div className="my-4">
<div className="mb-4 p-4 shadow bg-white dark:bg-surface-02dp rounded-lg">
<PaymentSummary
amount={invoice.satoshis || "0"} // TODO: allow entering amount or do not allow zero-amount invoices
amount={amountSat} // TODO: allow entering amount or do not allow zero-amount invoices
fiatAmount={fiatAmount}
description={invoice.tagsObject.description}
/>
Expand Down