The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update payment methods UI
Tim Wilsone6e7f1e5f2f8
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-method-types.ts b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-method-types.tsindex 9eb1fa4c20..8cef0321b9 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-method-types.ts+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-method-types.ts@@ -9,6 +9,7 @@ import {GreekTemple,StripeLink,} from "@dub/ui/icons";+import { capitalize } from "@dub/utils";import { Stripe } from "stripe";export const PaymentMethodTypesList = (paymentMethod?: Stripe.PaymentMethod) =>@@ -25,7 +26,7 @@ export const PaymentMethodTypesList = (paymentMethod?: Stripe.PaymentMethod) =>}[paymentMethod?.card.brand] ?? CreditCard: CreditCard,description: paymentMethod?.card- ? `Connected ${paymentMethod.card.brand} ***${paymentMethod.card.last4}`+ ? `Connected ${capitalize(paymentMethod.card.brand)} ***${paymentMethod.card.last4}`: "No card connected",iconBgColor: "bg-neutral-100",},@@ -34,15 +35,16 @@ export const PaymentMethodTypesList = (paymentMethod?: Stripe.PaymentMethod) =>title: "ACH",icon: GreekTemple,description: paymentMethod?.us_bank_account- ? `Connected ${paymentMethod.us_bank_account.account_holder_type} account ending in ${paymentMethod.us_bank_account.last4}`- : "No ACH Debit connected",+ ? `Account ending in ****${paymentMethod.us_bank_account.last4}`+ : "Not connected",},{type: "link",title: "Link",icon: StripeLink,+ iconBgColor: "bg-green-100",description: paymentMethod?.link- ? `Connected Link account ${paymentMethod.link?.email}`+ ? `Account with ${paymentMethod.link?.email}`: "No Link account connected",},] satisfies {diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-methods.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-methods.tsxindex 7e9002eaf0..40979e9fa3 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-methods.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/payment-methods.tsx@@ -3,8 +3,9 @@import usePaymentMethods from "@/lib/swr/use-payment-methods";import useWorkspace from "@/lib/swr/use-workspace";import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";-import { Badge, Button, CreditCard } from "@dub/ui";+import { Badge, Button, CreditCard, MoneyBill2 } from "@dub/ui";import { cn } from "@dub/utils";+import Link from "next/link";import { useState } from "react";import { Stripe } from "stripe";import { PaymentMethodTypesList } from "./payment-method-types";@@ -89,22 +90,20 @@ export default function PaymentMethods() {<PaymentMethodCardSkeleton /></>)}+ {partnersEnabled &&+ achPaymentMethods &&+ achPaymentMethods.length > 0 ? (+ achPaymentMethods.map((paymentMethod) => (+ <PaymentMethodCard+ key={paymentMethod.id}+ type={paymentMethod.type}+ paymentMethod={paymentMethod}+ />+ ))+ ) : (+ <PaymentMethodCard type="us_bank_account" />+ )}</div>- {partnersEnabled && achPaymentMethods && (- <div className="grid gap-4 rounded-bl-lg rounded-br-lg border-neutral-200 bg-neutral-100 px-6 pb-6 drop-shadow-sm">- {achPaymentMethods.length > 0 ? (- achPaymentMethods.map((paymentMethod) => (- <PaymentMethodCard- key={paymentMethod.id}- type={paymentMethod.type}- paymentMethod={paymentMethod}- />- ))- ) : (- <PaymentMethodCard type="us_bank_account" />- )}- </div>- )}</div>);}@@ -143,38 +142,70 @@ const PaymentMethodCard = ({};return (- <div className="flex items-center justify-between rounded-lg border border-neutral-200 bg-white p-4 drop-shadow-sm">- <div className="flex items-center gap-4">- <div- className={cn(- "flex size-12 items-center justify-center rounded-lg bg-neutral-100",- iconBgColor,- )}- >- <Icon className="size-6 text-neutral-700" />- </div>- <div>- <div className="flex items-center gap-2">- <p className="font-medium text-neutral-900">{title}</p>- {type === "us_bank_account" && (- <Badge variant="neutral">- Recommended for Dub Partners payouts- </Badge>+ <RecommendedForPayoutsWrapper recommended={type === "us_bank_account"}>+ <div className="flex items-center justify-between rounded-lg border border-neutral-200 bg-white p-4 drop-shadow-sm">+ <div className="flex items-center gap-4">+ <div+ className={cn(+ "flex size-12 items-center justify-center rounded-lg bg-neutral-100",+ iconBgColor,)}+ >+ <Icon className="size-6 text-neutral-700" />+ </div>+ <div>+ <div className="flex items-center gap-2">+ <p className="font-medium text-neutral-900">{title}</p>+ {paymentMethod &&+ (type === "us_bank_account" || paymentMethod.link?.email) && (+ <Badge className="border-transparent bg-green-200 text-[0.625rem] text-green-900">+ Connected+ </Badge>+ )}+ </div>+ <p className="text-sm text-neutral-500">{description}</p></div>- <p className="text-sm text-neutral-500">{description}</p></div>+ {!paymentMethod && (+ <Button+ variant="primary"+ className="h-9 w-fit"+ text="Connect"+ onClick={() => managePaymentMethods(type)}+ loading={isLoading}+ />+ )}</div>- {!paymentMethod && (- <Button- variant="primary"- className="h-9 w-fit"- text="Connect"- onClick={() => managePaymentMethods(type)}- loading={isLoading}- />- )}+ </RecommendedForPayoutsWrapper>+ );+};++const RecommendedForPayoutsWrapper = ({+ recommended,+ children,+}: {+ recommended: boolean;+ children: React.ReactNode;+}) => {+ return recommended ? (+ <div className="rounded-[0.75rem] bg-neutral-200 p-1">+ {children}+ <span className="flex items-center gap-2 px-3 pb-1 pt-1.5 text-xs text-neutral-800">+ <MoneyBill2 className="size-3.5 shrink-0" />+ <span>+ Recommended for Dub Partner payouts.{" "}+ <Link+ href="https://dub.co/help/article/partner-payouts"+ target="_blank"+ className="underline underline-offset-2 transition-colors duration-75 hover:text-neutral-900"+ >+ Learn more+ </Link>+ </span>+ </span></div>+ ) : (+ children);};