MyCrypto/common/containers/Tabs/Contracts/index.tsx

50 lines
1.5 KiB
TypeScript

import translate from 'translations';
import { Interact } from './components/Interact';
import { Deploy } from './components/Deploy';
import TabSection from 'containers/TabSection';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Switch, Route, Redirect, RouteComponentProps } from 'react-router';
import SubTabs from 'components/SubTabs';
import { RouteNotFound } from 'components/RouteNotFound';
const tabs = [
{
path: 'interact',
name: translate('CONTRACTS_INTERACT')
},
{
path: 'deploy',
name: translate('CONTRACTS_DEPLOY')
}
];
class Contracts extends Component<RouteComponentProps<{}>> {
public render() {
const { match, location, history } = this.props;
const currentPath = match.url;
return (
<TabSection isUnavailableOffline={true}>
<SubTabs tabs={tabs} match={match} location={location} history={history} />
<section className="Tab-content Contracts">
<div className="Contracts-content">
<Switch>
<Route
exact={true}
path={currentPath}
render={() => <Redirect from={`${currentPath}`} to={`${currentPath}/interact`} />}
/>
<Route exact={true} path={`${currentPath}/interact`} component={Interact} />
<Route exact={true} path={`${currentPath}/deploy`} component={Deploy} />
<RouteNotFound />
</Switch>
</div>
</section>
</TabSection>
);
}
}
export default connect(null, {})(Contracts);