forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wojciech: feat: reset demo balance (deriv-com#10769)
* feat: routing, skeleton for reset balance [wip] * feat: UI skeleton * feat: functionally complete, pending component updates and style updates * feat: switched buttons to new component * feat: removed old Text components, removed classes * feat: removed dependency on legacy components * feat: added styling * feat: final cleanups, added mobile (though would be cool to get rid of isMobile in future) * feat: fixed incorrect number * Update packages/wallets/src/features/cashier/flows/WalletResetBalance/WalletResetBalance.scss Co-authored-by: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com> * Update packages/wallets/src/features/cashier/flows/WalletResetBalance/WalletResetBalance.scss Co-authored-by: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com> * Update packages/wallets/src/features/cashier/flows/WalletResetBalance/WalletResetBalance.scss Co-authored-by: Aizad Ridzo <103104395+aizad-deriv@users.noreply.github.com> * feat: updated as per new requirements, switched to useMutation --------- Co-authored-by: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com> Co-authored-by: Aizad Ridzo <103104395+aizad-deriv@users.noreply.github.com>
- Loading branch information
1 parent
01398de
commit f9ced71
Showing
9 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 8 additions & 3 deletions
11
...ges/wallets/src/features/cashier/components/WalletCashierContent/WalletCashierContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/wallets/src/features/cashier/flows/WalletResetBalance/WalletResetBalance.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.wallets-reset-balance { | ||
text-align: center; | ||
|
||
&__icon { | ||
margin: 4rem 0rem; | ||
} | ||
|
||
&__title, | ||
&__subtitle { | ||
margin: 1.6rem 0rem; | ||
} | ||
|
||
&__button { | ||
margin-top: 3rem; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
packages/wallets/src/features/cashier/flows/WalletResetBalance/WalletResetBalance.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import { useActiveWalletAccount, useMutation } from '@deriv/api'; | ||
import { useHistory } from 'react-router-dom'; | ||
import useDevice from '../../../../hooks/useDevice'; | ||
import WalletButton from '../../../../components/Base/WalletButton/WalletButton'; | ||
import WalletText from '../../../../components/Base/WalletText/WalletText'; | ||
import IcResetDemoBalance from '../../../../public/images/ic-demo-reset-balance.svg'; | ||
import IcResetDemoBalanceDone from '../../../../public/images/ic-demo-reset-balance-done.svg'; | ||
import './WalletResetBalance.scss'; | ||
|
||
const WalletResetBalance = () => { | ||
const history = useHistory(); | ||
const { isSuccess: isResetBalanceSuccess, mutate } = useMutation('topup_virtual'); | ||
const { data: activeWallet } = useActiveWalletAccount(); | ||
const { isMobile } = useDevice(); | ||
|
||
const resetBalance = () => { | ||
mutate(); | ||
}; | ||
|
||
const showResetButton = activeWallet?.balance !== 10000; | ||
|
||
return ( | ||
<div className='wallets-reset-balance'> | ||
<div className='wallets-reset-balance__icon'> | ||
{isResetBalanceSuccess ? <IcResetDemoBalanceDone /> : <IcResetDemoBalance />} | ||
</div> | ||
|
||
<div className='wallets-reset-balance__title'> | ||
<WalletText size={isMobile ? 'lg' : '2xl'} weight='bold'> | ||
Reset balance to 10,000.00 USD | ||
</WalletText> | ||
</div> | ||
|
||
<div className='wallets-reset-balance__subtitle'> | ||
<WalletText size={isMobile ? 'md' : 'lg'}> | ||
{isResetBalanceSuccess ? ( | ||
<>Your balance has been reset to 10,000.00 USD.</> | ||
) : ( | ||
<> Reset your virtual balance if it falls below 10,000.00 USD or exceeds 10,000.00 USD.</> | ||
)} | ||
</WalletText> | ||
</div> | ||
|
||
<div className='wallets-reset-balance__button'> | ||
{showResetButton && ( | ||
<WalletButton color='primary' onClick={resetBalance} size='lg' text='Reset balance' /> | ||
)} | ||
|
||
{!showResetButton && ( | ||
<WalletButton | ||
color='primary' | ||
onClick={() => history.push(`/wallets/cashier/transfer`)} | ||
size='lg' | ||
text='Transfer funds' | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WalletResetBalance; |
1 change: 1 addition & 0 deletions
1
packages/wallets/src/features/cashier/flows/WalletResetBalance/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as WalletResetBalance } from './WalletResetBalance'; |
1 change: 1 addition & 0 deletions
1
packages/wallets/src/public/images/ic-demo-reset-balance-done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters