<commit_before>React = require 'react'
extend = require 'lodash/extend'
{Redirect, Link} = require 'react-router-dom'

TutorRouter = require '../helpers/router'
{default: InvalidPage} = require '../components/invalid-page'

{default: CCStudentRedirect}       = require '../components/cc-student-redirect'
{default: StudentDashboardShell} = require '../components/student-dashboard'
CCDashboard = require '../components/cc-dashboard'
{CourseStore} = require '../flux/course'

MatchForTutor = require '../components/match-for-tutor'

module.exports =
  studentOrTeacher: (StudentComponent, TeacherComponent, defaultProps = {} ) ->
    (props) ->
      {courseId} = props.params
      componentProps = extend(props, defaultProps)
      if CourseStore.isTeacher(courseId)
        <TeacherComponent courseId={courseId} {...componentProps} />
      else
        <StudentComponent courseId={courseId} {...componentProps} />


  dashboard: (props) ->
    {courseId} = props.params

    extend(props, {courseId})
    course = CourseStore.get(courseId)
    unless course
      return <InvalidPage message="course was not found" />
    unless props.match.isExact
      return <MatchForTutor {...props} /><commit_msg>display warning message when course isn't found<commit_after>React = require 'react'
extend = require 'lodash/extend'
{Redirect, Link} = require 'react-router-dom'

TutorRouter = require '../helpers/router'
{default: InvalidPage} = require '../components/invalid-page'

{default: CCStudentRedirect}       = require '../components/cc-student-redirect'
{default: StudentDashboardShell} = require '../components/student-dashboard'
{default: WarningModal} = require '../components/warning-modal'
CCDashboard = require '../components/cc-dashboard'
{CourseStore} = require '../flux/course'

MatchForTutor = require '../components/match-for-tutor'

module.exports =
  studentOrTeacher: (StudentComponent, TeacherComponent, defaultProps = {} ) ->
    (props) ->
      {courseId} = props.params
      componentProps = extend(props, defaultProps)
      if CourseStore.isTeacher(courseId)
        <TeacherComponent courseId={courseId} {...componentProps} />
      else
        <StudentComponent courseId={courseId} {...componentProps} />


  dashboard: (props) ->
    {courseId} = props.params

    extend(props, {courseId})
    course = CourseStore.get(courseId)
    unless course
      return (
        <WarningModal
          title="Sorry, you can’t access this course"
          message="You are no longer a student in this course. Please contact your instructor if you are still enrolled in this course and need to be re-added."
        />
      )
    unless props.match.isExact
      return <MatchForTutor {...props} />
{'fraction_non_alphanumeric': 0.13166605369621184, 'fraction_numerical': 0.0, 'mean_word_length': 3.548494983277592, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '3510233', 'n_tokens_mistral': 776, 'n_tokens_neox': 755, 'n_words': 188}