-
Notifications
You must be signed in to change notification settings - Fork 21
Wallet and review phase display issue fixes #1280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| /* eslint-disable react/jsx-wrap-multilines */ | ||
| import { FC, useEffect, useState } from 'react' | ||
| import { FC, useMemo } from 'react' | ||
|
|
||
| import { UserProfile } from '~/libs/core' | ||
| import { IconOutline, LinkButton, LoadingCircles } from '~/libs/ui' | ||
|
|
||
| import { Balance } from '../../../lib/models/WalletDetails' | ||
| import { InfoRow, PayoutGuard } from '../../../lib' | ||
| import { BannerImage, BannerText } from '../../../lib/assets/home' | ||
| import { nullToZero } from '../../../lib/util' | ||
|
|
@@ -17,21 +16,136 @@ interface HomeTabProps { | |
| profile: UserProfile | ||
| } | ||
|
|
||
| type WalletDetailsData = NonNullable<WalletDetailsResponse['data']> | ||
| interface WalletInfoRowsProps { | ||
| walletDetails: WalletDetailsData | ||
| profile: UserProfile | ||
| balanceSum: number | ||
| } | ||
|
|
||
| const WalletInfoRows: FC<WalletInfoRowsProps> = props => ( | ||
| <div className={styles['info-row-container']}> | ||
| <InfoRow | ||
| title='Account Balance' | ||
| value={`$${props.balanceSum}`} | ||
| action={ | ||
| <LinkButton | ||
| label='MANAGE YOUR WINNINGS' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#winnings' | ||
| /> | ||
| } | ||
| /> | ||
|
|
||
| <PayoutGuard profile={props.profile}> | ||
| {props.walletDetails.withdrawalMethod.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Est. Payment Fees' | ||
| value={`$${nullToZero(props.walletDetails.estimatedFees)} USD`} | ||
| action={ | ||
| <LinkButton | ||
| label='ADJUST YOUR PAYOUT SETTINGS' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
| {props.walletDetails.taxForm.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Est. Tax Withholding %' | ||
| value={`${nullToZero(props.walletDetails.taxWithholdingPercentage)}%`} | ||
| action={ | ||
| <LinkButton | ||
| label='ADJUST YOUR PAYOUT SETTINGS' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
|
|
||
| {!props.walletDetails.withdrawalMethod.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Withdrawal Method' | ||
| value={<Chip text='Setup Required' />} | ||
| action={ | ||
| <LinkButton | ||
| label='SETUP WITHDRAWAL METHOD' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
|
|
||
| {!props.walletDetails.taxForm.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Tax Form' | ||
| value={<Chip text='Setup Required' />} | ||
| action={ | ||
| <LinkButton | ||
| label='COMPLETE TAX FORM' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
| {!props.walletDetails.identityVerification.isSetupComplete && ( | ||
| <InfoRow | ||
| title='ID Verification' | ||
| value={<Chip text='Setup Required' />} | ||
| action={ | ||
| <LinkButton | ||
| label='COMPLETE VERIFICATION' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
| </PayoutGuard> | ||
| </div> | ||
| ) | ||
|
|
||
| const HomeTab: FC<HomeTabProps> = props => { | ||
|
|
||
| const { data: walletDetails, isLoading, error }: WalletDetailsResponse = useWalletDetails() | ||
| const [balanceSum, setBalanceSum] = useState(0) | ||
|
|
||
| useEffect(() => { | ||
| if (walletDetails) { | ||
| setBalanceSum( | ||
| walletDetails.account.balances.reduce((sum: number, balance: Balance) => sum + balance.amount, 0), | ||
| ) | ||
| } | ||
| }, [walletDetails]) | ||
| const balanceSum = useMemo( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| () => (walletDetails ? walletDetails.account.balances.reduce((sum, balance) => sum + balance.amount, 0) : 0), | ||
| [walletDetails], | ||
| ) | ||
|
|
||
| if (error) { | ||
| return <div>{error}</div> | ||
| let errorMessage = 'Unable to load wallet details.' | ||
|
|
||
| if (typeof error === 'string') { | ||
| errorMessage = error | ||
| } else if (error && typeof error === 'object' && 'message' in error) { | ||
| errorMessage = (error as Error).message || errorMessage | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| } | ||
|
|
||
| return <div>{errorMessage}</div> | ||
| } | ||
|
|
||
| return ( | ||
|
|
@@ -42,117 +156,7 @@ const HomeTab: FC<HomeTabProps> = props => { | |
| </div> | ||
| {isLoading && <LoadingCircles />} | ||
| {!isLoading && walletDetails && ( | ||
| <div className={styles['info-row-container']}> | ||
| <InfoRow | ||
| title='Account Balance' | ||
| value={`$${balanceSum}`} | ||
| action={ | ||
| <LinkButton | ||
| label='MANAGE YOUR WINNINGS' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#winnings' | ||
| /> | ||
| } | ||
| /> | ||
|
|
||
| <PayoutGuard profile={props.profile}> | ||
| {walletDetails.withdrawalMethod.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Est. Payment Fees' | ||
| value={`$${nullToZero(walletDetails.estimatedFees)} USD`} | ||
| action={ | ||
| <LinkButton | ||
| label='ADJUST YOUR PAYOUT SETTINGS' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
| {walletDetails.taxForm.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Est. Tax Withholding %' | ||
| value={`${nullToZero(walletDetails.taxWithholdingPercentage)}%`} | ||
| action={ | ||
| <LinkButton | ||
| label='ADJUST YOUR PAYOUT SETTINGS' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
|
|
||
| {!walletDetails?.withdrawalMethod.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Withdrawal Method' | ||
| value={ | ||
| walletDetails?.withdrawalMethod.isSetupComplete ? ( | ||
| 'Your preferred method' | ||
| ) : ( | ||
| <Chip text='Setup Required' /> | ||
| ) | ||
| } | ||
| action={ | ||
| <LinkButton | ||
| label='SETUP WITHDRAWAL METHOD' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
|
|
||
| {!walletDetails?.taxForm.isSetupComplete && ( | ||
| <InfoRow | ||
| title='Tax Form' | ||
| value={ | ||
| walletDetails?.taxForm.isSetupComplete | ||
| ? 'All set' | ||
| : <Chip text='Setup Required' /> | ||
| } | ||
| action={ | ||
| <LinkButton | ||
| label='COMPLETE TAX FORM' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
| {!walletDetails?.identityVerification.isSetupComplete && ( | ||
| <InfoRow | ||
| title='ID Verification' | ||
| value={<Chip text='Setup Required' />} | ||
| action={ | ||
| <LinkButton | ||
| label='COMPLETE VERIFICATION' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#payout' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
| </PayoutGuard> | ||
| </div> | ||
| <WalletInfoRows walletDetails={walletDetails} profile={props.profile} balanceSum={balanceSum} /> | ||
| )} | ||
| </div> | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import { getWalletDetails } from '../services/wallet' | |
|
|
||
| export interface Response<T> { | ||
| data?: Readonly<T> | ||
| error?: Readonly<string> | ||
| error?: Readonly<Error> | string | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| mutate: KeyedMutator<any> | ||
| isLoading?: Readonly<boolean> | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[⚠️
correctness]The check for
fragment === 'iterative'is case-sensitive. If there is any chance thatfragmentcould be in a different case (e.g., 'Iterative'), consider normalizing the case offragmentbefore comparison to ensure consistency.