Search.tsx 1.19 KB
Newer Older
Andrew Hrdy's avatar
Andrew Hrdy 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 '../ts/section';
import SearchBar from '../components/SearchBar';
import SectionList from '../components/SectionList';
import { connect } from 'react-redux';
import { State } from '../reducers';
import { searchSections } from '../actions/search/search.actions';
import { addSection } from '../actions/schedule/schedule.actions';

interface SearchProps {
    searchedSections: Section[];
    searchSections: (crn: string) => any;
    addSection: (section: Section) => any;
}

class Search extends React.Component<SearchProps> {
    constructor(props: SearchProps) {
        super(props);
    }

    render() {
        return (
            <div>
                <SearchBar onSearch={this.props.searchSections} />
                <SectionList
                    sections={this.props.searchedSections}
                    buttonText="Add to schedule"
                    selectSectionCallback={this.props.addSection}
                />
            </div>
        );
    }
}

const mapStateToProps = (state: State) => ({
    searchedSections: state.search.searchedSections
});

export default connect(mapStateToProps, {
    searchSections,
    addSection
})(Search);