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

View File

@ -8,8 +8,6 @@ import { useTranslation } from 'next-i18next'
import useMangoAccount from 'hooks/useMangoAccount'
import useMangoGroup from 'hooks/useMangoGroup'
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 }) => {
return (
@ -25,8 +23,6 @@ const MangoAccountSummary = () => {
const { group } = useMangoGroup()
const { mangoAccount } = useMangoAccount()
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(() => {
if (!group || !mangoAccount) return [0, 0, 0]
@ -62,11 +58,7 @@ const MangoAccountSummary = () => {
<div className="space-y-2">
<SummaryItem
label={t('account-value')}
value={
!hideAccountValue
? formatFixedDecimals(accountValue, true, true)
: '*****'
}
value={formatFixedDecimals(accountValue, true, true)}
/>
<SummaryItem label={t('health')} value={`${health}%`} />
<SummaryItem
@ -76,7 +68,7 @@ const MangoAccountSummary = () => {
<SummaryItem label={t('leverage')} value={`${leverage.toFixed(2)}x`} />
<SummaryItem
label={t('pnl')}
value={!hidePnl ? formatFixedDecimals(pnl, true, true) : '*****'}
value={formatFixedDecimals(pnl, true, true)}
/>
</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 HIDE_ACCOUNT_VALUE_KEY = 'hideAccountValue-0.1'
export const HIDE_PNL_KEY = 'hidePnl-0.1'
// Unused
export const PROFILE_CATEGORIES = [
'borrower',