Added subs management (wip)

This commit is contained in:
vjrj 2017-12-16 18:47:08 +01:00
parent 6123977974
commit 316e14f0ea
21 changed files with 427 additions and 39 deletions

View file

@ -33,7 +33,7 @@ class SelectionMap extends Component {
this.updatePosition = this.updatePosition.bind(this);
this.fit = this.fit.bind(this);
this.addScale = this.addScale.bind(this);
this.doSubs = this.doSubs.bind(this);
this.onSubs = this.onSubs.bind(this);
}
componentDidMount() {
@ -57,6 +57,13 @@ class SelectionMap extends Component {
this.fit();
}
onSubs() {
this.props.onSubs({
location: { lat: this.state.center[0], lon: this.state.center[1] },
distance: this.state.distance
});
}
getMap() {
return this.selectionMap.leafletElement;
}
@ -92,13 +99,6 @@ class SelectionMap extends Component {
Leaflet.control.graphicScale([options]).addTo(map);
}
doSubs() { // event param not used
this.props.history.push(
'/login',
{ subscription: { center: this.state.center, distance: this.state.distance } }
);
}
isValidState() {
return this.state.center && this.state.center[0] && this.state.distance;
}
@ -152,9 +152,9 @@ class SelectionMap extends Component {
<ButtonToolbar>
<Button
bsStyle="success"
onClick={event => this.doSubs(event)}
onClick={event => this.onSubs(event)}
>
{this.props.t('Subscribirme a fuegos en este rádio')}
{this.props.subsBtn}
</Button>
</ButtonToolbar>
</Control>
@ -165,11 +165,12 @@ class SelectionMap extends Component {
}
SelectionMap.propTypes = {
history: PropTypes.object.isRequired,
t: PropTypes.func.isRequired,
center: PropTypes.array,
center: PropTypes.arrayOf(PropTypes.number),
distance: PropTypes.number,
onSelection: PropTypes.func.isRequired
onSelection: PropTypes.func.isRequired,
subsBtn: PropTypes.string.isRequired,
onSubs: PropTypes.func.isRequired
};
export default translate([], { wait: true })(withTracker(props => ({