@influenzanet/case-web-app-core 2.7.8 → 2.8.0

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.
package/build/index.js CHANGED
@@ -5103,6 +5103,13 @@ var dialogSlice = createSlice({
5103
5103
  payload: action.payload.payload
5104
5104
  };
5105
5105
  },
5106
+ openVerifyWhatsAppDialog: function (state, action) {
5107
+ state.config = {
5108
+ type: action.payload.type,
5109
+ origin: action.payload.origin,
5110
+ payload: action.payload.payload
5111
+ };
5112
+ },
5106
5113
  }
5107
5114
  });
5108
5115
  var dialogActions = dialogSlice.actions;
@@ -15707,7 +15714,7 @@ var round = Math.round;
15707
15714
  function getUAString() {
15708
15715
  var uaData = navigator.userAgentData;
15709
15716
 
15710
- if (uaData != null && uaData.brands) {
15717
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
15711
15718
  return uaData.brands.map(function (item) {
15712
15719
  return item.brand + "/" + item.version;
15713
15720
  }).join(' ');
@@ -15998,17 +16005,7 @@ function effect$1(_ref2) {
15998
16005
  }
15999
16006
  }
16000
16007
 
16001
- if (process.env.NODE_ENV !== "production") {
16002
- if (!isHTMLElement(arrowElement)) {
16003
- console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
16004
- }
16005
- }
16006
-
16007
16008
  if (!contains$1(state.elements.popper, arrowElement)) {
16008
- if (process.env.NODE_ENV !== "production") {
16009
- console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
16010
- }
16011
-
16012
16009
  return;
16013
16010
  }
16014
16011
 
@@ -16039,10 +16036,9 @@ var unsetSides = {
16039
16036
  // Zooming can change the DPR, but it seems to report a value that will
16040
16037
  // cleanly divide the values into the appropriate subpixels.
16041
16038
 
16042
- function roundOffsetsByDPR(_ref) {
16039
+ function roundOffsetsByDPR(_ref, win) {
16043
16040
  var x = _ref.x,
16044
16041
  y = _ref.y;
16045
- var win = window;
16046
16042
  var dpr = win.devicePixelRatio || 1;
16047
16043
  return {
16048
16044
  x: round(x * dpr) / dpr || 0,
@@ -16125,7 +16121,7 @@ function mapToStyles(_ref2) {
16125
16121
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
16126
16122
  x: x,
16127
16123
  y: y
16128
- }) : {
16124
+ }, getWindow(popper)) : {
16129
16125
  x: x,
16130
16126
  y: y
16131
16127
  };
@@ -16151,17 +16147,6 @@ function computeStyles(_ref5) {
16151
16147
  adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
16152
16148
  _options$roundOffsets = options.roundOffsets,
16153
16149
  roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
16154
-
16155
- if (process.env.NODE_ENV !== "production") {
16156
- var transitionProperty = getComputedStyle$1(state.elements.popper).transitionProperty || '';
16157
-
16158
- if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
16159
- return transitionProperty.indexOf(property) >= 0;
16160
- })) {
16161
- console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
16162
- }
16163
- }
16164
-
16165
16150
  var commonStyles = {
16166
16151
  placement: getBasePlacement(state.placement),
16167
16152
  variation: getVariation(state.placement),
@@ -16602,10 +16587,6 @@ function computeAutoPlacement(state, options) {
16602
16587
 
16603
16588
  if (allowedPlacements.length === 0) {
16604
16589
  allowedPlacements = placements$1;
16605
-
16606
- if (process.env.NODE_ENV !== "production") {
16607
- console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
16608
- }
16609
16590
  } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
16610
16591
 
16611
16592
 
@@ -17157,108 +17138,6 @@ function debounce(fn) {
17157
17138
  };
17158
17139
  }
17159
17140
 
17160
- function format$1(str) {
17161
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
17162
- args[_key - 1] = arguments[_key];
17163
- }
17164
-
17165
- return [].concat(args).reduce(function (p, c) {
17166
- return p.replace(/%s/, c);
17167
- }, str);
17168
- }
17169
-
17170
- var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
17171
- var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
17172
- var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
17173
- function validateModifiers(modifiers) {
17174
- modifiers.forEach(function (modifier) {
17175
- [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
17176
- .filter(function (value, index, self) {
17177
- return self.indexOf(value) === index;
17178
- }).forEach(function (key) {
17179
- switch (key) {
17180
- case 'name':
17181
- if (typeof modifier.name !== 'string') {
17182
- console.error(format$1(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
17183
- }
17184
-
17185
- break;
17186
-
17187
- case 'enabled':
17188
- if (typeof modifier.enabled !== 'boolean') {
17189
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
17190
- }
17191
-
17192
- break;
17193
-
17194
- case 'phase':
17195
- if (modifierPhases.indexOf(modifier.phase) < 0) {
17196
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
17197
- }
17198
-
17199
- break;
17200
-
17201
- case 'fn':
17202
- if (typeof modifier.fn !== 'function') {
17203
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
17204
- }
17205
-
17206
- break;
17207
-
17208
- case 'effect':
17209
- if (modifier.effect != null && typeof modifier.effect !== 'function') {
17210
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
17211
- }
17212
-
17213
- break;
17214
-
17215
- case 'requires':
17216
- if (modifier.requires != null && !Array.isArray(modifier.requires)) {
17217
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
17218
- }
17219
-
17220
- break;
17221
-
17222
- case 'requiresIfExists':
17223
- if (!Array.isArray(modifier.requiresIfExists)) {
17224
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
17225
- }
17226
-
17227
- break;
17228
-
17229
- case 'options':
17230
- case 'data':
17231
- break;
17232
-
17233
- default:
17234
- console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
17235
- return "\"" + s + "\"";
17236
- }).join(', ') + "; but \"" + key + "\" was provided.");
17237
- }
17238
-
17239
- modifier.requires && modifier.requires.forEach(function (requirement) {
17240
- if (modifiers.find(function (mod) {
17241
- return mod.name === requirement;
17242
- }) == null) {
17243
- console.error(format$1(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
17244
- }
17245
- });
17246
- });
17247
- });
17248
- }
17249
-
17250
- function uniqueBy(arr, fn) {
17251
- var identifiers = new Set();
17252
- return arr.filter(function (item) {
17253
- var identifier = fn(item);
17254
-
17255
- if (!identifiers.has(identifier)) {
17256
- identifiers.add(identifier);
17257
- return true;
17258
- }
17259
- });
17260
- }
17261
-
17262
17141
  function mergeByName(modifiers) {
17263
17142
  var merged = modifiers.reduce(function (merged, current) {
17264
17143
  var existing = merged[current.name];
@@ -17274,8 +17153,6 @@ function mergeByName(modifiers) {
17274
17153
  });
17275
17154
  }
17276
17155
 
17277
- var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
17278
- var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
17279
17156
  var DEFAULT_OPTIONS = {
17280
17157
  placement: 'bottom',
17281
17158
  modifiers: [],
@@ -17337,42 +17214,7 @@ function popperGenerator(generatorOptions) {
17337
17214
 
17338
17215
  state.orderedModifiers = orderedModifiers.filter(function (m) {
17339
17216
  return m.enabled;
17340
- }); // Validate the provided modifiers so that the consumer will get warned
17341
- // if one of the modifiers is invalid for any reason
17342
-
17343
- if (process.env.NODE_ENV !== "production") {
17344
- var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
17345
- var name = _ref.name;
17346
- return name;
17347
- });
17348
- validateModifiers(modifiers);
17349
-
17350
- if (getBasePlacement(state.options.placement) === auto) {
17351
- var flipModifier = state.orderedModifiers.find(function (_ref2) {
17352
- var name = _ref2.name;
17353
- return name === 'flip';
17354
- });
17355
-
17356
- if (!flipModifier) {
17357
- console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
17358
- }
17359
- }
17360
-
17361
- var _getComputedStyle = getComputedStyle$1(popper),
17362
- marginTop = _getComputedStyle.marginTop,
17363
- marginRight = _getComputedStyle.marginRight,
17364
- marginBottom = _getComputedStyle.marginBottom,
17365
- marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
17366
- // cause bugs with positioning, so we'll warn the consumer
17367
-
17368
-
17369
- if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
17370
- return parseFloat(margin);
17371
- })) {
17372
- console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
17373
- }
17374
- }
17375
-
17217
+ });
17376
17218
  runModifierEffects();
