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.

Add free withdrawal progress

Tim Wilsonef8ffea1c39d
diff --git a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx
index 4851ad1a96..abc88ec462 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx
@@ -8,8 +8,12 @@ import { usePayoutWithdrawSheet } from "@/ui/partners/payout-withdraw-sheet";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
import { CheckCircleFill, X } from "@/ui/shared/icons";
import { Button, Modal, Note } from "@dub/ui";
-import { GreekTemple, MobilePhone } from "@dub/ui/src/icons";
-import { currencyFormatter } from "@dub/utils";
+import { GiftFill, GreekTemple, MobilePhone } from "@dub/ui/src/icons";
+import {
+ cn,
+ currencyFormatter,
+ FREE_WITHDRAWAL_MINIMUM_BALANCE,
+} from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
import { useParams } from "next/navigation";
import { useState } from "react";
@@ -73,8 +77,8 @@ export function PayoutsSettingsPageClient() {
<div className="grid gap-4 rounded-lg border border-neutral-300 bg-white p-5">
<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 justify-between gap-5">
- <div className="p-1 text-sm text-neutral-500">
+ <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>
@@ -99,10 +103,10 @@ export function PayoutsSettingsPageClient() {
</div>
</div>
<div className="mt-6 flex grow flex-col justify-end p-1">
- {dotsUser ? (
- <div className="text-2xl text-neutral-800">
+ <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,
+ dotsUser.wallet.withdrawable_amount / 100,
{
minimumFractionDigits: 2,
maximumFractionDigits: 2,
@@ -110,9 +114,13 @@ export function PayoutsSettingsPageClient() {
)}{" "}
USD
</div>
- ) : (
- <div className="h-8 w-32 animate-pulse rounded bg-neutral-200" />
- )}
+ {partner.country === "US" &&
+ dotsUser.wallet.withdrawable_amount > 0 && (
+ <FreeWithdrawalProgress
+ balance={dotsUser.wallet.withdrawable_amount}
+ />
+ )}
+ </div>
</div>
</div>
<div className="flex flex-col p-4">
@@ -247,3 +255,43 @@ export function PayoutsSettingsPageClient() {
</>
);
}
+
+function FreeWithdrawalProgress({ balance }: { balance: number }) {
+ const remaining = FREE_WITHDRAWAL_MINIMUM_BALANCE - balance;
+ const isFree = balance >= FREE_WITHDRAWAL_MINIMUM_BALANCE;
+
+ return (
+ <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>
+ );
+}
diff --git a/apps/web/lib/actions/partners/create-dots-withdrawal.ts b/apps/web/lib/actions/partners/create-dots-withdrawal.ts
index e81a36ad54..1a6d6fb3a7 100644
--- a/apps/web/lib/actions/partners/create-dots-withdrawal.ts
+++ b/apps/web/lib/actions/partners/create-dots-withdrawal.ts
@@ -3,6 +3,7 @@
import { createWithdrawal } from "@/lib/dots/create-withdrawal";
import { retrieveDotsUser } from "@/lib/dots/retrieve-dots-user";
import { dotsPayoutPlatforms } from "@/lib/dots/schemas";
+import { FREE_WITHDRAWAL_MINIMUM_BALANCE } from "@dub/utils";
import { z } from "zod";
import { authPartnerActionClient } from "../safe-action";
@@ -34,7 +35,8 @@ export const createDotsWithdrawalAction = authPartnerActionClient
platform,
// for US-based withdrawals over $1,000, we pay the fee
payoutFeeParty:
- partner.country === "US" && amountToWithdraw > 100000
+ partner.country === "US" &&
+ amountToWithdraw > FREE_WITHDRAWAL_MINIMUM_BALANCE
? "platform"
: "user",
});
diff --git a/packages/tailwind-config/tailwind.config.ts b/packages/tailwind-config/tailwind.config.ts
index 88ed02f373..24d2a9059f 100644
--- a/packages/tailwind-config/tailwind.config.ts
+++ b/packages/tailwind-config/tailwind.config.ts
@@ -32,6 +32,14 @@ const config: Config = {
"monospace",
],
},
+ fontSize: {
+ "2xs": [
+ "0.625rem",
+ {
+ lineHeight: "0.875rem",
+ },
+ ],
+ },
animation: {
// Modal
"scale-in": "scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1)",