@aclymatepackages/modules 5.0.3 → 5.0.5

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.
@@ -12,6 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
12
12
  var _material = require("@mui/material");
13
13
  var _atoms = require("@aclymatepackages/atoms");
14
14
  var _otherHelpers = require("@aclymatepackages/other-helpers");
15
+ var _lists = require("@aclymatepackages/lists");
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
18
  const IndustryAutocomplete = _ref => {
@@ -31,16 +32,29 @@ const IndustryAutocomplete = _ref => {
31
32
  setNaicsCodesOptions(options || []);
32
33
  setLoading(false);
33
34
  };
34
- const onSelectOption = _ref2 => {
35
+ const deriveBuildingsSlug = naicsCode => {
36
+ const threeDigitPrefix = "".concat(naicsCode).slice(0, 3);
37
+ const {
38
+ buildingsSlug
39
+ } = _lists.threeDigitNaicsCodesIndustries.find(_ref2 => {
40
+ let {
41
+ naics
42
+ } = _ref2;
43
+ return naics === threeDigitPrefix;
44
+ }) || {};
45
+ return buildingsSlug || "office";
46
+ };
47
+ const onSelectOption = _ref3 => {
35
48
  let {
36
49
  code,
37
50
  description,
38
51
  tonsCo2ePerDollar
39
- } = _ref2;
52
+ } = _ref3;
40
53
  setIndustry({
41
54
  naicsCode: code,
42
55
  naicsTitle: description,
43
- tonsCo2ePerDollar
56
+ tonsCo2ePerDollar,
57
+ buildingsSlug: deriveBuildingsSlug(code)
44
58
  });
45
59
  setNaicsCodesOptions([]);
46
60
  };
@@ -89,12 +103,12 @@ const IndustryAutocomplete = _ref => {
89
103
  container: true,
90
104
  justifyContent: "center",
91
105
  spacing: 2
92
- }, naicsCodesOptions.map((_ref3, idx) => {
106
+ }, naicsCodesOptions.map((_ref4, idx) => {
93
107
  let {
94
108
  code,
95
109
  description,
96
110
  tonsCo2ePerDollar
97
- } = _ref3;
111
+ } = _ref4;
98
112
  return /*#__PURE__*/_react.default.createElement(_material.Grid, {
99
113
  item: true,
100
114
  key: "naics-chip-".concat(idx)
@@ -165,6 +165,9 @@ const PlacesAutocomplete = _ref => {
165
165
  color: "textSecondary"
166
166
  }, option === null || option === void 0 || (_option$structured_fo3 = option.structured_formatting) === null || _option$structured_fo3 === void 0 ? void 0 : _option$structured_fo3.secondary_text))));
167
167
  }
168
+ if (typeof option !== "string") {
169
+ return null;
170
+ }
168
171
  return /*#__PURE__*/_react.default.createElement("li", props, option);
169
172
  }
170
173
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aclymatepackages/modules",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "Aclymate modules",
5
5
  "author": "William Loopesko",
6
6
  "main": "dist/index.js",
@@ -7,6 +7,7 @@ import {
7
7
  SearchActionInput,
8
8
  } from "@aclymatepackages/atoms";
9
9
  import { truncateText } from "@aclymatepackages/other-helpers";
10
+ import { threeDigitNaicsCodesIndustries } from "@aclymatepackages/lists";
10
11
 
11
12
  const IndustryAutocomplete = ({
12
13
  industry,
@@ -27,11 +28,21 @@ const IndustryAutocomplete = ({
27
28
  setLoading(false);
28
29
  };
29
30
 
31
+ const deriveBuildingsSlug = (naicsCode) => {
32
+ const threeDigitPrefix = `${naicsCode}`.slice(0, 3);
33
+ const { buildingsSlug } =
34
+ threeDigitNaicsCodesIndustries.find(
35
+ ({ naics }) => naics === threeDigitPrefix
36
+ ) || {};
37
+ return buildingsSlug || "office";
38
+ };
39
+
30
40
  const onSelectOption = ({ code, description, tonsCo2ePerDollar }) => {
31
41
  setIndustry({
32
42
  naicsCode: code,
33
43
  naicsTitle: description,
34
44
  tonsCo2ePerDollar,
45
+ buildingsSlug: deriveBuildingsSlug(code),
35
46
  });
36
47
  setNaicsCodesOptions([]);
37
48
  };
@@ -166,6 +166,9 @@ const PlacesAutocomplete = ({
166
166
  );
167
167
  }
168
168
 
169
+ if (typeof option !== "string") {
170
+ return null;
171
+ }
169
172
  return <li {...props}>{option}</li>;
170
173
  }}
171
174
  />