17377
17219
  return instance.update();
17378
17220
  },
@@ -17392,10 +17234,6 @@ function popperGenerator(generatorOptions) {
17392
17234
  // anymore
17393
17235
 
17394
17236
  if (!areValidElements(reference, popper)) {
17395
- if (process.env.NODE_ENV !== "production") {
17396
- console.error(INVALID_ELEMENT_ERROR);
17397
- }
17398
-
17399
17237
  return;
17400
17238
  } // Store the reference and popper rects to be read by modifiers
17401
17239
 
@@ -17418,18 +17256,8 @@ function popperGenerator(generatorOptions) {
17418
17256
  state.orderedModifiers.forEach(function (modifier) {
17419
17257
  return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
17420
17258
  });
17421
- var __debug_loops__ = 0;
17422
17259
 
17423
17260
  for (var index = 0; index < state.orderedModifiers.length; index++) {
17424
- if (process.env.NODE_ENV !== "production") {
17425
- __debug_loops__ += 1;
17426
-
17427
- if (__debug_loops__ > 100) {
17428
- console.error(INFINITE_LOOP_ERROR);
17429
- break;
17430
- }
17431
- }
17432
-
17433
17261
  if (state.reset === true) {
17434
17262
  state.reset = false;
17435
17263
  index = -1;
@@ -17467,10 +17295,6 @@ function popperGenerator(generatorOptions) {
17467
17295
  };
17468
17296
 
17469
17297
  if (!areValidElements(reference, popper)) {
17470
- if (process.env.NODE_ENV !== "production") {
17471
- console.error(INVALID_ELEMENT_ERROR);
17472
- }
17473
-
17474
17298
  return instance;
17475
17299
  }
17476
17300
 
@@ -17485,11 +17309,11 @@ function popperGenerator(generatorOptions) {
17485
17309
  // one.
17486
17310
 
17487
17311
  function runModifierEffects() {
17488
- state.orderedModifiers.forEach(function (_ref3) {
17489
- var name = _ref3.name,
17490
- _ref3$options = _ref3.options,
17491
- options = _ref3$options === void 0 ? {} : _ref3$options,
17492
- effect = _ref3.effect;
17312
+ state.orderedModifiers.forEach(function (_ref) {
17313
+ var name = _ref.name,
17314
+ _ref$options = _ref.options,
17315
+ options = _ref$options === void 0 ? {} : _ref$options,
17316
+ effect = _ref.effect;
17493
17317
 
17494
17318
  if (typeof effect === 'function') {
17495
17319
  var cleanupFn = effect({
@@ -20918,9 +20742,13 @@ var parseBooleanFlag = function (v, empty, other) {
20918
20742
 
20919
20743
  var marginBottomClass = "mb-2";
20920
20744
  var emailFormatRegexp = new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
20745
+ var phoneFormatRegexp = new RegExp(/^\+\d{1,3}[-\s]?(\(?\d+\)?[-\s]?)*\d{4,}$/);
20921
20746
  var checkEmailFormat = function (email) {
20922
20747
  return emailFormatRegexp.test(email);
20923
20748
  };
20749
+ var checkPhoneFormat = function (phone) {
20750
+ return phoneFormatRegexp.test(phone);
20751
+ };
20924
20752
  var signUpInfoCheckStyle = {
20925
20753
  position: 'absolute',
20926
20754
  opacity: 0,
@@ -20944,6 +20772,7 @@ var SignupForm = function (props) {
20944
20772
  var _b = React$1.useState(props.initialSignupData ? props.initialSignupData : {
20945
20773
  email: '',
20946
20774
  password: '',
20775
+ phone: '',
20947
20776
  confirmPassword: '',
20948
20777
  infoCheck: '',
20949
20778
  }), signupData = _b[0], setSignupData = _b[1];
@@ -20956,6 +20785,7 @@ var SignupForm = function (props) {
20956
20785
  var _g = React$1.useState(false), showEmailError = _g[0], setShowEmailError = _g[1];
20957
20786
  var _h = React$1.useState(false), showPasswordError = _h[0], setShowPasswordError = _h[1];
20958
20787
  var _j = React$1.useState(false), showConfirmPasswordError = _j[0], setShowConfirmPasswordError = _j[1];
20788
+ var _k = React$1.useState(false), showPhoneError = _k[0], setShowPhoneError = _k[1];
20959
20789
  var reCaptchaSiteKey = process.env.REACT_APP_RECAPTCHA_SITEKEY ? process.env.REACT_APP_RECAPTCHA_SITEKEY : '';
20960
20790
  var useRecaptcha = process.env.REACT_APP_USE_RECAPTCHA === 'true';
20961
20791
  var recaptchaRef = React$1.useRef(null);
@@ -20963,6 +20793,7 @@ var SignupForm = function (props) {
20963
20793
  setSignupData(props.initialSignupData ? props.initialSignupData : {
20964
20794
  email: '',
20965
20795
  password: '',
20796
+ phone: '',
20966
20797
  confirmPassword: '',
20967
20798
  infoCheck: '',
20968
20799
  });
@@ -20973,8 +20804,9 @@ var SignupForm = function (props) {
20973
20804
  };
20974
20805
  var isDisabled = function () {
20975
20806
  var emailOk = checkEmailFormat(signupData.email);
20807
+ var phoneOk = checkPhoneFormat(signupData.phone);
20976
20808
  var passwordRuleOk = checkPasswordRules(signupData.password);
20977
- return !(!props.isLoading && (!useRecaptcha || reCaptchaAccepted) && acceptedPrivacyPolicy && emailOk && passwordRuleOk && passwordsMatch());
20809
+ return !(!props.isLoading && (!useRecaptcha || reCaptchaAccepted) && acceptedPrivacyPolicy && emailOk && passwordRuleOk && phoneOk && passwordsMatch());
20978
20810
  };
20979
20811
  var submit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
20980
20812
  var reCaptchaToken, captchaResponse;
@@ -21016,6 +20848,8 @@ var SignupForm = function (props) {
21016
20848
  var passwordInputPlaceholder = t('signup.passwordInputPlaceholder');
21017
20849
  var confirmPasswordInputLabel = t('signup.confirmPasswordInputLabel');
21018
20850
  var confirmPasswordPlaceholder = t('signup.confirmPasswordInputLabel');
20851
+ var phoneInputLabel = t('signup.phoneInputLabel');
20852
+ var phoneInputPlaceholder = t('signup.phoneInputPlaceholder');
21019
20853
  var dialogSize = consentDialogSize();
21020
20854
  return (jsxRuntime.jsxs(React$1.Fragment, { children: [infoText && infoText.length > 0 ?
21021
20855
  jsxRuntime.jsx(caseWebUi.AlertBox, { type: "info", className: marginBottomClass, content: infoText }, void 0) : null, useRecaptcha && reCaptchaAccepted ? jsxRuntime.jsx("div", { children: reCaptchaSiteKey ?
@@ -21035,6 +20869,11 @@ var SignupForm = function (props) {
21035
20869
  }, onChange: function (event) {
21036
20870
  var value = event.target.value;
21037
20871
  setSignupData(function (prev) { return __assign(__assign({}, prev), { confirmPassword: value }); });
20872
+ } }, void 0), jsxRuntime.jsx(caseWebUi.TextField, { id: "signupPhone", label: phoneInputLabel, placeholder: phoneInputPlaceholder, type: "text", name: "phone", className: marginBottomClass, value: signupData.phone, required: false, errorMsg: t("dialogs:signup.errors.phone"), hasError: !checkPhoneFormat(signupData.phone) && showPhoneError, onBlur: function () {
20873
+ setShowPhoneError(true);
20874
+ }, onChange: function (event) {
20875
+ var value = event.target.value;
20876
+ setSignupData(function (prev) { return __assign(__assign({}, prev), { phone: value }); });
21038
20877
  } }, void 0), jsxRuntime.jsx("label", { style: signUpInfoCheckStyle, "aria-hidden": "true", htmlFor: 'name' }, void 0), jsxRuntime.jsx("input", { style: signUpInfoCheckStyle, type: "text", id: "name", name: "name", value: signupData.infoCheck, tabIndex: -1, autoComplete: 'off', onChange: function (event) {
21039
20878
  var value = event.target.value;
21040
20879
  setSignupData(function (prev) { return __assign(__assign({}, prev), { infoCheck: value }); });
@@ -21115,6 +20954,7 @@ var Signup = function () {
21115
20954
  return [4 /*yield*/, signupWithEmailRequest({
21116
20955
  email: data.email,
21117
20956
  password: data.password,
20957
+ phone: data.phone,
21118
20958
  infoCheck: data.infoCheck,
21119
20959
  instanceId: instanceId,
21120
20960
  preferredLanguage: i18n.language,
@@ -21227,6 +21067,16 @@ var changeAccountEmailReq = function (newEmail, keepOldEmail, password) {
21227
21067
  password: password,
21228
21068
  });
21229
21069
  };
21070
+ var changeAccountPhoneReq = function (newPhone) {
21071
+ return authApiInstance.post("/v1/user/contact/change-phone", {
21072
+ newPhone: newPhone
21073
+ });
21074
+ };
21075
+ var newAccountPhoneReq = function (newPhone) {
21076
+ return authApiInstance.post("/v1/user/contact/add-phone", {
21077
+ newPhone: newPhone
21078
+ });
21079
+ };
21230
21080
  var setPreferredLanguageReq = function (languageCode) {
21231
21081
  return authApiInstance.post("/v1/user/set-language", { languageCode: languageCode });
21232
21082
  };
@@ -21281,17 +21131,29 @@ var revokeAllRefreshTokensReq = function () {
21281
21131
  };
21282
21132
  var deleteAccountReq = function (userId) {
21283
21133
  return authApiInstance.post("/v1/user/delete", { userId: userId });
21134
+ };
21135
+ var deletePhoneReq = function () {
21136
+ return authApiInstance.delete("/v1/user/contact/delete-phone");
21137
+ };
21138
+ // WhatsApp Verification API
21139
+ var verifyWhatsAppCodeReq = function (code) {
21140
+ return authApiInstance.post("/v1/user/contact/verify-whatsapp", {
21141
+ code: code,
21142
+ });
21284
21143
  };
21285
21144
 
21286
21145
  var userAPI = /*#__PURE__*/Object.freeze({
21287
21146
  __proto__: null,
21288
21147
  addEmailReq: addEmailReq,
21289
21148
  changeAccountEmailReq: changeAccountEmailReq,
21149
+ changeAccountPhoneReq: changeAccountPhoneReq,
21290
21150
  changePasswordReq: changePasswordReq,
21291
21151
  deleteAccountReq: deleteAccountReq,
21152
+ deletePhoneReq: deletePhoneReq,
21292
21153
  getInfosForPasswordResetReq: getInfosForPasswordResetReq,
21293
21154
  getUserReq: getUserReq,
21294
21155
  initiatePasswordResetReq: initiatePasswordResetReq,
21156
+ newAccountPhoneReq: newAccountPhoneReq,
21295
21157
  removeEmailReq: removeEmailReq,
21296
21158
  removeProfileReq: removeProfileReq,
21297
21159
  resendVerificationEmailReq: resendVerificationEmailReq,
@@ -21301,7 +21163,8 @@ var userAPI = /*#__PURE__*/Object.freeze({
21301
21163
  setPreferredLanguageReq: setPreferredLanguageReq,
21302
21164
  unsubscribeNewsletterReq: unsubscribeNewsletterReq,
21303
21165
  updateContactPreferencesReq: updateContactPreferencesReq,
21304
- verifyContactReq: verifyContactReq
21166
+ verifyContactReq: verifyContactReq,
21167
+ verifyWhatsAppCodeReq: verifyWhatsAppCodeReq
21305
21168
  });
21306
21169
 
21307
21170
  var SignupSuccess = function () {
@@ -21644,17 +21507,21 @@ var ChangeLanguage = function (props) {
21644
21507
  };
21645
21508
 
21646
21509
  var ChangeNotifications = function (props) {
21647
- var _a;
21510
+ var _a, _b;
21648
21511
  var t = reactI18next.useTranslation(['dialogs']).t;
21649
21512
  var dispatch = reactRedux.useDispatch();
21650
21513
  var dialogState = reactRedux.useSelector(function (state) { return state.dialog; });
21651
21514
  var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'changeNotifications';
21652
21515
  var currentUser = reactRedux.useSelector(function (state) { return state.user.currentUser; });
21653
- var _b = React$1.useState(false), loading = _b[0], setLoading = _b[1];
21654
- var _c = React$1.useState(''), error = _c[0], setError = _c[1];
21655
- var _d = React$1.useState(false), changed = _d[0], setChanged = _d[1];
21656
- var _e = React$1.useState(false), weeklyEnabled = _e[0], setWeeklyEnabled = _e[1];
21657
- var _f = React$1.useState(false), newsletterEnabled = _f[0], setNewsletterEnabled = _f[1];
21516
+ var _c = React$1.useState(false), loading = _c[0], setLoading = _c[1];
21517
+ var _d = React$1.useState(''), error = _d[0], setError = _d[1];
21518
+ var _e = React$1.useState(false), changed = _e[0], setChanged = _e[1];
21519
+ var _f = React$1.useState(false), weeklyEnabled = _f[0], setWeeklyEnabled = _f[1];
21520
+ var _g = React$1.useState(false), weeklyPhone = _g[0], setWeeklyPhone = _g[1];
21521
+ var _h = React$1.useState(false), newsletterEnabled = _h[0], setNewsletterEnabled = _h[1];
21522
+ var phoneInfo = currentUser.contactInfos.find(function (info) { return info.type === 'phone'; });
21523
+ var isPhonePresent = phoneInfo ? true : false;
21524
+ var confirmedPhone = ((_b = phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.confirmedAt) !== null && _b !== void 0 ? _b : 0) > 0 ? true : false;
21658
21525
  React$1.useEffect(function () {
21659
21526
  if (open) {
21660
21527
  fetchUser();
@@ -21662,8 +21529,10 @@ var ChangeNotifications = function (props) {
21662
21529
  // eslint-disable-next-line react-hooks/exhaustive-deps
21663
21530
  }, [open]);
21664
21531
  React$1.useEffect(function () {
21532
+ var _a;
21665
21533
  setNewsletterEnabled(currentUser.contactPreferences.subscribedToNewsletter ? true : false);
21666
21534
  setWeeklyEnabled(currentUser.contactPreferences.subscribedToWeekly ? true : false);
21535
+ setWeeklyPhone(currentUser.contactPreferences.sendNewsletterTo.includes((_a = phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.id) !== null && _a !== void 0 ? _a : '') ? true : false);
21667
21536
  }, [currentUser]);
21668
21537
  var fetchUser = function () { return __awaiter(void 0, void 0, void 0, function () {
21669
21538
  var user, e_1;
@@ -21706,6 +21575,12 @@ var ChangeNotifications = function (props) {
21706
21575
  setLoading(true);
21707
21576
  setError("");
21708
21577
  contactPreferences = __assign(__assign({}, currentUser.contactPreferences), { subscribedToWeekly: weeklyEnabled, subscribedToNewsletter: newsletterEnabled });
21578
+ if (weeklyPhone && isPhonePresent && confirmedPhone && (phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.id)) {
21579
+ contactPreferences.sendNewsletterTo = __spreadArray$1(__spreadArray$1([], contactPreferences.sendNewsletterTo, true), [phoneInfo.id], false);
21580
+ }
21581
+ if (!weeklyPhone && isPhonePresent && confirmedPhone && (phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.id)) {
21582
+ contactPreferences.sendNewsletterTo = contactPreferences.sendNewsletterTo.filter(function (id) { return id !== phoneInfo.id; });
21583
+ }
21709
21584
  _a.label = 1;
21710
21585
  case 1:
21711
21586
  _a.trys.push([1, 3, , 4]);
@@ -21738,7 +21613,12 @@ var ChangeNotifications = function (props) {
21738
21613
  setWeeklyEnabled(value);
21739
21614
  } }, { children: weeklyEnabled ?
21740
21615
  t('dialogs:changeNotifications.weeklyReminder.on') :
21741
- t('dialogs:changeNotifications.weeklyReminder.off') }), void 0), jsxRuntime.jsx("label", __assign({ className: "mt-2 mb-1 form-label", htmlFor: "newsletter" }, { children: t('dialogs:changeNotifications.newsletter.label') }), void 0), jsxRuntime.jsx(caseWebUi.Checkbox, __assign({ id: "newsletter", name: "newsletter", checked: newsletterEnabled, onChange: function (value) {
21616
+ t('dialogs:changeNotifications.weeklyReminder.off') }), void 0), jsxRuntime.jsx("label", __assign({ className: "mb-1 form-label mt-2", htmlFor: "weeklyPhone" }, { children: t('dialogs:changeNotifications.weeklyReminderPhone.label') }), void 0), confirmedPhone && (jsxRuntime.jsx(caseWebUi.Checkbox, __assign({ id: "weeklyPhone", name: "weeklyPhone", checked: weeklyPhone, onChange: function (value) {
21617
+ setChanged(true);
21618
+ setWeeklyPhone(value);
21619
+ } }, { children: weeklyPhone ?
21620
+ t('dialogs:changeNotifications.weeklyReminderPhone.on') :
21621
+ t('dialogs:changeNotifications.weeklyReminderPhone.off') }), void 0)), (!confirmedPhone && !isPhonePresent) && (jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'addPhone' })); } }, { children: t('dialogs:changeNotifications.addPhone') }), void 0)), (!confirmedPhone && isPhonePresent) && (jsxRuntime.jsx(caseWebUi.AlertBox, { className: "mt-2", type: "info", content: t('changeNotifications.phoneNotConfirmed') }, void 0)), (!confirmedPhone && isPhonePresent) && (jsxRuntime.jsx(Button$1, __assign({ className: "mt-2", onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'addPhone' })); }, variant: "link" }, { children: t('dialogs:changeNotifications.verifyPhone') }), void 0)), jsxRuntime.jsx("label", __assign({ className: "mt-2 mb-1 form-label", htmlFor: "newsletter" }, { children: t('dialogs:changeNotifications.newsletter.label') }), void 0), jsxRuntime.jsx(caseWebUi.Checkbox, __assign({ id: "newsletter", name: "newsletter", checked: newsletterEnabled, onChange: function (value) {
21742
21622
  setChanged(true);
21743
21623
  setNewsletterEnabled(value);
21744
21624
  } }, { children: newsletterEnabled ?
@@ -22394,11 +22274,353 @@ var PasswordForgotten = function () {
22394
22274
  return (jsxRuntime.jsx(caseWebUi.Dialog, __assign({ open: open, title: t('passwordForgotten.title'), onClose: handleClose, ariaLabelledBy: "passwordForgottenTitle" }, { children: jsxRuntime.jsxs("div", __assign({ className: clsx(caseWebUi.defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: [jsxRuntime.jsx(caseWebUi.AlertBox, { className: "mb-2", type: "info", useIcon: false, content: t('passwordForgotten.info') }, void 0), jsxRuntime.jsx(caseWebUi.AlertBox, { className: "mb-2", hide: !success, type: "success", useIcon: true, content: t('passwordForgotten.successMessage') }, void 0), jsxRuntime.jsx(caseWebUi.AlertBox, { className: "mb-2", hide: !error, type: "danger", useIcon: true, content: error, closable: true, onClose: function () { return setError(''); } }, void 0), jsxRuntime.jsxs("form", __assign({ onSubmit: onResetPasswordClicked }, { children: [jsxRuntime.jsx(caseWebUi.TextField, { id: "email", label: t("passwordForgotten.emailInputLabel"), placeholder: t("passwordForgotten.emailInputPlaceholder"), type: "email", name: "email", className: "mb-2", value: email, required: true, onChange: emailChanged }, void 0), jsxRuntime.jsx(caseWebUi.DialogBtn, { type: "submit", label: t('passwordForgotten.submitBtn'), disabled: loading || disabled || email.length < 3, loading: loading, loadingLabel: t('loadingMsg') }, void 0)] }), void 0)] }), void 0) }), void 0));
22395
22275
  };
22396
22276
 
22277
+ var ChangePhone = function () {
22278
+ var _a;
22279
+ var t = reactI18next.useTranslation(['dialogs']).t;
22280
+ var dispatch = reactRedux.useDispatch();
22281
+ var dialogState = reactRedux.useSelector(function (state) { return state.dialog; });
22282
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'changePhone';
22283
+ var _b = React$1.useState(false), loading = _b[0], setLoading = _b[1];
22284
+ var _c = React$1.useState(''), error = _c[0], setError = _c[1];
22285
+ var _d = React$1.useState(false), openConfirm = _d[0], setOpenConfirm = _d[1];
22286
+ var _e = React$1.useState({
22287
+ newPhone: ''
22288
+ }), formData = _e[0], setFormData = _e[1];
22289
+ React$1.useEffect(function () {
22290
+ if (!open) {
22291
+ resetForm();
22292
+ }
22293
+ }, [open]);
22294
+ var resetForm = function () {
22295
+ setLoading(false);
22296
+ setError('');
22297
+ setFormData({
22298
+ newPhone: ''
22299
+ });
22300
+ };
22301
+ var handleClose = function () {
22302
+ dispatch(dialogActions.closeDialog());
22303
+ };
22304
+ var changePhone = function () { return __awaiter(void 0, void 0, void 0, function () {
22305
+ var response, userData, e_1, errorResponse;
22306
+ var _a, _b;
22307
+ return __generator$1(this, function (_c) {
22308
+ switch (_c.label) {
22309
+ case 0:
22310
+ setLoading(true);
22311
+ setError("");
22312
+ _c.label = 1;
22313
+ case 1:
22314
+ _c.trys.push([1, 6, 7, 8]);
22315
+ return [4 /*yield*/, changeAccountPhoneReq(formData.newPhone)];
22316
+ case 2:
22317
+ response = _c.sent();
22318
+ if (!(response.status === 200)) return [3 /*break*/, 5];
22319
+ renewToken();
22320
+ if (!response.data) return [3 /*break*/, 3];
22321
+ dispatch(userActions.setUser(response.data));
22322
+ return [3 /*break*/, 5];
22323
+ case 3: return [4 /*yield*/, getUserReq()];
22324
+ case 4:
22325
+ userData = (_c.sent()).data;
22326
+ dispatch(userActions.setUser(userData));
22327
+ _c.label = 5;
22328
+ case 5:
22329
+ dispatch(dialogActions.openVerifyWhatsAppDialog({
22330
+ type: 'verifyWhatsApp',
22331
+ payload: {
22332
+ phoneNumber: formData.newPhone,
22333
+ }
22334
+ }));
22335
+ return [3 /*break*/, 8];
22336
+ case 6:
22337
+ e_1 = _c.sent();
22338
+ console.error(e_1);
22339
+ errorResponse = e_1;
22340
+ handleError((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error);
22341
+ return [3 /*break*/, 8];
22342
+ case 7:
22343
+ setLoading(false);
22344
+ return [7 /*endfinally*/];
22345
+ case 8: return [2 /*return*/];
22346
+ }
22347
+ });
22348
+ }); };
22349
+ var handleError = function (errorMsg) {
22350
+ switch (errorMsg) {
22351
+ case 'action failed':
22352
+ setError(t('changePhone.errors.wrongPasswordOrAccountId'));
22353
+ break;
22354
+ case 'phone not valid':
22355
+ setError(t('changePhone.errors.wrongPhoneFormat'));
22356
+ break;
22357
+ default:
22358
+ setError(t('changePhone.errors.unknown'));
22359
+ break;
22360
+ }
22361
+ };
22362
+ var onSubmit = function (event) {
22363
+ event.preventDefault();
22364
+ setOpenConfirm(true);
22365
+ };
22366
+ var buttonDisabled = function () {
22367
+ return loading || formData.newPhone.length < 8;
22368
+ };
22369
+ return (jsxRuntime.jsxs(caseWebUi.Dialog, __assign({ open: open, title: t('changePhone.title'), onClose: handleClose, ariaLabelledBy: "changePhoneDialogTitle" }, { children: [jsxRuntime.jsx("div", __assign({ className: clsx(caseWebUi.defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: jsxRuntime.jsxs("form", __assign({ onSubmit: onSubmit }, { children: [jsxRuntime.jsx(caseWebUi.TextField, { className: "mb-2", id: "newPhone", name: "newPhone", type: "text", label: t('dialogs:changePhone.phoneInputLabel'), placeholder: t('dialogs:changePhone.phoneInputPlaceholder'), value: formData.newPhone, autoFocus: true, autoComplete: "off", onChange: function (event) {
22370
+ var value = event.target.value;
22371
+ setFormData(function (prev) { return __assign(__assign({}, prev), { newPhone: value }); });
22372
+ } }, void 0), jsxRuntime.jsx(caseWebUi.AlertBox, { type: "info", content: t('changePhone.info') }, void 0), jsxRuntime.jsx(caseWebUi.AlertBox, { type: "danger", className: "mt-2", hide: !error, closable: true, useIcon: true, onClose: function () { return setError(""); }, content: error }, void 0), jsxRuntime.jsxs("div", __assign({ className: "d-flex flex-wrap" }, { children: [jsxRuntime.jsx(caseWebUi.DialogBtn, { className: "mt-2 me-2", type: "button", color: "primary", outlined: true, label: t('changePhone.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsxRuntime.jsx(caseWebUi.DialogBtn, { className: "mt-2", type: "submit", color: "primary", loading: loading, disabled: buttonDisabled(), label: t('changePhone.confirmBtn') }, void 0)] }), void 0)] }), void 0) }), void 0), jsxRuntime.jsx(caseWebUi.ConfirmDialog, __assign({ open: openConfirm, title: t('changePhone.warningDialog.title'), onConfirm: function () {
22373
+ setOpenConfirm(false);
22374
+ changePhone();
22375
+ }, color: "warning", onClose: function () { return setOpenConfirm(false); }, cancelText: t('changePhone.warningDialog.cancelBtn'), confirmText: t('changePhone.warningDialog.confirmBtn') }, { children: jsxRuntime.jsx(caseWebUi.AlertBox, { type: "warning", content: t('changePhone.warningDialog.content') }, void 0) }), void 0)] }), void 0));
22376
+ };
22377
+
22378
+ var DeletePhone = function (props) {
22379
+ var _a;
22380
+ var t = reactI18next.useTranslation(['dialogs']).t;
22381
+ var dispatch = reactRedux.useDispatch();
22382
+ var dialogState = reactRedux.useSelector(function (state) { return state.dialog; });
22383
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'deletePhone';
22384
+ reactRedux.useSelector(function (state) { return state.user; });
22385
+ var _b = React$1.useState(false), loading = _b[0], setLoading = _b[1];
22386
+ var _c = React$1.useState(''), error = _c[0], setError = _c[1];
22387
+ var handleClose = function () {
22388
+ setError('');
22389
+ setLoading(false);
22390
+ dispatch(dialogActions.closeDialog());
22391
+ };
22392
+ var onDeletePhone = function () { return __awaiter(void 0, void 0, void 0, function () {
22393
+ var response, userData_1, userData, e_1, err;
22394
+ return __generator$1(this, function (_a) {
22395
+ switch (_a.label) {
22396
+ case 0:
22397
+ setLoading(true);
22398
+ _a.label = 1;
22399
+ case 1:
22400
+ _a.trys.push([1, 7, , 8]);
22401
+ return [4 /*yield*/, deletePhoneReq()];
22402
+ case 2:
22403
+ response = _a.sent();
22404
+ if (!(response.status === 200)) return [3 /*break*/, 5];
22405
+ if (!response.data) return [3 /*break*/, 3];
22406
+ dispatch(userActions.setUser(response.data));
22407
+ return [3 /*break*/, 5];
22408
+ case 3: return [4 /*yield*/, getUserReq()];
22409
+ case 4:
22410
+ userData_1 = (_a.sent()).data;
22411
+ dispatch(userActions.setUser(userData_1));
22412
+ _a.label = 5;
22413
+ case 5:
22414
+ dispatch(dialogActions.openAlertDialog({
22415
+ type: 'alertDialog',
22416
+ payload: {
22417
+ color: 'success',
22418
+ title: t('dialogs:deletePhone.successDialog.title'),
22419
+ content: t('dialogs:deletePhone.successDialog.content'),
22420
+ btn: t('dialogs:deletePhone.successDialog.btn'),
22421
+ }
22422
+ }));
22423
+ return [4 /*yield*/, getUserReq()];
22424
+ case 6:
22425
+ userData = (_a.sent()).data;
22426
+ dispatch(userActions.setUser(userData));
22427
+ return [3 /*break*/, 8];
22428
+ case 7:
22429
+ e_1 = _a.sent();
22430
+ err = getErrorMsg(e_1);
22431
+ setError(err);
22432
+ setLoading(false);
22433
+ return [3 /*break*/, 8];
22434
+ case 8: return [2 /*return*/];
22435
+ }
22436
+ });
22437
+ }); };
22438
+ return (jsxRuntime.jsx(caseWebUi.Dialog, __assign({ open: open, title: t('deletePhone.title'), color: "danger", onClose: handleClose, ariaLabelledBy: "deletePhoneDialogTitle" }, { children: jsxRuntime.jsxs("div", __assign({ className: clsx(caseWebUi.defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: [jsxRuntime.jsx(caseWebUi.AlertBox, { type: "danger", content: t('dialogs:deletePhone.info') }, void 0), jsxRuntime.jsx(caseWebUi.AlertBox, { className: "mt-2", type: "danger", hide: !error, closable: true, onClose: function () { return setError(''); }, content: error }, void 0), jsxRuntime.jsxs("div", __assign({ className: "d-flex flex-wrap" }, { children: [jsxRuntime.jsx(caseWebUi.DialogBtn, { className: "mt-2 me-2", type: "button", color: "primary", label: t('deletePhone.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsxRuntime.jsx(caseWebUi.DialogBtn, { type: "button", color: "danger", className: "mt-2", loading: loading, outlined: true, label: t('deletePhone.confirmBtn'), onClick: function () { return onDeletePhone(); } }, void 0)] }), void 0)] }), void 0) }), void 0));
22439
+ };
22440
+
22441
+ var AddPhone = function () {
22442
+ var _a;
22443
+ var t = reactI18next.useTranslation(['dialogs']).t;
22444
+ var dispatch = reactRedux.useDispatch();
22445
+ var dialogState = reactRedux.useSelector(function (state) { return state.dialog; });
22446
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'addPhone';
22447
+ var _b = React$1.useState(false), loading = _b[0], setLoading = _b[1];
22448
+ var _c = React$1.useState(''), error = _c[0], setError = _c[1];
22449
+ var _d = React$1.useState(false), openConfirm = _d[0], setOpenConfirm = _d[1];
22450
+ var _e = React$1.useState({
22451
+ newPhone: ''
22452
+ }), formData = _e[0], setFormData = _e[1];
22453
+ React$1.useEffect(function () {
22454
+ if (!open) {
22455
+ resetForm();
22456
+ }
22457
+ }, [open]);
22458
+ var resetForm = function () {
22459
+ setLoading(false);
22460
+ setError('');
22461
+ setFormData({
22462
+ newPhone: ''
22463
+ });
22464
+ };
22465
+ var handleClose = function () {
22466
+ dispatch(dialogActions.closeDialog());
22467
+ };
22468
+ var addPhone = function () { return __awaiter(void 0, void 0, void 0, function () {
22469
+ var response, userData, e_1, errorResponse;
22470
+ var _a, _b;
22471
+ return __generator$1(this, function (_c) {
22472
+ switch (_c.label) {
22473
+ case 0:
22474
+ setLoading(true);
22475
+ setError("");
22476
+ _c.label = 1;
22477
+ case 1:
22478
+ _c.trys.push([1, 7, 8, 9]);
22479
+ return [4 /*yield*/, newAccountPhoneReq(formData.newPhone)];
22480
+ case 2:
22481
+ response = _c.sent();
22482
+ if (!(response.status === 200)) return [3 /*break*/, 6];
22483
+ renewToken();
22484
+ if (!response.data) return [3 /*break*/, 3];
22485
+ dispatch(userActions.setUser(response.data));
22486
+ return [3 /*break*/, 5];
22487
+ case 3: return [4 /*yield*/, getUserReq()];
22488
+ case 4:
22489
+ userData = (_c.sent()).data;
22490
+ dispatch(userActions.setUser(userData));
22491
+ _c.label = 5;
22492
+ case 5:
22493
+ dispatch(dialogActions.openVerifyWhatsAppDialog({
22494
+ type: 'verifyWhatsApp',
22495
+ payload: {
22496
+ phoneNumber: formData.newPhone,
22497
+ }
22498
+ }));
22499
+ _c.label = 6;
22500
+ case 6: return [3 /*break*/, 9];
22501
+ case 7:
22502
+ e_1 = _c.sent();
22503
+ console.error(e_1);
22504
+ errorResponse = e_1;
22505
+ handleError((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error);
22506
+ return [3 /*break*/, 9];
22507
+ case 8:
22508
+ setLoading(false);
22509
+ return [7 /*endfinally*/];
22510
+ case 9: return [2 /*return*/];
22511
+ }
22512
+ });
22513
+ }); };
22514
+ var handleError = function (errorMsg) {
22515
+ switch (errorMsg) {
22516
+ case 'action failed':
22517
+ setError(t('addPhone.errors.wrongPasswordOrAccountId'));
22518
+ break;
22519
+ case 'phone not valid':
22520
+ setError(t('addPhone.errors.wrongPhoneFormat'));
22521
+ break;
22522
+ default:
22523
+ setError(t('addPhone.errors.unknown'));
22524
+ break;
22525
+ }
22526
+ };
22527
+ var onSubmit = function (event) {
22528
+ event.preventDefault();
22529
+ setOpenConfirm(true);
22530
+ };
22531
+ var buttonDisabled = function () {
22532
+ return loading || formData.newPhone.length < 8;
22533
+ };
22534
+ return (jsxRuntime.jsxs(caseWebUi.Dialog, __assign({ open: open, title: t('addPhone.title'), onClose: handleClose, ariaLabelledBy: "addPhoneDialogTitle" }, { children: [jsxRuntime.jsx("div", __assign({ className: clsx(caseWebUi.defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: jsxRuntime.jsxs("form", __assign({ onSubmit: onSubmit }, { children: [jsxRuntime.jsx(caseWebUi.TextField, { className: "mb-2", id: "newPhone", name: "newPhone", type: "text", label: t('dialogs:addPhone.phoneInputLabel'), placeholder: t('dialogs:addPhone.phoneInputPlaceholder'), value: formData.newPhone, autoFocus: true, autoComplete: "off", onChange: function (event) {
22535
+ var value = event.target.value;
22536
+ setFormData(function (prev) { return __assign(__assign({}, prev), { newPhone: value }); });
22537
+ } }, void 0), jsxRuntime.jsx(caseWebUi.AlertBox, { type: "info", content: t('addPhone.info') }, void 0), jsxRuntime.jsx(caseWebUi.AlertBox, { type: "danger", className: "mt-2", hide: !error, closable: true, useIcon: true, onClose: function () { return setError(""); }, content: error }, void 0), jsxRuntime.jsxs("div", __assign({ className: "d-flex flex-wrap" }, { children: [jsxRuntime.jsx(caseWebUi.DialogBtn, { className: "mt-2 me-2", type: "button", color: "primary", outlined: true, label: t('addPhone.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsxRuntime.jsx(caseWebUi.DialogBtn, { className: "mt-2", type: "submit", color: "primary", loading: loading, disabled: buttonDisabled(), label: t('addPhone.confirmBtn') }, void 0)] }), void 0)] }), void 0) }), void 0), jsxRuntime.jsx(caseWebUi.ConfirmDialog, __assign({ open: openConfirm, title: t('addPhone.warningDialog.title'), onConfirm: function () {
22538
+ setOpenConfirm(false);
22539
+ addPhone();
22540
+ }, color: "warning", onClose: function () { return setOpenConfirm(false); }, cancelText: t('addPhone.warningDialog.cancelBtn'), confirmText: t('addPhone.warningDialog.confirmBtn') }, { children: jsxRuntime.jsx(caseWebUi.AlertBox, { type: "warning", content: t('addPhone.warningDialog.content') }, void 0) }), void 0)] }), void 0));
22541
+ };
22542
+
22543
+ var VerifyWhatsApp = function () {
22544
+ var _a;
22545
+ var dispatch = reactRedux.useDispatch();
22546
+ var t = reactI18next.useTranslation(['dialogs']).t;
22547
+ var dialogState = reactRedux.useSelector(function (state) { return state.dialog; });
22548
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'verifyWhatsApp';
22549
+ var dialogContent = open ? dialogState.config.payload : undefined;
22550
+ var _b = React$1.useState(false), loading = _b[0], setLoading = _b[1];
22551
+ var _c = React$1.useState(''), error = _c[0], setError = _c[1];
22552
+ var _d = React$1.useState(''), verificationCode = _d[0], setVerificationCode = _d[1];
22553
+ var phoneNumber = (dialogContent === null || dialogContent === void 0 ? void 0 : dialogContent.phoneNumber) || '';
22554
+ var close = function () {
22555
+ dispatch(dialogActions.closeDialog());
22556
+ setVerificationCode('');
22557
+ setError('');
22558
+ };
22559
+ var verifyCode = function () { return __awaiter(void 0, void 0, void 0, function () {
22560
+ var response, userData, e_1, errorResponse;
22561
+ var _a, _b;
22562
+ return __generator$1(this, function (_c) {
22563
+ switch (_c.label) {
22564
+ case 0:
22565
+ if (!verificationCode.trim()) {
22566
+ setError(t('verifyWhatsApp.errors.codeRequired'));
22567
+ return [2 /*return*/];
22568
+ }
22569
+ setLoading(true);
22570
+ setError('');
22571
+ _c.label = 1;
22572
+ case 1:
22573
+ _c.trys.push([1, 7, 8, 9]);
22574
+ return [4 /*yield*/, verifyWhatsAppCodeReq(verificationCode)];
22575
+ case 2:
22576
+ response = _c.sent();
22577
+ if (!(response.status === 200)) return [3 /*break*/, 6];
22578
+ renewToken();
22579
+ if (!response.data) return [3 /*break*/, 3];
22580
+ dispatch(userActions.setUser(response.data));
22581
+ return [3 /*break*/, 5];
22582
+ case 3: return [4 /*yield*/, getUserReq()];
22583
+ case 4:
22584
+ userData = (_c.sent()).data;
22585
+ dispatch(userActions.setUser(userData));
22586
+ _c.label = 5;
22587
+ case 5:
22588
+ // Show success message
22589
+ dispatch(dialogActions.openAlertDialog({
22590
+ type: 'alertDialog',
22591
+ payload: {
22592
+ color: 'success',
22593
+ title: t('verifyWhatsApp.successDialog.title'),
22594
+ content: t('verifyWhatsApp.successDialog.content'),
22595
+ btn: t('verifyWhatsApp.successDialog.btn'),
22596
+ }
22597
+ }));
22598
+ _c.label = 6;
22599
+ case 6: return [3 /*break*/, 9];
22600
+ case 7:
22601
+ e_1 = _c.sent();
22602
+ console.error(e_1);
22603
+ errorResponse = e_1;
22604
+ setError(((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) || t('verifyWhatsApp.errors.verificationFailed'));
22605
+ return [3 /*break*/, 9];
22606
+ case 8:
22607
+ setLoading(false);
22608
+ return [7 /*endfinally*/];
22609
+ case 9: return [2 /*return*/];
22610
+ }
22611
+ });
22612
+ }); };
22613
+ if (!open) {
22614
+ return null;
22615
+ }
22616
+ return (jsxRuntime.jsxs(caseWebUi.Dialog, __assign({ open: open, title: t('verifyWhatsApp.title'), ariaLabelledBy: "verify-whatsapp-title", onClose: close, size: "sm" }, { children: [jsxRuntime.jsxs("div", __assign({ className: caseWebUi.defaultDialogPaddingXClass }, { children: [jsxRuntime.jsx("div", __assign({ className: "mb-3" }, { children: jsxRuntime.jsx("p", { children: t('verifyWhatsApp.description', { phoneNumber: phoneNumber }) }, void 0) }), void 0), error && (jsxRuntime.jsx(caseWebUi.AlertBox, { type: "danger", content: error, className: "mb-3" }, void 0)), jsxRuntime.jsx(caseWebUi.TextField, { id: "verification-code", name: "verificationCode", label: t('verifyWhatsApp.form.verificationCode.label'), placeholder: t('verifyWhatsApp.form.verificationCode.placeholder'), value: verificationCode, onChange: function (event) { return setVerificationCode(event.target.value); }, maxLength: 6, autoComplete: "off" }, void 0)] }), void 0), jsxRuntime.jsxs("div", __assign({ className: "d-flex justify-content-end gap-2 p-3" }, { children: [jsxRuntime.jsx(caseWebUi.DialogBtn, { type: "button", onClick: close, label: t('buttons.cancel'), disabled: loading }, void 0), jsxRuntime.jsx(caseWebUi.DialogBtn, { type: "button", onClick: verifyCode, color: "primary", label: t('verifyWhatsApp.form.submit'), loading: loading, disabled: !verificationCode.trim() }, void 0)] }), void 0)] }), void 0));
22617
+ };
22618
+
22397
22619
  var GlobalDialogs = function (props) {
22398
22620
  var isAuth = useIsAuthenticated();
22399
22621
  var hasToken = useAuthTokenCheck();
22400
22622
  var authDialogs = function () {
22401
- return jsxRuntime.jsxs(React$1.Fragment, { children: [jsxRuntime.jsx(ChangeEmail, {}, void 0), jsxRuntime.jsx(ChangePassword, {}, void 0), jsxRuntime.jsx(ChangeLanguage, { onChangeLanguage: props.onChangeLanguage }, void 0), jsxRuntime.jsx(ChangeNotifications, {}, void 0), jsxRuntime.jsx(DeleteAccount$1, {}, void 0)] }, void 0);
22623
+ return jsxRuntime.jsxs(React$1.Fragment, { children: [jsxRuntime.jsx(ChangeEmail, {}, void 0), jsxRuntime.jsx(ChangePhone, {}, void 0), jsxRuntime.jsx(AddPhone, {}, void 0), jsxRuntime.jsx(VerifyWhatsApp, {}, void 0), jsxRuntime.jsx(ChangePassword, {}, void 0), jsxRuntime.jsx(ChangeLanguage, { onChangeLanguage: props.onChangeLanguage }, void 0), jsxRuntime.jsx(ChangeNotifications, {}, void 0), jsxRuntime.jsx(DeleteAccount$1, {}, void 0), jsxRuntime.jsx(DeletePhone, {}, void 0)] }, void 0);
22402
22624
  };
22403
22625
  return (jsxRuntime.jsxs(React$1.Fragment, { children: [jsxRuntime.jsx(Login, { defaultRoutes: props.defaultRoutes }, void 0), jsxRuntime.jsx(Signup, {}, void 0), jsxRuntime.jsx(SignupSuccess, {}, void 0), jsxRuntime.jsx(PasswordForgotten, {}, void 0), jsxRuntime.jsx(AlertDialog, {}, void 0), hasToken ? jsxRuntime.jsx(ManageProfiles, {}, void 0) : null, isAuth ? authDialogs() : null] }, void 0));
22404
22626
  };
@@ -23709,6 +23931,13 @@ var blurEmail = function (email) {
23709
23931
  return items[0][0] + '****@' + items.slice(1).join('');
23710
23932
  };
23711
23933
 
23934
+ var blurPhone = function (phone) {
23935
+ if (phone.length < 4) {
23936
+ return '****';
23937
+ }
23938
+ return phone.slice(0, 2) + '****' + phone.slice(-2);
23939
+ };
23940
+
23712
23941
  var AccountSettings = function (props) {
23713
23942
  var t = reactI18next.useTranslation(['settings']).t;
23714
23943
  var isAuth = useIsAuthenticated();
@@ -23717,13 +23946,16 @@ var AccountSettings = function (props) {
23717
23946
  if (!isAuth) {
23718
23947
  return jsxRuntime.jsx("div", __assign({ className: "bg-warning-light p-3" }, { children: 'authentication needed' }), void 0);
23719
23948
  }
23949
+ var phoneInfo = currentUser.contactInfos.find(function (info) { return info.type === 'phone'; });
23720
23950
  var renderProfileSettings = function () {
23721
23951
  if (props.hideProfileSettings === true) {
23722
23952
  return null;
23723
23953
  }
23724
23954
  return jsxRuntime.jsxs(React$1.Fragment, { children: [jsxRuntime.jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".profiles.title")) }), void 0), jsxRuntime.jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".profiles.info")) }), void 0), jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'manageProfiles' })); } }, { children: t("".concat(props.itemKey, ".profiles.btn"), { count: currentUser.profiles.length }) }), void 0)] }, void 0);
23725
23955
  };
23726
- return (jsxRuntime.jsxs("div", __assign({ className: "border-primary border-top-2 pt-2" }, { children: [jsxRuntime.jsx("h2", { children: t("".concat(props.itemKey, ".title")) }, void 0), jsxRuntime.jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".email.title")) }), void 0), jsxRuntime.jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".email.info")) }), void 0), jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changeEmail' })); } }, { children: blurEmail(currentUser.account.accountId) }), void 0), jsxRuntime.jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".password.title")) }), void 0), jsxRuntime.jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".password.info")) }), void 0), jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changePassword' })); } }, { children: "••••••••••••••" }), void 0), renderProfileSettings()] }), void 0));
23956
+ return (jsxRuntime.jsxs("div", __assign({ className: "border-primary border-top-2 pt-2" }, { children: [jsxRuntime.jsx("h2", { children: t("".concat(props.itemKey, ".title")) }, void 0), jsxRuntime.jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".email.title")) }), void 0), jsxRuntime.jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".email.info")) }), void 0), jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changeEmail' })); } }, { children: blurEmail(currentUser.account.accountId) }), void 0), jsxRuntime.jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".phone.title")) }), void 0), phoneInfo ? (jsxRuntime.jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".phone.info")) }), void 0)) : (jsxRuntime.jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".phone.infoAdd")) }), void 0)), jsxRuntime.jsxs("div", __assign({ className: "m-0 d-flex align-items-center py-2" }, { children: [phoneInfo ? (jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changePhone' })); } }, { children: blurPhone(phoneInfo.phone) }), void 0)) : (jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'addPhone' })); } }, { children: t("".concat(props.itemKey, ".phone.btn")) }), void 0)), phoneInfo && (jsxRuntime.jsx("button", __assign({ className: "btn btn-danger-light", onClick: function () {
23957
+ dispatch(dialogActions.openDialogWithoutPayload({ type: 'deletePhone' }));
23958
+ } }, { children: jsxRuntime.jsx("i", { className: "fas fa-trash text-grey-5" }, void 0) }), void 0))] }), void 0), jsxRuntime.jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".password.title")) }), void 0), jsxRuntime.jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".password.info")) }), void 0), jsxRuntime.jsx(caseWebUi.EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changePassword' })); } }, { children: "••••••••••••••" }), void 0), renderProfileSettings()] }), void 0));
23727
23959
  };
23728
23960
 
23729
23961
  var CommunicationSettings = function (props) {