<commit_before>import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import DowntimeNotification from 'platform/monitoring/DowntimeNotification';

import LoadingIndicator from '@department-of-veterans-affairs/formation-react/LoadingIndicator';

import { enterPreviewMode, exitPreviewMode, fetchConstants } from '../actions';
import Modals from '../containers/Modals';
import PreviewBanner from '../components/heading/PreviewBanner';
import GiBillBreadcrumbs from '../components/heading/GiBillBreadcrumbs';
import AboutThisTool from '../components/content/AboutThisTool';
import ServiceError from '../components/ServiceError';
import Covid19Banner from '../components/heading/Covid19Banner';
import environment from 'platform/utilities/environment';

const Disclaimer = () => (
  <div className="row disclaimer">
    <p>
      Please note: Content on this Web page is for informational purposes only.
      It is not intended to provide legal advice or to be a comprehensive
      statement or analysis of applicable statutes, regulations, and case law
      governing this topic. Rather, it’s a plain-language summary. If you are
      seeking claims assistance, your local VA regional office, a VA-recognized
      Veterans Service Organization, or a VA-accredited attorney or agent can
      help.{' '}
      <a
        target="_blank"
        rel="noopener noreferrer"
        href="https://www.va.gov/ogc/apps/accreditation/index.asp"
      >
        Search Accredited Attorneys, Claims Agents, or Veterans Service
        Organizations (VSO) Representatives
      </a>
      .
    </p>
  </div>
);

export class GiBillApp extends React.Component {
  constructor(props) {
    super(props);
    this.exitPreviewMode = this.exitPreviewMode.bind(this);
  }

  componentDidMount() {
    this.props.fetchConstants(this.props.location.query.version);
  }

  componentDidUpdate(prevProps) {
    const {
      preview,
      location: {
        query: { version: uuid },
      },
    } = this.props;

    const shouldExitPreviewMode = preview.display && !uuid;
    const shouldEnterPreviewMode =
      !preview.display && uuid && preview.version.createdAt;

    if (shouldExitPreviewMode) {
      this.props.exitPreviewMode();
    } else if (shouldEnterPreviewMode) {
      this.props.enterPreviewMode();
    }

    const shouldRefetchConstants = prevProps.location.query.version !== uuid;

    if (shouldRefetchConstants) {
      this.props.fetchConstants(uuid);
    }
  }

  exitPreviewMode() {
    const { location } = this.props;
    const query = { ...location.query };
    delete query.version;
    this.props.router.push({ ...location, query });
  }

  render() {
    const { constants, preview, search } = this.props;
    const { facilityCode } = this.props.params;
    let content;

    if (constants.inProgress) {
      content = <LoadingIndicator message="Loading..." />;
    } else {
      content = this.props.children;
    }
    return (
      <div className="gi-app">
        {!environment.isProduction() &&
          location.pathname === '/gi-bill-comparison-tool/' && (
            <Covid19Banner />
          )}
        <div className="row">
          <div className="columns small-12">
            {preview.display && (
              <PreviewBanner
                version={preview.version}
                onViewLiveVersion={this.exitPreviewMode}
              />
            )}
            <GiBillBreadcrumbs
              searchQuery={search.query}
              facilityCode={facilityCode}
              location={this.props.location}
            />
            <DowntimeNotification appTitle={'GI Bill Comparison Tool'}>
              {constants.error ? <ServiceError /> : content}
            </DowntimeNotification>
            <AboutThisTool />
            <Disclaimer />
            <Modals />
          </div>
        </div>
      </div>
    );
  }
}

GiBillApp.propTypes = {
  children: PropTypes.element.isRequired,
};

const mapStateToProps = state => {
  const { constants, preview, search } = state;
  return { constants, preview, search };
};

const mapDispatchToProps = {
  enterPreviewMode,
  exitPreviewMode,
  fetchConstants,
};

