2
0

🐛 (billing) Fix crash when having a draft invoice

This commit is contained in:
Baptiste Arnaud
2023-02-16 16:24:56 +01:00
parent 44cb14d0cb
commit d805ea9c10
3 changed files with 30 additions and 23 deletions

View File

@@ -16,7 +16,7 @@ export const BillingContent = () => {
return ( return (
<Stack spacing="10" w="full"> <Stack spacing="10" w="full">
<UsageContent workspace={workspace} /> <UsageContent workspace={workspace} />
<Stack spacing="2"> <Stack spacing="4">
<CurrentSubscriptionContent <CurrentSubscriptionContent
plan={workspace.plan} plan={workspace.plan}
stripeId={workspace.stripeId} stripeId={workspace.stripeId}

View File

@@ -18,6 +18,7 @@ import { Workspace } from 'db'
import Link from 'next/link' import Link from 'next/link'
import React from 'react' import React from 'react'
import { useInvoicesQuery } from './queries/useInvoicesQuery' import { useInvoicesQuery } from './queries/useInvoicesQuery'
import { isDefined } from 'utils'
type Props = { type Props = {
workspace: Workspace workspace: Workspace
@@ -44,15 +45,20 @@ export const InvoicesList = ({ workspace }: Props) => {
</Tr> </Tr>
</Thead> </Thead>
<Tbody> <Tbody>
{invoices?.map((invoice) => ( {invoices
?.filter((invoice) => isDefined(invoice.url))
.map((invoice) => (
<Tr key={invoice.id}> <Tr key={invoice.id}>
<Td> <Td>
<FileIcon /> <FileIcon />
</Td> </Td>
<Td>{invoice.id}</Td> <Td>{invoice.id}</Td>
<Td>{new Date(invoice.date * 1000).toDateString()}</Td> <Td>{new Date(invoice.date * 1000).toDateString()}</Td>
<Td>{getFormattedPrice(invoice.amount, invoice.currency)}</Td>
<Td> <Td>
{getFormattedPrice(invoice.amount, invoice.currency)}
</Td>
<Td>
{invoice.url && (
<IconButton <IconButton
as={Link} as={Link}
size="xs" size="xs"
@@ -62,6 +68,7 @@ export const InvoicesList = ({ workspace }: Props) => {
target="_blank" target="_blank"
aria-label={'Download invoice'} aria-label={'Download invoice'}
/> />
)}
</Td> </Td>
</Tr> </Tr>
))} ))}

View File

@@ -4,7 +4,7 @@ import { env } from 'utils'
type Invoice = { type Invoice = {
id: string id: string
url: string url: string | null
date: number date: number
currency: string currency: string
amount: number amount: number