Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Handle if invoice is null

Joshen Lim86f3c8d2cfaf
diff --git a/studio/components/interfaces/Billing/Invoices.tsx b/studio/components/interfaces/Billing/Invoices.tsx
index 618aaba77ab..19ae2658c85 100644
--- a/studio/components/interfaces/Billing/Invoices.tsx
+++ b/studio/components/interfaces/Billing/Invoices.tsx
@@ -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 (
diff --git a/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx b/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
index c7267766955..a102f419d92 100644
--- a/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
+++ b/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
@@ -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 (