<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';
import LoadingIndicator from '@department-of-veterans-affairs/formation-react/LoadingIndicator';

import RequiredLoginView from 'platform/user/authorization/components/RequiredLoginView';
import backendServices from 'platform/user/profile/constants/backendServices';
import {
  createIsServiceAvailableSelector,
  isMultifactorEnabled,
  selectProfile,
} from 'platform/user/selectors';
import { fetchMHVAccount as fetchMHVAccountAction } from 'platform/user/profile/actions';
import {
  fetchMilitaryInformation as fetchMilitaryInformationAction,
  fetchHero as fetchHeroAction,
  fetchPersonalInformation as fetchPersonalInformationAction,
} from 'applications/personalization/profile360/actions';
import {
  directDepositAddressIsSetUp,
  directDepositIsBlocked,
  directDepositIsSetUp,
} from 'applications/personalization/profile360/selectors';
import { fetchPaymentInformation as fetchPaymentInformationAction } from 'applications/personalization/profile360/actions/paymentInformation';
import getRoutes from '../routes';

import Profile2Wrapper from './Profile2Wrapper';

class Profile2Router extends Component {
  componentDidMount() {
    const {
      fetchFullName,
      fetchMHVAccount,
      fetchMilitaryInformation,
      fetchPersonalInformation,
      fetchPaymentInformation,
      shouldFetchDirectDepositInformation,
    } = this.props;
    fetchMHVAccount();
    fetchMilitaryInformation();
    fetchFullName();
    fetchPersonalInformation();
    if (shouldFetchDirectDepositInformation) {
      fetchPaymentInformation();
    }
  }

  componentDidUpdate(prevProps) {
    if (
      this.props.shouldFetchDirectDepositInformation &&
      !prevProps.shouldFetchDirectDepositInformation
    ) {
      this.props.fetchPaymentInformation();
    }
  }

  // content to show if the component is waiting for data to load. This loader
  // matches the loader shown by the RequiredLoginView component, so when the
  // RequiredLoginView is done with its loading and this function takes over, it
  // appears seamless to the user.
  loadingContent = () => (
    <div className="vads-u-margin-y--5">
      <LoadingIndicator setFocus message="Loading your information..." />
    </div>
  );

  // content to show after data has loaded
  mainContent = () => {
    const routes = getRoutes(this.props.shouldShowDirectDeposit);
    return (
      <BrowserRouter>
        <Profile2Wrapper routes={routes}>
          <Switch>
            {/* Redirect users to Account Security to upgrade their account if they need to */}
            {routes.map(route => {
              if (
                (route.requiresLOA3 && !this.props.isLOA3) ||
                (route.requiresMVI && !this.props.isInMVI)
              ) {
                return (
                  <Redirect
                    from={route.path}
                    key="/profile/account-security"
                    to="/profile/account-security"
                  />
                );
              }

              return (
                <Route
                  component={route.component}
                  exact
                  key={route.path}
                  path={route.path}
                />
              );
            })}

            <Redirect
              exact
              from="/profile"
              key="/profile/personal-information"
              to="/profile/personal-information"
            />

            {/* fallback handling: redirect to root route */}
            <Route path="*">
              <Redirect to="/profile" />
            </Route>
          </Switch>
        </Profile2Wrapper>
      </BrowserRouter>
    );
  };

  renderContent = () => {
    if (this.props.showLoader) {
      return this.loadingContent();
    }
    return this.mainContent();<commit_msg>Redirect contact information on Profile 2.0 (#13279)<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';
import LoadingIndicator from '@department-of-veterans-affairs/formation-react/LoadingIndicator';

import RequiredLoginView from 'platform/user/authorization/components/RequiredLoginView';
import backendServices from 'platform/user/profile/constants/backendServices';
import {
  createIsServiceAvailableSelector,
  isMultifactorEnabled,
  selectProfile,
} from 'platform/user/selectors';
import { fetchMHVAccount as fetchMHVAccountAction } from 'platform/user/profile/actions';
import {
  fetchMilitaryInformation as fetchMilitaryInformationAction,
  fetchHero as fetchHeroAction,
  fetchPersonalInformation as fetchPersonalInformationAction,
} from 'applications/personalization/profile360/actions';
import {
  directDepositAddressIsSetUp,
  directDepositIsBlocked,
  directDepositIsSetUp,
} from 'applications/personalization/profile360/selectors';
import { fetchPaymentInformation as fetchPaymentInformationAction } from 'applications/personalization/profile360/actions/paymentInformation';
import getRoutes from '../routes';

import Profile2Wrapper from './Profile2Wrapper';

class Profile2Router extends Component {
  componentDidMount() {
    const {
      fetchFullName,
      fetchMHVAccount,
      fetchMilitaryInformation,
      fetchPersonalInformation,
      fetchPaymentInformation,
      shouldFetchDirectDepositInformation,
    } = this.props;
    fetchMHVAccount();
    fetchMilitaryInformation();
    fetchFullName();
    fetchPersonalInformation();
    if (shouldFetchDirectDepositInformation) {
      fetchPaymentInformation();
    }
  }

  componentDidUpdate(prevProps) {
    if (
      this.props.shouldFetchDirectDepositInformation &&
      !prevProps.shouldFetchDirectDepositInformation
    ) {
      this.props.fetchPaymentInformation();
    }
  }

  // content to show if the component is waiting for data to load. This loader
  // matches the loader shown by the RequiredLoginView component, so when the
  // RequiredLoginView is done with its loading and this function takes over, it
  // appears seamless to the user.
  loadingContent = () => (
    <div className="vads-u-margin-y--5">
      <LoadingIndicator setFocus message="Loading your information..." />
    </div>
  );

  // content to show after data has loaded
  mainContent = () => {
    const routes = getRoutes(this.props.shouldShowDirectDeposit);
    return (
      <BrowserRouter>
        <Profile2Wrapper routes={routes}>
          <Switch>
            {/* Redirect users to Account Security to upgrade their account if they need to */}
            {routes.map(route => {
              if (
                (route.requiresLOA3 && !this.props.isLOA3) ||
                (route.requiresMVI && !this.props.isInMVI)
              ) {
                return (
                  <Redirect from={route.path} to="/profile/account-security" />
                );
              }

              return (
                <Route
                  component={route.component}
                  exact
                  key={route.path}
                  path={route.path}
                />
              );
            })}

            <Redirect
              exact
              from="/profile#contact-information"
              to="/profile/personal-information"
            />

            <Redirect
              exact
              from="/profile"
              to="/profile/personal-information"
            />

            {/* fallback handling: redirect to root route */}
            <Route path="*">
              <Redirect to="/profile" />
            </Route>
          </Switch>
        </Profile2Wrapper>
      </BrowserRouter>
    );
  };

  renderContent = () => {
    if (this.props.showLoader) {
      return this.loadingContent();
    }
    return this.mainContent();
{'fraction_non_alphanumeric': 0.09702797202797203, 'fraction_numerical': 0.00511988011988012, 'mean_word_length': 2.467099567099567, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 42, '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': '2655236', 'n_tokens_mistral': 2084, 'n_tokens_neox': 1986, 'n_words': 455}