Skip to content

Commit 827c1db

Browse files
authored
Merge pull request #1111 from topcoder-platform/PM-1278_limit-withdrawal-min
PM-1278 limit withdrawal min
2 parents 7dda0ba + 620eb49 commit 827c1db

File tree

5 files changed

+52
-19
lines changed

5 files changed

+52
-19
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 30 additions & 9 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,33 @@ 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}
197+
<Tooltip
198+
content={(
199+
<>
200+
Minimum withdrawal amounti is $
201+
{props.minWithdrawAmount}
202+
.
203+
<br />
204+
Please select more payments.
205+
</>
206+
)}
207+
disableTooltip={!isPaymeDisabled}
200208
>
201-
PAY ME
202-
</Button>
209+
<Button
210+
primary
211+
onClick={() => {
212+
if (isPaymeDisabled) {
213+
return
214+
}
215+
216+
props.onPayMeClick(selectedPayments, total.toFixed(2))
217+
}}
218+
className={styles.paymeBtn}
219+
disabled={isPaymeDisabled}
220+
>
221+
PAY ME
222+
</Button>
223+
</Tooltip>
203224
</div>
204225
</>
205226
)

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)