const React = window.React; const Component = React.Component; const EventItem = require("./EventItem.js"); const FILTER_OPTIONS = { all: "", important: "important", upcoming: "upcoming", finished: "finished" }; const SORT_OPTIONS = { asc: "asc", desc: "desc" }; module.exports = class EventList extends Component { constructor(props) { super(props); this.state = { queryString: "", filterOption: FILTER_OPTIONS.all, sortOption: SORT_OPTIONS.asc, items: [] }; this.onSearchChange = this.onSearchChange.bind(this); this.onFilterSelectionChange = this.onFilterSelectionChange.bind(this); this.onSortChange = this.onSortChange.bind(this); this._compareByTitle = this._compareBy.bind(this, "title"); } componentDidMount() { return this.loadData(); } loadData() { fetch(' ../data/eventList.json').then((resp) => { return resp.json(); }).then((eventData) => { this.setState({ items: eventData }); }); return this; } onSearchChange(event) { if (event && event.target && event.target.value !== this.state.queryString) { this.setState({ queryString: event.target.value }); } return this; } onFilterSelectionChange(event) { if (event && event.target && event.target.name === "filter-select") { this.setState({ filterOption: event.target.value }); } return this; } onSortChange() { this.setState({ sortOption: this.state.sortOption === SORT_OPTIONS.asc ? SORT_OPTIONS.desc : SORT_OPTIONS.asc }); return this; } render() { const checked = this.state.filterOption; return (