 
 SectionsChooser = React.createClass
   propTypes:
-    ecosystemId: React.PropTypes.string
-    courseId: React.PropTypes.string
-    onSelectionChange: React.PropTypes.func.isRequired
-    selectedSections: React.PropTypes.arrayOf(
+    onSelectionChange: React.PropTypes.func
+    chapters: React.PropTypes.arrayOf(
+      React.PropTypes.shape(
+        id: React.PropTypes.string
+        title: React.PropTypes.string
+        chapter_section: React.PropTypes.array
+        children: React.PropTypes.array
+      )
+    ).isRequired
+    selectedSectionIds: React.PropTypes.arrayOf(
       React.PropTypes.string
     )
 
   getInitialState: -> {selections: {}}
 
   componentWillMount: ->
-    @copySelectionStateFromProps(
-      if @props.selectedSections then @props.selectedSections else []
+    @copySelectionStateFrom(
+      if @props.selectedSectionIds then @props.selectedSectionIds else []
     )
 
   componentWillReceiveProps: (nextProps) ->
-    @copySelectionStateFrom(nextProps.selectedSections) if nextProps.selectedSections
+    @copySelectionStateFrom(nextProps.selectedSectionIds) if nextProps.selectedSectionIds?
 
-  copySelectionStateFromProps: (selections) ->
+  copySelectionStateFrom: (sectionIds) ->
     selections = {}
-    for sectionId in selections
-      selections[sectionId]
+    selections[id] = true for id in sectionIds
     @setState({selections})
-
-  getEcosystemId: ->
-    @props.ecosystemId or CourseStore.get(@props.courseId)?.ecosystem_id or (
-      throw new Error("BUG: ecosystemId wasn't provided and unable to find it on course")
-    )
 
   getSelectedSectionIds: (selections = @state.selections) ->
     sectionId for sectionId, value of selections when value
 
   onSectionSelectionChange: (update) ->
     selections = _.extend({}, @state.selections, update)
-    console.log selections
     @setState({selections})
     @props.onSelectionChange?( @getSelectedSectionIds(selections) )
 
-  renderChapters: ->
+
+  render: ->
     <div className="sections-chooser">
-    {for chapter in TocStore.get(@getEcosystemId())
-      <ChapterAccordion key={chapter.id} {...@props}
-        onChange={@onSectionSelectionChange}
-        selections={@state.selections} chapter={chapter} />}
+      {for chapter in @props.chapters
+        <ChapterAccordion key={chapter.id} {...@props}
+          onChange={@onSectionSelectionChange}
+          selections={@state.selections} chapter={chapter} />}
     </div>
 
-  render: ->
-    <LoadableItem
-      id={@getEcosystemId()}
-      store={TocStore}
-      actions={TocActions}
-      renderItem={@renderChapters}
-    />
 
 
 module.exports = SectionsChooser

React = require 'react'
_ = require 'underscore'
BS = require 'react-bootstrap'
LoadableItem = require './loadable-item'
ChapterSection = require './task-plan/chapter-section'
BrowseTheBook = require './buttons/browse-the-book'
TriStateCheckbox = require './tri-state-checkbox'
classnames = require 'classnames'

{TocStore, TocActions} = require '../flux/toc'

{CourseStore} = require '../flux/course'

SectionTopic = React.createClass


    selections: React.PropTypes.object.isRequired
    onChange: React.PropTypes.func.isRequired

  isSelected:    -> @props.selections[@props.section.id]
  toggleSection: -> @props.onChange({"#{@props.section.id}": not @isSelected()})
  render: ->
    classNames = classnames 'section', {selected: @props.selected}
    <div key={@props.section.id} className={classNames} onClick={@toggleSection}>
