The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add stripe bank account details
Steven Tey911f1c1abae6
diff --git a/apps/web/app/api/partners/[partnerId]/payouts/settings/route.ts b/apps/web/app/api/partners/[partnerId]/payouts/settings/route.tsnew file mode 100644index 0000000000..548d4d620f--- /dev/null+++ b/apps/web/app/api/partners/[partnerId]/payouts/settings/route.ts@@ -0,0 +1,19 @@+import { withPartner } from "@/lib/auth/partner";+import { stripe } from "@/lib/stripe";+import { NextResponse } from "next/server";++// GET /api/partners/[partnerId]/payouts/settings+export const GET = withPartner(async ({ partner }) => {+ if (!partner.stripeConnectId) {+ return NextResponse.json({});+ }++ const externalAccounts = await stripe.accounts.listExternalAccounts(+ partner.stripeConnectId,+ {+ object: "bank_account",+ },+ );++ return NextResponse.json(externalAccounts.data[0]);+});diff --git a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page.tsx b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page.tsxindex 6ea2532cbe..7df5968c42 100644--- a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page.tsx+++ b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page.tsx@@ -1,13 +1,13 @@import { PageContent } from "@/ui/layout/page-content";import { MaxWidthWrapper } from "@dub/ui";-import { PayoutSettings } from "./payout-settings";+import { PayoutStatsAndSettings } from "./payout-stats-and-settings";import { PayoutTable } from "./payout-table";export default function PartnersPayoutsSettings() {return (<PageContent title="Payouts" hideReferButton><MaxWidthWrapper className="grid gap-4">- <PayoutSettings />+ <PayoutStatsAndSettings /><PayoutTable /></MaxWidthWrapper></PageContent>diff --git a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-settings.tsx b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-stats-and-settings.tsxsimilarity index 54%rename from apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-settings.tsxrename to apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-stats-and-settings.tsxindex 476084f60d..7267766d3b 100644--- a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-settings.tsx+++ b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-stats-and-settings.tsx@@ -3,16 +3,25 @@import usePartnerPayoutsCount from "@/lib/swr/use-partner-payouts-count";import usePartnerProfile from "@/lib/swr/use-partner-profile";import StripeConnectButton from "@/ui/partners/stripe-connect-button";+import { MatrixLines } from "@dub/ui";+import { fetcher } from "@dub/utils";import NumberFlow from "@number-flow/react";import { PayoutStatus } from "@prisma/client";+import { Stripe } from "stripe";+import useSWR from "swr";-export function PayoutSettings() {+export function PayoutStatsAndSettings() {const { partner } = usePartnerProfile();const { payoutsCount } = usePartnerPayoutsCount();+ const { data: bankAccount } = useSWR<Stripe.BankAccount>(+ partner?.id && `/api/partners/${partner.id}/payouts/settings`,+ fetcher,+ );+return (<div className="grid grid-cols-1 divide-neutral-200 rounded-lg border border-neutral-200 bg-neutral-50 max-sm:divide-y sm:grid-cols-2 sm:divide-x">- <div className="flex flex-col p-4">+ <div className="flex flex-col gap-1.5 p-4"><div className="flex justify-between gap-5"><div className="p-1"><div className="text-sm text-neutral-500">Upcoming payouts</div>@@ -25,22 +34,35 @@ export function PayoutSettings() {variant={partner?.payoutsEnabled ? "secondary" : "primary"}/></div>- <NumberFlow- className="mt-2 text-2xl text-neutral-800"- value={- (payoutsCount?.find((p) => p.status === PayoutStatus.pending)- ?.amount ?? 0) / 100- }- format={{- style: "currency",- currency: "USD",- // @ts-ignore – this is a valid option but TS is outdated- trailingZeroDisplay: "stripIfInteger",- }}- />+ <div className="flex items-end justify-between gap-5">+ <NumberFlow+ className="mt-2 text-2xl text-neutral-800"+ value={+ (payoutsCount?.find((p) => p.status === PayoutStatus.pending)+ ?.amount ?? 0) / 100+ }+ format={{+ style: "currency",+ currency: "USD",+ // @ts-ignore – this is a valid option but TS is outdated+ trailingZeroDisplay: "stripIfInteger",+ }}+ />+ {bankAccount && (+ <div className="text-sm">+ <p className="text-neutral-600">{bankAccount.bank_name}</p>+ <div className="flex items-center gap-1.5 font-mono text-gray-400">+ <MatrixLines className="size-3" />+ {bankAccount.routing_number}+ <MatrixLines className="size-3" />+ ••••{bankAccount.last4}+ </div>+ </div>+ )}+ </div></div>- <div className="flex flex-col p-4">+ <div className="flex flex-col gap-1.5 p-4"><div className="flex justify-between gap-5"><div className="p-1"><div className="text-sm text-neutral-500">Total payouts</div>diff --git a/packages/ui/src/icons/index.tsx b/packages/ui/src/icons/index.tsxindex a3ce4ac814..06306f275e 100644--- a/packages/ui/src/icons/index.tsx+++ b/packages/ui/src/icons/index.tsx@@ -7,6 +7,7 @@ import { ComponentType, SVGProps } from "react";export { default as Copy } from "./copy";export { default as ExpandingArrow } from "./expanding-arrow";export { default as Magic } from "./magic";+export * from "./matrix-lines";export { default as Photo } from "./photo";export { default as SortOrder } from "./sort-order";export { default as Success } from "./success";diff --git a/packages/ui/src/icons/matrix-lines.tsx b/packages/ui/src/icons/matrix-lines.tsxnew file mode 100644index 0000000000..a3ec063389--- /dev/null+++ b/packages/ui/src/icons/matrix-lines.tsx@@ -0,0 +1,37 @@+import { SVGProps } from "react";++export function MatrixLines(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="12"+ width="12"+ viewBox="0 0 12 12"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="M4.5 7.5L4.5 4.5"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ <path+ d="M7.75 4.5L7.75 1.5"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ <path+ d="M7.75 10.5L7.75 7.5"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ </g>+ </svg>+ );+}