Skip to content

Commit

Permalink
solution: render tabs as array of components
Browse files Browse the repository at this point in the history
  • Loading branch information
BOOMER74 committed Oct 18, 2023
1 parent f0a72f7 commit 8b6bd29
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/react-app/src/wallets/WalletDetails/WalletDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ const WalletDetails: React.FC<OwnProps & StateProps & DispatchProps> = ({

const [tab, setTab] = React.useState(initialTab ?? WalletTabs.BALANCE);

const renderTabs = (): React.ReactNode => {
const tabs = [<Tab key={WalletTabs.BALANCE} label="Balance" value={WalletTabs.BALANCE} />];

if (hasEthereumEntry) {
tabs.push(<Tab key={WalletTabs.ALLOWANCES} label="Allowances" value={WalletTabs.ALLOWANCES} />);
}

return [
...tabs,
<Tab key={WalletTabs.ADDRESSES} label="Addresses" value={WalletTabs.ADDRESSES} />,
<Tab key={WalletTabs.TRANSACTIONS} label="Transactions" value={WalletTabs.TRANSACTIONS} />,
];
};

React.useEffect(() => {
if (currentWallet.current !== walletId) {
currentWallet.current = walletId;
Expand All @@ -128,10 +142,7 @@ const WalletDetails: React.FC<OwnProps & StateProps & DispatchProps> = ({
<TabContext value={tab}>
<div className={styles.tabs}>
<TabList indicatorColor="primary" textColor="primary" onChange={(event, selected) => setTab(selected)}>
<Tab label="Balance" value={WalletTabs.BALANCE} />
{hasEthereumEntry && <Tab label="Allowances" value={WalletTabs.ALLOWANCES} />}
<Tab label="Addresses" value={WalletTabs.ADDRESSES} />
<Tab label="Transactions" value={WalletTabs.TRANSACTIONS} />
{renderTabs()}
</TabList>
<WalletMenu walletId={walletId} />
</div>
Expand Down

0 comments on commit 8b6bd29

Please sign in to comment.