playov2-js-utilities 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/notification-templates.js +7 -3
- package/lib/util.js +19 -3
- package/package.json +3 -2
|
@@ -205,13 +205,17 @@ const host_cancelled_activity = {
|
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
*
|
|
208
|
+
* Template for sending activity reminder.
|
|
209
|
+
* Notification is received by all the players of the activity.
|
|
210
|
+
* Text render only
|
|
211
|
+
* @param {String} sport_name
|
|
212
|
+
* @param {String} date
|
|
209
213
|
*/
|
|
210
214
|
const activity_reminder = {
|
|
211
215
|
heading: '⏰, Activity reminder!',
|
|
212
|
-
text: 'You have a {sport_name}} game coming up on {{date}}. Best of luck!',
|
|
216
|
+
text: 'You have a {{sport_name}} game coming up on {{date}}. Best of luck!',
|
|
213
217
|
buttons: [],
|
|
214
|
-
notificationId: notificationIds.ACTIVITY_REMINDER
|
|
218
|
+
notificationId: notificationIds.ACTIVITY_REMINDER
|
|
215
219
|
};
|
|
216
220
|
|
|
217
221
|
const host_updated_activity_details = {
|
package/lib/util.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Ideally new repositories should import utils from here only. Todo- look for a workaround - named imports
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const hbs = require('handlebars');
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Finds rating given to a user for a sport by playpals <Assumes playpalDocs supplied are already filtered for a user>
|
|
9
11
|
* @param {Array} playpalDocs
|
|
@@ -125,12 +127,26 @@ const getCategoricalBreakUpFromRecentUserRatings = (palRatingDict, levelCategori
|
|
|
125
127
|
|
|
126
128
|
const noop = () => {
|
|
127
129
|
return undefined;
|
|
128
|
-
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
* @param {String} template - Handlebars compatible template
|
|
135
|
+
* @param {Object} data - Data points containing key value pairs of data required in template supplied
|
|
136
|
+
* @returns {String}
|
|
137
|
+
*/
|
|
138
|
+
const renderTemplate = (template, data) => {
|
|
139
|
+
|
|
140
|
+
const temp = hbs.compile(template);
|
|
141
|
+
|
|
142
|
+
return temp(data);
|
|
143
|
+
};
|
|
129
144
|
|
|
130
145
|
module.exports = {
|
|
131
146
|
getRatingsFromPlaypalDocs,
|
|
132
147
|
findAverage,
|
|
133
148
|
getRecentRatingDictOfPals,
|
|
134
149
|
getCategoricalBreakUpFromRecentUserRatings,
|
|
135
|
-
noop
|
|
136
|
-
|
|
150
|
+
noop,
|
|
151
|
+
renderTemplate
|
|
152
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playov2-js-utilities",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Private package for JS utility functions",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@google-cloud/tasks": "^2.5.0",
|
|
25
25
|
"@playo/logger": "^0.9.18",
|
|
26
26
|
"axios": "^0.24.0",
|
|
27
|
-
"cron": "^1.8.2"
|
|
27
|
+
"cron": "^1.8.2",
|
|
28
|
+
"handlebars": "^4.7.7"
|
|
28
29
|
}
|
|
29
30
|
}
|