<commit_before>'use strict'
import React from 'react'
import {Router, Route, IndexRedirect, browserHistory} from 'react-router'
import {render} from 'react-dom'
import {connect, Provider} from 'react-redux'

import store from './store'

import Login from './components/Login'
import WhoAmI from './components/WhoAmI'
import FAQ from './components/FAQ'

import AppContainer from './containers/AppContainer'
import HomeContainer from './containers/HomeContainer'
import StudentAppContainer from './containers/StudentAppContainer'
import TeacherAppContainer from './containers/TeacherAppContainer'
import StudentDashboardContainer from './containers/StudentDashboardContainer'
import TeacherDashboardContainer from './containers/TeacherDashboardContainer'
import StudentTrackerContainer from './containers/StudentTrackerContainer'
import StudentCalendarContainer from './containers/StudentCalendarContainer'
import StudentReportCardContainer from './containers/StudentReportCardContainer'
import AssignmentContainer from './containers/AssignmentContainer'
import ClassTrackerContainer from './containers/ClassTrackerContainer'
import LibraryContainer from './containers/LibraryContainer'
import TeacherCalendarContainer from './containers/TeacherCalendarContainer'
import RewardsContainer from './containers/RewardsContainer'
import QuizContainer from './containers/QuizContainer'
import CompletedQuizContainer from './containers/CompletedQuizContainer'
import TeacherFunctionsContainer from './containers/TeacherFunctionsContainer'
import SignUpContainer from './containers/SignUpContainer'
import CreateQuizContainer from './containers/CreateQuizContainer'
import CreateTaskContainer from './containers/CreateTaskContainer'
import CompletedAssignmentContainer from './containers/CompletedAssignmentContainer'
import TeacherStudentsContainer from './containers/TeacherStudentsContainer'
import SettingsContainer from './containers/SettingsContainer'

import {whoami} from './reducers/auth'

import {loadAssignments, loadCurrentAssignment, loadStudent, loadQuiz, loadTask} from './reducers/student'
import {loadCalendar, loadStudents, loadCurrentStudent} from './reducers/teacher'
import {loadLibrary} from './reducers/library'
import {loadBoard} from './reducers/tracker'
import {loadTeachers} from './reducers/signup'

const onEnterSignup = () => {
  store.dispatch(loadTeachers())
  .catch(console.error.bind(console))
}

const onEnterApp = (nextState, replace, done) => {
  store.dispatch(whoami())
  .then(() => done())
  .catch(err => console.error(err))
}

const onEnterStudent = (nextState, replace, done) => (
  store.dispatch(whoami())
    .then(user => {
      if(user.teacher_id && nextState.params && nextState.params.assignmentId) return replace (`/teacher/assignment/${nextState.params.assignmentId}`)
      return store.dispatch(loadStudent())
    })
    .then(() => done())

    .catch(err => console.error(err))
)

const onEnterTeacher = (nextState, replace, done) => (
  store.dispatch(whoami())
    .then(res => store.dispatch(loadStudents()))
    .then(res => store.dispatch(loadCalendar()))
    .then(res => done())
    .catch(err => console.error(err))
)

const onEnterTeacherFunctions = (nextState, replace) => (
  store.dispatch(loadLibrary())<commit_msg>if logged in, redirect to correct dashboard<commit_after>'use strict'
import React from 'react'
import {Router, Route, IndexRedirect, browserHistory} from 'react-router'
import {render} from 'react-dom'
import {connect, Provider} from 'react-redux'

import store from './store'

import Login from './components/Login'
import WhoAmI from './components/WhoAmI'
import FAQ from './components/FAQ'

import AppContainer from './containers/AppContainer'
import HomeContainer from './containers/HomeContainer'
import StudentAppContainer from './containers/StudentAppContainer'
import TeacherAppContainer from './containers/TeacherAppContainer'
import StudentDashboardContainer from './containers/StudentDashboardContainer'
import TeacherDashboardContainer from './containers/TeacherDashboardContainer'
import StudentTrackerContainer from './containers/StudentTrackerContainer'
import StudentCalendarContainer from './containers/StudentCalendarContainer'
import StudentReportCardContainer from './containers/StudentReportCardContainer'
import AssignmentContainer from './containers/AssignmentContainer'
import ClassTrackerContainer from './containers/ClassTrackerContainer'
import LibraryContainer from './containers/LibraryContainer'
import TeacherCalendarContainer from './containers/TeacherCalendarContainer'
import RewardsContainer from './containers/RewardsContainer'
import QuizContainer from './containers/QuizContainer'
import CompletedQuizContainer from './containers/CompletedQuizContainer'
import TeacherFunctionsContainer from './containers/TeacherFunctionsContainer'
import SignUpContainer from './containers/SignUpContainer'
import CreateQuizContainer from './containers/CreateQuizContainer'
import CreateTaskContainer from './containers/CreateTaskContainer'
import CompletedAssignmentContainer from './containers/CompletedAssignmentContainer'
import TeacherStudentsContainer from './containers/TeacherStudentsContainer'
import SettingsContainer from './containers/SettingsContainer'

import {whoami} from './reducers/auth'

import {loadAssignments, loadCurrentAssignment, loadStudent, loadQuiz, loadTask} from './reducers/student'
import {loadCalendar, loadStudents, loadCurrentStudent} from './reducers/teacher'
import {loadLibrary} from './reducers/library'
import {loadBoard} from './reducers/tracker'
import {loadTeachers} from './reducers/signup'

const onEnterSignup = () => {
  store.dispatch(loadTeachers())
  .catch(console.error.bind(console))
}

const onEnterApp = (nextState, replace, done) => {
  store.dispatch(whoami())
  .then(() => done())
  .catch(err => console.error(err))
}

const onEnterStudent = (nextState, replace, done) => (
  store.dispatch(whoami())
    .then(user => {
      if(user.teacher_id && nextState.params && nextState.params.assignmentId) return replace (`/teacher/assignment/${nextState.params.assignmentId}`)
      else if(user.teacher_id) return replace('/teacher/dashboard')
      return store.dispatch(loadStudent())
    })
    .then(() => done())

    .catch(err => console.error(err))
)

const onEnterTeacher = (nextState, replace, done) => (
  store.dispatch(whoami())
    .then(user => {
          if (user.student_id) return replace('/student/dashboard')
          else return store.dispatch(loadStudents())})
    .then(res => store.dispatch(loadCalendar()))
    .then(res => done())
    .catch(err => console.error(err))
)

const onEnterTeacherFunctions = (nextState, replace) => (
  store.dispatch(loadLibrary())
{'fraction_non_alphanumeric': 0.11695819745034094, 'fraction_numerical': 0.0, 'mean_word_length': 6.132135306553911, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '2703351', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1760, 'n_words': 439}