stacker.news/components/invoice.js

19 lines
499 B
JavaScript
Raw Normal View History

2023-01-18 18:49:20 +00:00
import Qr from './qr'
2021-05-06 21:15:22 +00:00
export function Invoice ({ invoice }) {
2021-05-13 13:28:38 +00:00
let variant = 'default'
2021-05-11 15:52:50 +00:00
let status = 'waiting for you'
if (invoice.confirmedAt) {
2021-05-13 13:28:38 +00:00
variant = 'confirmed'
2022-11-15 20:51:55 +00:00
status = `${invoice.satsReceived} sats deposited`
2021-05-11 15:52:50 +00:00
} else if (invoice.cancelled) {
2021-05-13 13:28:38 +00:00
variant = 'failed'
2021-05-11 15:52:50 +00:00
status = 'cancelled'
} else if (invoice.expiresAt <= new Date()) {
2021-05-13 13:28:38 +00:00
variant = 'failed'
2021-05-11 15:52:50 +00:00
status = 'expired'
}
2021-05-06 21:15:22 +00:00
2023-01-18 18:49:20 +00:00
return <Qr webLn value={invoice.bolt11} statusVariant={variant} status={status} />
2021-05-06 21:15:22 +00:00
}