-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestaurantFilter.js
More file actions
63 lines (55 loc) · 1.51 KB
/
RestaurantFilter.js
File metadata and controls
63 lines (55 loc) · 1.51 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from "react";
class RestaurantFilter extends React.Component {
constructor(props) {
super(props);
this.state = { value: "All" };
this.onChange = this.onChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
}
onChange = event => {
this.setState({ value: event.target.value });
};
onSubmit = event => {
event.preventDefault();
this.props.onFormSubmit(this.state.value);
//call back function
};
onFilterClick = event => {
this.props.onFilterClick();
};
onNearMeClick = event => {
this.props.onNearMeClick();
};
render() {
return (
<div className="average-rating">
<button
className="view-restaurants-button"
onClick={this.onNearMeClick}
>
Find restaurants near me
</button>
<form onSubmit={this.onSubmit}>
<label>
{" "}
Filter by average rating:
<select
value={this.state.value}
onChange={this.onChange}
onClick={this.onFilterClick}
>
<option value="All">All</option>
<option value={1}>1</option>
<option value={2}>2</option>
<option value={3}>3</option>
<option value={4}>4</option>
<option value={5}>5</option>
</select>
</label>
<input type="submit" value="Submit" className="submit-button" />
</form>
</div>
);
}
}
export default RestaurantFilter;