diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-02-13 13:58:11 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-02-13 13:58:11 +0100 |
| commit | 392ea8d0ba2fdc713ae156517b0575e8219b9f1c (patch) | |
| tree | bb29c19f9f0a2d970c39c813130361405fccbe4e /scraper/client/search/panicButton.component.js | |
| parent | dc7d9cbba842472efb33186e97ee55751e4d50ca (diff) | |
adding geocode client
Diffstat (limited to 'scraper/client/search/panicButton.component.js')
| -rw-r--r-- | scraper/client/search/panicButton.component.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scraper/client/search/panicButton.component.js b/scraper/client/search/panicButton.component.js new file mode 100644 index 00000000..a12c817b --- /dev/null +++ b/scraper/client/search/panicButton.component.js @@ -0,0 +1,49 @@ +import React, { Component } from 'react' +import { withRouter } from 'react-router-dom' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import * as actions from './search.actions' + +class PanicButton extends Component { + constructor() { + super() + this.keydown = this.keydown.bind(this) + } + + componentDidMount() { + document.addEventListener('keydown', this.keydown) + } + + componentWillUnmount() { + document.removeEventListener('keydown', this.keydown) + } + + keydown(e) { + if (e.keyCode === 27) { + this.panic() + } + } + + panic() { + this.props.actions.panic() + this.props.history.push('/search/') + } + + render() { + return ( + <button className='btn panic' onClick={() => this.panic()}> + <span>⚠</span> Panic + </button> + ) + } +} + +const mapStateToProps = state => ({ +}) + +const mapDispatchToProps = dispatch => ({ + actions: bindActionCreators({ panic: actions.panic }, dispatch) +}) + +export default withRouter(connect(mapStateToProps, mapDispatchToProps)(PanicButton)) |
