Commit 7b3ad293 authored by Zac Wood's avatar Zac Wood

Added "remove from schedule" button

parent d8818812
......@@ -21,7 +21,11 @@ class App extends React.Component<any, State> {
<h2>Search</h2>
<Search addSearchResultCallback={this.addSectionToCurrentScheduleIfUnique} />
<h2>Your schedule</h2>
<SectionList sections={this.state.currentSchedule} />
<SectionList
sections={this.state.currentSchedule}
buttonText="Remove from schedule"
selectSectionCallback={this.removeFromSchedule}
/>
<button onClick={this.generateSchedule}>Generate Schedule</button>
</div>
);
......@@ -46,9 +50,15 @@ class App extends React.Component<any, State> {
})
.then(response => response.text())
.then(text => {
const blob = new Blob([text], { type: 'text/plain;charset=utf-9' });
const blob = new Blob([text], { type: 'text/plain;charset=utf-8' });
FileSaver.saveAs(blob, 'GMU Fall 2018.ics');
});
};
removeFromSchedule = (section: Section) => {
this.setState({
currentSchedule: this.state.currentSchedule.filter(other => section !== other),
});
};
}
export default App;
......@@ -23,6 +23,7 @@ export default class Search extends React.Component<Props, State> {
<SearchBar onSearch={this.searchForSections} />
<SectionList
sections={this.state.sections}
buttonText="Add to schedule"
selectSectionCallback={this.props.addSearchResultCallback}
/>
</div>
......
......@@ -3,6 +3,7 @@ import Section from '../section';
interface Props {
sections: Section[];
buttonText: string;
selectSectionCallback?: (section: Section) => void;
}
......@@ -49,7 +50,9 @@ export default class SectionList extends React.Component<Props, any> {
const sectionWithCRN = this.getSectionWithCRN(rowCRN);
return (
<td>
<button onClick={() => this.props.selectSectionCallback(sectionWithCRN)}>Add to schedule</button>
<button onClick={() => this.props.selectSectionCallback(sectionWithCRN)}>
{this.props.buttonText}
</button>
</td>
);
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment