/ common / components / renderCbs / FullWalletOnly.tsx
FullWalletOnly.tsx
 1  import * as React from 'react';
 2  import { connect } from 'react-redux';
 3  
 4  import { IWallet, IFullWallet } from 'libs/wallet';
 5  import { AppState } from 'features/reducers';
 6  
 7  interface Props {
 8    wallet: IWallet;
 9    withFullWallet(wallet: IFullWallet): React.ReactElement<any>;
10    withoutFullWallet(): React.ReactElement<any>;
11  }
12  
13  class FullWalletOnly extends React.Component<Props, {}> {
14    public render() {
15      const { wallet, withFullWallet, withoutFullWallet } = this.props;
16      if (!wallet || wallet.isReadOnly) {
17        if (withoutFullWallet) {
18          return withoutFullWallet();
19        }
20        return null;
21      }
22      return withFullWallet(wallet);
23    }
24  }
25  
26  export default connect((state: AppState) => ({
27    wallet: state.wallet.inst
28  }))(FullWalletOnly);