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.

update dropdown

Kiran K8c973e9ef12c
diff --git a/apps/web/ui/partners/payout-methods-dropdown.tsx b/apps/web/ui/partners/payout-methods-dropdown.tsx
index 3a5b6415c0..04c126899d 100644
--- a/apps/web/ui/partners/payout-methods-dropdown.tsx
+++ b/apps/web/ui/partners/payout-methods-dropdown.tsx
@@ -4,41 +4,51 @@ import { createAccountLinkAction } from "@/lib/actions/partners/create-account-l
import { generatePaypalOAuthUrl } from "@/lib/actions/partners/generate-paypal-oauth-url";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
import { PartnerProps } from "@/lib/types";
-import { Button, Paypal, Popover, Stripe } from "@dub/ui";
-import { cn } from "@dub/utils";
+import { Button, Paypal, Popover, Stripe as StripeIcon } from "@dub/ui";
+import { cn, fetcher } from "@dub/utils";
import { ChevronsUpDown } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
import { useState } from "react";
import { toast } from "sonner";
-
-const payoutMethods = [
- {
- id: "paypal",
- label: "PayPal",
- color: "bg-blue-100",
- icon: <Paypal />,
- getAccountDetails: (partner: Pick<PartnerProps, "paypalEmail">) =>
- `Account ${partner?.paypalEmail}` || "Not connected",
- isVisible: (partner: Pick<PartnerProps, "country">) =>
- partner?.country !== "US",
- },
- {
- id: "stripe",
- label: "Stripe Test Bank",
- color: "bg-purple-100",
- icon: <Stripe />,
- getAccountDetails: (partner: Pick<PartnerProps, "stripeConnectId">) =>
- partner?.stripeConnectId
- ? `${partner.stripeConnectId} •••• 5290`
- : "Not connected",
- isVisible: () => true,
- },
-];
+import type { Stripe } from "stripe";
+import useSWR from "swr";
export function PayoutMethodsDropdown() {
const { partner } = usePartnerProfile();
const [openPopover, setOpenPopover] = useState(false);
+ const { data: bankAccount } = useSWR<Stripe.BankAccount>(
+ partner?.stripeConnectId ? "/api/partner-profile/payouts/settings" : null,
+ fetcher,
+ );
+
+ const payoutMethods = [
+ {
+ id: "paypal",
+ label: "PayPal",
+ color: "bg-blue-100",
+ icon: <Paypal />,
+ getAccountDetails: (partner: Pick<PartnerProps, "paypalEmail">) =>
+ `Account ${partner?.paypalEmail}` || "Not connected",
+ isVisible: (partner: Pick<PartnerProps, "country">) =>
+ partner?.country !== "US",
+ },
+ {
+ id: "stripe",
+ label: "Stripe Test Bank",
+ color: "bg-purple-100",
+ icon: <StripeIcon />,
+ getAccountDetails: (partner: Pick<PartnerProps, "stripeConnectId">) => {
+ if (!partner?.stripeConnectId || !bankAccount) {
+ return "Not connected";
+ }
+
+ return `${bankAccount.bank_name} •••• ${bankAccount.last4}`;
+ },
+ isVisible: () => true,
+ },
+ ];
+
const { executeAsync: executeStripeAsync, isPending: isStripePending } =
useAction(createAccountLinkAction, {
onSuccess: ({ data }) => {
@@ -119,7 +129,7 @@ export function PayoutMethodsDropdown() {
<div>
<Popover
content={
- <div className="relative w-full">
+ <div className="relative w-[350px]">
<div className="w-full space-y-0.5 rounded-lg bg-white p-2 text-sm">
<div className="flex flex-col gap-2">
{payoutMethods