remove show/hide account values

This commit is contained in:
saml33 2023-01-24 09:52:59 +11:00
parent cea7ee54ed
commit 0f99619e2c
3 changed files with 51 additions and 110 deletions

View File

@ -20,8 +20,6 @@ import {
ArrowsPointingOutIcon, ArrowsPointingOutIcon,
ChartBarIcon, ChartBarIcon,
ClockIcon, ClockIcon,
EyeIcon,
EyeSlashIcon,
} from '@heroicons/react/20/solid' } from '@heroicons/react/20/solid'
import { Transition } from '@headlessui/react' import { Transition } from '@headlessui/react'
import AccountTabs from './AccountTabs' import AccountTabs from './AccountTabs'
@ -32,8 +30,6 @@ import Change from '../shared/Change'
import Tooltip from '@components/shared/Tooltip' import Tooltip from '@components/shared/Tooltip'
import { import {
ANIMATION_SETTINGS_KEY, ANIMATION_SETTINGS_KEY,
HIDE_ACCOUNT_VALUE_KEY,
HIDE_PNL_KEY,
// IS_ONBOARDED_KEY // IS_ONBOARDED_KEY
} from 'utils/constants' } from 'utils/constants'
// import { useWallet } from '@solana/wallet-adapter-react' // import { useWallet } from '@solana/wallet-adapter-react'
@ -76,11 +72,6 @@ const AccountPage = () => {
ANIMATION_SETTINGS_KEY, ANIMATION_SETTINGS_KEY,
INITIAL_ANIMATION_SETTINGS INITIAL_ANIMATION_SETTINGS
) )
const [hideAccountValue, setHideAccountValue] = useLocalStorageState(
HIDE_ACCOUNT_VALUE_KEY,
false
)
const [hidePnl, setHidePnl] = useLocalStorageState(HIDE_PNL_KEY, false)
useEffect(() => { useEffect(() => {
if (mangoAccountAddress) { if (mangoAccountAddress) {
@ -241,32 +232,18 @@ const AccountPage = () => {
<div className="flex flex-col border-b-0 border-th-bkg-3 px-6 py-3 lg:flex-row lg:items-center lg:justify-between lg:border-b"> <div className="flex flex-col border-b-0 border-th-bkg-3 px-6 py-3 lg:flex-row lg:items-center lg:justify-between lg:border-b">
<div className="flex flex-col md:flex-row md:items-center md:space-x-6"> <div className="flex flex-col md:flex-row md:items-center md:space-x-6">
<div id="account-step-three"> <div id="account-step-three">
<div className="mb-2 flex items-center space-x-2">
<Tooltip <Tooltip
maxWidth="20rem" maxWidth="20rem"
placement="bottom-start" placement="bottom-start"
content="The value of your assets (deposits) minus the value of your liabilities (borrows)." content="The value of your assets (deposits) minus the value of your liabilities (borrows)."
delay={250} delay={250}
> >
<p className="tooltip-underline text-base"> <p className="tooltip-underline mb-2 text-base">
{t('account-value')} {t('account-value')}
</p> </p>
</Tooltip> </Tooltip>
<IconButton
className="text-th-fgd-4"
hideBg
onClick={() => setHideAccountValue(!hideAccountValue)}
>
{hideAccountValue ? (
<EyeSlashIcon className="h-4 w-4" />
) : (
<EyeIcon className="h-4 w-4" />
)}
</IconButton>
</div>
<div className="mb-2 flex items-center font-display text-5xl text-th-fgd-1"> <div className="mb-2 flex items-center font-display text-5xl text-th-fgd-1">
{!hideAccountValue ? ( {animationSettings['number-scroll'] ? (
animationSettings['number-scroll'] ? (
group && mangoAccount ? ( group && mangoAccount ? (
<FlipNumbers <FlipNumbers
height={48} height={48}
@ -288,25 +265,18 @@ const AccountPage = () => {
) )
) : ( ) : (
<span>{formatFixedDecimals(accountValue, true, true)}</span> <span>{formatFixedDecimals(accountValue, true, true)}</span>
)
) : (
<span className={!mangoAccount ? 'mb-1' : ''}>*****</span>
)} )}
</div> </div>
<div className="flex items-center space-x-1.5"> <div className="flex items-center space-x-1.5">
{!hideAccountValue ? (
<Change <Change
change={Number(formatDecimal(accountValueChange, 2))} change={Number(formatDecimal(accountValueChange, 2))}
prefix="$" prefix="$"
/> />
) : (
<p>*****</p>
)}
<p className="text-th-fgd-4">{t('today')}</p> <p className="text-th-fgd-4">{t('today')}</p>
</div> </div>
</div> </div>
{performanceInitialLoad ? ( {performanceInitialLoad ? (
!hideAccountValue && oneDayPerformanceData.length ? ( oneDayPerformanceData.length ? (
<div <div
className="relative mt-4 flex h-40 items-end md:mt-0 md:h-24 md:w-48" className="relative mt-4 flex h-40 items-end md:mt-0 md:h-24 md:w-48"
onMouseEnter={() => onMouseEnter={() =>
@ -473,7 +443,6 @@ const AccountPage = () => {
<div className="col-span-5 border-t border-th-bkg-3 py-3 pl-6 pr-4 lg:col-span-1 lg:border-l lg:border-t-0"> <div className="col-span-5 border-t border-th-bkg-3 py-3 pl-6 pr-4 lg:col-span-1 lg:border-l lg:border-t-0">
<div id="account-step-seven" className="flex flex-col items-start"> <div id="account-step-seven" className="flex flex-col items-start">
<div className="flex w-full items-center justify-between"> <div className="flex w-full items-center justify-between">
<div className="flex items-center space-x-2">
<Tooltip <Tooltip
content={t('account:tooltip-pnl')} content={t('account:tooltip-pnl')}
placement="bottom" placement="bottom"
@ -483,18 +452,6 @@ const AccountPage = () => {
{t('pnl')} {t('pnl')}
</p> </p>
</Tooltip> </Tooltip>
<IconButton
className="text-th-fgd-4"
hideBg
onClick={() => setHidePnl(!hidePnl)}
>
{hidePnl ? (
<EyeSlashIcon className="h-4 w-4" />
) : (
<EyeIcon className="h-4 w-4" />
)}
</IconButton>
</div>
{mangoAccountAddress ? ( {mangoAccountAddress ? (
<div className="flex items-center space-x-3"> <div className="flex items-center space-x-3">
{performanceData.length > 4 ? ( {performanceData.length > 4 ? (
@ -521,18 +478,14 @@ const AccountPage = () => {
) : null} ) : null}
</div> </div>
<p className="mt-1 mb-0.5 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl"> <p className="mt-1 mb-0.5 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
{!hidePnl ? formatFixedDecimals(accountPnl, true, true) : '*****'} {formatFixedDecimals(accountPnl, true, true)}
</p> </p>
<div className="flex space-x-1"> <div className="flex space-x-1">
{!hidePnl ? (
<Change <Change
change={Number(formatDecimal(oneDayPnlChange, 2))} change={Number(formatDecimal(oneDayPnlChange, 2))}
prefix="$" prefix="$"
size="small" size="small"
/> />
) : (
<p className="leading-none">*****</p>
)}
<p className="text-xs text-th-fgd-4">{t('today')}</p> <p className="text-xs text-th-fgd-4">{t('today')}</p>
</div> </div>
</div> </div>

View File

@ -8,8 +8,6 @@ import { useTranslation } from 'next-i18next'
import useMangoAccount from 'hooks/useMangoAccount' import useMangoAccount from 'hooks/useMangoAccount'
import useMangoGroup from 'hooks/useMangoGroup' import useMangoGroup from 'hooks/useMangoGroup'
import { useMemo } from 'react' import { useMemo } from 'react'
import useLocalStorageState from 'hooks/useLocalStorageState'
import { HIDE_ACCOUNT_VALUE_KEY, HIDE_PNL_KEY } from 'utils/constants'
const SummaryItem = ({ label, value }: { label: string; value: string }) => { const SummaryItem = ({ label, value }: { label: string; value: string }) => {
return ( return (
@ -25,8 +23,6 @@ const MangoAccountSummary = () => {
const { group } = useMangoGroup() const { group } = useMangoGroup()
const { mangoAccount } = useMangoAccount() const { mangoAccount } = useMangoAccount()
const performanceData = mangoStore((s) => s.mangoAccount.performance.data) const performanceData = mangoStore((s) => s.mangoAccount.performance.data)
const [hideAccountValue] = useLocalStorageState(HIDE_ACCOUNT_VALUE_KEY, true)
const [hidePnl] = useLocalStorageState(HIDE_PNL_KEY, true)
const [accountValue, freeCollateral, health] = useMemo(() => { const [accountValue, freeCollateral, health] = useMemo(() => {
if (!group || !mangoAccount) return [0, 0, 0] if (!group || !mangoAccount) return [0, 0, 0]
@ -62,11 +58,7 @@ const MangoAccountSummary = () => {
<div className="space-y-2"> <div className="space-y-2">
<SummaryItem <SummaryItem
label={t('account-value')} label={t('account-value')}
value={ value={formatFixedDecimals(accountValue, true, true)}
!hideAccountValue
? formatFixedDecimals(accountValue, true, true)
: '*****'
}
/> />
<SummaryItem label={t('health')} value={`${health}%`} /> <SummaryItem label={t('health')} value={`${health}%`} />
<SummaryItem <SummaryItem
@ -76,7 +68,7 @@ const MangoAccountSummary = () => {
<SummaryItem label={t('leverage')} value={`${leverage.toFixed(2)}x`} /> <SummaryItem label={t('leverage')} value={`${leverage.toFixed(2)}x`} />
<SummaryItem <SummaryItem
label={t('pnl')} label={t('pnl')}
value={!hidePnl ? formatFixedDecimals(pnl, true, true) : '*****'} value={formatFixedDecimals(pnl, true, true)}
/> />
</div> </div>
) )

View File

@ -45,10 +45,6 @@ export const RPC_PROVIDER_KEY = 'rpcProviderKey-0.4'
export const PRIORITY_FEE_KEY = 'priorityFeeKey-0.1' export const PRIORITY_FEE_KEY = 'priorityFeeKey-0.1'
export const HIDE_ACCOUNT_VALUE_KEY = 'hideAccountValue-0.1'
export const HIDE_PNL_KEY = 'hidePnl-0.1'
// Unused // Unused
export const PROFILE_CATEGORIES = [ export const PROFILE_CATEGORIES = [
'borrower', 'borrower',