Skip to content

Commit f15eaf1

Browse files
committed
Refactor payout method handling: replace direct payoutMethod usage with partner's defaultPayoutMethod across payout details and stats components for improved consistency and clarity.
1 parent 45abba8 commit f15eaf1

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type PayoutDetailsSheetProps = {
4646
};
4747

4848
function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
49-
const { partner, payoutMethod } = usePartnerProfile();
49+
const { partner } = usePartnerProfile();
5050

5151
const {
5252
data: earnings,
@@ -143,8 +143,8 @@ function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
143143
value: (
144144
<span className="text-red-600">{payout.failureReason}</span>
145145
),
146-
tooltip: `Payout failures are usually due to ${payoutMethod === "paypal" ? "incorrect PayPal account configuration" : "invalid bank account details"}. Once you've [updated your account](/payouts?settings=true), ${
147-
payoutMethod === "paypal"
146+
tooltip: `Payout failures are usually due to ${partner?.defaultPayoutMethod === "paypal" ? "incorrect PayPal account configuration" : "invalid bank account details"}. Once you've [updated your account](/payouts?settings=true), ${
147+
partner?.defaultPayoutMethod === "paypal"
148148
? "you can retry the payout"
149149
: "the payout will be retried automatically"
150150
}.`,

apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function PayoutStatsCard({
112112
}
113113

114114
export function PayoutStats() {
115-
const { payoutMethod } = usePartnerProfile();
115+
const { partner } = usePartnerProfile();
116116

117117
const { payoutsCount, error } = usePartnerPayoutsCount<PayoutsCount[]>({
118118
groupBy: "status",
@@ -122,8 +122,8 @@ export function PayoutStats() {
122122
payoutsCount?.map((p) => [p.status, p]) || [],
123123
) as Record<PayoutStatus, PayoutsCount>;
124124

125-
const tooltip = payoutMethod
126-
? PAYOUT_STATUS_DESCRIPTIONS[payoutMethod]
125+
const tooltip = partner?.defaultPayoutMethod
126+
? PAYOUT_STATUS_DESCRIPTIONS[partner?.defaultPayoutMethod]
127127
: undefined;
128128

129129
const payoutStats = [
@@ -145,7 +145,7 @@ export function PayoutStats() {
145145
error: !!error,
146146
},
147147

148-
...(payoutMethod === "stripe"
148+
...(partner?.defaultPayoutMethod === "connect"
149149
? [
150150
{
151151
label: "Processed",
@@ -266,7 +266,9 @@ export function PayoutStats() {
266266
<div
267267
className={cn(
268268
"hidden divide-x divide-neutral-200 overflow-hidden rounded-lg border border-neutral-200 bg-white md:grid",
269-
payoutMethod === "stripe" ? "md:grid-cols-5" : "md:grid-cols-3",
269+
partner?.defaultPayoutMethod === "connect"
270+
? "md:grid-cols-5"
271+
: "md:grid-cols-3",
270272
)}
271273
>
272274
{payoutStats.map((stat) => (

apps/web/ui/partners/payout-row-menu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useState } from "react";
1212
import { toast } from "sonner";
1313

1414
export function PayoutRowMenu({ row }: { row: Row<PartnerPayoutResponse> }) {
15-
const { payoutMethod } = usePartnerProfile();
15+
const { partner } = usePartnerProfile();
1616
const [isOpen, setIsOpen] = useState(false);
1717

1818
const { executeAsync: executeRetryPayout, isPending: isRetryPayoutPending } =
@@ -42,7 +42,8 @@ export function PayoutRowMenu({ row }: { row: Row<PartnerPayoutResponse> }) {
4242
});
4343

4444
const canRetry =
45-
row.original.status === "failed" && payoutMethod === "paypal";
45+
row.original.status === "failed" &&
46+
partner?.defaultPayoutMethod === "paypal";
4647

4748
if (!canRetry) {
4849
return null;

0 commit comments

Comments
 (0)