Handle if invoice is null

This commit is contained in:
Joshen Lim committed 2022-03-27 14:44:33 +08:00
1 parent d183d2b5d9
commit 86f3c8d2cf
2 files changed
+16 -2

No files matched your search

@@ -74,7 +74,14 @@ const Invoices: FC<Props> = ({ projectRef }) => {
const fetchInvoice = async (invoiceId: string) => {
const invoice = await get(`${API_URL}/stripe/invoices/${invoiceId}`)
window.open(invoice.invoice_pdf, '_blank')
if (invoice?.invoice_pdf) {
window.open(invoice.invoice_pdf, '_blank')
} else {
ui.setNotification({
category: 'info',
message: 'Unable to fetch the selected invoice',
})
}
}
return (
@@ -81,7 +81,14 @@ const InvoicesSettings: FC<Props> = ({ organization }) => {
const fetchInvoice = async (invoiceId: string) => {
const invoice = await get(`${API_URL}/stripe/invoices/${invoiceId}`)
window.open(invoice.invoice_pdf, '_blank')
if (invoice?.invoice_pdf) {
window.open(invoice.invoice_pdf, '_blank')
} else {
ui.setNotification({
category: 'info',
message: 'Unable to fetch the selected invoice',
})
}
}
return (