Warning big zones subscriptions

This commit is contained in:
vjrj 2018-02-28 11:22:01 +01:00
parent 7d5fe8f0ee
commit b546106066

View file

@ -80,7 +80,8 @@ class Subscriptions extends Component {
const { const {
loading, loading,
t, t,
subscriptions subscriptions,
maxDistance
} = this.props; } = this.props;
const firstBtnTitle = ['Añadir zona', '', 'Terminar']; // view, add, edit const firstBtnTitle = ['Añadir zona', '', 'Terminar']; // view, add, edit
return (!loading ? ( return (!loading ? (
@ -92,6 +93,9 @@ class Subscriptions extends Component {
{ subscriptions.length === 0 ? { subscriptions.length === 0 ?
<Alert bsStyle="warning"><Trans>No estás suscrito a fuegos en ninguna zona</Trans></Alert> : <Alert bsStyle="warning"><Trans>No estás suscrito a fuegos en ninguna zona</Trans></Alert> :
<Alert bsStyle="success"><Trans>En verde, áreas de las que recibirás alertas de fuegos</Trans></Alert> <Alert bsStyle="success"><Trans>En verde, áreas de las que recibirás alertas de fuegos</Trans></Alert>
}
{ maxDistance && maxDistance.distance > 20 &&
<Alert bsStyle="warning"><Trans>Estás subscrito a una zona muy grande</Trans></Alert>
} }
<br /> <br />
<SelectionMap <SelectionMap
@ -118,6 +122,7 @@ Subscriptions.propTypes = {
match: PropTypes.object.isRequired, match: PropTypes.object.isRequired,
t: PropTypes.func.isRequired, t: PropTypes.func.isRequired,
history: PropTypes.object.isRequired, history: PropTypes.object.isRequired,
maxDistance: PropTypes.object,
location: PropTypes.object location: PropTypes.object
}; };
@ -126,6 +131,7 @@ export default translate([], { wait: true })(withTracker(() => {
// console.log(UserSubsToFiresCollection.find().fetch()); // console.log(UserSubsToFiresCollection.find().fetch());
return { return {
loading: !subscription.ready(), loading: !subscription.ready(),
subscriptions: UserSubsToFiresCollection.find({ owner: Meteor.userId() }).fetch() subscriptions: UserSubsToFiresCollection.find({ owner: Meteor.userId() }).fetch(),
maxDistance: UserSubsToFiresCollection.findOne({ owner: Meteor.userId() }, { sort: { distance: -1 } })
}; };
})(Subscriptions)); })(Subscriptions));