Extracted events amount badge to function

This commit is contained in:
Shay Nehmad 2019-09-04 17:00:28 +03:00
parent 146c87c338
commit 5a29e047ab
1 changed files with 13 additions and 10 deletions

View File

@ -20,23 +20,26 @@ export default class EventsButton extends Component {
};
render() {
return <Fragment>
<EventsModal events={this.props.events} showEvents={this.state.isShow} hideCallback={this.hide}
exportFilename={this.props.exportFilename}/>
<div className="text-center" style={{"display": "grid"}}>
<Button className="btn btn-primary btn-lg" onClick={this.show}>
<i className="fa fa-list"/> Events {this.createEventsAmountBadge()}
</Button>
</div>
</Fragment>;
}
createEventsAmountBadge() {
let eventsAmountBadge;
if (this.props.events.length > 10) {
eventsAmountBadge = <Badge>9+</Badge>;
} else {
eventsAmountBadge = <Badge>{this.props.events.length}</Badge>;
}
return <Fragment>
<EventsModal events={this.props.events} showEvents={this.state.isShow} hideCallback={this.hide}
exportFilename={this.props.exportFilename}/>
<div className="text-center" style={{"display": "grid"}}>
<Button className="btn btn-primary btn-lg" onClick={this.show}>
<i className="fa fa-list"/> Events {eventsAmountBadge}
</Button>
</div>
</Fragment>;
return eventsAmountBadge;
}
}
EventsButton.propTypes = {