Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix the log and disable the button

Kiran K8adc169fb4e2
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx
index 1919393522..e46202d616 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx
+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx
@@ -2,15 +2,20 @@ import { DubApiError } from "@/lib/api/errors";
import { withWorkspace } from "@/lib/auth";
import { stripe } from "@/lib/stripe";
import { prisma } from "@dub/prisma";
-import { capitalize, currencyFormatter, formatDate } from "@dub/utils";
+import {
+ capitalize,
+ currencyFormatter,
+ DUB_WORDMARK,
+ formatDate,
+} from "@dub/utils";
import {
Document,
Image,
Link,
Page,
+ renderToBuffer,
Text,
View,
- renderToBuffer,
} from "@react-pdf/renderer";
import { createTw } from "react-pdf-tailwind";
import Stripe from "stripe";
@@ -152,10 +157,7 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
<Document>
<Page size="A4" style={tw("p-20 font-sans")}>
<View style={tw("flex-row justify-between items-center mb-10")}>
- <Image
- src="https://dubassets.com/logos/clrei1gld0002vs9mzn93p8ik_384uSfo"
- style={tw("w-12 h-12")}
- />
+ <Image src={DUB_WORDMARK} style={tw("w-20 h-10")} />
<View style={tw("text-right w-1/2")}>
<Text style={tw("text-sm font-medium text-neutral-800")}>
Dub Technologies Inc.
@@ -264,7 +266,7 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
<View
key={index}
style={tw(
- `flex-row text-sm font-medium text-neutral-700 border-neutral-200 ${index + 1 === invoice.payouts.length ? "" : "border-b"}`,
+ `flex-row text-sm font-medium text-neutral-700 border-neutral-200 items-center ${index + 1 === invoice.payouts.length ? "" : "border-b"}`,
)}
>
<View style={tw("flex-row items-center gap-2 w-2/6 p-3.5")}>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/invoices/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/invoices/page-client.tsx
index 4b9e5bf577..7a861c15c1 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/invoices/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/invoices/page-client.tsx
@@ -5,6 +5,7 @@ import { InvoiceProps } from "@/lib/types";
import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
import {
+ Button,
buttonVariants,
InvoiceDollar,
Receipt2,
@@ -135,19 +136,29 @@ const InvoiceCard = ({ invoice }: { invoice: InvoiceProps }) => {
</div>
<div className="flex items-center justify-end">
- <a
- href={invoice.pdfUrl || "#"}
- target="_blank"
- download
- className={cn(
- buttonVariants({ variant: "secondary" }),
- "flex size-8 items-center justify-center rounded-md border text-sm sm:size-auto sm:h-9 sm:px-3",
- )}
- title="View invoice"
- >
- <p className="hidden sm:block">View invoice</p>
- <InvoiceDollar className="size-4 sm:hidden" />
- </a>
+ {invoice.pdfUrl ? (
+ <a
+ href={invoice.pdfUrl}
+ target="_blank"
+ download
+ className={cn(
+ buttonVariants({ variant: "secondary" }),
+ "flex size-8 items-center justify-center rounded-md border text-sm sm:size-auto sm:h-9 sm:px-3",
+ )}
+ title="View invoice"
+ >
+ <p className="hidden sm:block">View invoice</p>
+ <InvoiceDollar className="size-4 sm:hidden" />
+ </a>
+ ) : (
+ <Button
+ className="w-fit"
+ variant="secondary"
+ text="View invoice"
+ disabled
+ disabledTooltip="PDF will be available shortly after the payment is processed by Stripe."
+ />
+ )}
</div>
</div>
);
diff --git a/apps/web/lib/actions/partners/confirm-payouts.ts b/apps/web/lib/actions/partners/confirm-payouts.ts
index f222acb414..b875e0a69e 100644
--- a/apps/web/lib/actions/partners/confirm-payouts.ts
+++ b/apps/web/lib/actions/partners/confirm-payouts.ts
@@ -138,34 +138,3 @@ export const confirmPayoutsAction = authActionClient
};
});
});
-
-// Get the next invoice number for the given workspace
-const nextInvoiceNumber = async ({
- workspaceId,
- invoicePrefix,
-}: {
- workspaceId: string;
- invoicePrefix: string;
-}) => {
- const lastInvoice = await prisma.invoice.findFirst({
- where: {
- workspaceId,
- },
- select: {
- number: true,
- },
- orderBy: {
- createdAt: "desc",
- },
- });
-
- if (!lastInvoice) {
- return `${invoicePrefix}-1`;
- }
-
- const [_, number] = lastInvoice.number?.split("-") ?? [];
-
- const newNumber = parseInt(number) + 1;
-
- return `${invoicePrefix}-${newNumber}`;
-};