-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #943 from mars-protocol/develop
v2.3.5
- Loading branch information
Showing
14 changed files
with
249 additions
and
128 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useCallback, useMemo } from 'react' | ||
|
||
import AccountFundFullPage from 'components/account/AccountFund/AccountFundFullPage' | ||
import Button from 'components/common/Button' | ||
import { ArrowDownLine, ArrowUpLine, TrashBin } from 'components/common/Icons' | ||
import useAllAssets from 'hooks/assets/useAllAssets' | ||
import usePrices from 'hooks/prices/usePrices' | ||
import useStore from 'store' | ||
import { calculateAccountBalanceValue } from 'utils/accounts' | ||
|
||
interface Props { | ||
account: Account | ||
} | ||
|
||
export default function ManageAccount(props: Props) { | ||
const { account } = props | ||
const assets = useAllAssets() | ||
const { data: prices } = usePrices() | ||
const isHls = account.kind === 'high_levered_strategy' | ||
const positionBalance = useMemo( | ||
() => (!account ? null : calculateAccountBalanceValue(account, prices, assets)), | ||
[account, assets, prices], | ||
) | ||
const deleteAccountHandler = useCallback(() => { | ||
if (!account) return | ||
useStore.setState({ accountDeleteModal: account }) | ||
}, [account]) | ||
|
||
return ( | ||
<div className='flex flex-wrap justify-center w-full gap-4 md:justify-end'> | ||
{!isHls && ( | ||
<> | ||
<Button | ||
text='Fund' | ||
color='tertiary' | ||
leftIcon={<ArrowUpLine />} | ||
disabled={!positionBalance} | ||
onClick={() => { | ||
if (!positionBalance) return | ||
if (positionBalance.isLessThanOrEqualTo(0)) { | ||
useStore.setState({ | ||
focusComponent: { | ||
component: <AccountFundFullPage />, | ||
onClose: () => { | ||
useStore.setState({ getStartedModal: true }) | ||
}, | ||
}, | ||
}) | ||
return | ||
} | ||
useStore.setState({ fundAndWithdrawModal: 'fund' }) | ||
}} | ||
/> | ||
<Button | ||
color='tertiary' | ||
leftIcon={<ArrowDownLine />} | ||
text='Withdraw' | ||
onClick={() => { | ||
useStore.setState({ fundAndWithdrawModal: 'withdraw' }) | ||
}} | ||
disabled={!positionBalance || positionBalance.isLessThanOrEqualTo(0)} | ||
/> | ||
</> | ||
)} | ||
<Button | ||
color='tertiary' | ||
leftIcon={<TrashBin />} | ||
text='Delete' | ||
disabled={!account} | ||
onClick={() => { | ||
deleteAccountHandler() | ||
}} | ||
/> | ||
</div> | ||
) | ||
} |
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
Oops, something went wrong.