Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/App.js
Show All 17 Lines | |||||
import Configure from '@components/Configure/Configure'; | import Configure from '@components/Configure/Configure'; | ||||
import NotFound from '@components/NotFound'; | import NotFound from '@components/NotFound'; | ||||
import CashTab from '@assets/cashtab_xec.png'; | import CashTab from '@assets/cashtab_xec.png'; | ||||
import TabCash from '@assets/tabcash.png'; | import TabCash from '@assets/tabcash.png'; | ||||
import ABC from '@assets/logo_topright.png'; | import ABC from '@assets/logo_topright.png'; | ||||
import './App.css'; | import './App.css'; | ||||
import { WalletContext } from '@utils/context'; | import { WalletContext } from '@utils/context'; | ||||
import { checkForTokenById } from '@utils/tokenMethods.js'; | import { checkForTokenById } from '@utils/tokenMethods.js'; | ||||
import { isValidStoredWallet } from '@utils/cashMethods'; | |||||
import WalletLabel from '@components/Common/WalletLabel.js'; | import WalletLabel from '@components/Common/WalletLabel.js'; | ||||
import { | import { | ||||
Route, | Route, | ||||
Redirect, | Redirect, | ||||
Switch, | Switch, | ||||
useLocation, | useLocation, | ||||
useHistory, | useHistory, | ||||
} from 'react-router-dom'; | } from 'react-router-dom'; | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | export const AbcLogo = styled.img` | ||||
width: 150px; | width: 150px; | ||||
@media (max-width: 768px) { | @media (max-width: 768px) { | ||||
width: 120px; | width: 120px; | ||||
} | } | ||||
`; | `; | ||||
const App = () => { | const App = () => { | ||||
const ContextValue = React.useContext(WalletContext); | const ContextValue = React.useContext(WalletContext); | ||||
const { wallet, loading, tokens } = ContextValue; | const { wallet, loading } = ContextValue; | ||||
const [loadingUtxosAfterSend, setLoadingUtxosAfterSend] = useState(false); | const [loadingUtxosAfterSend, setLoadingUtxosAfterSend] = useState(false); | ||||
// If wallet is unmigrated, do not show page until it has migrated | |||||
const hasTab = checkForTokenById( | // An invalid wallet will be validated/populated after the next API call, ETA 10s | ||||
tokens, | const validWallet = isValidStoredWallet(wallet); | ||||
const hasTab = validWallet | |||||
? checkForTokenById( | |||||
wallet.state.tokens, | |||||
'50d8292c6255cda7afc6c8566fed3cf42a2794e9619740fe8f4c95431271410e', | '50d8292c6255cda7afc6c8566fed3cf42a2794e9619740fe8f4c95431271410e', | ||||
); | ) | ||||
: false; | |||||
const location = useLocation(); | const location = useLocation(); | ||||
const history = useHistory(); | const history = useHistory(); | ||||
const selectedKey = | const selectedKey = | ||||
location && location.pathname ? location.pathname.substr(1) : ''; | location && location.pathname ? location.pathname.substr(1) : ''; | ||||
return ( | return ( | ||||
<ThemeProvider theme={theme}> | <ThemeProvider theme={theme}> | ||||
<GlobalStyle /> | <GlobalStyle /> | ||||
<Spin | <Spin | ||||
spinning={loading || loadingUtxosAfterSend} | spinning={loading || loadingUtxosAfterSend || !validWallet} | ||||
indicator={CashLoadingIcon} | indicator={CashLoadingIcon} | ||||
> | > | ||||
<CustomApp> | <CustomApp> | ||||
<WalletBody> | <WalletBody> | ||||
<WalletCtn> | <WalletCtn> | ||||
<HeaderCtn> | <HeaderCtn> | ||||
<CashTabLogo src={CashTab} alt="cashtab" /> | <CashTabLogo src={CashTab} alt="cashtab" /> | ||||
{hasTab && ( | {hasTab && ( | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |