@becollective/utils 1.4.2 → 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 +47 -1
- package/index.js +4 -0
- package/package.json +3 -2
- package/src/opportunity.js +10 -0
- package/src/opportunityUser.js +16 -0
package/bundle.js
CHANGED
|
@@ -128,6 +128,50 @@ var makeMoneyString = function makeMoneyString(_ref) {
|
|
|
128
128
|
return "".concat(symbol).concat(localeAmount).concat(currencyCodeString);
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
+
function _defineProperty(obj, key, value) {
|
|
132
|
+
if (key in obj) {
|
|
133
|
+
Object.defineProperty(obj, key, {
|
|
134
|
+
value: value,
|
|
135
|
+
enumerable: true,
|
|
136
|
+
configurable: true,
|
|
137
|
+
writable: true
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
obj[key] = value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return obj;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var _TYPE_MAP;
|
|
147
|
+
|
|
148
|
+
var _require$1 = require('@becollective/constants'),
|
|
149
|
+
opportunities = _require$1.opportunities;
|
|
150
|
+
|
|
151
|
+
var opportunityTypes = opportunities.typesMap;
|
|
152
|
+
var TYPE_MAP = (_TYPE_MAP = {}, _defineProperty(_TYPE_MAP, opportunityTypes.roleFlexible, 'One-Off Task'), _defineProperty(_TYPE_MAP, opportunityTypes.roleFixed, 'Shift(s)'), _defineProperty(_TYPE_MAP, opportunityTypes.ongoing, 'Ongoing'), _TYPE_MAP);
|
|
153
|
+
var readableOpportunityType = function readableOpportunityType(type) {
|
|
154
|
+
return TYPE_MAP[type] || null;
|
|
155
|
+
};
|
|
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
|
+
|
|
131
175
|
var util = {
|
|
132
176
|
getAge: getAge,
|
|
133
177
|
getCurrencyFromCurrencyCode: getCurrencyFromCurrencyCode,
|
|
@@ -136,6 +180,8 @@ var util = {
|
|
|
136
180
|
password: password,
|
|
137
181
|
sort: {
|
|
138
182
|
datesByThemselves: datesByThemselves
|
|
139
|
-
}
|
|
183
|
+
},
|
|
184
|
+
readableOpportunityType: readableOpportunityType,
|
|
185
|
+
getTimeInfo: getTimeInfo
|
|
140
186
|
};
|
|
141
187
|
module.exports = util;
|
package/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { password } from './src/password';
|
|
2
2
|
import { isUnderSixteen, getAge, datesByThemselves } from './src/date-time';
|
|
3
3
|
import { getCurrencyFromCurrencyCode, makeMoneyString } from './src/money';
|
|
4
|
+
import { readableOpportunityType } from './src/opportunity';
|
|
5
|
+
import { getTimeInfo } from './src/opportunityUser';
|
|
4
6
|
|
|
5
7
|
const util = {
|
|
6
8
|
getAge,
|
|
@@ -11,6 +13,8 @@ const util = {
|
|
|
11
13
|
sort: {
|
|
12
14
|
datesByThemselves,
|
|
13
15
|
},
|
|
16
|
+
readableOpportunityType,
|
|
17
|
+
getTimeInfo,
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
module.exports = util;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@becollective/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Common utilities",
|
|
5
5
|
"main": "bundle.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"rollup-plugin-node-resolve": "^3.4.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@becollective/constants": "^3.6.
|
|
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,10 @@
|
|
|
1
|
+
const { opportunities } = require('@becollective/constants');
|
|
2
|
+
const { typesMap: opportunityTypes } = opportunities;
|
|
3
|
+
|
|
4
|
+
const TYPE_MAP = {
|
|
5
|
+
[opportunityTypes.roleFlexible]: 'One-Off Task',
|
|
6
|
+
[opportunityTypes.roleFixed]: 'Shift(s)',
|
|
7
|
+
[opportunityTypes.ongoing]: 'Ongoing',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const readableOpportunityType = type => TYPE_MAP[type] || null;
|
|
@@ -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
|
+
};
|