Skip to content

Commit e5ad4e1

Browse files
committed
Dashboard: Team invoices page style tweaks
1 parent 309d1d5 commit e5ad4e1

File tree

2 files changed

+58
-74
lines changed

2 files changed

+58
-74
lines changed

apps/dashboard/src/app/team/[team_slug]/(team)/~/settings/invoices/components/billing-history.tsx

Lines changed: 48 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
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
}

apps/dashboard/src/app/team/[team_slug]/(team)/~/settings/invoices/page.tsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import { getTeamInvoices } from "@/actions/stripe-actions";
22
import { getTeamBySlug } from "@/api/team";
3-
import {
4-
Card,
5-
CardContent,
6-
CardDescription,
7-
CardHeader,
8-
CardTitle,
9-
} from "@/components/ui/card";
103
import { redirect } from "next/navigation";
114
import type { SearchParams } from "nuqs/server";
125
import { getValidAccount } from "../../../../../../account/settings/getAccount";
@@ -41,16 +34,16 @@ export default async function Page(props: {
4134
});
4235

4336
return (
44-
<Card>
45-
<CardHeader>
46-
<CardTitle>Invoice History</CardTitle>
47-
<CardDescription className="mt-2">
37+
<div className="overflow-hidden rounded-lg border bg-card">
38+
<div className="p-6">
39+
<h2 className="font-semibold text-2xl leading-none tracking-tight">
40+
Invoice History
41+
</h2>
42+
<p className="mt-1 text-muted-foreground text-sm">
4843
View your past invoices and payment history
49-
</CardDescription>
50-
</CardHeader>
51-
<CardContent>
52-
<BillingHistory invoices={invoices.data} hasMore={invoices.has_more} />
53-
</CardContent>
54-
</Card>
44+
</p>
45+
</div>
46+
<BillingHistory invoices={invoices.data} hasMore={invoices.has_more} />
47+
</div>
5548
);
5649
}

0 commit comments

Comments
 (0)