<commit_before>import React from 'react';
import PropTypes, { instanceOf } from 'prop-types';
import { connect } from 'react-redux';
import { withCookies, Cookies } from 'react-cookie';
import * as TABS from '../../constants/tabs.js';
import Login from '../Login';
import Navbar from '../Navbar';
import Dashboard from '../Dashboard';
import AdminPanel from '../AdminPanel';
import AddContractor from '../AddContractor';
import ContractorInfo from '../ContractorInfo';
import Filtering from '../Filtering';
import Reports from '../Reports';
import User from '../User';
import css from './layout.css';

const mapStateToProps = (state, ownProps) => {
  return {
    tab: ownProps.cookies.get('tab') ? ownProps.cookies.get('tab') : state.main.tab,
    isLoading: state.main.isLoading,
    isLoggedIn: state.user.isLoggedIn
  };
};

function LayoutContainer({tab, isLoggedIn, isLoading}) {
  if (!isLoggedIn) {
    return <div>
      {isLoading ? <div className={css.spinner}></div> : null}
      <Login />
    </div>;
  }
  let child = null;
  switch (tab) {
    case TABS.ADMIN_PANEL:
      child = <AdminPanel />;
      break;
    case TABS.ADD_CONTRACTOR:
      child = <AddContractor />;
      break;
    case TABS.CONTRACTOR_INFO:
      child = <ContractorInfo />;
      break;
    case TABS.FILTERING:
      child = <Filtering />;
      break;
    case TABS.REPORTS:
      child = <Reports />;
      break;
    case TABS.DASHBOARD:
    default: // TODO: error page for default
      child = <Dashboard />;
      break;
  }
  return (
    <div className={css.wrapper}>
      {isLoading ? <div className={css.spinner}></div> : null}
      <User />
      <Navbar />
      <div className={css.content}>
        {child}
      </div>
    </div>
  );
}

LayoutContainer.propTypes = {
  tab: PropTypes.string.isRequired,
  isLoading: PropTypes.bool.isRequired,
  isLoggedIn: PropTypes.bool.isRequired,
  cookies: instanceOf(Cookies).isRequired
};

const Layout = connect(
  mapStateToProps,
  null
)(LayoutContainer);

export default withCookies(Layout);
<commit_msg>add chrome browser detection function<commit_after>import React from 'react';
import PropTypes, { instanceOf } from 'prop-types';
import { connect } from 'react-redux';
import { withCookies, Cookies } from 'react-cookie';
import * as TABS from '../../constants/tabs.js';
import Login from '../Login';
import Navbar from '../Navbar';
import Dashboard from '../Dashboard';
import AdminPanel from '../AdminPanel';
import AddContractor from '../AddContractor';
import ContractorInfo from '../ContractorInfo';
import Filtering from '../Filtering';
import Reports from '../Reports';
import User from '../User';
import css from './layout.css';

const mapStateToProps = (state, ownProps) => {
  return {
    tab: ownProps.cookies.get('tab') ? ownProps.cookies.get('tab') : state.main.tab,
    isLoading: state.main.isLoading,
    isLoggedIn: state.user.isLoggedIn
  };
};

function LayoutContainer({tab, isLoggedIn, isLoading}) {
  if (!isLoggedIn) {
    return <div>
      {isLoading ? <div className={css.spinner}></div> : null}
      <Login />
    </div>;
  }
  let child = null;
  switch (tab) {
    case TABS.ADMIN_PANEL:
      child = <AdminPanel />;
      break;
    case TABS.ADD_CONTRACTOR:
      child = <AddContractor />;
      break;
    case TABS.CONTRACTOR_INFO:
      child = <ContractorInfo />;
      break;
    case TABS.FILTERING:
      child = <Filtering />;
      break;
    case TABS.REPORTS:
      child = <Reports />;
      break;
    case TABS.DASHBOARD:
    default: // TODO: error page for default
      child = <Dashboard />;
      break;
  }
  return (
    <div className={css.wrapper}>
      {isLoading ? <div className={css.spinner}></div> : null}
      <User />
      <Navbar />
      <div className={css.content}>
        {child}
      </div>
    </div>
  );
}

function isChrome() {
  return typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.indexOf('Chrome') > -1;
}

LayoutContainer.propTypes = {
  tab: PropTypes.string.isRequired,
  isLoading: PropTypes.bool.isRequired,
  isLoggedIn: PropTypes.bool.isRequired,
  cookies: instanceOf(Cookies).isRequired
};

const Layout = connect(
  mapStateToProps,
  null
)(LayoutContainer);

export default withCookies(Layout);

{'fraction_non_alphanumeric': 0.14585764294049008, 'fraction_numerical': 0.00023337222870478414, 'mean_word_length': 3.1014354066985645, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 44, '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': '7310575', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1370, 'n_words': 339}