stacker.news/components/fund-error.js

27 lines
971 B
JavaScript
Raw Normal View History

2021-05-20 21:32:59 +00:00
import Link from 'next/link'
2023-07-24 18:35:05 +00:00
import Button from 'react-bootstrap/Button'
2023-08-09 23:45:59 +00:00
import { useInvoiceable } from './invoice'
2021-05-20 21:32:59 +00:00
export default function FundError ({ onClose, amount, onPayment }) {
2023-08-09 23:45:59 +00:00
const createInvoice = useInvoiceable(onPayment, { forceInvoice: true })
2021-05-20 21:32:59 +00:00
return (
<>
2023-08-11 22:02:53 +00:00
<p className='fw-bolder text-center'>you need more sats</p>
<div className='d-flex pb-3 pt-2 justify-content-center'>
<Link href='/wallet?type=fund'>
<Button variant='success' onClick={onClose}>fund wallet</Button>
</Link>
2023-08-11 22:02:53 +00:00
<span className='d-flex mx-3 fw-bold text-muted align-items-center'>or</span>
2023-08-09 23:45:59 +00:00
<Button variant='success' onClick={() => createInvoice(amount)}>pay invoice</Button>
</div>
</>
2021-05-20 21:32:59 +00:00
)
}
2023-08-09 23:45:59 +00:00
export const isInsufficientFundsError = (error) => {
if (Array.isArray(error)) {
return error.some(({ message }) => message.includes('insufficient funds'))
}
return error.toString().includes('insufficient funds')
}