Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/apps/wallet/src/home/tabs/winnings/WinningsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
<PaymentsTable
currentPage={pagination.currentPage}
numPages={pagination.totalPages}
minWithdrawAmount={walletDetails?.minWithdrawAmount ?? 0}
payments={winnings}
selectedPayments={selectedPayments}
onSelectedPaymentsChange={function onSelectedPaymentsChanged(selectedWinnings: { [paymentId: string]: Winning }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ table {

color: #333;
}

.paymeBtn {
pointer-events: initial;
&[disabled] {
cursor: not-allowed;
}
}
}

@media (max-width: 768px) {
Expand Down
39 changes: 30 additions & 9 deletions src/apps/wallet/src/lib/components/payments-table/PaymentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import React, { useEffect, useState } from 'react'

import { Button, IconOutline } from '~/libs/ui'
import { Button, IconOutline, Tooltip } from '~/libs/ui'

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

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

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

const total = calculateTotal()

const isPaymeDisabled = !total || total < props.minWithdrawAmount

return (
<>
<div className={styles.tableContainer}>
Expand Down Expand Up @@ -191,15 +194,33 @@ const PaymentsTable: React.FC<PaymentTableProps> = (props: PaymentTableProps) =>
</div>
</>
)}
<Button
primary
onClick={() => {
props.onPayMeClick(selectedPayments, total.toFixed(2))
}}
disabled={total === 0}
<Tooltip
content={(
<>
Minimum withdrawal amounti is $
{props.minWithdrawAmount}
.
<br />
Please select more payments.
</>
)}
disableTooltip={!isPaymeDisabled}
>
PAY ME
</Button>
<Button
primary
onClick={() => {
if (isPaymeDisabled) {
return
}

props.onPayMeClick(selectedPayments, total.toFixed(2))
}}
className={styles.paymeBtn}
disabled={isPaymeDisabled}
>
PAY ME
</Button>
</Tooltip>
</div>
</>
)
Expand Down
1 change: 1 addition & 0 deletions src/apps/wallet/src/lib/models/WalletDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export interface WalletDetails {
primaryCurrency?: string | null;
estimatedFees?: string | null;
taxWithholdingPercentage?: string | null;
minWithdrawAmount: number;
}
23 changes: 13 additions & 10 deletions src/libs/ui/lib/components/tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface TooltipProps {
children?: ReactNode
triggerOn?: 'click' | 'hover'
strategy?: 'absolute' | 'fixed'
disableTooltip?: boolean
}

function wrapComponents(el: ReactNode, disableWrap?: boolean): ReactNode {
Expand Down Expand Up @@ -56,16 +57,18 @@ const Tooltip: FC<TooltipProps> = (props: TooltipProps) => {
return (
<>
{renderTrigger()}
<ReactTooltip
className={classNames(styles.tooltip, props.className)}
id={tooltipId.current as string}
aria-haspopup='true'
openOnClick={triggerOnClick}
clickable={props.clickable}
positionStrategy={props.strategy ?? 'absolute'}
>
{props.content}
</ReactTooltip>
{!props.disableTooltip && (
<ReactTooltip
className={classNames(styles.tooltip, props.className)}
id={tooltipId.current as string}
aria-haspopup='true'
openOnClick={triggerOnClick}
clickable={props.clickable}
positionStrategy={props.strategy ?? 'absolute'}
>
{props.content}
</ReactTooltip>
)}
</>
)
}
Expand Down