The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add stripe connect button
Kiran Ke9d8fc4d8e41
diff --git a/apps/web/app/api/partners/[partnerId]/payout-methods/route.ts b/apps/web/app/api/partners/[partnerId]/payout-methods/route.tsdeleted file mode 100644index 7f47d32270..0000000000--- a/apps/web/app/api/partners/[partnerId]/payout-methods/route.ts+++ /dev/null@@ -1,14 +0,0 @@-import { withPartner } from "@/lib/auth/partner";-import { retrievePayoutMethods } from "@/lib/dots/retrieve-payout-methods";-import { NextResponse } from "next/server";--// GET /api/partners/[partnerId]/payout-methods – get payout methods for a partner-export const GET = withPartner(async ({ partner }) => {- if (!partner.dotsUserId) {- return NextResponse.json([]);- }-- const payoutMethods = await retrievePayoutMethods(partner.dotsUserId);-- return NextResponse.json(payoutMethods);-});diff --git a/apps/web/app/partners.dub.co/(dashboard)/settings/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/settings/page-client.tsxindex 1d0df7cd6c..b635215440 100644--- a/apps/web/app/partners.dub.co/(dashboard)/settings/page-client.tsx+++ b/apps/web/app/partners.dub.co/(dashboard)/settings/page-client.tsx@@ -1,5 +1,6 @@"use client";+import { createAccountLinkAction } from "@/lib/actions/partners/create-account-link";import { updatePartnerProfileAction } from "@/lib/actions/partners/update-partner-profile";import usePartnerProfile from "@/lib/swr/use-partner-profile";import { PartnerProps } from "@/lib/types";@@ -9,6 +10,7 @@ import {FileUpload,LoadingSpinner,MaxWidthWrapper,+ Note,useEnterSubmit,} from "@dub/ui";import { cn, DICEBEAR_AVATAR_URL } from "@dub/utils";@@ -41,6 +43,25 @@ export function ProfileSettingsPageClient() {</div>)}</div>++ <div className="mt-10 max-w-screen-md rounded-lg border border-neutral-200 bg-white">+ <div className="border-b border-neutral-200 p-6">+ <h2 className="text-xl font-medium text-neutral-800">Payouts</h2>+ </div>+ {partner ? (+ <StripeConnectForm />+ ) : (+ <div className="flex h-32 w-full items-center justify-center">+ {error ? (+ <span className="text-sm text-neutral-500">+ Failed to load profile data+ </span>+ ) : (+ <LoadingSpinner />+ )}+ </div>+ )}+ </div></MaxWidthWrapper>);}@@ -199,3 +220,44 @@ function FormRow({ children }: PropsWithChildren) {</div>);}++function StripeConnectForm() {+ const { executeAsync, isExecuting } = useAction(createAccountLinkAction, {+ onSuccess({ data }) {+ if (!data?.url) {+ toast.error("Unable to create account link. Please contact support.");+ return;+ }++ window.open(data.url, "_blank");+ },+ onError({ error }) {+ toast.error(error.serverError);+ },+ });++ return (+ <div className="flex items-center justify-between rounded-lg bg-white p-4">+ <div className="grid grid-cols-1 items-center sm:grid-cols-2">+ <div className="flex items-center gap-3">+ <div className="flex size-12 items-center justify-center rounded-full border border-neutral-200">+ <Note className="size-5 text-neutral-700" />+ </div>+ <div>+ <p className="font-medium text-neutral-900">Stripe Connect</p>+ <p className="text-sm text-neutral-500">+ Required to receive payouts.+ </p>+ </div>+ </div>+ </div>+ <Button+ text="Connect"+ loading={isExecuting}+ className="w-fit"+ variant="secondary"+ onClick={async () => await executeAsync()}+ />+ </div>+ );+}diff --git a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/activity.tsx b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/activity.tsxdeleted file mode 100644index 90a1516b7e..0000000000--- a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/activity.tsx+++ /dev/null@@ -1,97 +0,0 @@-"use client";--import { DotsWithdrawals } from "@/lib/dots/types";-import usePartnerProfile from "@/lib/swr/use-partner-profile";-import { PlatformBadge } from "@/ui/partners/platform-badge";-import { StatusBadge, Table, Tooltip, useTable } from "@dub/ui";-import {- capitalize,- currencyFormatter,- fetcher,- formatDateTime,-} from "@dub/utils";-import useSWR from "swr";--const StatusBadgeVariants = {- created: "new",- pending: "pending",- failed: "error",- completed: "success",- reversed: "error",- canceled: "error",- flagged: "warning",-};--export const PartnerWithdrawalsActivity = () => {- const { partner } = usePartnerProfile();-- const { data, error } = useSWR<DotsWithdrawals>(- partner && `/api/partners/${partner?.id}/withdrawals`,- fetcher,- {- keepPreviousData: true,- },- );-- const table = useTable({- data: data?.data || [],- loading: !data && !error,- error: error ? "Failed to load recent activity" : undefined,- emptyState: "No recent withdrawals",- columns: [- {- header: "Date",- accessorFn: (row) => formatDateTime(new Date(row.created), {}),- },- {- header: "Method",- cell: ({ row }) => <PlatformBadge platform={row.original.platform} />,- },- {- header: "Amount",- accessorFn: (row) =>- currencyFormatter(parseFloat(row.amount) / 100, {- minimumFractionDigits: 2,- maximumFractionDigits: 2,- }),- },- {- header: "Fee",- cell: ({ row }) =>- row.original.fee === "0" ? (- <Tooltip content="Since this withdrawal was above $1,000 and in the US, we covered the fee.">- <span className="cursor-default truncate underline decoration-dotted">- No fee- </span>- </Tooltip>- ) : (- currencyFormatter(parseFloat(row.original.fee) / 100, {- minimumFractionDigits: 2,- maximumFractionDigits: 2,- })- ),- },- {- header: "Status",- cell: ({ row }) => (- <StatusBadge variant={StatusBadgeVariants[row.original.status]}>- {capitalize(row.original.status)}- </StatusBadge>- ),- },- ],- thClassName: "border-l-0",- tdClassName: "border-l-0",- });-- return (- <div>- <h2 className="text-base font-semibold text-neutral-900">- Recent withdrawals- </h2>- <div className="mt-3">- <Table {...table} />- </div>- </div>- );-};diff --git a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/compliance-button.tsx b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/compliance-button.tsxdeleted file mode 100644index 5ca37c7bb8..0000000000--- a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/compliance-button.tsx+++ /dev/null@@ -1,30 +0,0 @@-import { createAccountLinkAction } from "@/lib/actions/partners/create-account-link";-import { Button } from "@dub/ui";-import { useAction } from "next-safe-action/hooks";-import { toast } from "sonner";--export const ComplianceButton = () => {- const { executeAsync, isExecuting } = useAction(createAccountLinkAction, {- onSuccess({ data }) {- if (!data?.url) {- toast.error("Unable to create account link. Please contact support.");- return;- }-- window.open(data.url, "_blank");- },- onError({ error }) {- toast.error(error.serverError);- },- });-- return (- <Button- text="Submit"- variant="secondary"- onClick={async () => await executeAsync()}- loading={isExecuting}- className="h-8 w-fit px-2"- />- );-};diff --git a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page-client.tsxdeleted file mode 100644index f3a5f2aab4..0000000000--- a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page-client.tsx+++ /dev/null@@ -1,310 +0,0 @@-"use client";--import useDotsUser from "@/lib/swr/use-dots-user";-import usePartnerProfile from "@/lib/swr/use-partner-profile";-import usePayoutMethods from "@/lib/swr/use-payout-methods";-import { usePayoutWithdrawSheet } from "@/ui/partners/payout-withdraw-sheet";-import { Note, SimpleTooltipContent, Tooltip } from "@dub/ui";-import { GiftFill } from "@dub/ui/icons";-import {- cn,- currencyFormatter,- FREE_WITHDRAWAL_MINIMUM_BALANCE,-} from "@dub/utils";-import { useState } from "react";-import { ComplianceButton } from "./compliance-button";--export function WalletSettingsPageClient() {- const { partner } = usePartnerProfile();- const { dotsUser, isLoading, mutate } = useDotsUser();-- const {- payoutMethods,- isLoading: payoutMethodsLoading,- mutate: mutatePayoutMethods,- } = usePayoutMethods();-- const [modalState, setModalState] = useState<{- show: boolean;- iframeSrc: string;- }>({- show: false,- iframeSrc: "",- });-- const { payoutWithdrawSheet, setIsOpen: setShowPayoutWithdrawSheet } =- usePayoutWithdrawSheet();-- return (- <div className="flex items-center justify-between rounded-lg border border-neutral-200 bg-white p-4">- <div className="flex items-center gap-3">- <div className="flex size-12 items-center justify-center rounded-full border border-neutral-200">- <Note className="size-5 text-neutral-700" />- </div>- <div>- <p className="font-medium text-neutral-900">Compliance documents</p>- {/* {dotsUser.compliance.submitted ? (- <div className="flex items-center gap-1">- <CheckCircleFill className="size-4 text-green-600" />- <p className="text-sm text-neutral-500">- {partner.country === "US"- ? "W-9 submitted"- : "W8-BEN submitted"}- </p>- </div>- ) : (- <p className="text-sm text-neutral-500">- W8-BEN (non-US) / W-9 (US) Required to withdraw payouts- </p>- )} */}- </div>- </div>- <ComplianceButton />- </div>- );-- // return (- // <>- // {payoutWithdrawSheet}- // {modalState.show && (- // <Modal- // showModal={modalState.show}- // setShowModal={() => setModalState({ show: false, iframeSrc: "" })}- // onClose={async () => {- // await Promise.all([mutate(), mutatePayoutMethods()]);- // }}- // className="h-full w-full bg-white p-4 sm:h-[80vh] sm:max-w-md"- // >- // <button- // onClick={() => setModalState({ show: false, iframeSrc: "" })}- // className="group absolute right-4 top-8 hidden rounded-full p-2 transition-colors hover:bg-neutral-100 sm:top-4 sm:block"- // >- // <X className="size-5 text-neutral-700 transition-all group-hover:scale-110 group-active:scale-90" />- // </button>- // <iframe- // src={modalState.iframeSrc}- // className="h-full w-full rounded-lg"- // />- // </Modal>- // )}-- // <div className="min-h-screen">- // {partner?.dotsUserId && dotsUser?.verified ? (- // <div className="grid grid-cols-1 gap-4">- // <div className="grid gap-4 rounded-lg border border-neutral-300 bg-white p-5">- // {dotsUser?.wallet && (- // <div className="grid divide-neutral-200 rounded-lg border border-neutral-200 bg-neutral-50 max-sm:divide-y sm:grid-cols-[repeat(2,minmax(0,1fr))] sm:divide-x">- // <div className="flex flex-col p-4">- // <div className="flex flex-wrap justify-between gap-x-5 gap-y-1">- // <div className="whitespace-nowrap p-1 text-sm text-neutral-500">- // Withdrawable balance- // </div>- // <div>- // {dotsUser ? (- // <Button- // text="Withdraw funds"- // onClick={() => setShowPayoutWithdrawSheet(true)}- // className="h-7 w-fit px-2"- // disabledTooltip={- // payoutMethods.length === 0- // ? "You need to connect a payout method first"- // : !dotsUser.compliance.submitted- // ? "You need to verify your identity first"- // : !dotsUser.wallet.withdrawable_amount- // ? "You need a positive balance to withdraw funds"- // : undefined- // }- // />- // ) : (- // <div className="h-7 w-24 animate-pulse rounded-md bg-neutral-200" />- // )}- // </div>- // </div>- // <div className="mt-6 flex grow flex-col justify-end p-1">- // <div className="flex flex-wrap items-end justify-between gap-x-4 gap-y-3">- // <div className="whitespace-nowrap text-2xl text-neutral-800">- // {currencyFormatter(- // dotsUser.wallet.withdrawable_amount / 100,- // {- // minimumFractionDigits: 2,- // maximumFractionDigits: 2,- // },- // )}{" "}- // USD- // </div>- // {partner.country === "US" &&- // dotsUser.wallet.withdrawable_amount > 0 && (- // <FreeWithdrawalProgress- // balance={dotsUser.wallet.withdrawable_amount}- // />- // )}- // </div>- // </div>- // </div>- // <div className="flex flex-col p-4">- // <div className="flex justify-between gap-5">- // <div className="p-1 text-sm text-neutral-500">- // Pending balance- // </div>- // </div>- // <div className="mt-6 flex grow flex-col justify-end p-1">- // {dotsUser ? (- // <div className="text-2xl text-neutral-800">- // {currencyFormatter(- // dotsUser?.wallet.pending_amount / 100,- // {- // minimumFractionDigits: 2,- // maximumFractionDigits: 2,- // },- // )}{" "}- // USD- // </div>- // ) : (- // <div className="h-8 w-32 animate-pulse rounded bg-neutral-200" />- // )}- // </div>- // </div>- // </div>- // )}-- // {!payoutMethodsLoading && payoutMethods.length === 0 ? (- // <AnimatedEmptyState- // title="No payout methods connected"- // description="Connect a payout method to start withdrawing funds"- // cardContent={() => (- // <>- // <GreekTemple className="size-4 text-neutral-700" />- // <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />- // </>- // )}- // addButton={- // <Button- // text="Connect payout method"- // // onClick={() => executeAsync({ flow: "manage-payouts" })}- // loading={isExecuting}- // />- // }- // />- // ) : (- // <div className="flex flex-col gap-4">- // <div className="flex items-center justify-between">- // <p className="font-medium text-neutral-900">- // Payout methods- // </p>- // <Button- // text="Manage"- // variant="secondary"- // // onClick={() => executeAsync({ flow: "manage-payouts" })}- // loading={isExecuting}- // className="h-8 w-fit px-2"- // />- // </div>- // <div className="grid gap-4">- // {payoutMethodsLoading- // ? Array.from({ length: 3 }).map((_, i) => (- // <PayoutMethodCardSkeleton key={i} />- // ))- // : payoutMethods.map(- // ({ platform, default: isDefault }) => (- // <PayoutMethodCard- // key={platform}- // platform={platform}- // isDefault={isDefault}- // />- // ),- // )}- // </div>- // </div>- // )}- // </div>-- // <div className="flex items-center justify-between rounded-lg border border-neutral-200 bg-white p-4">- // <div className="flex items-center gap-3">- // <div className="flex size-12 items-center justify-center rounded-full border border-neutral-200">- // <Note className="size-5 text-neutral-700" />- // </div>- // <div>- // <p className="font-medium text-neutral-900">- // Compliance documents- // </p>- // {dotsUser.compliance.submitted ? (- // <div className="flex items-center gap-1">- // <CheckCircleFill className="size-4 text-green-600" />- // <p className="text-sm text-neutral-500">- // {partner.country === "US"- // ? "W-9 submitted"- // : "W8-BEN submitted"}- // </p>- // </div>- // ) : (- // <p className="text-sm text-neutral-500">- // W8-BEN (non-US) / W-9 (US) Required to withdraw payouts- // </p>- // )}- // </div>- // </div>- // <ComplianceButton setModalState={setModalState} />- // </div>- // <div className="my-8">- // <PartnerWithdrawalsActivity />- // </div>- // </div>- // ) : !isLoading ? (- // <>Nothing here yet</>- // ) : (- // <LayoutLoader />- // )}- // </div>- // </>- // );-}--function FreeWithdrawalProgress({ balance }: { balance: number }) {- const remaining = FREE_WITHDRAWAL_MINIMUM_BALANCE - balance;- const isFree = balance >= FREE_WITHDRAWAL_MINIMUM_BALANCE;-- return (- <Tooltip- content={- <SimpleTooltipContent- title="Withdrawals above $1,000 in the US are free."- cta="Learn more"- href="https://dub.co/help" // TODO: [payouts] Add help page- />- }- >- <div className="flex flex-col gap-1.5">- <div className="text-2xs text-neutral-500 lg:whitespace-nowrap">- {isFree ? (- <p className="flex items-center gap-0.5 sm:pr-8">- <GiftFill className="mr-px inline-block size-2.5 text-green-900" />- Free withdrawal unlocked- </p>- ) : (- <>- You're{" "}- {currencyFormatter(remaining / 100, {- minimumFractionDigits: 2,- maximumFractionDigits: 2,- })}{" "}- away from a free withdrawal- </>- )}- </div>- <div className="h-0.5 w-full overflow-hidden rounded-full bg-neutral-200">- <div- className={cn(- "h-full rounded-full",- isFree ? "bg-green-500" : "bg-neutral-900",- )}- style={{- width: isFree- ? "100%"- : `${(balance / FREE_WITHDRAWAL_MINIMUM_BALANCE) * 100}%`,- }}- />- </div>- </div>- </Tooltip>- );-}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.tsxdeleted file mode 100644index 863d624f29..0000000000--- a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/page.tsx+++ /dev/null@@ -1,13 +0,0 @@-import { PageContent } from "@/ui/layout/page-content";-import { MaxWidthWrapper } from "@dub/ui";-import { WalletSettingsPageClient } from "./page-client";--export default function WalletSettings() {- return (- <PageContent title="Wallet" hideReferButton>- <MaxWidthWrapper>- <WalletSettingsPageClient />- </MaxWidthWrapper>- </PageContent>- );-}diff --git a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-method-card.tsx b/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-method-card.tsxdeleted file mode 100644index 617ff1c15c..0000000000--- a/apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-method-card.tsx+++ /dev/null@@ -1,58 +0,0 @@-import { dotsPayoutPlatforms } from "@/lib/dots/schemas";-import z from "@/lib/zod";-import { DOTS_PAYOUT_PLATFORMS } from "@/ui/dots/platforms";-import { StatusBadge } from "@dub/ui";-import { cn } from "@dub/utils";--export default function PayoutMethodCard({- platform,- isDefault,-}: {- platform: z.infer<typeof dotsPayoutPlatforms>;- isDefault?: boolean;-}) {- const {- icon: Icon,- name,- iconBgColor,- duration,- } = DOTS_PAYOUT_PLATFORMS.find((p) => p.id === platform) ||- DOTS_PAYOUT_PLATFORMS[0];-- return (- <div className="flex items-center justify-between rounded-lg border border-neutral-200 bg-white p-4">- <div className="flex items-center gap-3">- <div- className={cn(- "flex size-10 items-center justify-center rounded-full",- iconBgColor,- )}- >- <Icon className="size-4 text-neutral-700" />- </div>- <div>- <p className="font-medium text-neutral-900">{name}</p>- <p className="text-sm text-neutral-500">- Typically arrives {duration}- </p>- </div>- </div>- {isDefault && (- <StatusBadge variant="success" icon={null}>- Default- </StatusBadge>- )}- </div>- );-}--export function PayoutMethodCardSkeleton() {- return (- <div className="flex items-center justify-between rounded-lg border border-neutral-200 bg-white p-4">- <div className="flex items-center gap-3">- <div className="h-10 w-10 animate-pulse rounded-full bg-neutral-200" />- <div className="h-4 w-24 min-w-0 animate-pulse rounded-md bg-neutral-200" />- </div>- </div>- );-}diff --git a/apps/web/ui/partners/payout-withdraw-sheet.tsx b/apps/web/ui/partners/payout-withdraw-sheet.tsxdeleted file mode 100644index b3ce6e28f7..0000000000--- a/apps/web/ui/partners/payout-withdraw-sheet.tsx+++ /dev/null@@ -1,288 +0,0 @@-import { withdrawFundsAction } from "@/lib/actions/partners/withdraw-funds";-import { DotsPayoutPlatform } from "@/lib/dots/types";-import useDotsUser from "@/lib/swr/use-dots-user";-import usePartnerProfile from "@/lib/swr/use-partner-profile";-import usePayoutMethods from "@/lib/swr/use-payout-methods";-import { X } from "@/ui/shared/icons";-import { Button, Icon, Sheet } from "@dub/ui";-import {- cn,- currencyFormatter,- DICEBEAR_AVATAR_URL,- formatDate,-} from "@dub/utils";-import { useAction } from "next-safe-action/hooks";-import {- Dispatch,- Fragment,- SetStateAction,- useEffect,- useMemo,- useState,-} from "react";-import { toast } from "sonner";-import { mutate } from "swr";-import { DOTS_PAYOUT_PLATFORMS } from "../dots/platforms";--type PayoutWithdrawSheetProps = {- setIsOpen: Dispatch<SetStateAction<boolean>>;-};--function PayoutWithdrawSheetContent({ setIsOpen }: PayoutWithdrawSheetProps) {- const { partner, error: partnerError } = usePartnerProfile();- const { dotsUser, error: dotsUserError } = useDotsUser();- const { payoutMethods } = usePayoutMethods();-- const summaryData = useMemo(- () => ({- Partner: (- <div className="flex items-center gap-2">- {partner || partnerError ? (- <>- <img- src={partner?.image || `${DICEBEAR_AVATAR_URL}${partner?.name}`}- alt={partner?.name ?? "Partner"}- className="size-5 rounded-full"- />- <div>{partner?.name ?? "-"}</div>- </>- ) : (- <>- <div className="size-5 animate-pulse rounded-full bg-neutral-200" />- <div className="h-5 w-24 animate-pulse rounded-md bg-neutral-200" />- </>- )}- </div>- ),- Date: formatDate(new Date(), { month: "short" }),- Total: dotsUserError ? (- "-"- ) : dotsUser?.wallet ? (- currencyFormatter((dotsUser.wallet.withdrawable_amount ?? 0) / 100, {- minimumFractionDigits: 2,- maximumFractionDigits: 2,- })- ) : (- <div className="h-5 w-12 animate-pulse rounded-md bg-neutral-200" />- ),- }),- [partner, dotsUser],- );-- const [selectedPayoutMethod, setSelectedPayoutMethod] =- useState<DotsPayoutPlatform | null>(null);-- useEffect(() => {- if (!payoutMethods.length || selectedPayoutMethod !== null) return;-- setSelectedPayoutMethod(- dotsUser?.default_payout_method ?? payoutMethods[0].platform,- );- }, [dotsUser, selectedPayoutMethod]);-- const [submitting, setSubmitting] = useState(false);-- const { executeAsync } = useAction(withdrawFundsAction, {- onSuccess: async () => {- await mutate(- (key) =>- typeof key === "string" &&- (key.endsWith("/withdrawals") || key.endsWith("/dots-user")),- undefined,- { revalidate: true },- );- setIsOpen(false);- toast.success("Successfully initiated withdrawal!");- },- onError({ error }) {- toast.error(error.serverError);- },- });-- return (- <>- <div>- <div className="flex items-start justify-between border-b border-neutral-200 p-6">- <Sheet.Title className="text-xl font-semibold">- Confirm withdrawal- </Sheet.Title>- <Sheet.Close asChild>- <Button- variant="outline"- icon={<X className="size-5" />}- className="h-auto w-fit p-1"- />- </Sheet.Close>- </div>- <div className="flex flex-col gap-4 p-6">- <div className="text-base font-medium text-neutral-900">Summary</div>- <div className="grid grid-cols-2 gap-3 text-sm">- {Object.entries(summaryData).map(([key, value]) => (- <Fragment key={key}>- <div className="font-medium text-neutral-500">{key}</div>- <div className="text-neutral-800">{value}</div>- </Fragment>- ))}- </div>- </div>- <div className="p-6 pt-2">- <div className="text-base font-medium text-neutral-900">Method</div>- <div className="mt-4 flex flex-col gap-2">- {payoutMethods.length ? (- <>- {payoutMethods- .sort((a, b) => Number(b.default) - Number(a.default)) // Show default first- .map((method) => {- const platform =- DOTS_PAYOUT_PLATFORMS.find(- (p) => p.id === method.platform,- ) ?? DOTS_PAYOUT_PLATFORMS[0];-- return (- <PayoutMethodOption- key={method.platform}- {...platform}- description={`Typically arrives ${platform.duration}`}- isDefault={method.default}- selectedPayoutMethod={selectedPayoutMethod}- setSelectedPayoutMethod={setSelectedPayoutMethod}- />- );- })}- </>- ) : !dotsUserError ? (- [...Array(2)].map((_, idx) => (- <div- key={idx}- className="flex animate-pulse items-center gap-2 rounded-lg border border-neutral-200 bg-white p-4"- >- <div className="flex size-10 items-center justify-center rounded-md bg-neutral-200" />- <div>- <div className="h-4 w-24 rounded-md bg-neutral-200" />- <div className="mt-1 h-4 w-32 rounded-md bg-neutral-200" />- </div>- </div>- ))- ) : (- <div className="text-sm text-neutral-500">- Failed to load payout methods- </div>- )}- </div>- </div>- </div>- <div className="flex grow flex-col justify-end">- <div className="flex items-center justify-end gap-2 border-t border-neutral-200 p-5">- <Button- type="button"- variant="secondary"- onClick={() => setIsOpen(false)}- text="Cancel"- className="w-fit"- />- <Button- type="button"- variant="primary"- disabled={!dotsUser?.id || !selectedPayoutMethod}- onClick={() => {- setSubmitting(true);- selectedPayoutMethod &&- executeAsync({- platform: selectedPayoutMethod,- });- }}- loading={submitting}- text="Confirm withdrawal"- className="w-fit"- />- </div>- </div>- </>- );-}--function PayoutMethodOption({- id,- icon: Icon,- iconBgColor,- name,- description,- isDefault,- selectedPayoutMethod,- setSelectedPayoutMethod,-}: {- id: string;- icon: Icon;- iconBgColor: string;- name: string;- description: string;- isDefault?: boolean;- selectedPayoutMethod: DotsPayoutPlatform | null;- setSelectedPayoutMethod: Dispatch<SetStateAction<DotsPayoutPlatform | null>>;-}) {- return (- <button- type="button"- onClick={() => setSelectedPayoutMethod(id as DotsPayoutPlatform)}- className={cn(- "flex items-center justify-between gap-4 rounded-lg border border-neutral-200 bg-white p-4 text-left",- "transition-[background-color,border-color,box-shadow] duration-75 hover:bg-neutral-50",- selectedPayoutMethod === id &&- "border-neutral-900 ring-1 ring-inset ring-neutral-900",- )}- >- <div className="flex items-center gap-2">- <div- className={cn(- "flex size-10 items-center justify-center rounded-md",- iconBgColor,- )}- >- <Icon className="size-4.5 text-neutral-900" />- </div>- <div>- <div className="flex items-center gap-1">- <span className="text-sm font-medium text-neutral-800">{name}</span>- {isDefault && (- <div className="rounded bg-green-100 px-1.5 py-0.5 text-xs text-green-600">- Default- </div>- )}- </div>- <div className="text-xs text-neutral-400">{description}</div>- </div>- </div>- <div- className={cn(- "size-4 rounded-full border border-neutral-400 transition-shadow duration-75",- selectedPayoutMethod === id &&- "border-neutral-900 ring-2 ring-inset ring-neutral-900",- )}- />- </button>- );-}--export function PayoutWithdrawSheet({- isOpen,- ...rest-}: PayoutWithdrawSheetProps & {- isOpen: boolean;-}) {- return (- <Sheet open={isOpen} onOpenChange={rest.setIsOpen}>- <PayoutWithdrawSheetContent {...rest} />- </Sheet>- );-}--export function usePayoutWithdrawSheet() {- const [isOpen, setIsOpen] = useState(false);-- return {- payoutWithdrawSheet: (- <PayoutWithdrawSheet setIsOpen={setIsOpen} isOpen={isOpen} />- ),- setIsOpen,- };-}