 
 {CourseListingActions, CourseListingStore} = require '../../flux/course-listing'
 {CourseStore} = require '../../flux/course'
+{CurrentUserStore} = require '../../flux/current-user'
 {RefreshButton} = require 'shared'
 EmptyCourses    = require '../course-listing/empty'
 CourseData = require '../course-data-mixin'
 
 {Course, CoursePastTeacher} = require './course'
 
+getReactBaseName = (context) -> _.kebabCase(context.constructor.displayName)
 
 CourseLink = ({courseId, name, is_concept_coach}) ->
   props = CourseData.getCourseDataProps(courseId)

    </BS.Row>

  Title: ->
    <BS.Row>
      <BS.Col md={12}>
        <h1>Current Courses</h1>
      </BS.Col>
    </BS.Row>

  AddCourses: ->
    <BS.Row>
      {wrapCourseItem(AddCourseArea, {id: 'new'})}
    </BS.Row>

  render: ->
    {courses} = @props

    <BS.Grid className='course-listing-heading course-listing-current'>
      <@Title />
      {if _.isEmpty(courses)
        <@NoCourses />
      else
        <CourseListingBase courses={courses} Item={Course}/>}
      <@AddCourses />
    </BS.Grid>



      <Item course={course} />
    </BS.Col>

  shouldRedirect: (currentCourses) ->
    currentCourses.length is 1 and CurrentUserStore.getCourseRole(currentCourses[0].id) is 'student'

  shouldShowEmpty: (currentCourses, pastCourses) ->
    _.isEmpty(currentCourses) and _.isEmpty(pastCourses) # and some way to determine if student?!

  render: ->
    [currentCourses, pastCourses] = CourseListingStore.coursesWithRolesByActive()

    if @shouldShowEmpty(currentCourses, pastCourses)
      <EmptyCourses />
    else if @shouldRedirect(currentCourses, pastCourses)
      <Redirect to={Router.makePathname('dashboard', {courseId: currentCourses[0].id})} />
    else
      <div className='course-listing '>
        <CourseListingCurrent courses={currentCourses}/>
        <CourseListingPast courses={pastCourses}/>
      </div>


