🐛 (billing) Fix crash when having a draft invoice
This commit is contained in:
@ -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}
|
||||||
|
@ -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,27 +45,33 @@ export const InvoicesList = ({ workspace }: Props) => {
|
|||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
<Tbody>
|
<Tbody>
|
||||||
{invoices?.map((invoice) => (
|
{invoices
|
||||||
<Tr key={invoice.id}>
|
?.filter((invoice) => isDefined(invoice.url))
|
||||||
<Td>
|
.map((invoice) => (
|
||||||
<FileIcon />
|
<Tr key={invoice.id}>
|
||||||
</Td>
|
<Td>
|
||||||
<Td>{invoice.id}</Td>
|
<FileIcon />
|
||||||
<Td>{new Date(invoice.date * 1000).toDateString()}</Td>
|
</Td>
|
||||||
<Td>{getFormattedPrice(invoice.amount, invoice.currency)}</Td>
|
<Td>{invoice.id}</Td>
|
||||||
<Td>
|
<Td>{new Date(invoice.date * 1000).toDateString()}</Td>
|
||||||
<IconButton
|
<Td>
|
||||||
as={Link}
|
{getFormattedPrice(invoice.amount, invoice.currency)}
|
||||||
size="xs"
|
</Td>
|
||||||
icon={<DownloadIcon />}
|
<Td>
|
||||||
variant="outline"
|
{invoice.url && (
|
||||||
href={invoice.url}
|
<IconButton
|
||||||
target="_blank"
|
as={Link}
|
||||||
aria-label={'Download invoice'}
|
size="xs"
|
||||||
/>
|
icon={<DownloadIcon />}
|
||||||
</Td>
|
variant="outline"
|
||||||
</Tr>
|
href={invoice.url}
|
||||||
))}
|
target="_blank"
|
||||||
|
aria-label={'Download invoice'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Td>
|
||||||
|
</Tr>
|
||||||
|
))}
|
||||||
{isLoading &&
|
{isLoading &&
|
||||||
Array.from({ length: 3 }).map((_, idx) => (
|
Array.from({ length: 3 }).map((_, idx) => (
|
||||||
<Tr key={idx}>
|
<Tr key={idx}>
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user