From 2b1211083a0c8aa84ed105733045a60a7404b581 Mon Sep 17 00:00:00 2001 From: Collin Schaafsma Date: Sun, 27 Oct 2024 12:26:30 -0600 Subject: [PATCH] update components to use stripe api naming conventions --- .../account/_components/invoice-card.tsx | 128 ++---------------- .../_components/recent-transactions-card.tsx | 4 +- services/analytic.ts | 2 +- 3 files changed, 11 insertions(+), 123 deletions(-) diff --git a/app/(app)/account/_components/invoice-card.tsx b/app/(app)/account/_components/invoice-card.tsx index 7182b02..0ddbd62 100644 --- a/app/(app)/account/_components/invoice-card.tsx +++ b/app/(app)/account/_components/invoice-card.tsx @@ -1,22 +1,12 @@ import { Suspense } from "react" -import Link from "next/link" -import { - ChevronLeftIcon, - ChevronRightIcon, - ChevronsLeftIcon, - ChevronsRightIcon, - ExternalLink, -} from "lucide-react" +import { ExternalLink } from "lucide-react" import { currentUser } from "@/services/currentUser" -import { invoicesLimit } from "@/lib/constants" -import { centsToCurrency, cn } from "@/lib/utils" +import { centsToCurrency } from "@/lib/utils" import { Badge } from "@/components/ui/badge" -import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, - CardFooter, CardHeader, CardTitle, } from "@/components/ui/card" @@ -80,17 +70,19 @@ async function LoadInvoiceTableRows({ page }: Readonly<{ page: number }>) {
- {invoice.invoiceNumber} + {invoice.number}
- {invoice.created.toLocaleDateString()} - {centsToCurrency(invoice.amountPaid)} + + {new Date(invoice.created).toLocaleDateString()} + + {centsToCurrency(invoice.amount_paid)} {invoice.status} @@ -100,103 +92,6 @@ async function LoadInvoiceTableRows({ page }: Readonly<{ page: number }>) { ) } -async function LoadPagination({ page }: Readonly<{ page: number }>) { - const user = await currentUser.invoicesTotal() - - if (!user?.invoicesTotal) { - return null - } - - const totalPages = Math.ceil(user.invoicesTotal / invoicesLimit) - const firstPageDisabled = page === 1 - const lastPageDisabled = totalPages === page - const previousPageDisabled = page === 1 - const nextPageDisabled = totalPages === page - const nextPage = page + 1 - const previousPage = page - 1 - - if (totalPages <= 1) { - return null - } - - return ( -
- - - - -
- ) -} - export function InvoiceCard({ page }: Readonly<{ page: number }>) { return ( @@ -221,13 +116,6 @@ export function InvoiceCard({ page }: Readonly<{ page: number }>) { - - - - - - - ) } diff --git a/app/(app)/dashboard/_components/recent-transactions-card.tsx b/app/(app)/dashboard/_components/recent-transactions-card.tsx index 0e68657..e71df0e 100644 --- a/app/(app)/dashboard/_components/recent-transactions-card.tsx +++ b/app/(app)/dashboard/_components/recent-transactions-card.tsx @@ -39,9 +39,9 @@ async function LoadRecentTransactions() { {recentTransactions.map(transaction => ( - {transaction.user.email} + {transaction.customer_email} - ${transaction.amountPaid / 100} + ${transaction.amount_paid / 100} {transaction.status} ))} diff --git a/services/analytic.ts b/services/analytic.ts index 317f1ec..18b1c36 100644 --- a/services/analytic.ts +++ b/services/analytic.ts @@ -203,7 +203,7 @@ export const analytic = { gross: cache(async (range: { from: Date; to: Date }) => { const invoices = await invoice.list({ range }) const gross = invoices.reduce((acc, invoice) => { - return acc + invoice.amountPaid + return acc + invoice.amount_paid }, 0) // convert from cents to dollars with 2 decimal places