-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumberOfEvents.js
47 lines (39 loc) · 1.18 KB
/
NumberOfEvents.js
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
import React, {Component} from 'react';
import {ErrorAlert} from './Alert';
class NumberOfEvents extends Component {
state = {
// default number of events
eventNumber: 12,
};
handleInputChanged = (event) => {
const value = event.target.value;
this.props.updateEvents(null, value);
if (value < 1 ){
this.setState({
eventNumber: value,
errorText: 'Please choose at least one event to view.'
});
} else {
return this.setState({
eventNumber: value,
errorText: ''
});
}
}
render() {
return(
<div className='numberOfEvents'>
<ErrorAlert text={this.state.errorText} style={{margin: 0}}/>
<label className='eventNumberLabel'>Number of events/page:</label>
<input
type='number'
id='eventNumber'
className='eventNumber'
value={this.state.eventNumber}
onChange={this.handleInputChanged}
/>
</div>
)
}
}
export default NumberOfEvents;