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.

improve PartnerPayoutSettingsSheet

Steven Tey9bbffc007554
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-settings-sheet.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-settings-sheet.tsx
index 5784281697..244536ebe1 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-settings-sheet.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-settings-sheet.tsx
@@ -11,8 +11,14 @@ import usePartnerProfile from "@/lib/swr/use-partner-profile";
import { partnerPayoutSettingsSchema } from "@/lib/zod/schemas/partners";
import { ConnectPayoutButton } from "@/ui/partners/connect-payout-button";
import { PayoutMethodsDropdown } from "@/ui/partners/payout-methods-dropdown";
-import { Button, Sheet, Slider, useScrollProgress } from "@dub/ui";
-import { currencyFormatter } from "@dub/utils";
+import {
+ AnimatedSizeContainer,
+ Button,
+ Sheet,
+ Slider,
+ useScrollProgress,
+} from "@dub/ui";
+import { CONNECT_SUPPORTED_COUNTRIES, currencyFormatter } from "@dub/utils";
import NumberFlow from "@number-flow/react";
import { PartyPopper } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
@@ -126,64 +132,69 @@ function PartnerPayoutSettingsSheetInner({
</div>
{/* Minimum withdrawal amount */}
- <div className="space-y-6 py-6">
- <div>
- <h4 className="text-base font-semibold leading-6 text-neutral-900">
- Minimum withdrawal amount
- </h4>
- <p className="text-sm font-medium text-neutral-500">
- Set the minimum amount for funds to be withdrawn from Dub into
- your connected payout account.
- </p>
- </div>
+ {partner?.country &&
+ CONNECT_SUPPORTED_COUNTRIES.includes(partner.country) && (
+ <div className="space-y-6 py-6">
+ <div>
+ <h4 className="text-base font-semibold leading-6 text-neutral-900">
+ Minimum withdrawal amount
+ </h4>
+ <p className="text-sm font-medium text-neutral-500">
+ Set the minimum amount for funds to be automatically
+ withdrawn from Dub into your connected payout account.
+ </p>
+ </div>
- <div>
- <NumberFlow
- value={minWithdrawalAmount / 100}
- suffix=" USD"
- format={{
- style: "currency",
- currency: "USD",
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
- }}
- className="mb-2 text-2xl font-medium leading-6 text-neutral-800"
- />
+ <div>
+ <NumberFlow
+ value={minWithdrawalAmount / 100}
+ suffix=" USD"
+ format={{
+ style: "currency",
+ currency: "USD",
+ // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
+ trailingZeroDisplay: "stripIfInteger",
+ }}
+ className="mb-2 text-2xl font-medium leading-6 text-neutral-800"
+ />
- <Slider
- value={minWithdrawalAmount}
- min={ALLOWED_MIN_WITHDRAWAL_AMOUNTS[0]}
- max={
- ALLOWED_MIN_WITHDRAWAL_AMOUNTS[
- ALLOWED_MIN_WITHDRAWAL_AMOUNTS.length - 1
- ]
- }
- onChange={(value) => {
- const closest = ALLOWED_MIN_WITHDRAWAL_AMOUNTS.reduce(
- (prev, curr) =>
- Math.abs(curr - value) < Math.abs(prev - value)
- ? curr
- : prev,
- );
+ <Slider
+ value={minWithdrawalAmount}
+ min={ALLOWED_MIN_WITHDRAWAL_AMOUNTS[0]}
+ max={
+ ALLOWED_MIN_WITHDRAWAL_AMOUNTS[
+ ALLOWED_MIN_WITHDRAWAL_AMOUNTS.length - 1
+ ]
+ }
+ onChange={(value) => {
+ const closest = ALLOWED_MIN_WITHDRAWAL_AMOUNTS.reduce(
+ (prev, curr) =>
+ Math.abs(curr - value) < Math.abs(prev - value)
+ ? curr
+ : prev,
+ );
- setValue("minWithdrawalAmount", closest, {
- shouldDirty: true,
- });
- }}
- marks={ALLOWED_MIN_WITHDRAWAL_AMOUNTS}
- hint={
- minWithdrawalAmount < MIN_WITHDRAWAL_AMOUNT_CENTS ? (
- `${currencyFormatter(BELOW_MIN_WITHDRAWAL_FEE_CENTS / 100)} payout fee for payouts under $100`
- ) : (
- <div className="flex items-center gap-1 text-xs font-normal leading-4 text-neutral-500">
- <PartyPopper className="size-4" />
- Free payouts unlocked
- </div>
- )
- }
- />
- </div>
- </div>
+ setValue("minWithdrawalAmount", closest, {
+ shouldDirty: true,
+ });
+ }}
+ marks={ALLOWED_MIN_WITHDRAWAL_AMOUNTS}
+ hint={
+ <AnimatedSizeContainer height>
+ {minWithdrawalAmount < MIN_WITHDRAWAL_AMOUNT_CENTS ? (
+ `${currencyFormatter(BELOW_MIN_WITHDRAWAL_FEE_CENTS / 100)} withdrawal fee for balances under ${currencyFormatter(MIN_WITHDRAWAL_AMOUNT_CENTS / 100)}. If you have any previously processed payouts, they will be automatically transferred to your connected bank account once the minimum withdrawal amount is reached.`
+ ) : (
+ <div className="flex items-center gap-1 text-xs font-normal leading-4 text-neutral-500">
+ <PartyPopper className="size-4" />
+ Free withdrawals unlocked
+ </div>
+ )}
+ </AnimatedSizeContainer>
+ }
+ />
+ </div>
+ </div>
+ )}
{/* Invoice details */}
<div className="space-y-6 py-6">
diff --git a/apps/web/ui/partners/payout-methods-dropdown.tsx b/apps/web/ui/partners/payout-methods-dropdown.tsx
index 7c93204ebf..472a994d80 100644
--- a/apps/web/ui/partners/payout-methods-dropdown.tsx
+++ b/apps/web/ui/partners/payout-methods-dropdown.tsx
@@ -208,42 +208,42 @@ export function PayoutMethodsDropdown() {
openPopover={openPopover}
setOpenPopover={setOpenPopover}
>
- {isBankAccountLoading || isPartnerLoading ? (
- <div className="w-full rounded-lg border border-neutral-200">
+ <button
+ onClick={() => setOpenPopover(!openPopover)}
+ className={cn(
+ "flex w-full items-center justify-between rounded-lg bg-white p-2 text-left text-sm transition-all duration-75",
+ "border border-neutral-200 outline-none focus-visible:ring-2 focus-visible:ring-black/50",
+ )}
+ >
+ {isBankAccountLoading || isPartnerLoading ? (
<PayoutMethodSkeleton />
- </div>
- ) : (
- <button
- onClick={() => setOpenPopover(!openPopover)}
- className={cn(
- "flex w-full items-center justify-between rounded-lg bg-white p-2 text-left text-sm transition-all duration-75",
- "border border-neutral-200 outline-none focus-visible:ring-2 focus-visible:ring-black/50",
- )}
- >
- <div className="flex min-w-0 items-center gap-x-2.5 pr-2">
- <div
- className={cn(
- "size-8 shrink-0 rounded-lg p-2",
- selectedMethod?.color,
- )}
- >
- {selectedMethod?.icon}
+ ) : (
+ <>
+ <div className="flex min-w-0 items-center gap-x-2.5 pr-2">
+ <div
+ className={cn(
+ "size-8 shrink-0 rounded-lg p-2",
+ selectedMethod?.color,
+ )}
+ >
+ {selectedMethod?.icon}
+ </div>
+ <div className="min-w-0">
+ <span className="block text-xs font-medium text-neutral-900">
+ {selectedMethod?.label}
+ </span>
+ <span className="block w-44 truncate text-xs text-neutral-500">
+ {selectedMethod?.getAccountDetails(partner)}
+ </span>
+ </div>
</div>
- <div className="min-w-0">
- <span className="block text-xs font-medium text-neutral-900">
- {selectedMethod?.label}
- </span>
- <span className="block w-44 truncate text-xs text-neutral-500">
- {selectedMethod?.getAccountDetails(partner)}
- </span>
- </div>
- </div>
- <ChevronsUpDown
- className="size-4 shrink-0 text-neutral-400"
- aria-hidden="true"
- />
- </button>
- )}
+ <ChevronsUpDown
+ className="size-4 shrink-0 text-neutral-400"
+ aria-hidden="true"
+ />
+ </>
+ )}
+ </button>
</Popover>
</div>
);
@@ -251,15 +251,15 @@ export function PayoutMethodsDropdown() {
function PayoutMethodSkeleton() {
return (
- <div className="flex w-full items-center justify-between rounded-lg p-1.5">
+ <>
<div className="flex min-w-0 items-center gap-x-2.5 pr-2">
<div className="size-8 shrink-0 animate-pulse rounded-lg bg-neutral-200" />
- <div className="min-w-0 flex-1">
+ <div className="min-w-0">
<div className="h-3 w-24 animate-pulse rounded bg-neutral-200" />
<div className="mt-1 h-3 w-44 animate-pulse rounded bg-neutral-200" />
</div>
</div>
<div className="size-4 shrink-0 animate-pulse rounded bg-neutral-200" />
- </div>
+ </>
);
}