// Copyright 2017-2018 Jaco Greeff // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. // @flow import type { I18nProps } from '@polkadot/ui-app/types'; import './index.css'; import React from 'react'; import Button from '@polkadot/ui-app/Button'; import classes from '@polkadot/ui-app/util/classes'; import Hash from './Hash'; import Sign from './Sign'; import Verify from './Verify'; import translate from './translate'; type Actions = 'hash' | 'sign' | 'verify'; type Props = I18nProps & {}; type State = { action: Actions } // FIXME React-router would probably be the best route, not home-grown // flowlint-next-line unclear-type:off const Components: { [Actions]: React$ComponentType } = { 'hash': Hash, 'sign': Sign, 'verify': Verify }; class ToolboxApp extends React.PureComponent { state: State = { action: 'hash' }; render (): React$Node { const { className, style } = this.props; const { action } = this.state; const Component = Components[action]; return (
{this.renderButtons()}
); } renderButtons (): React$Node { const { t } = this.props; const { action } = this.state; return (