@becollective/utils 1.4.3 → 1.5.0

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/bundle.js CHANGED
@@ -154,6 +154,24 @@ var readableOpportunityType = function readableOpportunityType(type) {
154
154
  return TYPE_MAP[type] || null;
155
155
  };
156
156
 
157
+ var _require$2 = require('lodash'),
158
+ pick = _require$2.pick;
159
+ /**
160
+ *
161
+ * @param {*} opportunityUser
162
+ * @param {*} opportunity
163
+ */
164
+
165
+
166
+ var getTimeInfo = function getTimeInfo(opportunityUser) {
167
+ var opportunity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
168
+ var opp = opportunity || opportunityUser.opportunity;
169
+ var isEoi = opportunityUser && opportunityUser.eoi || opp && opp.eoi;
170
+ var record = isEoi ? opportunityUser : opp;
171
+ var fields = pick(record, ['startDate', 'endDate', 'type', 'dates', 'recurrenceRule', 'timezone', 'location', 'locationOther', 'locationVirtual']);
172
+ return fields;
173
+ };
174
+
157
175
  var util = {
158
176
  getAge: getAge,
159
177
  getCurrencyFromCurrencyCode: getCurrencyFromCurrencyCode,
@@ -163,6 +181,7 @@ var util = {
163
181
  sort: {
164
182
  datesByThemselves: datesByThemselves
165
183
  },
166
- readableOpportunityType: readableOpportunityType
184
+ readableOpportunityType: readableOpportunityType,
185
+ getTimeInfo: getTimeInfo
167
186
  };
168
187
  module.exports = util;
package/index.js CHANGED
@@ -2,6 +2,7 @@ import { password } from './src/password';
2
2
  import { isUnderSixteen, getAge, datesByThemselves } from './src/date-time';
3
3
  import { getCurrencyFromCurrencyCode, makeMoneyString } from './src/money';
4
4
  import { readableOpportunityType } from './src/opportunity';
5
+ import { getTimeInfo } from './src/opportunityUser';
5
6
 
6
7
  const util = {
7
8
  getAge,
@@ -13,6 +14,7 @@ const util = {
13
14
  datesByThemselves,
14
15
  },
15
16
  readableOpportunityType,
17
+ getTimeInfo,
16
18
  };
17
19
 
18
20
  module.exports = util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becollective/utils",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "Common utilities",
5
5
  "main": "bundle.js",
6
6
  "scripts": {
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@becollective/constants": "^3.6.3",
23
+ "lodash": "^4.17.15",
23
24
  "moment": "^2.24.0"
24
25
  },
25
26
  "jest": {
@@ -0,0 +1,16 @@
1
+ const { pick } = require('lodash');
2
+
3
+ /**
4
+ *
5
+ * @param {*} opportunityUser
6
+ * @param {*} opportunity
7
+ */
8
+ export const getTimeInfo = (opportunityUser, opportunity = null) => {
9
+ const opp = opportunity || opportunityUser.opportunity;
10
+ const isEoi = (opportunityUser && opportunityUser.eoi) || (opp && opp.eoi);
11
+ const record = isEoi ? opportunityUser : opp;
12
+ const fields = pick(record, ['startDate', 'endDate', 'type', 'dates',
13
+ 'recurrenceRule', 'timezone', 'location', 'locationOther', 'locationVirtual']);
14
+
15
+ return fields;
16
+ };