@influenzanet/case-web-app-core 2.9.4-staging → 2.9.6-staging

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.
@@ -10,4 +10,5 @@ export declare const BACKEND_ERRORS: {
10
10
  readonly CODE_EXPIRED: "verification code expired";
11
11
  readonly INVALID_CODE: "invalid verification code";
12
12
  readonly RATE_LIMITED: "too many phone verification attempts, try again later";
13
+ readonly RECIPIENT_NOT_ALLOWED: "phone number not enabled to receive WhatsApp messages";
13
14
  };
package/build/index.es.js CHANGED
@@ -21717,6 +21717,9 @@ var ChangeNotifications = function () {
21717
21717
  setChannelEmail(value);
21718
21718
  };
21719
21719
  var handleChannelWhatsapp = function (value) {
21720
+ // the UI checkbox cannot be disabled, so enforce the verified-phone requirement here
21721
+ if (value && !confirmedPhone)
21722
+ return;
21720
21723
  if (!value && !channelEmail)
21721
21724
  return;
21722
21725
  setChanged(true);
@@ -21773,7 +21776,7 @@ var ChangeNotifications = function () {
21773
21776
  setNewsletterEnabled(value);
21774
21777
  } }, { children: newsletterEnabled
21775
21778
  ? t('dialogs:changeNotifications.newsletter.on')
21776
- : t('dialogs:changeNotifications.newsletter.off') }), void 0), jsx("hr", { className: "my-3" }, void 0), jsx("label", __assign({ className: "mb-1 form-label" }, { children: t('dialogs:changeNotifications.channels.label') }), void 0), jsx(Checkbox, __assign({ id: "channelEmail", name: "channelEmail", checked: channelEmail }, { disabled: !confirmedPhone && channelEmail }, { onChange: handleChannelEmail }, { children: t('dialogs:changeNotifications.channels.email') }), void 0), jsx(Checkbox, __assign({ id: "channelWhatsapp", name: "channelWhatsapp", checked: channelWhatsapp }, { disabled: !confirmedPhone }, { onChange: handleChannelWhatsapp }, { children: t('dialogs:changeNotifications.channels.whatsapp') }), void 0), !confirmedPhone && (jsx(AlertBox, { type: "warning", className: "mt-2", content: t('dialogs:changeNotifications.channels.whatsappDisabled') }, void 0)), confirmedPhone && (jsx("p", __assign({ className: "mt-1", style: { fontSize: '0.8rem', color: '#888', fontStyle: 'italic' } }, { children: t('dialogs:changeNotifications.channels.note') }), void 0)), jsx(AlertBox, { type: "danger", className: "mt-2", hide: !error, closable: true, onClose: function () { return setError(''); }, useIcon: true, content: error }, void 0), jsxs("div", __assign({ className: "d-flex flex-wrap" }, { children: [jsx(DialogBtn, { className: "mt-2 me-2", type: "button", color: "primary", outlined: true, label: t('changeNotifications.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsx(DialogBtn, { className: "mt-2", type: "submit", color: "primary", loading: loading, disabled: loading || !changed, label: t('changeNotifications.submitBtn') }, void 0)] }), void 0)] }), void 0) }), void 0) }), void 0));
21779
+ : t('dialogs:changeNotifications.newsletter.off') }), void 0), jsx("hr", { className: "my-3" }, void 0), jsx("label", __assign({ className: "mb-1 form-label" }, { children: t('dialogs:changeNotifications.channels.label') }), void 0), jsx("div", __assign({ className: "mb-2" }, { children: jsx(Checkbox, __assign({ id: "channelEmail", name: "channelEmail", checked: channelEmail }, { disabled: !confirmedPhone && channelEmail }, { onChange: handleChannelEmail }, { children: t('dialogs:changeNotifications.channels.email') }), void 0) }), void 0), jsx("div", __assign({ className: "mb-2" }, { children: jsx(Checkbox, __assign({ id: "channelWhatsapp", name: "channelWhatsapp", checked: channelWhatsapp }, { disabled: !confirmedPhone }, { onChange: handleChannelWhatsapp }, { children: t('dialogs:changeNotifications.channels.whatsapp') }), void 0) }), void 0), !confirmedPhone && (jsx(AlertBox, { type: "warning", className: "mt-2", content: t('dialogs:changeNotifications.channels.whatsappDisabled') }, void 0)), confirmedPhone && (jsx("p", __assign({ className: "mt-1", style: { fontSize: '0.8rem', color: '#888', fontStyle: 'italic' } }, { children: t('dialogs:changeNotifications.channels.note') }), void 0)), jsx(AlertBox, { type: "danger", className: "mt-2", hide: !error, closable: true, onClose: function () { return setError(''); }, useIcon: true, content: error }, void 0), jsxs("div", __assign({ className: "d-flex flex-wrap" }, { children: [jsx(DialogBtn, { className: "mt-2 me-2", type: "button", color: "primary", outlined: true, label: t('changeNotifications.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsx(DialogBtn, { className: "mt-2", type: "submit", color: "primary", loading: loading, disabled: loading || !changed, label: t('changeNotifications.submitBtn') }, void 0)] }), void 0)] }), void 0) }), void 0) }), void 0));
21777
21780
  };
21778
21781
 
21779
21782
  var ChangePassword = function (props) {
@@ -22438,6 +22441,7 @@ var BACKEND_ERRORS = {
22438
22441
  CODE_EXPIRED: 'verification code expired',
22439
22442
  INVALID_CODE: 'invalid verification code',
22440
22443
  RATE_LIMITED: 'too many phone verification attempts, try again later',
22444
+ RECIPIENT_NOT_ALLOWED: 'phone number not enabled to receive WhatsApp messages',
22441
22445
  };
22442
22446
 
22443
22447
  var ChangePhone = function () {
@@ -22523,6 +22527,12 @@ var ChangePhone = function () {
22523
22527
  case BACKEND_ERRORS.PHONE_ALREADY_TAKEN:
22524
22528
  setError(t('changePhone.errors.phoneAlreadyTaken'));
22525
22529
  break;
22530
+ case BACKEND_ERRORS.RECIPIENT_NOT_ALLOWED:
22531
+ setError(t('changePhone.errors.recipientNotAllowed'));
22532
+ break;
22533
+ case BACKEND_ERRORS.RATE_LIMITED:
22534
+ setError(t('changePhone.errors.rateLimit'));
22535
+ break;
22526
22536
  default:
22527
22537
  setError(t('changePhone.errors.unknown'));
22528
22538
  break;
@@ -22707,6 +22717,12 @@ var AddPhone = function () {
22707
22717
  case BACKEND_ERRORS.PHONE_ALREADY_TAKEN:
22708
22718
  setError(t('addPhone.errors.phoneAlreadyTaken'));
22709
22719
  break;
22720
+ case BACKEND_ERRORS.RECIPIENT_NOT_ALLOWED:
22721
+ setError(t('addPhone.errors.recipientNotAllowed'));
22722
+ break;
22723
+ case BACKEND_ERRORS.RATE_LIMITED:
22724
+ setError(t('addPhone.errors.rateLimit'));
22725
+ break;
22710
22726
  default:
22711
22727
  setError(t('addPhone.errors.unknown'));
22712
22728
  break;
@@ -22753,7 +22769,7 @@ var VerifyWhatsApp = function () {
22753
22769
  setError('');
22754
22770
  };
22755
22771
  var resendCode = function () { return __awaiter(void 0, void 0, void 0, function () {
22756
- var e_1, errorResponse;
22772
+ var e_1, errorResponse, backendError;
22757
22773
  var _a, _b;
22758
22774
  return __generator$1(this, function (_c) {
22759
22775
  switch (_c.label) {
@@ -22772,7 +22788,18 @@ var VerifyWhatsApp = function () {
22772
22788
  e_1 = _c.sent();
22773
22789
  console.error(e_1);
22774
22790
  errorResponse = e_1;
22775
- setError(((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) || t('verifyWhatsApp.errors.unknown'));
22791
+ backendError = (_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error;
22792
+ switch (backendError) {
22793
+ case BACKEND_ERRORS.RATE_LIMITED:
22794
+ setError(t('verifyWhatsApp.errors.rateLimit'));
22795
+ break;
22796
+ case BACKEND_ERRORS.RECIPIENT_NOT_ALLOWED:
22797
+ setError(t('verifyWhatsApp.errors.recipientNotAllowed'));
22798
+ break;
22799
+ default:
22800
+ setError(backendError || t('verifyWhatsApp.errors.unknown'));
22801
+ break;
22802
+ }
22776
22803
  return [3 /*break*/, 5];
22777
22804
  case 4:
22778
22805
  setResendLoading(false);
@@ -24188,18 +24215,19 @@ var AccountSettings = function (props) {
24188
24215
  return jsx("div", __assign({ className: "bg-warning-light p-3" }, { children: 'authentication needed' }), void 0);
24189
24216
  }
24190
24217
  var handleResendCode = function () { return __awaiter(void 0, void 0, void 0, function () {
24191
- var error_1;
24192
- return __generator$1(this, function (_a) {
24193
- switch (_a.label) {
24218
+ var error_1, errorResponse;
24219
+ var _a, _b;
24220
+ return __generator$1(this, function (_c) {
24221
+ switch (_c.label) {
24194
24222
  case 0:
24195
24223
  setIsResending(true);
24196
24224
  setResendMessage(null);
24197
- _a.label = 1;
24225
+ _c.label = 1;
24198
24226
  case 1:
24199
- _a.trys.push([1, 3, 4, 5]);
24227
+ _c.trys.push([1, 3, 4, 5]);
24200
24228
  return [4 /*yield*/, resendWhatsAppCodeReq()];
24201
24229
  case 2:
24202
- _a.sent();
24230
+ _c.sent();
24203
24231
  // Use requestAnimationFrame to wait for React to finish rendering
24204
24232
  requestAnimationFrame(function () {
24205
24233
  dispatch(dialogActions.openVerifyWhatsAppDialog({
@@ -24215,12 +24243,29 @@ var AccountSettings = function (props) {
24215
24243
  });
24216
24244
  return [3 /*break*/, 5];
24217
24245
  case 3:
24218
- error_1 = _a.sent();
24246
+ error_1 = _c.sent();
24219
24247
  console.error('Error resending WhatsApp code:', error_1);
24220
- setResendMessage({
24221
- type: 'error',
24222
- text: t("".concat(props.itemKey, ".phone.resendError"), 'Errore nell\'invio del codice. Riprova.')
24223
- });
24248
+ errorResponse = error_1;
24249
+ switch ((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) {
24250
+ case BACKEND_ERRORS.RECIPIENT_NOT_ALLOWED:
24251
+ setResendMessage({
24252
+ type: 'error',
24253
+ text: t("".concat(props.itemKey, ".phone.recipientNotAllowedError"), 'Questo numero non \u00e8 abilitato a ricevere messaggi WhatsApp. Controlla il numero inserito.')
24254
+ });
24255
+ break;
24256
+ case BACKEND_ERRORS.RATE_LIMITED:
24257
+ setResendMessage({
24258
+ type: 'error',
24259
+ text: t("".concat(props.itemKey, ".phone.rateLimitError"), 'Hai richiesto troppi codici di verifica. Riprova pi\u00f9 tardi.')
24260
+ });
24261
+ break;
24262
+ default:
24263
+ setResendMessage({
24264
+ type: 'error',
24265
+ text: t("".concat(props.itemKey, ".phone.resendError"), 'Errore nell\'invio del codice. Riprova.')
24266
+ });
24267
+ break;
24268
+ }
24224
24269
  return [3 /*break*/, 5];
24225
24270
  case 4:
24226
24271
  setIsResending(false);