<commit_before>import React, { PropTypes as Types } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Message } from 'retranslate';
import { Link } from 'react-router';

import { Radio, Loader, InfoTooltip } from '../../common';
import TargetFundTooltipBody from './targetFundTooltipBody';
import { selectFutureContributionsFund } from '../../exchange/actions';

export const TransferFutureCapital = ({
  selectedFutureContributionsFundIsin,
  onSelectFutureCapitalFund,
  targetFunds,
  loadingTargetFunds,
}) => {
  if (loadingTargetFunds) {
    return <Loader className="align-middle" />;
  }
  return (
    <div>
      <div className="px-col">
        <p className="lead m-0">
          <Message>transfer.future.capital.intro</Message>
          <br /><br />
          <Message>transfer.future.capital.intro.choose</Message>
        </p>
      </div>
      {
        targetFunds.map(fund => (
          <Radio
            key={fund.isin}
            name="tv-transfer-future-capital"
            selected={fund.isin === selectedFutureContributionsFundIsin}
            className="mt-4"
            onSelect={() => onSelectFutureCapitalFund(fund.isin)}
          >
            <h3 className="m-0">
              <Message>{`transfer.future.capital.${fund.isin}.fund`}</Message>
              <InfoTooltip name={fund.isin}>
                <TargetFundTooltipBody targetFundIsin={fund.isin} />
              </InfoTooltip>
            </h3>
          </Radio>
        ))
      }
      <Radio
        name="tv-transfer-future-capital"
        selected={!selectedFutureContributionsFundIsin}
        className="mt-4"
        onSelect={() => onSelectFutureCapitalFund(null)}
      >
        <p className="m-0"><Message>transfer.future.capital.no</Message></p>
      </Radio>
      <div className="px-col mt-5">
        <Link className="btn btn-primary mr-2" to="/steps/confirm-mandate">
          <Message>steps.next</Message>
        </Link>
        <Link className="btn btn-secondary" to="/steps/select-sources">
          <Message>steps.previous</Message>
        </Link>
      </div>
    </div>
  );
};

const noop = () => null;

TransferFutureCapital.defaultProps = {
  selectedFutureContributionsFundIsin: null,
  onSelectFutureCapitalFund: noop,
  targetFunds: [],
  loadingTargetFunds: false,
};

TransferFutureCapital.propTypes = {
  selectedFutureContributionsFundIsin: Types.string,
  onSelectFutureCapitalFund: Types.func,
  targetFunds: Types.arrayOf(Types.shape({})),
  loadingTargetFunds: Types.bool,
};

const mapStateToProps = state => ({
  selectedFutureContributionsFundIsin: state.exchange.selectedFutureContributionsFundIsin,
  targetFunds: state.exchange.targetFunds,
  loadingTargetFunds: state.exchange.loadingTargetFunds,
});

const mapDispatchToProps = dispatch => bindActionCreators({
  onSelectFutureCapitalFund: selectFutureContributionsFund,
}, dispatch);

const connectToRedux = connect(mapStateToProps, mapDispatchToProps);

export default connectToRedux(TransferFutureCapital);<commit_msg>When user chosen not to transfer future contributions, show him his existing fund and management fee<commit_after>import React, { PropTypes as Types } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Message } from 'retranslate';
import { Link } from 'react-router';

import { Radio, Loader, InfoTooltip, utils } from '../../common';
import TargetFundTooltipBody from './targetFundTooltipBody';
import { selectFutureContributionsFund } from '../../exchange/actions';

export const TransferFutureCapital = ({
  selectedFutureContributionsFundIsin,
  onSelectFutureCapitalFund,
  targetFunds,
  loadingTargetFunds,
  activeSourceFund,
}) => {
  if (loadingTargetFunds) {
    return <Loader className="align-middle" />;
  }
  return (
    <div>
      <div className="px-col">
        <p className="lead m-0">
          <Message>transfer.future.capital.intro</Message>
          <br /><br />
          <Message>transfer.future.capital.intro.choose</Message>
        </p>
      </div>
      {
        targetFunds.map(fund => (
          <Radio
            key={fund.isin}
            name="tv-transfer-future-capital"
            selected={fund.isin === selectedFutureContributionsFundIsin}
            className="mt-4"
            onSelect={() => onSelectFutureCapitalFund(fund.isin)}
          >
            <h3 className="m-0">
              <Message>{`transfer.future.capital.${fund.isin}.fund`}</Message>
              <InfoTooltip name={fund.isin}>
                <TargetFundTooltipBody targetFundIsin={fund.isin} />
              </InfoTooltip>
            </h3>
          </Radio>
        ))
      }
      <Radio
        name="tv-transfer-future-capital"
        selected={!selectedFutureContributionsFundIsin}
        className="mt-4"
        onSelect={() => onSelectFutureCapitalFund(null)}
      >
        <p className={`m-0 ${!selectedFutureContributionsFundIsin ? 'text-bold' : ''}`}>
          <Message>transfer.future.capital.no</Message>
        </p>
        {
          (!selectedFutureContributionsFundIsin && activeSourceFund) ?
          (<p className="mb-0 mt-2">
            <Message
              params={{
                currentFundName: activeSourceFund.name,
                currentFundManagementFee: activeSourceFund.managementFeeRate,
              }}
            >
              transfer.future.capital.no.subtitle
            </Message>
          </p>) : ''
        }
      </Radio>
      <div className="px-col mt-5">
        <Link className="btn btn-primary mr-2" to="/steps/confirm-mandate">
          <Message>steps.next</Message>
        </Link>
        <Link className="btn btn-secondary" to="/steps/select-sources">
          <Message>steps.previous</Message>
        </Link>
      </div>
    </div>
  );
};

const noop = () => null;

TransferFutureCapital.defaultProps = {
  selectedFutureContributionsFundIsin: null,
  onSelectFutureCapitalFund: noop,
  targetFunds: [],
  loadingTargetFunds: false,
  activeSourceFund: null,
};

TransferFutureCapital.propTypes = {
  selectedFutureContributionsFundIsin: Types.string,
  onSelectFutureCapitalFund: Types.func,
  targetFunds: Types.arrayOf(Types.shape({})),
  loadingTargetFunds: Types.bool,
  activeSourceFund: Types.shape({}),
};

const mapStateToProps = state => ({
  selectedFutureContributionsFundIsin: state.exchange.selectedFutureContributionsFundIsin,
  targetFunds: state.exchange.targetFunds,
  loadingTargetFunds: state.exchange.loadingTargetFunds,
  activeSourceFund: utils.findWhere(state.exchange.sourceFunds || [],
    element => element.activeFund),
});

const mapDispatchToProps = dispatch => bindActionCreators({
  onSelectFutureCapitalFund: selectFutureContributionsFund,
}, dispatch);

const connectToRedux = connect(mapStateToProps, mapDispatchToProps);

export default connectToRedux(TransferFutureCapital);
{'fraction_non_alphanumeric': 0.12856320184278722, 'fraction_numerical': 0.0028793550244745176, 'mean_word_length': 2.9742562929061784, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 98, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3629518', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1981, 'n_words': 344}