export default withRouter(
  connect(
    mapStateToProps,
    mapDispatchToProps,
  )(GiBillApp),
);
<commit_msg>added alternate path name (#12859)<commit_after>import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import DowntimeNotification from 'platform/monitoring/DowntimeNotification';

import LoadingIndicator from '@department-of-veterans-affairs/formation-react/LoadingIndicator';

import { enterPreviewMode, exitPreviewMode, fetchConstants } from '../actions';
import Modals from '../containers/Modals';
import PreviewBanner from '../components/heading/PreviewBanner';
import GiBillBreadcrumbs from '../components/heading/GiBillBreadcrumbs';
import AboutThisTool from '../components/content/AboutThisTool';
import ServiceError from '../components/ServiceError';
import Covid19Banner from '../components/heading/Covid19Banner';
import environment from 'platform/utilities/environment';

const Disclaimer = () => (
  <div className="row disclaimer">
    <p>
      Please note: Content on this Web page is for informational purposes only.
      It is not intended to provide legal advice or to be a comprehensive
      statement or analysis of applicable statutes, regulations, and case law
      governing this topic. Rather, it’s a plain-language summary. If you are
      seeking claims assistance, your local VA regional office, a VA-recognized
      Veterans Service Organization, or a VA-accredited attorney or agent can
      help.{' '}
      <a
        target="_blank"
        rel="noopener noreferrer"
        href="https://www.va.gov/ogc/apps/accreditation/index.asp"
      >
        Search Accredited Attorneys, Claims Agents, or Veterans Service
        Organizations (VSO) Representatives
      </a>
      .
    </p>
  </div>
);

export class GiBillApp extends React.Component {
  constructor(props) {
    super(props);
    this.exitPreviewMode = this.exitPreviewMode.bind(this);
  }

  componentDidMount() {
    this.props.fetchConstants(this.props.location.query.version);
  }

  componentDidUpdate(prevProps) {
    const {
      preview,
      location: {
        query: { version: uuid },
      },
    } = this.props;

    const shouldExitPreviewMode = preview.display && !uuid;
    const shouldEnterPreviewMode =
      !preview.display && uuid && preview.version.createdAt;

    if (shouldExitPreviewMode) {
      this.props.exitPreviewMode();
    } else if (shouldEnterPreviewMode) {
      this.props.enterPreviewMode();
    }

    const shouldRefetchConstants = prevProps.location.query.version !== uuid;

    if (shouldRefetchConstants) {
      this.props.fetchConstants(uuid);
    }
  }

  exitPreviewMode() {
    const { location } = this.props;
    const query = { ...location.query };
    delete query.version;
    this.props.router.push({ ...location, query });
  }

  render() {
    const { constants, preview, search } = this.props;
    const { facilityCode } = this.props.params;
    let content;

    if (constants.inProgress) {
      content = <LoadingIndicator message="Loading..." />;
    } else {
      content = this.props.children;
    }
    return (
      <div className="gi-app">
        {!environment.isProduction() &&
          (location.pathname === '/gi-bill-comparison-tool/' ||
            location.pathname === '/gi-bill-comparison-tool') && (
            <Covid19Banner />
          )}
        <div className="row">
          <div className="columns small-12">
            {preview.display && (
              <PreviewBanner
                version={preview.version}
                onViewLiveVersion={this.exitPreviewMode}
              />
            )}
            <GiBillBreadcrumbs
              searchQuery={search.query}
              facilityCode={facilityCode}
              location={this.props.location}
            />
            <DowntimeNotification appTitle={'GI Bill Comparison Tool'}>
              {constants.error ? <ServiceError /> : content}
            </DowntimeNotification>
            <AboutThisTool />
            <Disclaimer />
            <Modals />
          </div>
        </div>
      </div>
    );
  }
}

GiBillApp.propTypes = {
  children: PropTypes.element.isRequired,
};

const mapStateToProps = state => {
  const { constants, preview, search } = state;
  return { constants, preview, search };
};

const mapDispatchToProps = {
  enterPreviewMode,
  exitPreviewMode,
  fetchConstants,
};

export default withRouter(
  connect(
    mapStateToProps,
    mapDispatchToProps,
  )(GiBillApp),
);

{'fraction_non_alphanumeric': 0.11428247819685129, 'fraction_numerical': 0.002378525314305131, 'mean_word_length': 2.7007544006705784, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 51, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '360660', 'n_tokens_mistral': 2466, 'n_tokens_neox': 2398, 'n_words': 576}