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.

payoutMethodId

Steven Tey58397c2c558d
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts
index 6dca23c2ac..c1124c8c3d 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts
@@ -64,6 +64,8 @@ const payoutInvoices = async (workspaceId: string) => {
id: true,
total: true,
createdAt: true,
+ receiptUrl: true,
+ status: true,
},
orderBy: {
createdAt: "desc",
@@ -73,7 +75,7 @@ const payoutInvoices = async (workspaceId: string) => {
return invoices.map((invoice) => {
return {
...invoice,
- pdfUrl: null,
+ pdfUrl: invoice.receiptUrl,
};
});
};
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 50148dc4ad..134989413a 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
@@ -1,8 +1,17 @@
"use client";
+import useWorkspace from "@/lib/swr/use-workspace";
import { InvoiceProps } from "@/lib/types";
+import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { buttonVariants, Receipt2, useRouterStuff } from "@dub/ui";
+import {
+ buttonVariants,
+ InvoiceDollar,
+ Receipt2,
+ StatusBadge,
+ TabSelect,
+ useRouterStuff,
+} from "@dub/ui";
import { cn, fetcher } from "@dub/utils";
import { ChevronLeft } from "lucide-react";
import Link from "next/link";
@@ -11,7 +20,8 @@ import useSWR from "swr";
export default function WorkspaceInvoicesClient() {
const { slug } = useParams();
- const { searchParams } = useRouterStuff();
+ const { payoutMethodId } = useWorkspace();
+ const { searchParams, queryParams } = useRouterStuff();
const invoiceType = searchParams.get("type") || "subscription";
@@ -22,8 +32,8 @@ export default function WorkspaceInvoicesClient() {
return (
<div className="rounded-lg border border-neutral-200 bg-white">
- <div className="flex flex-col items-start justify-between gap-y-4 p-6 md:p-8 xl:flex-row">
- <div className="flex items-center gap-4">
+ <div className="flex flex-col items-start justify-between gap-y-4 p-4 md:pt-6 xl:flex-row">
+ <div className="flex items-center gap-2">
<Link
href={`/${slug}/settings/billing`}
className="rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"
@@ -38,7 +48,24 @@ export default function WorkspaceInvoicesClient() {
</div>
</div>
</div>
- <div className="grid divide-y divide-neutral-200 border-t border-neutral-200 p-4">
+ {payoutMethodId && (
+ <TabSelect
+ className="px-4 sm:px-10"
+ options={[
+ { id: "subscription", label: "Subscription" },
+ { id: "payout", label: "Payout" },
+ ]}
+ selected={invoiceType}
+ onSelect={(id) => {
+ queryParams({
+ set: {
+ type: id,
+ },
+ });
+ }}
+ />
+ )}
+ <div className="grid divide-y divide-neutral-200 border-t border-neutral-200">
{invoices ? (
invoices.length > 0 ? (
invoices.map((invoice) => (
@@ -71,7 +98,7 @@ export default function WorkspaceInvoicesClient() {
const InvoiceCard = ({ invoice }: { invoice: InvoiceProps }) => {
return (
- <div className="grid grid-cols-3 gap-4 p-4">
+ <div className="grid grid-cols-3 gap-4 px-6 py-4 sm:px-12">
<div className="text-sm">
<div className="font-medium">{invoice.description}</div>
<div className="text-neutral-500">
@@ -85,24 +112,37 @@ const InvoiceCard = ({ invoice }: { invoice: InvoiceProps }) => {
<div className="text-left text-sm">
<div className="font-medium">Total</div>
- <div className="text-neutral-500">
- ${(invoice.total / 100).toFixed(2)}
+ <div className="flex items-center gap-1.5 text-neutral-500">
+ <span className="text-sm">${(invoice.total / 100).toFixed(2)}</span>
+ {invoice.status &&
+ (() => {
+ const badge = PayoutStatusBadges[invoice.status];
+ return (
+ <StatusBadge
+ icon={null}
+ variant={badge.variant}
+ className="rounded-full py-0.5"
+ >
+ {badge.label}
+ </StatusBadge>
+ );
+ })()}
</div>
</div>
- <div className="flex justify-end">
+ <div className="flex items-center justify-end">
<a
href={invoice.pdfUrl || "#"}
target="_blank"
download
className={cn(
buttonVariants({ variant: "secondary" }),
- "flex h-10 items-center rounded-md border px-4 text-sm",
- !invoice.pdfUrl && "pointer-events-none opacity-50",
+ "flex size-8 items-center justify-center rounded-md border text-sm sm:size-auto sm:h-9 sm:px-3",
)}
- title={invoice.pdfUrl ? "View invoice" : "Not available"}
+ title="View invoice"
>
- View invoice
+ <p className="hidden sm:block">View invoice</p>
+ <InvoiceDollar className="size-4 sm:hidden" />
</a>
</div>
</div>
@@ -111,7 +151,7 @@ const InvoiceCard = ({ invoice }: { invoice: InvoiceProps }) => {
const InvoiceCardSkeleton = () => {
return (
- <div className="flex items-center justify-between p-4">
+ <div className="flex items-center justify-between px-6 py-4 sm:px-12">
<div className="flex flex-col gap-1 text-sm">
<div className="h-4 w-32 animate-pulse rounded-md bg-neutral-200" />
<div className="h-4 w-24 animate-pulse rounded-md bg-neutral-200" />
diff --git a/apps/web/lib/zod/schemas/invoices.ts b/apps/web/lib/zod/schemas/invoices.ts
index 52a7ae653d..09dbcae7eb 100644
--- a/apps/web/lib/zod/schemas/invoices.ts
+++ b/apps/web/lib/zod/schemas/invoices.ts
@@ -1,8 +1,10 @@
import z from "@/lib/zod";
+import { InvoiceStatus } from "@prisma/client";
export const InvoiceSchema = z.object({
id: z.string(),
total: z.number(),
+ status: z.nativeEnum(InvoiceStatus).optional(),
createdAt: z.date(),
description: z.string().default("Dub payout"),
pdfUrl: z.string().nullable(),
diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.ts
index d3292cb6ef..632daf7299 100644
--- a/apps/web/lib/zod/schemas/workspaces.ts
+++ b/apps/web/lib/zod/schemas/workspaces.ts
@@ -44,6 +44,12 @@ export const WorkspaceSchema = z
.describe(
"[BETA – Dub Conversions]: The Stripe Connect ID of the workspace.",
),
+ payoutMethodId: z
+ .string()
+ .nullable()
+ .describe(
+ "[BETA – Dub Partners]: The ID of the payment method for partner payouts.",
+ ),
usage: z.number().describe("The usage of the workspace."),
usageLimit: z.number().describe("The usage limit of the workspace."),
@@ -101,27 +107,6 @@ export const WorkspaceSchema = z
.describe(
"The feature flags of the workspace, indicating which features are enabled.",
),
- bankAccountName: z
- .string()
- .nullable()
- .describe(
- "[BETA – Dub Partners]: The name of the connected bank account.",
- ),
- partialAccountNumber: z
- .string()
- .nullable()
- .describe(
- "[BETA – Dub Partners]: The partial account number of the bank account.",
- ),
- routingNumber: z
- .string()
- .nullable()
- .describe(
- "[BETA – Dub Partners]: The routing number of the bank account.",
- ),
- bankAccountVerified: z
- .boolean()
- .describe("[BETA – Dub Partners]: Whether the bank account is verified."),
})
.openapi({
title: "Workspace",