@aclymatepackages/modules 2.1.18 → 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.
@@ -40,7 +40,8 @@ const CompanySelectionChip = _ref => {
40
40
  };
41
41
  const PdlCompanySelect = _ref2 => {
42
42
  let {
43
- onSelectCompany,
43
+ onCompanyNotFound,
44
+ onCompanySelected,
44
45
  matchingFunction,
45
46
  label = "Enter your company's name",
46
47
  actionLabel = "Please select your company from these options"
@@ -50,6 +51,7 @@ const PdlCompanySelect = _ref2 => {
50
51
  const [inputComplete, setInputComplete] = (0, _react.useState)(false);
51
52
  const [pdlFetchLoading, setPdlFetchLoading] = (0, _react.useState)(false);
52
53
  const [selectedCompanyId, setSelectedCompanyId] = (0, _react.useState)(null);
54
+ const [nextStepLoading, setNextStepLoading] = (0, _react.useState)(false);
53
55
  const fetchMatchingCompanies = async () => {
54
56
  setPdlFetchLoading(true);
55
57
  const matchingCompanies = await matchingFunction(inputValue);
@@ -57,14 +59,19 @@ const PdlCompanySelect = _ref2 => {
57
59
  setMatchingCompanies(matchingCompanies);
58
60
  return setInputComplete(true);
59
61
  };
60
- const {
61
- name: selectedCompanyName
62
- } = 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 => {
63
70
  let {
64
71
  id
65
72
  } = _ref3;
66
73
  return selectedCompanyId === id;
67
- }) || {};
74
+ });
68
75
  return /*#__PURE__*/_react.default.createElement(_material.Grid, {
69
76
  container: true,
70
77
  spacing: 2,
@@ -125,13 +132,18 @@ const PdlCompanySelect = _ref2 => {
125
132
  justifyContent: "center"
126
133
  }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
127
134
  item: true
128
- }, selectedCompanyId ? /*#__PURE__*/_react.default.createElement(_material.Button, {
135
+ }, selectedCompanyId ? /*#__PURE__*/_react.default.createElement(_atoms.LoadingButton, {
136
+ isLoading: nextStepLoading,
137
+ label: "Choose This Company",
129
138
  variant: "contained",
130
139
  color: "secondary",
131
- onClick: () => onSelectCompany(selectedCompanyId, selectedCompanyName)
132
- }, "Choose this company") : /*#__PURE__*/_react.default.createElement(_material.Button, {
140
+ onClick: () => onSelectCompany(selectedCompany)
141
+ }) : /*#__PURE__*/_react.default.createElement(_atoms.LoadingButton, {
142
+ isLoading: nextStepLoading,
133
143
  color: "primary",
134
- onClick: () => onSelectCompany("none", inputValue)
135
- }, "I don't see my company")))));
144
+ onClick: () => onSelectCompany("none", inputValue),
145
+ label: "I don't see my company",
146
+ variant: "text"
147
+ })))));
136
148
  };
137
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.18",
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">
@@ -111,22 +122,21 @@ const PdlCompanySelect = ({
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>