<commit_before>import React from 'react';
import Types from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link, Redirect } from 'react-router-dom';
import { Message } from 'retranslate';

import ThirdPillarTermsAgreement from './ThirdPillarTermsAgreement';
import PoliticallyExposedPersonAgreement from './PoliticallyExposedPersonAgreement';
import { actions as exchangeActions } from '../../../exchange';
import FundTransferTable from '../../secondPillar/confirmMandate/fundTransferTable';
import ResidencyAgreement from './ResidencyAgreement';
import { AuthenticationLoader, ErrorMessage, Loader } from '../../../common';
import { hasAddress } from '../../../common/user/address';
import OccupationAgreement from './OccupationAgreement';

export const ConfirmThirdPillarMandate = ({
  previousPath,
  nextPath,
  signedMandateId,
  exchangeExistingUnits,
  exchangeableSourceFunds,
  selectedFutureContributionsFund,
  agreedToTerms,
  isResident,
  isPoliticallyExposed,
  occupation,
  loadingSourceFunds,
  isAddressFilled,
  onSign,
  onPreview,
  onCancelSigningMandate,
  onCloseErrorMessages,
  loadingMandate,
  mandateSigningControlCode,
  mandateSigningError,
}) => {
  const buttonDisabled =
    !agreedToTerms || isResident === null || isPoliticallyExposed === null || !occupation;
  return (
    <>
      {signedMandateId && <Redirect to={nextPath} />}
      {!isAddressFilled && <Redirect to={previousPath} />}
      {loadingMandate || mandateSigningControlCode ? (
        <AuthenticationLoader
          controlCode={mandateSigningControlCode}
          onCancel={onCancelSigningMandate}
          overlayed
        />
      ) : (
        ''
      )}

      <Message>confirmThirdPillarMandate.intro</Message>

      {selectedFutureContributionsFund && (
        <div className="mt-4">
          <Message>confirmThirdPillarMandate.contribution</Message>

          <div>
            <b className="highlight">{selectedFutureContributionsFund.name}</b>
          </div>
        </div>
      )}
      {loadingSourceFunds && <Loader className="align-middle" />}
      {exchangeExistingUnits &&
        !loadingSourceFunds &&
        exchangeableSourceFunds &&
        !!exchangeableSourceFunds.length &&
        selectedFutureContributionsFund && (<commit_msg>Fix 3rd pillar mandate confirmation button disabling logic<commit_after>import React from 'react';
import Types from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link, Redirect } from 'react-router-dom';
import { Message } from 'retranslate';

import ThirdPillarTermsAgreement from './ThirdPillarTermsAgreement';
import PoliticallyExposedPersonAgreement from './PoliticallyExposedPersonAgreement';
import { actions as exchangeActions } from '../../../exchange';
import FundTransferTable from '../../secondPillar/confirmMandate/fundTransferTable';
import ResidencyAgreement from './ResidencyAgreement';
import { AuthenticationLoader, ErrorMessage, Loader } from '../../../common';
import { hasAddress } from '../../../common/user/address';
import OccupationAgreement from './OccupationAgreement';

export const ConfirmThirdPillarMandate = ({
  previousPath,
  nextPath,
  signedMandateId,
  exchangeExistingUnits,
  exchangeableSourceFunds,
  selectedFutureContributionsFund,
  agreedToTerms,
  isResident,
  isPoliticallyExposed,
  occupation,
  loadingSourceFunds,
  isAddressFilled,
  onSign,
  onPreview,
  onCancelSigningMandate,
  onCloseErrorMessages,
  loadingMandate,
  mandateSigningControlCode,
  mandateSigningError,
}) => {
  const buttonDisabled = !agreedToTerms || !isResident || isPoliticallyExposed || !occupation;
  return (
    <>
      {signedMandateId && <Redirect to={nextPath} />}
      {!isAddressFilled && <Redirect to={previousPath} />}
      {loadingMandate || mandateSigningControlCode ? (
        <AuthenticationLoader
          controlCode={mandateSigningControlCode}
          onCancel={onCancelSigningMandate}
          overlayed
        />
      ) : (
        ''
      )}

      <Message>confirmThirdPillarMandate.intro</Message>

      {selectedFutureContributionsFund && (
        <div className="mt-4">
          <Message>confirmThirdPillarMandate.contribution</Message>

          <div>
            <b className="highlight">{selectedFutureContributionsFund.name}</b>
          </div>
        </div>
      )}
      {loadingSourceFunds && <Loader className="align-middle" />}
      {exchangeExistingUnits &&
        !loadingSourceFunds &&
        exchangeableSourceFunds &&
        !!exchangeableSourceFunds.length &&
        selectedFutureContributionsFund && (
{'fraction_non_alphanumeric': 0.11364605543710021, 'fraction_numerical': 0.0006396588486140725, 'mean_word_length': 3.7383838383838386, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, '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': '3233701', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1314, 'n_words': 249}