-
Notifications
You must be signed in to change notification settings - Fork 21
PM-3260 points in wallet #1409
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
PM-3260 points in wallet #1409
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 |
|---|---|---|
|
|
@@ -20,14 +20,15 @@ type WalletDetailsData = NonNullable<WalletDetailsResponse['data']> | |
| interface WalletInfoRowsProps { | ||
| walletDetails: WalletDetailsData | ||
| profile: UserProfile | ||
| balanceSum: number | ||
| paymentsBalance: number | ||
| pointsBalance?: number | ||
| } | ||
|
|
||
| const WalletInfoRows: FC<WalletInfoRowsProps> = props => ( | ||
| <div className={styles['info-row-container']}> | ||
| <InfoRow | ||
| title='Account Balance' | ||
| value={`$${props.balanceSum}`} | ||
| value={`$${props.paymentsBalance}`} | ||
| action={ | ||
| <LinkButton | ||
| label='MANAGE YOUR WINNINGS' | ||
|
|
@@ -40,6 +41,23 @@ const WalletInfoRows: FC<WalletInfoRowsProps> = props => ( | |
| } | ||
| /> | ||
|
|
||
| {!!props.pointsBalance && ( | ||
|
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. [ |
||
| <InfoRow | ||
| title='Points Balance' | ||
| value={`${props.pointsBalance} points`} | ||
| action={ | ||
| <LinkButton | ||
| label='VIEW YOUR POINTS' | ||
| iconToRight | ||
| icon={IconOutline.ArrowRightIcon} | ||
| size='md' | ||
| link | ||
| to='#winnings?type=points' | ||
| /> | ||
| } | ||
| /> | ||
| )} | ||
|
|
||
| <PayoutGuard profile={props.profile}> | ||
| {props.walletDetails.withdrawalMethod.isSetupComplete && ( | ||
| <InfoRow | ||
|
|
@@ -131,8 +149,18 @@ const HomeTab: FC<HomeTabProps> = props => { | |
|
|
||
| const { data: walletDetails, isLoading, error }: WalletDetailsResponse = useWalletDetails() | ||
|
|
||
| const balanceSum = useMemo( | ||
| () => (walletDetails ? walletDetails.account.balances.reduce((sum, balance) => sum + balance.amount, 0) : 0), | ||
| const [paymentsBalance, pointsBalance] = useMemo( | ||
| () => ((walletDetails?.account.balances ?? []).reduce((sums, balance) => { | ||
|
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. [💡 |
||
| if (balance.type === 'PAYMENT') { | ||
| sums[0] += balance.amount | ||
| } | ||
|
|
||
| if (balance.type === 'POINTS') { | ||
| sums[1] += balance.amount | ||
| } | ||
|
|
||
| return sums | ||
| }, [0, 0])), | ||
| [walletDetails], | ||
| ) | ||
|
|
||
|
|
@@ -156,7 +184,12 @@ const HomeTab: FC<HomeTabProps> = props => { | |
| </div> | ||
| {isLoading && <LoadingCircles />} | ||
| {!isLoading && walletDetails && ( | ||
| <WalletInfoRows walletDetails={walletDetails} profile={props.profile} balanceSum={balanceSum} /> | ||
| <WalletInfoRows | ||
| walletDetails={walletDetails} | ||
| profile={props.profile} | ||
| paymentsBalance={paymentsBalance} | ||
| pointsBalance={pointsBalance} | ||
| /> | ||
| )} | ||
| </div> | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.