import "./Invoice.css"; import { useState } from "react"; import { useIntl, FormattedMessage } from "react-intl"; import { useMemo } from "react"; import SendSats from "Element/SendSats"; import Icon from "Icons/Icon"; import { useWallet } from "Wallet"; import { decodeInvoice } from "Util"; import messages from "./messages"; export interface InvoiceProps { invoice: string; } export default function Invoice(props: InvoiceProps) { const invoice = props.invoice; const { formatMessage } = useIntl(); const [showInvoice, setShowInvoice] = useState(false); const walletState = useWallet(); const wallet = walletState.wallet; const info = useMemo(() => decodeInvoice(invoice), [invoice]); const [isPaid, setIsPaid] = useState(false); const isExpired = info?.expired; const amount = info?.amount ?? 0; const description = info?.description; function header() { return ( <>
{amount > 0 && ( <> {(amount / 1_000).toLocaleString()} sat{amount === 1_000 ? "" : "s"} > )}
{description}
} {isPaid ? (