Skip to content

Commit 4c99809

Browse files
committed
PM-1278 - disable payme button in wallet if min withdrawal amount is not met
1 parent 7dda0ba commit 4c99809

File tree

5 files changed

+48
-21
lines changed

5 files changed

+48
-21
lines changed

src/apps/wallet/src/home/tabs/winnings/WinningsTab.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { toast } from 'react-toastify'
44
import { AxiosError } from 'axios'
55
import { Link } from 'react-router-dom'
6-
import React, { FC, useCallback, useEffect } from 'react'
6+
import React, { FC, useCallback, useEffect, useMemo } from 'react'
77

88
import { Collapsible, ConfirmModal, LoadingCircles } from '~/libs/ui'
99
import { UserProfile } from '~/libs/core'
@@ -414,6 +414,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
414414
<PaymentsTable
415415
currentPage={pagination.currentPage}
416416
numPages={pagination.totalPages}
417+
minWithdrawAmount={walletDetails?.minWithdrawAmount ?? 0}
417418
payments={winnings}
418419
selectedPayments={selectedPayments}
419420
onSelectedPaymentsChange={function onSelectedPaymentsChanged(selectedWinnings: { [paymentId: string]: Winning }) {

src/apps/wallet/src/lib/components/payments-table/PaymentTable.module.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ table {
9191

9292
color: #333;
9393
}
94+
95+
.paymeBtn {
96+
pointer-events: initial;
97+
&[disabled] {
98+
cursor: not-allowed;
99+
}
100+
}
94101
}
95102

96103
@media (max-width: 768px) {

src/apps/wallet/src/lib/components/payments-table/PaymentTable.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
/* eslint-disable @typescript-eslint/explicit-function-return-type */
33
import React, { useEffect, useState } from 'react'
44

5-
import { Button, IconOutline } from '~/libs/ui'
5+
import { Button, IconOutline, Tooltip } from '~/libs/ui'
66

77
import { Winning } from '../../models/WinningDetail'
88

99
import styles from './PaymentTable.module.scss'
1010

1111
interface PaymentTableProps {
12+
minWithdrawAmount: number;
1213
payments: ReadonlyArray<Winning>;
1314
selectedPayments?: { [paymentId: string]: Winning };
1415
currentPage: number;
@@ -85,6 +86,8 @@ const PaymentsTable: React.FC<PaymentTableProps> = (props: PaymentTableProps) =>
8586

8687
const total = calculateTotal()
8788

89+
const isPaymeDisabled = !total || total < props.minWithdrawAmount;
90+
8891
return (
8992
<>
9093
<div className={styles.tableContainer}>
@@ -191,15 +194,27 @@ const PaymentsTable: React.FC<PaymentTableProps> = (props: PaymentTableProps) =>
191194
</div>
192195
</>
193196
)}
194-
<Button
195-
primary
196-
onClick={() => {
197-
props.onPayMeClick(selectedPayments, total.toFixed(2))
198-
}}
199-
disabled={total === 0}
200-
>
201-
PAY ME
202-
</Button>
197+
<Tooltip content={(
198+
<>
199+
Minimum withdrawal amounti is ${props.minWithdrawAmount}.
200+
<br />
201+
Please select more payments.
202+
</>
203+
)} disableTooltip={!isPaymeDisabled}>
204+
<Button
205+
primary
206+
onClick={() => {
207+
if (isPaymeDisabled) {
208+
return;
209+
}
210+
props.onPayMeClick(selectedPayments, total.toFixed(2))
211+
}}
212+
className={styles.paymeBtn}
213+
disabled={isPaymeDisabled}
214+
>
215+
PAY ME
216+
</Button>
217+
</Tooltip>
203218
</div>
204219
</>
205220
)

src/apps/wallet/src/lib/models/WalletDetails.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ export interface WalletDetails {
2323
primaryCurrency?: string | null;
2424
estimatedFees?: string | null;
2525
taxWithholdingPercentage?: string | null;
26+
minWithdrawAmount: number;
2627
}

src/libs/ui/lib/components/tooltip/Tooltip.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface TooltipProps {
2525
children?: ReactNode
2626
triggerOn?: 'click' | 'hover'
2727
strategy?: 'absolute' | 'fixed'
28+
disableTooltip?: boolean
2829
}
2930

3031
function wrapComponents(el: ReactNode, disableWrap?: boolean): ReactNode {
@@ -56,16 +57,18 @@ const Tooltip: FC<TooltipProps> = (props: TooltipProps) => {
5657
return (
5758
<>
5859
{renderTrigger()}
59-
<ReactTooltip
60-
className={classNames(styles.tooltip, props.className)}
61-
id={tooltipId.current as string}
62-
aria-haspopup='true'
63-
openOnClick={triggerOnClick}
64-
clickable={props.clickable}
65-
positionStrategy={props.strategy ?? 'absolute'}
66-
>
67-
{props.content}
68-
</ReactTooltip>
60+
{!props.disableTooltip && (
61+
<ReactTooltip
62+
className={classNames(styles.tooltip, props.className)}
63+
id={tooltipId.current as string}
64+
aria-haspopup='true'
65+
openOnClick={triggerOnClick}
66+
clickable={props.clickable}
67+
positionStrategy={props.strategy ?? 'absolute'}
68+
>
69+
{props.content}
70+
</ReactTooltip>
71+
)}
6972
</>
7073
)
7174
}

0 commit comments

Comments
 (0)