Implement account switching logic
This commit is contained in:
parent
26c57c1da6
commit
99ab6286f2
@ -1,8 +1,15 @@
|
|||||||
export default function AccountPicker() {
|
import { ReactEventHandler } from 'react'
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
value: number
|
||||||
|
onChange: ReactEventHandler<HTMLSelectElement>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AccountPicker({ value, onChange }: IProps) {
|
||||||
return (
|
return (
|
||||||
<select value="Account 1">
|
<select value={Number(value)} onChange={onChange}>
|
||||||
<option value="Account 1">Account 1</option>
|
<option value={0}>Account 1</option>
|
||||||
<option value="Account 2">Account 2</option>
|
<option value={1}>Account 2</option>
|
||||||
</select>
|
</select>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,23 +5,24 @@ import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
|||||||
import SettingsStore from '@/store/SettingsStore'
|
import SettingsStore from '@/store/SettingsStore'
|
||||||
import { wallets } from '@/utils/WalletUtil'
|
import { wallets } from '@/utils/WalletUtil'
|
||||||
import { Text } from '@nextui-org/react'
|
import { Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment, useState } from 'react'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
|
const [account, setAccount] = useState(0)
|
||||||
const { testNets } = useSnapshot(SettingsStore.state)
|
const { testNets } = useSnapshot(SettingsStore.state)
|
||||||
const addresses = Object.keys(wallets)
|
const addresses = Object.keys(wallets)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<PageHeader title="Accounts">
|
<PageHeader title="Accounts">
|
||||||
<AccountPicker />
|
<AccountPicker value={account} onChange={e => setAccount(Number(e.currentTarget.value))} />
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<Text h4 css={{ marginBottom: '$5' }}>
|
<Text h4 css={{ marginBottom: '$5' }}>
|
||||||
Mainnets
|
Mainnets
|
||||||
</Text>
|
</Text>
|
||||||
{Object.values(EIP155_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
{Object.values(EIP155_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={addresses[0]} />
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={addresses[account]} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{testNets ? (
|
{testNets ? (
|
||||||
@ -30,7 +31,13 @@ export default function HomePage() {
|
|||||||
Testnets
|
Testnets
|
||||||
</Text>
|
</Text>
|
||||||
{Object.values(EIP155_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
{Object.values(EIP155_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={addresses[0]} />
|
<AccountCard
|
||||||
|
key={name}
|
||||||
|
name={name}
|
||||||
|
logo={logo}
|
||||||
|
rgb={rgb}
|
||||||
|
address={addresses[account]}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
|
Loading…
Reference in New Issue
Block a user