22/* eslint-disable react/jsx-no-bind */
33import { toast } from 'react-toastify'
44import { AxiosError } from 'axios'
5+ import { Link } from 'react-router-dom'
56import React , { FC , useCallback , useEffect } from 'react'
67
78import { Collapsible , ConfirmModal , LoadingCircles } from '~/libs/ui'
@@ -12,6 +13,8 @@ import { Winning, WinningDetail } from '../../../lib/models/WinningDetail'
1213import { FilterBar } from '../../../lib'
1314import { ConfirmFlowData } from '../../../lib/models/ConfirmFlowData'
1415import { PaginationInfo } from '../../../lib/models/PaginationInfo'
16+ import { useWalletDetails , WalletDetailsResponse } from '../../../lib/hooks/use-wallet-details'
17+ import { nullToZero } from '../../../lib/util'
1518import PaymentsTable from '../../../lib/components/payments-table/PaymentTable'
1619
1720import styles from './Winnings.module.scss'
@@ -74,6 +77,8 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
7477 const [ selectedPayments , setSelectedPayments ] = React . useState < { [ paymentId : string ] : Winning } > ( { } )
7578 const [ isLoading , setIsLoading ] = React . useState < boolean > ( false )
7679 const [ filters , setFilters ] = React . useState < Record < string , string [ ] > > ( { } )
80+ const { data : walletDetails } : WalletDetailsResponse = useWalletDetails ( )
81+
7782 const [ pagination , setPagination ] = React . useState < PaginationInfo > ( {
7883 currentPage : 1 ,
7984 pageSize : 10 ,
@@ -180,6 +185,58 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
180185 fetchWinnings ( )
181186 }
182187
188+ function handlePayMeClick (
189+ paymentIds : { [ paymentId : string ] : Winning } ,
190+ totalAmount : string ,
191+ ) : void {
192+ setConfirmFlow ( {
193+ action : 'Yes' ,
194+ callback : ( ) => processPayouts ( Object . keys ( paymentIds ) ) ,
195+ content : (
196+ < >
197+ You are about to process payments for a total of USD
198+ { ' ' }
199+ { totalAmount }
200+ .
201+ < br />
202+ < br />
203+ { walletDetails && (
204+ < >
205+ < div className = { styles . taxes } >
206+ Est. Payment Fees:
207+ { ' ' }
208+ { nullToZero ( walletDetails . estimatedFees ) }
209+ { ' ' }
210+ USD and Tax Withholding:
211+ { ' ' }
212+ { `${ nullToZero ( walletDetails . taxWithholdingPercentage ) } %` }
213+ { ' ' }
214+ will be applied on the payment.
215+ </ div >
216+ < div className = { styles . taxes } >
217+ { walletDetails . primaryCurrency && (
218+ < >
219+ You will receive the payment in
220+ { ' ' }
221+ { walletDetails . primaryCurrency }
222+ { ' ' }
223+ currency after 2% coversion fees applied.
224+ </ >
225+ ) }
226+ </ div >
227+ < div className = { `${ styles . taxes } ${ styles . mt } ` } >
228+ You can adjust your payout settings to customize your estimated payment fee and tax withholding percentage in
229+ { ' ' }
230+ < Link to = '#payout' > Payout</ Link >
231+ </ div >
232+ </ >
233+ ) }
234+ </ >
235+ ) ,
236+ title : 'Are you sure?' ,
237+ } )
238+ }
239+
183240 return (
184241 < >
185242 < div className = { styles . container } >
@@ -338,17 +395,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
338395 currentPage : pageNumber ,
339396 } )
340397 } }
341- onPayMeClick = { async function onPayMeClicked (
342- paymentIds : { [ paymentId : string ] : Winning } ,
343- totalAmount : string ,
344- ) {
345- setConfirmFlow ( {
346- action : 'Yes' ,
347- callback : ( ) => processPayouts ( Object . keys ( paymentIds ) ) ,
348- content : `You are about to process payments for a total of USD ${ totalAmount } ` ,
349- title : 'Are you sure?' ,
350- } )
351- } }
398+ onPayMeClick = { handlePayMeClick }
352399 />
353400 ) }
354401 { ! isLoading && winnings . length === 0 && (
0 commit comments