@aclymatepackages/modules 2.1.17 → 2.1.20

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.
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.object.assign.js");
4
3
  require("core-js/modules/es.weak-map.js");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
@@ -16,7 +15,6 @@ var _atoms = require("@aclymatepackages/atoms");
16
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
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); }
18
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; }
19
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
18
  const CompanySelectionChip = _ref => {
21
19
  let {
22
20
  id,
@@ -42,7 +40,8 @@ const CompanySelectionChip = _ref => {
42
40
  };
43
41
  const PdlCompanySelect = _ref2 => {
44
42
  let {
45
- onSelectCompany,
43
+ onCompanyNotFound,
44
+ onCompanySelected,
46
45
  matchingFunction,
47
46
  label = "Enter your company's name",
48
47
  actionLabel = "Please select your company from these options"
@@ -52,6 +51,7 @@ const PdlCompanySelect = _ref2 => {
52
51
  const [inputComplete, setInputComplete] = (0, _react.useState)(false);
53
52
  const [pdlFetchLoading, setPdlFetchLoading] = (0, _react.useState)(false);
54
53
  const [selectedCompanyId, setSelectedCompanyId] = (0, _react.useState)(null);
54
+ const [nextStepLoading, setNextStepLoading] = (0, _react.useState)(false);
55
55
  const fetchMatchingCompanies = async () => {
56
56
  setPdlFetchLoading(true);
57
57
  const matchingCompanies = await matchingFunction(inputValue);
@@ -59,14 +59,19 @@ const PdlCompanySelect = _ref2 => {
59
59
  setMatchingCompanies(matchingCompanies);
60
60
  return setInputComplete(true);
61
61
  };
62
- const {
63
- name: selectedCompanyName
64
- } = matchingCompanies.find(_ref3 => {
62
+ const onSelectCompany = async (companyId, name) => {
63
+ setNextStepLoading(true);
64
+ if (!companyId || companyId === "none") {
65
+ return await onCompanyNotFound(name);
66
+ }
67
+ return await onCompanySelected(companyId, name);
68
+ };
69
+ const selectedCompany = matchingCompanies.find(_ref3 => {
65
70
  let {
66
71
  id
67
72
  } = _ref3;
68
73
  return selectedCompanyId === id;
69
- }) || {};
74
+ });
70
75
  return /*#__PURE__*/_react.default.createElement(_material.Grid, {
71
76
  container: true,
72
77
  spacing: 2,
@@ -113,12 +118,13 @@ const PdlCompanySelect = _ref2 => {
113
118
  name,
114
119
  id
115
120
  } = _ref5;
116
- return /*#__PURE__*/_react.default.createElement(CompanySelectionChip, _extends({
121
+ return /*#__PURE__*/_react.default.createElement(CompanySelectionChip, {
117
122
  key: "company-list-item-".concat(idx),
118
123
  name: name,
119
124
  isSelected: selectedCompanyId === id,
120
- setSelectedCompanyId: setSelectedCompanyId
121
- }, meta));
125
+ setSelectedCompanyId: setSelectedCompanyId,
126
+ id: id
127
+ });
122
128
  })), /*#__PURE__*/_react.default.createElement(_material.Grid, {
123
129
  item: true,
124
130
  container: true,
@@ -126,13 +132,18 @@ const PdlCompanySelect = _ref2 => {
126
132
  justifyContent: "center"
127
133
  }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
128
134
  item: true
129
- }, selectedCompanyId ? /*#__PURE__*/_react.default.createElement(_material.Button, {
135
+ }, selectedCompanyId ? /*#__PURE__*/_react.default.createElement(_atoms.LoadingButton, {
136
+ isLoading: nextStepLoading,
137
+ label: "Choose This Company",
130
138
  variant: "contained",
131
139
  color: "secondary",
132
- onClick: () => onSelectCompany(selectedCompanyId, selectedCompanyName)
133
- }, "Choose this company") : /*#__PURE__*/_react.default.createElement(_material.Button, {
140
+ onClick: () => onSelectCompany(selectedCompany)
141
+ }) : /*#__PURE__*/_react.default.createElement(_atoms.LoadingButton, {
142
+ isLoading: nextStepLoading,
134
143
  color: "primary",
135
- onClick: () => onSelectCompany("none", inputValue)
136
- }, "I don't see my company")))));
144
+ onClick: () => onSelectCompany("none", inputValue),
145
+ label: "I don't see my company",
146
+ variant: "text"
147
+ })))));
137
148
  };
