@becollective/utils 1.4.1 → 1.4.3

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
@@ -128,6 +128,32 @@ 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
+
131
157
  var util = {
132
158
  getAge: getAge,
133
159
  getCurrencyFromCurrencyCode: getCurrencyFromCurrencyCode,
@@ -136,6 +162,7 @@ var util = {
136
162
  password: password,
137
163
  sort: {
138
164
  datesByThemselves: datesByThemselves
139
- }
165
+ },
166
+ readableOpportunityType: readableOpportunityType
140
167
  };
141
168
  module.exports = util;
package/index.js CHANGED
@@ -1,6 +1,7 @@
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';
4
5
 
5
6
  const util = {
6
7
  getAge,
@@ -11,6 +12,7 @@ const util = {
11
12
  sort: {
12
13
  datesByThemselves,
13
14
  },
15
+ readableOpportunityType,
14
16
  };
15
17
 
16
18
  module.exports = util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becollective/utils",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Common utilities",
5
5
  "main": "bundle.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "rollup-plugin-node-resolve": "^3.4.0"
20
20
  },
21
21
  "dependencies": {
22
- "@becollective/constants": "^3.3.2",
22
+ "@becollective/constants": "^3.6.3",
23
23
  "moment": "^2.24.0"
24
24
  },
25
25
  "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;