separate presentational from container component

pull/448/head
slowbackspace 5 years ago
parent de1c7740cb
commit d0bb9cbbac

@ -0,0 +1,44 @@
/* @flow */
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { injectIntl } from 'react-intl';
import * as WalletActions from 'actions/WalletActions';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
import WalletSettings from './index';
type OwnProps = {};
type StateProps = {
wallet: $ElementType<State, 'wallet'>,
fiat: $ElementType<State, 'fiat'>,
localStorage: $ElementType<State, 'localStorage'>,
};
type DispatchProps = {
setLocalCurrency: typeof WalletActions.setLocalCurrency,
};
export type Props = StateProps & DispatchProps;
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (
state: State
): StateProps => ({
wallet: state.wallet,
fiat: state.fiat,
localStorage: state.localStorage,
});
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (
dispatch: Dispatch
): DispatchProps => ({
setLocalCurrency: bindActionCreators(WalletActions.setLocalCurrency, dispatch),
});
export default injectIntl(
connect(
mapStateToProps,
mapDispatchToProps
)(WalletSettings)
);

@ -1,13 +1,7 @@
/* @flow */
import styled from 'styled-components';
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { FormattedMessage, injectIntl } from 'react-intl';
import * as WalletActions from 'actions/WalletActions';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
import { FormattedMessage } from 'react-intl';
import Link from 'components/Link';
import Content from 'views/Wallet/components/Content';
@ -19,6 +13,7 @@ import { FIAT_CURRENCIES } from 'config/app';
import { FONT_SIZE } from 'config/variables';
import l10nCommonMessages from 'views/common.messages';
import l10nMessages from './index.messages';
import type { Props } from './Container';
const CurrencySelect = styled(Select)`
min-width: 77px;
@ -56,6 +51,7 @@ const buildCurrencyOption = currency => {
const WalletSettings = (props: Props) => (
<Content>
{console.log(props)}
<Section>
<CurrencyLabel>
<FormattedMessage {...l10nMessages.TR_LOCAL_CURRENCY} />
@ -83,37 +79,4 @@ const WalletSettings = (props: Props) => (
</Content>
);
type OwnProps = {};
type StateProps = {
wallet: $ElementType<State, 'wallet'>,
fiat: $ElementType<State, 'fiat'>,
localStorage: $ElementType<State, 'localStorage'>,
};
type DispatchProps = {
setLocalCurrency: typeof WalletActions.setLocalCurrency,
};
export type Props = StateProps & DispatchProps;
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (
state: State
): StateProps => ({
wallet: state.wallet,
fiat: state.fiat,
localStorage: state.localStorage,
});
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (
dispatch: Dispatch
): DispatchProps => ({
setLocalCurrency: bindActionCreators(WalletActions.setLocalCurrency, dispatch),
});
export default injectIntl(
connect(
mapStateToProps,
mapDispatchToProps
)(WalletSettings)
);
export default WalletSettings;

@ -25,7 +25,7 @@ import AccountSignVerify from 'views/Wallet/views/Account/SignVerify/Container';
import WalletDashboard from 'views/Wallet/views/Dashboard';
import WalletDeviceSettings from 'views/Wallet/views/DeviceSettings';
import WalletSettings from 'views/Wallet/views/WalletSettings';
import WalletSettings from 'views/Wallet/views/WalletSettings/Container';
import WalletBootloader from 'views/Wallet/views/Bootloader';
import WalletFirmwareUpdate from 'views/Wallet/views/FirmwareUpdate';
import WalletNoBackup from 'views/Wallet/views/NoBackup';

Loading…
Cancel
Save