SectionList.tsx 1.23 KB
Newer Older
Zac Wood's avatar
Zac Wood committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
import * as React from 'react';
import Section from '../section';

interface Props {
    sections: Section[];
    addToScheduleCallback?: (section: Section) => void;
}

export default class SectionList extends React.Component<Props, any> {
    render() {
        return (
            <table>
                <tr>
                    <th>Course</th>
                    <th>Section Name</th>
                    <th>CRN</th>
                    <th>Days</th>
                    <th>Instructor</th>
                    <th>Location</th>
                    <th>Time</th>
                </tr>
                {this.renderRowsForSections(this.state.sections)}
            </table>
        );
    }

    renderRowsForSections(sections: Section[]): JSX.Element[] {
        return sections.map(section => {
            return (
                <tr>
                    <td>{section.name}</td>
                    <td>{section.title}</td>
                    <td>{section.crn}</td>
                    <td>{section.days}</td>
                    <td>{section.instructor}</td>
                    <td>{section.location}</td>
                    <td>{[section.startTime, section.endTime].join(' - ')}</td>
                </tr>
            );
        });
    }
}