@@ -25,6 +25,31 @@ import { ToolTipLabel } from "@/components/ui/tooltip";
2525import { ThirdwebMiniLogo } from "../../../../../../../components/ThirdwebMiniLogo" ;
2626import { searchParams } from "../search-params" ;
2727
28+ function getStatusBadge ( invoice : Stripe . Invoice ) {
29+ switch ( invoice . status ) {
30+ case "paid" :
31+ return < Badge variant = "success" > Paid</ Badge > ;
32+ case "open" :
33+ // we treate "uncollectible" as unpaid
34+ case "uncollectible" : {
35+ // if the invoice due date is in the past, we want to display it as past due
36+ if ( invoice . due_date && invoice . due_date < Date . now ( ) ) {
37+ return < Badge variant = "destructive" > Past Due</ Badge > ;
38+ }
39+ return < Badge variant = "outline" > Open</ Badge > ;
40+ }
41+ case "void" :
42+ return < Badge variant = "secondary" > Void</ Badge > ;
43+
44+ default :
45+ return < Badge variant = "outline" > Unknown</ Badge > ;
46+ }
47+ }
48+
49+ function isInvoicePayable ( invoice : Stripe . Invoice ) {
50+ return invoice . status === "open" || invoice . status === "uncollectible" ;
51+ }
52+
2853export function BillingHistory ( props : {
2954 teamSlug : string ;
3055 invoices : Stripe . Invoice [ ] ;
@@ -57,27 +82,6 @@ export function BillingHistory(props: {
5782 } ) ;
5883 } ;
5984
60- const getStatusBadge = ( invoice : Stripe . Invoice ) => {
61- switch ( invoice . status ) {
62- case "paid" :
63- return < Badge variant = "success" > Paid</ Badge > ;
64- case "open" :
65- // we treate "uncollectible" as unpaid
66- case "uncollectible" : {
67- // if the invoice due date is in the past, we want to display it as past due
68- if ( invoice . due_date && invoice . due_date * 1000 < Date . now ( ) ) {
69- return < Badge variant = "destructive" > Past Due</ Badge > ;
70- }
71- return < Badge variant = "outline" > Open</ Badge > ;
72- }
73- case "void" :
74- return < Badge variant = "secondary" > Void</ Badge > ;
75-
76- default :
77- return < Badge variant = "outline" > Unknown</ Badge > ;
78- }
79- } ;
80-
8185 if ( props . invoices . length === 0 ) {
8286 if ( props . status === "open" ) {
8387 return (
@@ -126,7 +130,7 @@ export function BillingHistory(props: {
126130 < TableCell > { getStatusBadge ( invoice ) } </ TableCell >
127131 < TableCell className = "text-right" >
128132 < div className = "flex justify-end space-x-2" >
129- { invoice . status === "open" && (
133+ { isInvoicePayable ( invoice ) && (
130134 < >
131135 { /* always show the crypto payment button */ }
132136 < ToolTipLabel
0 commit comments