-
Notifications
You must be signed in to change notification settings - Fork 1
/
slack-invite.js
45 lines (40 loc) · 1.05 KB
/
slack-invite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Slack = new Mongo.Collection('slack');
if (Meteor.isClient) {
Template.slackInvite.onCreated(function() {
var instance = this;
instance.invite = new ReactiveVar(false);
instance.error = new ReactiveVar("");
instance.subscribe('slack');
});
Template.slackInvite.helpers({
invite: function() {
var instance = Template.instance();
return instance.invite.get();
},
slack: function() {
return Slack.findOne();
},
error: function() {
var instance = Template.instance();
return instance.error.get();
}
});
Template.slackInvite.events({
'submit form': function(e, instance) {
e.preventDefault();
var email = instance.find('input').value;
Meteor.call('invite', email, function(err, res) {
if (!err && res.ok) {
instance.error.set("");
instance.invite.set(true);
}
else if (!err){
instance.error.set(res.error);
}
else {
instance.error.set('Someting is broken here.');
}
});
}
});
}