@aclymatepackages/modules 5.0.2 → 5.0.4

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.
@@ -13,6 +13,7 @@ var _Cancel = _interopRequireDefault(require("@mui/icons-material/Cancel"));
13
13
  var _arrayImmutabilityHelpers = require("@aclymatepackages/array-immutability-helpers");
14
14
  var _atoms = require("@aclymatepackages/atoms");
15
15
  var _modules = require("@aclymatepackages/modules");
16
+ var _IndustryAutocomplete = _interopRequireDefault(require("./IndustryAutocomplete"));
16
17
  var _regExp = require("@aclymatepackages/reg-exp");
17
18
  var _googleMaps = _interopRequireDefault(require("@aclymatepackages/google-maps"));
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -21,7 +22,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
21
22
  const CompanyDataConfirmation = _ref => {
22
23
  let {
23
24
  companyData,
24
- onConfirmClick
25
+ onConfirmClick,
26
+ fetchNaicsCodes
25
27
  } = _ref;
26
28
  const {
27
29
  address: existingAddress
@@ -56,10 +58,10 @@ const CompanyDataConfirmation = _ref => {
56
58
  value: employeeCount,
57
59
  setValue: editCompanyData("employeeCount"),
58
60
  error: employeeCount && !(0, _regExp.numbersRegExpTest)(employeeCount)
59
- }), /*#__PURE__*/_react.default.createElement(_modules.IndustryAutocomplete, {
61
+ }), /*#__PURE__*/_react.default.createElement(_IndustryAutocomplete.default, {
60
62
  industry: industry,
61
63
  setIndustry: editCompanyData("industry"),
62
- helperText: "We'll use this to estimate your emissions and benchmark to other similar companies"
64
+ fetchNaicsCodes: fetchNaicsCodes
63
65
  }), /*#__PURE__*/_react.default.createElement(_modules.YesNoQuestion, {
64
66
  question: "Does your company only work remotely?",
65
67
  value: isRemote,
@@ -28,6 +28,7 @@ const CompanyOnboardingInput = _ref => {
28
28
  let {
29
29
  appCheckToken,
30
30
  companyName = "",
31
+ fetchNaicsCodes,
31
32
  header,
32
33
  onFormComplete,
33
34
  PlacesAutocomplete,
@@ -67,10 +68,9 @@ const CompanyOnboardingInput = _ref => {
67
68
  }, {
68
69
  value: industry,
69
70
  input: /*#__PURE__*/_react.default.createElement(_IndustryAutocomplete.default, {
70
- label: "Choose your company's industry",
71
71
  industry: industry,
72
72
  setIndustry: editInputData("industry"),
73
- helperText: "We'll use this to estimate your emissions and benchmark to other similar companies"
73
+ fetchNaicsCodes: fetchNaicsCodes
74
74
  })
75
75
  }, {
76
76
  value: location,
@@ -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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aclymatepackages/modules",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "Aclymate modules",
5
5
  "author": "William Loopesko",
6
6
  "main": "dist/index.js",
@@ -16,15 +16,13 @@ import CancelIcon from "@mui/icons-material/Cancel";
16
16
 
17
17
  import { editObjectData } from "@aclymatepackages/array-immutability-helpers";
18
18
  import { TextField } from "@aclymatepackages/atoms";
19
- import {
20
- IndustryAutocomplete,
21
- YesNoQuestion,
22
- PlacesAutocomplete,
23
- } from "@aclymatepackages/modules";
19
+ import { YesNoQuestion, PlacesAutocomplete } from "@aclymatepackages/modules";
20
+
21
+ import IndustryAutocomplete from "./IndustryAutocomplete";
24
22
  import { numbersRegExpTest } from "@aclymatepackages/reg-exp";
25
23
  import GoogleMap from "@aclymatepackages/google-maps";
26
24
 
27
- const CompanyDataConfirmation = ({ companyData, onConfirmClick }) => {
25
+ const CompanyDataConfirmation = ({ companyData, onConfirmClick, fetchNaicsCodes }) => {
28
26
  const { address: existingAddress } = companyData || {};
29
27
  const { coordinates: existingCoordinates } = existingAddress || {};
30
28
 
@@ -64,7 +62,7 @@ const CompanyDataConfirmation = ({ companyData, onConfirmClick }) => {
64
62
  <IndustryAutocomplete
65
63
  industry={industry}
66
64
  setIndustry={editCompanyData("industry")}
67
- helperText="We'll use this to estimate your emissions and benchmark to other similar companies"
65
+ fetchNaicsCodes={fetchNaicsCodes}
68
66
  />,
69
67
  <YesNoQuestion
70
68
  question="Does your company only work remotely?"
@@ -15,6 +15,7 @@ import PlacesAutocompleteModule from "./PlacesAutocomplete";
15
15
  const CompanyOnboardingInput = ({
16
16
  appCheckToken,
17
17
  companyName = "",
18
+ fetchNaicsCodes,
18
19
  header,
19
20
  onFormComplete,
20
21
  PlacesAutocomplete,
@@ -65,10 +66,9 @@ const CompanyOnboardingInput = ({
65
66
  value: industry,
66
67
  input: (
67
68
  <IndustryAutocomplete
68
- label="Choose your company's industry"
69
69
  industry={industry}
70
70
  setIndustry={editInputData("industry")}
71
- helperText="We'll use this to estimate your emissions and benchmark to other similar companies"
71
+ fetchNaicsCodes={fetchNaicsCodes}
72
72
  />
73
73
  ),
74
74
  },
@@ -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
  };