import React, { Component, PropTypes } from 'react';
import { Card, CardHeader, CardText } from 'material-ui';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import UCdefaultTheme from '../../../themes/DefaultTheme';

import ClassScheduleTermListItem from './ClassScheduleTermListItem';

export default class ClassScheduleTermList extends Component {
  // constructor(props) {
  //   super(props);
  // }

  getChildContext() {
    const theme = getMuiTheme(UCdefaultTheme);
    return {
      muiTheme: theme,
    };
  }

  render() {
    const { number, description, sections } = this.props;
    const content = sections.map((item, key) => (
      <ClassScheduleTermListItem
        key={`cs-term-list-item-${key}`}
        classNumber={item.classNumber}
        section={item.classSection}
        type={item.component}
        instructor={item.instructor}
        room={item.room}
        days={item.days}
        times={item.times}
        booklink={item.bookLink}
      />));

    return (
      <Card className="class-card">
        <CardHeader
          title={number}
          subtitle={description}
          actAsExpander
          showExpandableButton
          style={{ height: 'auto' }}
        />
        <CardText expandable>
          {content}
        </CardText>
      </Card>
    );
  }
}

ClassScheduleTermList.propTypes = {
  number:PropTypes.string,
  description:PropTypes.string,
  sections: PropTypes.array,
};

ClassScheduleTermList.childContextTypes = {
  muiTheme: PropTypes.object,
};