138
149
  var _default = exports.default = PdlCompanySelect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aclymatepackages/modules",
3
- "version": "2.1.17",
3
+ "version": "2.1.20",
4
4
  "description": "Aclymate modules",
5
5
  "author": "William Loopesko",
6
6
  "main": "dist/index.js",
@@ -6,13 +6,12 @@ import {
6
6
  InputAdornment,
7
7
  CircularProgress,
8
8
  IconButton,
9
- Button,
10
9
  Typography,
11
10
  } from "@mui/material";
12
11
  import CheckIcon from "@mui/icons-material/Check";
13
12
  import SearchIcon from "@mui/icons-material/Search";
14
13
 
15
- import { TextField } from "@aclymatepackages/atoms";
14
+ import { TextField, LoadingButton } from "@aclymatepackages/atoms";
16
15
 
17
16
  const CompanySelectionChip = ({
18
17
  id,
@@ -34,7 +33,8 @@ const CompanySelectionChip = ({
34
33
  );
35
34
 
36
35
  const PdlCompanySelect = ({
37
- onSelectCompany,
36
+ onCompanyNotFound,
37
+ onCompanySelected,
38
38
  matchingFunction,
39
39
  label = "Enter your company's name",
40
40
  actionLabel = "Please select your company from these options",
@@ -44,6 +44,7 @@ const PdlCompanySelect = ({
44
44
  const [inputComplete, setInputComplete] = useState(false);
45
45
  const [pdlFetchLoading, setPdlFetchLoading] = useState(false);
46
46
  const [selectedCompanyId, setSelectedCompanyId] = useState(null);
47
+ const [nextStepLoading, setNextStepLoading] = useState(false);
47
48
 
48
49
  const fetchMatchingCompanies = async () => {
49
50
  setPdlFetchLoading(true);
@@ -55,8 +56,18 @@ const PdlCompanySelect = ({
55
56
  return setInputComplete(true);
56
57
  };
57
58
 
58
- const { name: selectedCompanyName } =
59
- matchingCompanies.find(({ id }) => selectedCompanyId === id) || {};
59
+ const onSelectCompany = async (companyId, name) => {
60
+ setNextStepLoading(true);
61
+ if (!companyId || companyId === "none") {
62
+ return await onCompanyNotFound(name);
63
+ }
64
+
65
+ return await onCompanySelected(companyId, name);
66
+ };
67
+
68
+ const selectedCompany = matchingCompanies.find(
69
+ ({ id }) => selectedCompanyId === id
70
+ );
60
71
 
61
72
  return (
62
73
  <Grid container spacing={2} direction="column">
@@ -104,29 +115,28 @@ const PdlCompanySelect = ({
104
115
  name={name}
105
116
  isSelected={selectedCompanyId === id}
106
117
  setSelectedCompanyId={setSelectedCompanyId}
107
- {...meta}
118
+ id={id}
108
119
  />
109
120
  ))}
110
121
  </Grid>
111
122
  <Grid item container spacing={2} justifyContent="center">
112
123
  <Grid item>
113
124
  {selectedCompanyId ? (
114
- <Button
125
+ <LoadingButton
126
+ isLoading={nextStepLoading}
127
+ label="Choose This Company"
115
128
  variant="contained"
116
129
  color="secondary"
117
- onClick={() =>
118
- onSelectCompany(selectedCompanyId, selectedCompanyName)
119
- }
120
- >
121
- Choose this company
122
- </Button>
130
+ onClick={() => onSelectCompany(selectedCompany)}
131
+ />
123
132
  ) : (
124
- <Button
133
+ <LoadingButton
134
+ isLoading={nextStepLoading}
125
135
  color="primary"
126
136
  onClick={() => onSelectCompany("none", inputValue)}
127
- >
128
- I don't see my company
129
- </Button>
137
+ label="I don't see my company"
138
+ variant="text"
139
+ />
130
140
  )}
131
141
  </Grid>
132
142
  </Grid>