<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Match, Redirect } from 'react-router';
import App from './App';
import Notes from './components/pages/Notes';
import Login from './components/pages/Login';
import Auth from './data/Auth.js';
import './index.scss';

const MatchWhenAuthorized = ({ component: Component, ...rest }) => (
  <Match
    {...rest}
    render={props => (
      Auth.isAuthenticated
      ? <Component {...props} />
      : (
        <Redirect
          to={{
            pathname: '/',
            state: { from: props.location },
          }}
        />
      )
    )}
  />
);

const Router = () => (
  <BrowserRouter>
    {({ router }) => (
      <div>
        {Auth.isAuthenticated ? (
          <p>
            {/* TODO: add headerbar */}
            Headerbar! {' '}
            <button onClick={() => (
              Auth.signOut().then(() => router.transitionTo('/'))
            )}>Sign out</button>
          </p>
        ) : (
          <div>
            {/* TODO: possibly remove App */}
            <App />
            <Login />
          </div>
        )}

        <MatchWhenAuthorized pattern="/notes" component={Notes}/>
      </div>
    )}
  </BrowserRouter>
)

ReactDOM.render(
  <Router />,
  document.getElementById('root')
);<commit_msg>Move router to App layer<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import Router from './App';
import './index.scss';

ReactDOM.render(<Router />, document.getElementById('root'));
{'fraction_non_alphanumeric': 0.17487046632124353, 'fraction_numerical': 0.0, 'mean_word_length': 1.965451055662188, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '6089175', 'n_tokens_mistral': 453, 'n_tokens_neox': 448, 'n_words': 103}