<commit_before>/* global document, window */
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter as Router, Switch, Route, Redirect } from 'react-router-dom';

import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';

import rootReducer from './reducers';
import App from './components/App';
import Login from './components/Login';
import LoginCallback from './components/Login/LoginCallback';
import StartScreen from './components/StartScreen';
import ResetPassword from './components/ResetPassword';
import SignUp from './components/SignUp';

import './index.css';

const configureStore = () => {
  if (process.env.NODE_ENV === 'production') {
    return createStore(rootReducer, applyMiddleware(thunk));
  }

  return createStore(
    rootReducer,
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(), // eslint-disable-line
    applyMiddleware(thunk),
  );
};

const isAuthenticated = () => {
  const token = window.localStorage.getItem('jwt.token');

  if (window.location.pathname.startsWith('/') && !token) {
    return <Route exact path="/" component={StartScreen} />;
  }

  if (token === null || token === undefined) {
    return <Redirect to="/" />;
  }

  return <App />;
};

const Root = () => (
  <Provider store={configureStore()}>
    <Router>
      <Switch>
        <Route exact path="/login" component={Login} />
        <Route exact path="/login/callback/facebook/:token" component={LoginCallback} />
        <Route exact path="/reset-password" component={ResetPassword} />

        <Route exact path="/sign-up" component={SignUp} />

        {isAuthenticated()}
      </Switch>
    </Router>
  </Provider>
);

render(<Root />, document.getElementById('root'));
<commit_msg>show the NotFound component if page is not found<commit_after>/* global document, window */
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter as Router, Switch, Route, Redirect } from 'react-router-dom';

import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';

import rootReducer from './reducers';
import App from './components/App';
import Login from './components/Login';
import LoginCallback from './components/Login/LoginCallback';
import StartScreen from './components/StartScreen';
import ResetPassword from './components/ResetPassword';
import SignUp from './components/SignUp';
import NotFound from './components/NotFound';

import './index.css';

const configureStore = () => {
  if (process.env.NODE_ENV === 'production') {
    return createStore(rootReducer, applyMiddleware(thunk));
  }

  return createStore(
    rootReducer,
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(), // eslint-disable-line
    applyMiddleware(thunk),
  );
};

const isAuthenticated = () => {
  const token = window.localStorage.getItem('jwt.token');

  if (window.location.pathname.startsWith('/') && !token) {
    return <Route exact path="/" component={StartScreen} />;
  }

  if (token === null || token === undefined) {
    return <Redirect to="/" />;
  }

  return <App />;
};

const Root = () => (
  <Provider store={configureStore()}>
    <Router>
      <Switch>
        <Route exact path="/login" component={Login} />
        <Route exact path="/login/callback/facebook/:token" component={LoginCallback} />
        <Route exact path="/reset-password" component={ResetPassword} />

        <Route exact path="/sign-up" component={SignUp} />

        {isAuthenticated()}
        <Route component={NotFound} />
      </Switch>
    </Router>
  </Provider>
);

render(<Root />, document.getElementById('root'));

{'fraction_non_alphanumeric': 0.15755968169761272, 'fraction_numerical': 0.0, 'mean_word_length': 3.9488188976377954, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 38, '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': '472063', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1086, 'n_words': 274}