Skip to content

Commit

Permalink
feat(neuron-ui): add a condition of isMainnet for displaying addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Sep 18, 2019
1 parent d55a415 commit 5be0335
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/neuron-ui/src/components/Addresses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ const Addresses = ({
loadings: { addressList: isLoading },
},
wallet: { addresses = [], id: walletID },
settings: { showAddressBook = false },
chain: { networkID },
settings: { showAddressBook = false, networks = [] },
history,
dispatch,
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
const isMainnet = (networks.find(n => n.id === networkID) || {}).type === 'mainnet'
const [showMainnetAddress, setShowMainnetAddress] = useState(false)
const [t] = useTranslation()
useEffect(() => {
Expand Down Expand Up @@ -211,11 +213,13 @@ const Addresses = ({
return (
<>
<Stack verticalAlign="center" horizontalAlign="start" tokens={{ childrenGap: 15 }}>
<DefaultButton
text={t(`addresses.display-${showMainnetAddress ? 'testnet' : 'mainnet'}-addresses`)}
onClick={() => setShowMainnetAddress(!showMainnetAddress)}
/>
{showMainnetAddress ? (
{!isMainnet ? (
<DefaultButton
text={t(`addresses.display-${showMainnetAddress ? 'testnet' : 'mainnet'}-addresses`)}
onClick={() => setShowMainnetAddress(!showMainnetAddress)}
/>
) : null}
{showMainnetAddress && !isMainnet ? (
<Text variant="medium" style={{ color: semanticColors.errorText }}>
{t('addresses.mainnet-address-caution')}
</Text>
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/types/App/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ declare namespace State {
interface NetworkProperty {
name: string
remote: string
type?: 'mainnet' | 'testnet'
}

interface Network extends NetworkProperty {
Expand Down

0 comments on commit 5be0335

Please sign in to comment.