tidy: refactor

This commit is contained in:
Linkie Link 2024-01-24 17:20:51 +01:00
parent 11dac403a0
commit 7cfe05ebb7
No known key found for this signature in database
GPG Key ID: 5318B0F2564D38EA

View File

@ -77,44 +77,55 @@ export default function AccountSummary(props: Props) {
[accountSummaryTabs, setAccountSummaryTabs], [accountSummaryTabs, setAccountSummaryTabs],
) )
const items = [ const items = useMemo(() => {
{ const itemsArray = [
title: `Credit Account ${props.account.id} Composition`, {
renderContent: () => title: `Credit Account ${props.account.id} Composition`,
props.account ? <AccountComposition account={props.account} isHls={props.isHls} /> : null, renderContent: () =>
isOpen: accountSummaryTabs[0], props.account ? <AccountComposition account={props.account} isHls={props.isHls} /> : null,
toggleOpen: (index: number) => handleToggle(index), isOpen: accountSummaryTabs[0],
renderSubTitle: () => <></>, toggleOpen: (index: number) => handleToggle(index),
}, renderSubTitle: () => <></>,
{ },
title: 'Balances', {
renderContent: () => title: 'Balances',
props.account ? ( renderContent: () =>
<AccountBalancesTable props.account ? (
account={props.account} <AccountBalancesTable
borrowingData={borrowAssetsData} account={props.account}
lendingData={lendingAssetsData} borrowingData={borrowAssetsData}
hideCard lendingData={lendingAssetsData}
isHls={props.isHls} hideCard
/> isHls={props.isHls}
) : null, />
isOpen: accountSummaryTabs[1], ) : null,
toggleOpen: (index: number) => handleToggle(index), isOpen: accountSummaryTabs[1],
renderSubTitle: () => <></>, toggleOpen: (index: number) => handleToggle(index),
}, renderSubTitle: () => <></>,
] },
]
if (chainConfig.perps)
itemsArray.push({
title: 'Perp Positions',
renderContent: () =>
props.account && props.account.perps.length > 0 ? (
<AccountPerpPositionTable account={props.account} hideCard />
) : null,
isOpen: accountSummaryTabs[2] ?? false,
toggleOpen: (index: number) => handleToggle(index),
renderSubTitle: () => <></>,
})
if (chainConfig.perps) return itemsArray
items.push({ }, [
title: 'Perp Positions', props.account,
renderContent: () => borrowAssetsData,
props.account && props.account.perps.length > 0 ? ( lendingAssetsData,
<AccountPerpPositionTable account={props.account} hideCard /> props.isHls,
) : null, chainConfig.perps,
isOpen: accountSummaryTabs[2] ?? false, handleToggle,
toggleOpen: (index: number) => handleToggle(index), accountSummaryTabs,
renderSubTitle: () => <></>, ])
})
if (!props.account) return null if (!props.account) return null
return ( return (