(Fix) Add `isTestnet` function to helpers.js

This commit is contained in:
Vadim Arasev 2018-10-02 14:21:40 +03:00
parent c28d307916
commit 27404d1b9c
4 changed files with 19 additions and 20 deletions

View File

@ -7,7 +7,7 @@ import { Route } from 'react-router-dom'
import { inject, observer } from 'mobx-react'
import swal from 'sweetalert2'
import { messages } from './messages'
import { constants } from './constants'
import { isTestnet } from './helpers'
@inject('commonStore', 'contractsStore')
@observer
@ -125,9 +125,7 @@ class App extends Component {
getNetIdClass() {
const { contractsStore } = this.props
const netId = contractsStore.netId
const isTestnet = netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST
return isTestnet ? 'sokol' : ''
return isTestnet(contractsStore.netId) ? 'sokol' : ''
}
render() {
@ -144,9 +142,6 @@ class App extends Component {
''
)
const netId = contractsStore.netId
const isTestnet = netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST
return (
<section className={`content ${this.state.showMobileMenu ? 'content-menu-open' : ''}`}>
{loading}
@ -160,7 +155,7 @@ class App extends Component {
{search}
<div
className={`app-container ${this.state.showMobileMenu ? 'app-container-open-mobile-menu' : ''} ${
isTestnet ? 'sokol' : ''
isTestnet(contractsStore.netId) ? 'sokol' : ''
}`}
>
<div className="container">

View File

@ -2,11 +2,10 @@ import React from 'react'
import moment from 'moment'
import { Link } from 'react-router-dom'
import Socials from './Socials.jsx'
import { constants } from '../constants'
import { isTestnet } from '../helpers'
export const Footer = ({ netId }) => {
const isTestnet = netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST
const footerClassName = isTestnet ? 'sokol' : ''
const footerClassName = isTestnet(netId) ? 'sokol' : ''
return (
<footer className={`footer ${footerClassName}`}>

View File

@ -7,14 +7,14 @@ import menuOpenIconBase from '../assets/images/icons/icon-close.svg'
import menuOpenIconSokol from '../assets/images/icons/icon-close-sokol.svg'
import NavigationLinks from './NavigationLinks.jsx'
import MobileMenuLinks from './MobileMenuLinks.jsx'
import { constants } from '../constants'
import { isTestnet } from '../helpers'
export const Header = ({ netId, baseRootPath, navigationData, showMobileMenu, onMenuToggle }) => {
const isTestnet = netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST
const headerClassName = isTestnet ? 'sokol' : ''
const logoImageName = isTestnet ? logoSokol : logoBase
const menuIcon = isTestnet ? menuIconSokol : menuIconBase
const menuOpenIcon = isTestnet ? menuOpenIconSokol : menuOpenIconBase
const thisIsTestnet = isTestnet(netId)
const headerClassName = thisIsTestnet ? 'sokol' : ''
const logoImageName = thisIsTestnet ? logoSokol : logoBase
const menuIcon = thisIsTestnet ? menuIconSokol : menuIconBase
const menuOpenIcon = thisIsTestnet ? menuOpenIconSokol : menuOpenIconBase
return (
<header className={`header ${headerClassName}`}>

View File

@ -59,7 +59,12 @@ function sendTransactionByVotingKey(props, to, data, cb, warning) {
)
}
module.exports = {
toAscii: toAscii,
sendTransactionByVotingKey: sendTransactionByVotingKey
function isTestnet(netId) {
return netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST
}
module.exports = {
toAscii,
sendTransactionByVotingKey,
isTestnet
}