@homeworksenergy/utility-service 1.2.9 → 1.2.11

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.
Files changed (2) hide show
  1. package/index.js +5 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -170,26 +170,17 @@ const getHweCode = ({ state, department, eventType}) => {
170
170
  };
171
171
 
172
172
  const decodeEventType = (eventType) => {
173
+ if (!eventType) return { state: null, business: null, businessEvent: null };
173
174
  const state = eventType.slice(0, 2);
174
- const business = eventType.slice(2, 4);
175
- const businessEvent = eventType.slice(4, 6);
175
+ const business = eventType.length > 2 ? eventType.slice(2, 4) : null;
176
+ const businessEvent = eventType.length > 4 ? eventType.slice(4, 6) : null;
176
177
  return {
177
178
  state: STATES[state],
178
- business: BUSINESSES[business],
179
- businessEvent: EVENT_TYPES[state][business][businessEvent],
179
+ business: business? BUSINESSES[business] : null,
180
+ businessEvent: businessEvent ? EVENT_TYPES[state][business][businessEvent] : null,
180
181
  };
181
182
  };
182
183
 
183
- // TODO: I don't think this is used anywhere
184
- const getEventTypeForDepartment = (department, state = 'MA') => {
185
- const stateId = Object.keys(STATES).find((id) => STATES[id] === state);
186
- const departmentId = Object.keys(BUSINESSES).find(
187
- (id) => BUSINESSES[id] === department
188
- );
189
- if (!stateId || !departmentId) return null;
190
- return `${stateId}${departmentId}%`;
191
- };
192
-
193
184
  const isHWEUser = (user)=>{
194
185
  const { company } = user;
195
186
  return company?.toLowerCase()?.includes('hwe') || false;
@@ -198,7 +189,6 @@ const isHWEUser = (user)=>{
198
189
  module.exports = {
199
190
  decodeEventType,
200
191
  getHweCode,
201
- getEventTypeForDepartment,
202
192
  // Multi day
203
193
  getDefaultStartEndTimes,
204
194
  formatStartEndTimesAsDatabaseEventRow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homeworksenergy/utility-service",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "Added CT insulation install event types",
5
5
  "main": "index.js",
6
6
  "scripts": {