Dup subscriptions not allowed
This commit is contained in:
parent
621cf4e2ad
commit
e703057377
4 changed files with 13 additions and 3 deletions
|
|
@ -25,6 +25,10 @@ Meteor.methods({
|
|||
...doc
|
||||
};
|
||||
// console.log(newDoc);
|
||||
const already = Subscriptions.findOne(newDoc);
|
||||
if (already) {
|
||||
throw new Meteor.Error('500', 'on-already-subscribed');
|
||||
}
|
||||
return Subscriptions.insert(newDoc);
|
||||
} catch (exception) {
|
||||
console.error(exception);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ class SubscriptionEditor extends React.Component {
|
|||
if (authenticated) {
|
||||
Meteor.call(methodToCall, doc, (error, subscriptionId) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
if (error.reason && error.reason.reason) {
|
||||
Bert.alert(t(error.reason.reason), 'danger');
|
||||
}
|
||||
} else {
|
||||
const confirmation = existingSubscription ? t('Zona actualizada') : t('Zona añadida');
|
||||
Bert.alert(confirmation, 'success');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue