66 Table ,
77 TableBody ,
88 TableCell ,
9+ TableContainer ,
910 TableHead ,
1011 TableHeader ,
1112 TableRow ,
@@ -26,7 +27,6 @@ export function BillingHistory(props: {
2627 invoices : Stripe . Invoice [ ] ;
2728 hasMore : boolean ;
2829} ) {
29- console . log ( props . invoices . map ( ( i ) => i . id ) ) ;
3030 const [ isLoading , startTransition ] = useTransition ( ) ;
3131 const [ cursor , setCursor ] = useQueryState (
3232 "cursor" ,
@@ -55,24 +55,13 @@ export function BillingHistory(props: {
5555 const getStatusBadge = ( invoice : Stripe . Invoice ) => {
5656 switch ( invoice . status ) {
5757 case "paid" :
58- return (
59- < Badge className = "bg-green-100 text-green-800 hover:bg-green-100" >
60- Paid
61- </ Badge >
62- ) ;
58+ return < Badge variant = "success" > Paid</ Badge > ;
6359 case "open" :
6460 // we treate "uncollectible" as unpaid
6561 case "uncollectible" : {
6662 // if the invoice due date is in the past, we want to display it as past due
6763 if ( invoice . due_date && invoice . due_date < Date . now ( ) ) {
68- return (
69- < Badge
70- variant = "outline"
71- className = "border-red-200 bg-red-50 text-red-800"
72- >
73- Past Due
74- </ Badge >
75- ) ;
64+ return < Badge variant = "destructive" > Past Due</ Badge > ;
7665 }
7766 return < Badge variant = "outline" > Open</ Badge > ;
7867 }
@@ -96,9 +85,11 @@ export function BillingHistory(props: {
9685 ) ;
9786 }
9887
88+ const showPagination = props . hasMore || cursor ;
89+
9990 return (
10091 < div >
101- < div className = "overflow-x-auto " >
92+ < TableContainer className = "rounded-none border-x-0 border-b-0 " >
10293 < Table >
10394 < TableHeader >
10495 < TableRow >
@@ -130,7 +121,7 @@ export function BillingHistory(props: {
130121 target = "_blank"
131122 rel = "noopener noreferrer"
132123 >
133- < CreditCard className = "mr-2 h-4 w-4" />
124+ < CreditCard className = "mr-2 h-4 w-4 text-muted-foreground " />
134125 Pay Now
135126 </ a >
136127 </ Button >
@@ -143,7 +134,7 @@ export function BillingHistory(props: {
143134 target = "_blank"
144135 rel = "noopener noreferrer"
145136 >
146- < Download className = "mr-2 h-4 w-4" />
137+ < Download className = "mr-2 h-4 w-4 text-muted-foreground " />
147138 PDF
148139 </ a >
149140 </ Button >
@@ -154,47 +145,47 @@ export function BillingHistory(props: {
154145 ) ) }
155146 </ TableBody >
156147 </ Table >
157- </ div >
148+ </ TableContainer >
158149
159- { /* Pagination Controls */ }
160- < hr className = "my-4" / >
161- < div className = "flex items-center justify-between" >
162- < Button
163- variant = "outline "
164- size = "sm"
165- onClick = { ( ) => {
166- // use browser history to go back
167- // this is KINDA hacky but it works (as long as the user doesn't send the URL to someone else...)
168- window . history . back ( ) ;
169- } }
170- disabled = { isLoading || ! cursor }
171- >
172- { isLoading ? (
173- < div className = "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
174- ) : (
175- < ChevronLeftIcon className = "mr-2 h-4 w-4" />
176- ) }
177- Previous
178- </ Button >
179- < Button
180- variant = "outline "
181- size = "sm"
182- onClick = { ( ) => {
183- const lastInvoice = props . invoices [ props . invoices . length - 1 ] ;
184- if ( lastInvoice && props . hasMore ) {
185- setCursor ( lastInvoice . id ) ;
186- }
187- } }
188- disabled = { ! props . hasMore || isLoading }
189- >
190- Next
191- { isLoading && props . hasMore ? (
192- < div className = "ml-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
193- ) : (
194- < ChevronRight className = "ml-2 h-4 w-4" />
195- ) }
196- </ Button >
197- </ div >
150+ { showPagination && (
151+ < div className = "flex items-center justify-between border-t p-6" >
152+ < Button
153+ variant = "outline"
154+ size = "sm "
155+ onClick = { ( ) => {
156+ // use browser history to go back
157+ // this is KINDA hacky but it works (as long as the user doesn't send the URL to someone else...)
158+ window . history . back ( ) ;
159+ } }
160+ disabled = { isLoading || ! cursor }
161+ >
162+ { isLoading ? (
163+ < div className = "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
164+ ) : (
165+ < ChevronLeftIcon className = "mr-2 h-4 w-4" />
166+ ) }
167+ Previous
168+ </ Button >
169+ < Button
170+ variant = "outline"
171+ size = "sm "
172+ onClick = { ( ) => {
173+ const lastInvoice = props . invoices [ props . invoices . length - 1 ] ;
174+ if ( lastInvoice && props . hasMore ) {
175+ setCursor ( lastInvoice . id ) ;
176+ }
177+ } }
178+ disabled = { ! props . hasMore || isLoading }
179+ >
180+ Next
181+ { isLoading && props . hasMore ? (
182+ < div className = "ml-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
183+ ) : (
184+ < ChevronRight className = "ml-2 h-4 w-4" />
185+ ) }
186+ </ Button >
187+ </ div >
188+ ) }
198189 </ div >
199190 ) ;
200191}
0 commit comments