@basiq/connect-auth 1.0.7 → 1.0.9

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.
@@ -7,6 +7,7 @@ interface IProps {
7
7
  subTitle?: string;
8
8
  shadow: boolean;
9
9
  onBack?: () => void;
10
+ backDisabled?: boolean;
10
11
  }
11
12
  export interface IButton {
12
13
  label: string;
@@ -670,7 +670,8 @@ function Page(props) {
670
670
  title = props.title,
671
671
  subTitle = props.subTitle,
672
672
  shadow = props.shadow,
673
- onBack = props.onBack;
673
+ onBack = props.onBack,
674
+ backDisabled = props.backDisabled;
674
675
  var _useTranslation = reactI18next.useTranslation(),
675
676
  t = _useTranslation.t;
676
677
  return React__default.createElement(PageStyled, {
@@ -678,7 +679,8 @@ function Page(props) {
678
679
  }, onBack && React__default.createElement(Button, {
679
680
  onClick: onBack,
680
681
  label: t('back'),
681
- buttonType: "back"
682
+ buttonType: "back",
683
+ disabled: backDisabled
682
684
  }), title && React__default.createElement("h3", null, title), subTitle && React__default.createElement(PageSubtitle, null, subTitle), React__default.createElement(PageMainContainer, null, children), React__default.createElement(PageControlsSection, {
683
685
  notEmpty: ((_buttons$length = buttons == null ? void 0 : buttons.length) != null ? _buttons$length : 0) > 0
684
686
  }, React__default.createElement(PageShadowWrapper, null, shadow && React__default.createElement(PageShadow, null), buttons == null ? void 0 : buttons.map(function (b, index) {
@@ -1071,6 +1073,9 @@ function AuthScreen(_ref) {
1071
1073
  var _useState5 = React.useState(false),
1072
1074
  loading = _useState5[0],
1073
1075
  setLoading = _useState5[1];
1076
+ var _useState6 = React.useState(false),
1077
+ tooManyAttemps = _useState6[0],
1078
+ setTooManyAttemps = _useState6[1];
1074
1079
  var handleCodeApply = React.useCallback( /*#__PURE__*/function () {
1075
1080
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
1076
1081
  var _response$data, response, _response$data2;
@@ -1078,7 +1083,7 @@ function AuthScreen(_ref) {
1078
1083
  while (1) switch (_context.prev = _context.next) {
1079
1084
  case 0:
1080
1085
  if (!(smsCode.length === 4 && error.length === 0 && (!e || (e == null ? void 0 : e.key) === 'Enter'))) {
1081
- _context.next = 7;
1086
+ _context.next = 6;
1082
1087
  break;
1083
1088
  }
1084
1089
  setLoading(true);
@@ -1092,12 +1097,15 @@ function AuthScreen(_ref) {
1092
1097
  response = _context.sent;
1093
1098
  if (response != null && (_response$data = response.data) != null && _response$data.access_token) {
1094
1099
  window.open("https://consent.basiq.io/home?token=" + (response == null || (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token) + "&action=" + (action.length > 0 ? action : 'connect'), "_self");
1095
- }
1096
- if (response != null && response.error) {
1100
+ } else if ((response == null ? void 0 : response.statusCode) === 204) {
1101
+ setLoading(false);
1102
+ setTooManyAttemps(true);
1103
+ setError(t('too_many_attempts'));
1104
+ } else if (response != null && response.error) {
1097
1105
  setLoading(false);
1098
1106
  setError(t('this_code_doesnt_appear_to_be_valid'));
1099
1107
  }
1100
- case 7:
1108
+ case 6:
1101
1109
  case "end":
1102
1110
  return _context.stop();
1103
1111
  }
@@ -1161,7 +1169,8 @@ function AuthScreen(_ref) {
1161
1169
  }),
1162
1170
  shadow: shadow,
1163
1171
  buttons: buttons,
1164
- onBack: onBack
1172
+ onBack: onBack,
1173
+ backDisabled: tooManyAttemps
1165
1174
  }, React__default.createElement(InnerContainer, null, React__default.createElement(InputContainer, null, React__default.createElement(InputStyled, {
1166
1175
  pattern: "\\d{4}",
1167
1176
  inputMode: "numeric",
@@ -1171,16 +1180,17 @@ function AuthScreen(_ref) {
1171
1180
  onChange: handleInput,
1172
1181
  value: smsCode,
1173
1182
  filled: smsCode.length === 4,
1174
- error: !!error,
1183
+ error: tooManyAttemps || !!error,
1184
+ disabled: tooManyAttemps,
1175
1185
  onKeyPress: function onKeyPress(e) {
1176
1186
  return handleCodeApply(e);
1177
1187
  }
1178
1188
  })), React__default.createElement(PageConnectFooterControl, null, resend && React__default.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React__default.createElement(StatusMessage, {
1179
1189
  error: true
1180
1190
  }, error), React__default.createElement(PageConnectFooterText, null, React__default.createElement("span", null, React__default.createElement(React__default.Fragment, null, t('didnt_receive_the_code'), " ", React__default.createElement(DivAsLink, {
1181
- disabled: resendLoading,
1191
+ disabled: tooManyAttemps || resendLoading,
1182
1192
  onClick: function onClick() {
1183
- return !resendLoading && handleResend();
1193
+ return !tooManyAttemps && !resendLoading && handleResend();
1184
1194
  }
1185
1195
  }, t('resend_sms')))))), React__default.createElement(LoadingModal, {
1186
1196
  isOpen: loading
@@ -1361,6 +1371,7 @@ var resend_sms = "Resend SMS";
1361
1371
  var failed_to_send_sms = "Failed to send SMS.";
1362
1372
  var page_not_found = "Page not found";
1363
1373
  var missing_authentication_token = "Missing Authentication Token";
1374
+ var too_many_attempts = "Too many attempts. Please use a new link to try again.";
1364
1375
  var translationEN = {
1365
1376
  back: back,
1366
1377
  error: error,
@@ -1388,7 +1399,8 @@ var translationEN = {
1388
1399
  resend_sms: resend_sms,
1389
1400
  failed_to_send_sms: failed_to_send_sms,
1390
1401
  page_not_found: page_not_found,
1391
- missing_authentication_token: missing_authentication_token
1402
+ missing_authentication_token: missing_authentication_token,
1403
+ too_many_attempts: too_many_attempts
1392
1404
  };
1393
1405
 
1394
1406
  // the translations