@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.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import React__default$1, { Component, useEffect, useRef, useState, useCallback, useContext as useContext$1, useMemo, useLayoutEffect, useReducer, createContext, forwardRef as forwardRef$2, useImperativeHandle, createElement, Suspense } from 'react';
4
- import { LoadingPlaceholder, SimpleHeader, Footer, Avatar, containerClassName, ChevronUp, ChevronDown, Dialog, defaultDialogPaddingXClass, Checkbox, AlertBox, TextField, DialogBtn, useFetchTextFile, TextLink, ConsentDialog, ConfirmDialog, SelectField, AvatarSelector, EditBtn, SurveyList as SurveyList$1, getExternalOrLocalContentURL, ReportList as ReportList$1, TitleBar, ComposedLineAndScatterChartLoader, MapWithTimeSliderLoader, LinkList, handleOpenExternalPage, LogoCredits, SimpleCard, AccordionList, LoginCard, VideoPlayer, ImageContainer, ActionCard, MarkdownRenderer, ImageCard, TeaserImage, MarkdownLoader, getLocalizedString, SurveyView } from '@influenzanet/case-web-ui';
4
+ import { LoadingPlaceholder, SimpleHeader, Footer, Avatar, containerClassName, ChevronUp, ChevronDown, Dialog, defaultDialogPaddingXClass, Checkbox, AlertBox, TextField, DialogBtn, useFetchTextFile, TextLink, ConsentDialog, ConfirmDialog, SelectField, EditBtn, AvatarSelector, SurveyList as SurveyList$1, getExternalOrLocalContentURL, ReportList as ReportList$1, TitleBar, ComposedLineAndScatterChartLoader, MapWithTimeSliderLoader, LinkList, handleOpenExternalPage, LogoCredits, SimpleCard, AccordionList, LoginCard, VideoPlayer, ImageContainer, ActionCard, MarkdownRenderer, ImageCard, TeaserImage, MarkdownLoader, getLocalizedString, SurveyView } from '@influenzanet/case-web-ui';
5
5
  import { useTranslation, Trans, initReactI18next } from 'react-i18next';
6
6
  import { useSelector, useDispatch } from 'react-redux';
7
7
  import { combineReducers, applyMiddleware, createStore, compose } from 'redux';
@@ -5083,6 +5083,13 @@ var dialogSlice = createSlice({
5083
5083
  payload: action.payload.payload
5084
5084
  };
5085
5085
  },
5086
+ openVerifyWhatsAppDialog: function (state, action) {
5087
+ state.config = {
5088
+ type: action.payload.type,
5089
+ origin: action.payload.origin,
5090
+ payload: action.payload.payload
5091
+ };
5092
+ },
5086
5093
  }
5087
5094
  });
5088
5095
  var dialogActions = dialogSlice.actions;
@@ -15687,7 +15694,7 @@ var round = Math.round;
15687
15694
  function getUAString() {
15688
15695
  var uaData = navigator.userAgentData;
15689
15696
 
15690
- if (uaData != null && uaData.brands) {
15697
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
15691
15698
  return uaData.brands.map(function (item) {
15692
15699
  return item.brand + "/" + item.version;
15693
15700
  }).join(' ');
@@ -15978,17 +15985,7 @@ function effect$1(_ref2) {
15978
15985
  }
15979
15986
  }
15980
15987
 
15981
- if (process.env.NODE_ENV !== "production") {
15982
- if (!isHTMLElement(arrowElement)) {
15983
- 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(' '));
15984
- }
15985
- }
15986
-
15987
15988
  if (!contains$1(state.elements.popper, arrowElement)) {
15988
- if (process.env.NODE_ENV !== "production") {
15989
- console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
15990
- }
15991
-
15992
15989
  return;
15993
15990
  }
15994
15991
 
@@ -16019,10 +16016,9 @@ var unsetSides = {
16019
16016
  // Zooming can change the DPR, but it seems to report a value that will
16020
16017
  // cleanly divide the values into the appropriate subpixels.
16021
16018
 
16022
- function roundOffsetsByDPR(_ref) {
16019
+ function roundOffsetsByDPR(_ref, win) {
16023
16020
  var x = _ref.x,
16024
16021
  y = _ref.y;
16025
- var win = window;
16026
16022
  var dpr = win.devicePixelRatio || 1;
16027
16023
  return {
16028
16024
  x: round(x * dpr) / dpr || 0,
@@ -16105,7 +16101,7 @@ function mapToStyles(_ref2) {
16105
16101
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
16106
16102
  x: x,
16107
16103
  y: y
16108
- }) : {
16104
+ }, getWindow(popper)) : {
16109
16105
  x: x,
16110
16106
  y: y
16111
16107
  };
@@ -16131,17 +16127,6 @@ function computeStyles(_ref5) {
16131
16127
  adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
16132
16128
  _options$roundOffsets = options.roundOffsets,
16133
16129
  roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
16134
-
16135
- if (process.env.NODE_ENV !== "production") {
16136
- var transitionProperty = getComputedStyle$1(state.elements.popper).transitionProperty || '';
16137
-
16138
- if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
16139
- return transitionProperty.indexOf(property) >= 0;
16140
- })) {
16141
- 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(' '));
16142
- }
16143
- }
16144
-
16145
16130
  var commonStyles = {
16146
16131
  placement: getBasePlacement(state.placement),
16147
16132
  variation: getVariation(state.placement),
@@ -16582,10 +16567,6 @@ function computeAutoPlacement(state, options) {
16582
16567
 
16583
16568
  if (allowedPlacements.length === 0) {
16584
16569
  allowedPlacements = placements$1;
16585
-
16586
- if (process.env.NODE_ENV !== "production") {
16587
- 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(' '));
16588
- }
16589
16570
  } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
16590
16571
 
16591
16572
 
@@ -17137,108 +17118,6 @@ function debounce(fn) {
17137
17118
  };
17138
17119
  }
17139
17120
 
17140
- function format$1(str) {
17141
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
17142
- args[_key - 1] = arguments[_key];
17143
- }
17144
-
17145
- return [].concat(args).reduce(function (p, c) {
17146
- return p.replace(/%s/, c);
17147
- }, str);
17148
- }
17149
-
17150
- var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
17151
- var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
17152
- var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
17153
- function validateModifiers(modifiers) {
17154
- modifiers.forEach(function (modifier) {
17155
- [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
17156
- .filter(function (value, index, self) {
17157
- return self.indexOf(value) === index;
17158
- }).forEach(function (key) {
17159
- switch (key) {
17160
- case 'name':
17161
- if (typeof modifier.name !== 'string') {
17162
- console.error(format$1(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
17163
- }
17164
-
17165
- break;
17166
-
17167
- case 'enabled':
17168
- if (typeof modifier.enabled !== 'boolean') {
17169
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
17170
- }
17171
-
17172
- break;
17173
-
17174
- case 'phase':
17175
- if (modifierPhases.indexOf(modifier.phase) < 0) {
17176
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
17177
- }
17178
-
17179
- break;
17180
-
17181
- case 'fn':
17182
- if (typeof modifier.fn !== 'function') {
17183
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
17184
- }
17185
-
17186
- break;
17187
-
17188
- case 'effect':
17189
- if (modifier.effect != null && typeof modifier.effect !== 'function') {
17190
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
17191
- }
17192
-
17193
- break;
17194
-
17195
- case 'requires':
17196
- if (modifier.requires != null && !Array.isArray(modifier.requires)) {
17197
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
17198
- }
17199
-
17200
- break;
17201
-
17202
- case 'requiresIfExists':
17203
- if (!Array.isArray(modifier.requiresIfExists)) {
17204
- console.error(format$1(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
17205
- }
17206
-
17207
- break;
17208
-
17209
- case 'options':
17210
- case 'data':
17211
- break;
17212
-
17213
- default:
17214
- console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
17215
- return "\"" + s + "\"";
17216
- }).join(', ') + "; but \"" + key + "\" was provided.");
17217
- }
17218
-
17219
- modifier.requires && modifier.requires.forEach(function (requirement) {
17220
- if (modifiers.find(function (mod) {
17221
- return mod.name === requirement;
17222
- }) == null) {
17223
- console.error(format$1(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
17224
- }
17225
- });
17226
- });
17227
- });
17228
- }
17229
-
17230
- function uniqueBy(arr, fn) {
17231
- var identifiers = new Set();
17232
- return arr.filter(function (item) {
17233
- var identifier = fn(item);
17234
-
17235
- if (!identifiers.has(identifier)) {
17236
- identifiers.add(identifier);
17237
- return true;
17238
- }
17239
- });
17240
- }
17241
-
17242
17121
  function mergeByName(modifiers) {
17243
17122
  var merged = modifiers.reduce(function (merged, current) {
17244
17123
  var existing = merged[current.name];
@@ -17254,8 +17133,6 @@ function mergeByName(modifiers) {
17254
17133
  });
17255
17134
  }
17256
17135
 
17257
- var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
17258
- 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.';
17259
17136
  var DEFAULT_OPTIONS = {
17260
17137
  placement: 'bottom',
17261
17138
  modifiers: [],
@@ -17317,42 +17194,7 @@ function popperGenerator(generatorOptions) {
17317
17194
 
17318
17195
  state.orderedModifiers = orderedModifiers.filter(function (m) {
17319
17196
  return m.enabled;
17320
- }); // Validate the provided modifiers so that the consumer will get warned
17321
- // if one of the modifiers is invalid for any reason
17322
-
17323
- if (process.env.NODE_ENV !== "production") {
17324
- var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
17325
- var name = _ref.name;
17326
- return name;
17327
- });
17328
- validateModifiers(modifiers);
17329
-
17330
- if (getBasePlacement(state.options.placement) === auto) {
17331
- var flipModifier = state.orderedModifiers.find(function (_ref2) {
17332
- var name = _ref2.name;
17333
- return name === 'flip';
17334
- });
17335
-
17336
- if (!flipModifier) {
17337
- console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
17338
- }
17339
- }
17340
-
17341
- var _getComputedStyle = getComputedStyle$1(popper),
17342
- marginTop = _getComputedStyle.marginTop,
17343
- marginRight = _getComputedStyle.marginRight,
17344
- marginBottom = _getComputedStyle.marginBottom,
17345
- marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
17346
- // cause bugs with positioning, so we'll warn the consumer
17347
-
17348
-
17349
- if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
17350
- return parseFloat(margin);
17351
- })) {
17352
- 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(' '));
17353
- }
17354
- }
17355
-
17197
+ });
17356
17198
  runModifierEffects();
17357
17199
  return instance.update();
17358
17200
  },
@@ -17372,10 +17214,6 @@ function popperGenerator(generatorOptions) {
17372
17214
  // anymore
17373
17215
 
17374
17216
  if (!areValidElements(reference, popper)) {
17375
- if (process.env.NODE_ENV !== "production") {
17376
- console.error(INVALID_ELEMENT_ERROR);
17377
- }
17378
-
17379
17217
  return;
17380
17218
  } // Store the reference and popper rects to be read by modifiers
17381
17219
 
@@ -17398,18 +17236,8 @@ function popperGenerator(generatorOptions) {
17398
17236
  state.orderedModifiers.forEach(function (modifier) {
17399
17237
  return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
17400
17238
  });
17401
- var __debug_loops__ = 0;
17402
17239
 
17403
17240
  for (var index = 0; index < state.orderedModifiers.length; index++) {
17404
- if (process.env.NODE_ENV !== "production") {
17405
- __debug_loops__ += 1;
17406
-
17407
- if (__debug_loops__ > 100) {
17408
- console.error(INFINITE_LOOP_ERROR);
17409
- break;
17410
- }
17411
- }
17412
-
17413
17241
  if (state.reset === true) {
17414
17242
  state.reset = false;
17415
17243
  index = -1;
@@ -17447,10 +17275,6 @@ function popperGenerator(generatorOptions) {
17447
17275
  };
17448
17276
 
17449
17277
  if (!areValidElements(reference, popper)) {
17450
- if (process.env.NODE_ENV !== "production") {
17451
- console.error(INVALID_ELEMENT_ERROR);
17452
- }
17453
-
17454
17278
  return instance;
17455
17279
  }
17456
17280
 
@@ -17465,11 +17289,11 @@ function popperGenerator(generatorOptions) {
17465
17289
  // one.
17466
17290
 
17467
17291
  function runModifierEffects() {
17468
- state.orderedModifiers.forEach(function (_ref3) {
17469
- var name = _ref3.name,
17470
- _ref3$options = _ref3.options,
17471
- options = _ref3$options === void 0 ? {} : _ref3$options,
17472
- effect = _ref3.effect;
17292
+ state.orderedModifiers.forEach(function (_ref) {
17293
+ var name = _ref.name,
17294
+ _ref$options = _ref.options,
17295
+ options = _ref$options === void 0 ? {} : _ref$options,
17296
+ effect = _ref.effect;
17473
17297
 
17474
17298
  if (typeof effect === 'function') {
17475
17299
  var cleanupFn = effect({
@@ -20898,9 +20722,13 @@ var parseBooleanFlag = function (v, empty, other) {
20898
20722
 
20899
20723
  var marginBottomClass = "mb-2";
20900
20724
  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,}))$/);
20725
+ var phoneFormatRegexp = new RegExp(/^\+\d{1,3}[-\s]?(\(?\d+\)?[-\s]?)*\d{4,}$/);
20901
20726
  var checkEmailFormat = function (email) {
20902
20727
  return emailFormatRegexp.test(email);
20903
20728
  };
20729
+ var checkPhoneFormat = function (phone) {
20730
+ return phoneFormatRegexp.test(phone);
20731
+ };
20904
20732
  var signUpInfoCheckStyle = {
20905
20733
  position: 'absolute',
20906
20734
  opacity: 0,
@@ -20924,6 +20752,7 @@ var SignupForm = function (props) {
20924
20752
  var _b = useState(props.initialSignupData ? props.initialSignupData : {
20925
20753
  email: '',
20926
20754
  password: '',
20755
+ phone: '',
20927
20756
  confirmPassword: '',
20928
20757
  infoCheck: '',
20929
20758
  }), signupData = _b[0], setSignupData = _b[1];
@@ -20936,6 +20765,7 @@ var SignupForm = function (props) {
20936
20765
  var _g = useState(false), showEmailError = _g[0], setShowEmailError = _g[1];
20937
20766
  var _h = useState(false), showPasswordError = _h[0], setShowPasswordError = _h[1];
20938
20767
  var _j = useState(false), showConfirmPasswordError = _j[0], setShowConfirmPasswordError = _j[1];
20768
+ var _k = useState(false), showPhoneError = _k[0], setShowPhoneError = _k[1];
20939
20769
  var reCaptchaSiteKey = process.env.REACT_APP_RECAPTCHA_SITEKEY ? process.env.REACT_APP_RECAPTCHA_SITEKEY : '';
20940
20770
  var useRecaptcha = process.env.REACT_APP_USE_RECAPTCHA === 'true';
20941
20771
  var recaptchaRef = useRef(null);
@@ -20943,6 +20773,7 @@ var SignupForm = function (props) {
20943
20773
  setSignupData(props.initialSignupData ? props.initialSignupData : {
20944
20774
  email: '',
20945
20775
  password: '',
20776
+ phone: '',
20946
20777
  confirmPassword: '',
20947
20778
  infoCheck: '',
20948
20779
  });
@@ -20953,8 +20784,9 @@ var SignupForm = function (props) {
20953
20784
  };
20954
20785
  var isDisabled = function () {
20955
20786
  var emailOk = checkEmailFormat(signupData.email);
20787
+ var phoneOk = checkPhoneFormat(signupData.phone);
20956
20788
  var passwordRuleOk = checkPasswordRules(signupData.password);
20957
- return !(!props.isLoading && (!useRecaptcha || reCaptchaAccepted) && acceptedPrivacyPolicy && emailOk && passwordRuleOk && passwordsMatch());
20789
+ return !(!props.isLoading && (!useRecaptcha || reCaptchaAccepted) && acceptedPrivacyPolicy && emailOk && passwordRuleOk && phoneOk && passwordsMatch());
20958
20790
  };
20959
20791
  var submit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
20960
20792
  var reCaptchaToken, captchaResponse;
@@ -20996,6 +20828,8 @@ var SignupForm = function (props) {
20996
20828
  var passwordInputPlaceholder = t('signup.passwordInputPlaceholder');
20997
20829
  var confirmPasswordInputLabel = t('signup.confirmPasswordInputLabel');
20998
20830
  var confirmPasswordPlaceholder = t('signup.confirmPasswordInputLabel');
20831
+ var phoneInputLabel = t('signup.phoneInputLabel');
20832
+ var phoneInputPlaceholder = t('signup.phoneInputPlaceholder');
20999
20833
  var dialogSize = consentDialogSize();
21000
20834
  return (jsxs(React__default$1.Fragment, { children: [infoText && infoText.length > 0 ?
21001
20835
  jsx(AlertBox, { type: "info", className: marginBottomClass, content: infoText }, void 0) : null, useRecaptcha && reCaptchaAccepted ? jsx("div", { children: reCaptchaSiteKey ?
@@ -21015,6 +20849,11 @@ var SignupForm = function (props) {
21015
20849
  }, onChange: function (event) {
21016
20850
  var value = event.target.value;
21017
20851
  setSignupData(function (prev) { return __assign(__assign({}, prev), { confirmPassword: value }); });
20852
+ } }, void 0), jsx(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 () {
20853
+ setShowPhoneError(true);
20854
+ }, onChange: function (event) {
20855
+ var value = event.target.value;
20856
+ setSignupData(function (prev) { return __assign(__assign({}, prev), { phone: value }); });
21018
20857
  } }, void 0), jsx("label", { style: signUpInfoCheckStyle, "aria-hidden": "true", htmlFor: 'name' }, void 0), jsx("input", { style: signUpInfoCheckStyle, type: "text", id: "name", name: "name", value: signupData.infoCheck, tabIndex: -1, autoComplete: 'off', onChange: function (event) {
21019
20858
  var value = event.target.value;
21020
20859
  setSignupData(function (prev) { return __assign(__assign({}, prev), { infoCheck: value }); });
@@ -21095,6 +20934,7 @@ var Signup = function () {
21095
20934
  return [4 /*yield*/, signupWithEmailRequest({
21096
20935
  email: data.email,
21097
20936
  password: data.password,
20937
+ phone: data.phone,
21098
20938
  infoCheck: data.infoCheck,
21099
20939
  instanceId: instanceId,
21100
20940
  preferredLanguage: i18n.language,
@@ -21207,6 +21047,16 @@ var changeAccountEmailReq = function (newEmail, keepOldEmail, password) {
21207
21047
  password: password,
21208
21048
  });
21209
21049
  };
21050
+ var changeAccountPhoneReq = function (newPhone) {
21051
+ return authApiInstance.post("/v1/user/contact/change-phone", {
21052
+ newPhone: newPhone
21053
+ });
21054
+ };
21055
+ var newAccountPhoneReq = function (newPhone) {
21056
+ return authApiInstance.post("/v1/user/contact/add-phone", {
21057
+ newPhone: newPhone
21058
+ });
21059
+ };
21210
21060
  var setPreferredLanguageReq = function (languageCode) {
21211
21061
  return authApiInstance.post("/v1/user/set-language", { languageCode: languageCode });
21212
21062
  };
@@ -21261,17 +21111,29 @@ var revokeAllRefreshTokensReq = function () {
21261
21111
  };
21262
21112
  var deleteAccountReq = function (userId) {
21263
21113
  return authApiInstance.post("/v1/user/delete", { userId: userId });
21114
+ };
21115
+ var deletePhoneReq = function () {
21116
+ return authApiInstance.delete("/v1/user/contact/delete-phone");
21117
+ };
21118
+ // WhatsApp Verification API
21119
+ var verifyWhatsAppCodeReq = function (code) {
21120
+ return authApiInstance.post("/v1/user/contact/verify-whatsapp", {
21121
+ code: code,
21122
+ });
21264
21123
  };
21265
21124
 
21266
21125
  var userAPI = /*#__PURE__*/Object.freeze({
21267
21126
  __proto__: null,
21268
21127
  addEmailReq: addEmailReq,
21269
21128
  changeAccountEmailReq: changeAccountEmailReq,
21129
+ changeAccountPhoneReq: changeAccountPhoneReq,
21270
21130
  changePasswordReq: changePasswordReq,
21271
21131
  deleteAccountReq: deleteAccountReq,
21132
+ deletePhoneReq: deletePhoneReq,
21272
21133
  getInfosForPasswordResetReq: getInfosForPasswordResetReq,
21273
21134
  getUserReq: getUserReq,
21274
21135
  initiatePasswordResetReq: initiatePasswordResetReq,
21136
+ newAccountPhoneReq: newAccountPhoneReq,
21275
21137
  removeEmailReq: removeEmailReq,
21276
21138
  removeProfileReq: removeProfileReq,
21277
21139
  resendVerificationEmailReq: resendVerificationEmailReq,
@@ -21281,7 +21143,8 @@ var userAPI = /*#__PURE__*/Object.freeze({
21281
21143
  setPreferredLanguageReq: setPreferredLanguageReq,
21282
21144
  unsubscribeNewsletterReq: unsubscribeNewsletterReq,
21283
21145
  updateContactPreferencesReq: updateContactPreferencesReq,
21284
- verifyContactReq: verifyContactReq
21146
+ verifyContactReq: verifyContactReq,
21147
+ verifyWhatsAppCodeReq: verifyWhatsAppCodeReq
21285
21148
  });
21286
21149
 
21287
21150
  var SignupSuccess = function () {
@@ -21624,17 +21487,21 @@ var ChangeLanguage = function (props) {
21624
21487
  };
21625
21488
 
21626
21489
  var ChangeNotifications = function (props) {
21627
- var _a;
21490
+ var _a, _b;
21628
21491
  var t = useTranslation(['dialogs']).t;
21629
21492
  var dispatch = useDispatch();
21630
21493
  var dialogState = useSelector(function (state) { return state.dialog; });
21631
21494
  var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'changeNotifications';
21632
21495
  var currentUser = useSelector(function (state) { return state.user.currentUser; });
21633
- var _b = useState(false), loading = _b[0], setLoading = _b[1];
21634
- var _c = useState(''), error = _c[0], setError = _c[1];
21635
- var _d = useState(false), changed = _d[0], setChanged = _d[1];
21636
- var _e = useState(false), weeklyEnabled = _e[0], setWeeklyEnabled = _e[1];
21637
- var _f = useState(false), newsletterEnabled = _f[0], setNewsletterEnabled = _f[1];
21496
+ var _c = useState(false), loading = _c[0], setLoading = _c[1];
21497
+ var _d = useState(''), error = _d[0], setError = _d[1];
21498
+ var _e = useState(false), changed = _e[0], setChanged = _e[1];
21499
+ var _f = useState(false), weeklyEnabled = _f[0], setWeeklyEnabled = _f[1];
21500
+ var _g = useState(false), weeklyPhone = _g[0], setWeeklyPhone = _g[1];
21501
+ var _h = useState(false), newsletterEnabled = _h[0], setNewsletterEnabled = _h[1];
21502
+ var phoneInfo = currentUser.contactInfos.find(function (info) { return info.type === 'phone'; });
21503
+ var isPhonePresent = phoneInfo ? true : false;
21504
+ var confirmedPhone = ((_b = phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.confirmedAt) !== null && _b !== void 0 ? _b : 0) > 0 ? true : false;
21638
21505
  useEffect(function () {
21639
21506
  if (open) {
21640
21507
  fetchUser();
@@ -21642,8 +21509,10 @@ var ChangeNotifications = function (props) {
21642
21509
  // eslint-disable-next-line react-hooks/exhaustive-deps
21643
21510
  }, [open]);
21644
21511
  useEffect(function () {
21512
+ var _a;
21645
21513
  setNewsletterEnabled(currentUser.contactPreferences.subscribedToNewsletter ? true : false);
21646
21514
  setWeeklyEnabled(currentUser.contactPreferences.subscribedToWeekly ? true : false);
21515
+ setWeeklyPhone(currentUser.contactPreferences.sendNewsletterTo.includes((_a = phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.id) !== null && _a !== void 0 ? _a : '') ? true : false);
21647
21516
  }, [currentUser]);
21648
21517
  var fetchUser = function () { return __awaiter(void 0, void 0, void 0, function () {
21649
21518
  var user, e_1;
@@ -21686,6 +21555,12 @@ var ChangeNotifications = function (props) {
21686
21555
  setLoading(true);
21687
21556
  setError("");
21688
21557
  contactPreferences = __assign(__assign({}, currentUser.contactPreferences), { subscribedToWeekly: weeklyEnabled, subscribedToNewsletter: newsletterEnabled });
21558
+ if (weeklyPhone && isPhonePresent && confirmedPhone && (phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.id)) {
21559
+ contactPreferences.sendNewsletterTo = __spreadArray$1(__spreadArray$1([], contactPreferences.sendNewsletterTo, true), [phoneInfo.id], false);
21560
+ }
21561
+ if (!weeklyPhone && isPhonePresent && confirmedPhone && (phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.id)) {
21562
+ contactPreferences.sendNewsletterTo = contactPreferences.sendNewsletterTo.filter(function (id) { return id !== phoneInfo.id; });
21563
+ }
21689
21564
  _a.label = 1;
21690
21565
  case 1:
21691
21566
  _a.trys.push([1, 3, , 4]);
@@ -21718,7 +21593,12 @@ var ChangeNotifications = function (props) {
21718
21593
  setWeeklyEnabled(value);
21719
21594
  } }, { children: weeklyEnabled ?
21720
21595
  t('dialogs:changeNotifications.weeklyReminder.on') :
21721
- t('dialogs:changeNotifications.weeklyReminder.off') }), void 0), jsx("label", __assign({ className: "mt-2 mb-1 form-label", htmlFor: "newsletter" }, { children: t('dialogs:changeNotifications.newsletter.label') }), void 0), jsx(Checkbox, __assign({ id: "newsletter", name: "newsletter", checked: newsletterEnabled, onChange: function (value) {
21596
+ t('dialogs:changeNotifications.weeklyReminder.off') }), void 0), jsx("label", __assign({ className: "mb-1 form-label mt-2", htmlFor: "weeklyPhone" }, { children: t('dialogs:changeNotifications.weeklyReminderPhone.label') }), void 0), confirmedPhone && (jsx(Checkbox, __assign({ id: "weeklyPhone", name: "weeklyPhone", checked: weeklyPhone, onChange: function (value) {
21597
+ setChanged(true);
21598
+ setWeeklyPhone(value);
21599
+ } }, { children: weeklyPhone ?
21600
+ t('dialogs:changeNotifications.weeklyReminderPhone.on') :
21601
+ t('dialogs:changeNotifications.weeklyReminderPhone.off') }), void 0)), (!confirmedPhone && !isPhonePresent) && (jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'addPhone' })); } }, { children: t('dialogs:changeNotifications.addPhone') }), void 0)), (!confirmedPhone && isPhonePresent) && (jsx(AlertBox, { className: "mt-2", type: "info", content: t('changeNotifications.phoneNotConfirmed') }, void 0)), (!confirmedPhone && isPhonePresent) && (jsx(Button$1, __assign({ className: "mt-2", onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'addPhone' })); }, variant: "link" }, { children: t('dialogs:changeNotifications.verifyPhone') }), void 0)), jsx("label", __assign({ className: "mt-2 mb-1 form-label", htmlFor: "newsletter" }, { children: t('dialogs:changeNotifications.newsletter.label') }), void 0), jsx(Checkbox, __assign({ id: "newsletter", name: "newsletter", checked: newsletterEnabled, onChange: function (value) {
21722
21602
  setChanged(true);
21723
21603
  setNewsletterEnabled(value);
21724
21604
  } }, { children: newsletterEnabled ?
@@ -22374,11 +22254,353 @@ var PasswordForgotten = function () {
22374
22254
  return (jsx(Dialog, __assign({ open: open, title: t('passwordForgotten.title'), onClose: handleClose, ariaLabelledBy: "passwordForgottenTitle" }, { children: jsxs("div", __assign({ className: clsx(defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: [jsx(AlertBox, { className: "mb-2", type: "info", useIcon: false, content: t('passwordForgotten.info') }, void 0), jsx(AlertBox, { className: "mb-2", hide: !success, type: "success", useIcon: true, content: t('passwordForgotten.successMessage') }, void 0), jsx(AlertBox, { className: "mb-2", hide: !error, type: "danger", useIcon: true, content: error, closable: true, onClose: function () { return setError(''); } }, void 0), jsxs("form", __assign({ onSubmit: onResetPasswordClicked }, { children: [jsx(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), jsx(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));
22375
22255
  };
22376
22256
 
22257
+ var ChangePhone = function () {
22258
+ var _a;
22259
+ var t = useTranslation(['dialogs']).t;
22260
+ var dispatch = useDispatch();
22261
+ var dialogState = useSelector(function (state) { return state.dialog; });
22262
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'changePhone';
22263
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
22264
+ var _c = useState(''), error = _c[0], setError = _c[1];
22265
+ var _d = useState(false), openConfirm = _d[0], setOpenConfirm = _d[1];
22266
+ var _e = useState({
22267
+ newPhone: ''
22268
+ }), formData = _e[0], setFormData = _e[1];
22269
+ useEffect(function () {
22270
+ if (!open) {
22271
+ resetForm();
22272
+ }
22273
+ }, [open]);
22274
+ var resetForm = function () {
22275
+ setLoading(false);
22276
+ setError('');
22277
+ setFormData({
22278
+ newPhone: ''
22279
+ });
22280
+ };
22281
+ var handleClose = function () {
22282
+ dispatch(dialogActions.closeDialog());
22283
+ };
22284
+ var changePhone = function () { return __awaiter(void 0, void 0, void 0, function () {
22285
+ var response, userData, e_1, errorResponse;
22286
+ var _a, _b;
22287
+ return __generator$1(this, function (_c) {
22288
+ switch (_c.label) {
22289
+ case 0:
22290
+ setLoading(true);
22291
+ setError("");
22292
+ _c.label = 1;
22293
+ case 1:
22294
+ _c.trys.push([1, 6, 7, 8]);
22295
+ return [4 /*yield*/, changeAccountPhoneReq(formData.newPhone)];
22296
+ case 2:
22297
+ response = _c.sent();
22298
+ if (!(response.status === 200)) return [3 /*break*/, 5];
22299
+ renewToken();
22300
+ if (!response.data) return [3 /*break*/, 3];
22301
+ dispatch(userActions.setUser(response.data));
22302
+ return [3 /*break*/, 5];
22303
+ case 3: return [4 /*yield*/, getUserReq()];
22304
+ case 4:
22305
+ userData = (_c.sent()).data;
22306
+ dispatch(userActions.setUser(userData));
22307
+ _c.label = 5;
22308
+ case 5:
22309
+ dispatch(dialogActions.openVerifyWhatsAppDialog({
22310
+ type: 'verifyWhatsApp',
22311
+ payload: {
22312
+ phoneNumber: formData.newPhone,
22313
+ }
22314
+ }));
22315
+ return [3 /*break*/, 8];
22316
+ case 6:
22317
+ e_1 = _c.sent();
22318
+ console.error(e_1);
22319
+ errorResponse = e_1;
22320
+ handleError((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error);
22321
+ return [3 /*break*/, 8];
22322
+ case 7:
22323
+ setLoading(false);
22324
+ return [7 /*endfinally*/];
22325
+ case 8: return [2 /*return*/];
22326
+ }
22327
+ });
22328
+ }); };
22329
+ var handleError = function (errorMsg) {
22330
+ switch (errorMsg) {
22331
+ case 'action failed':
22332
+ setError(t('changePhone.errors.wrongPasswordOrAccountId'));
22333
+ break;
22334
+ case 'phone not valid':
22335
+ setError(t('changePhone.errors.wrongPhoneFormat'));
22336
+ break;
22337
+ default:
22338
+ setError(t('changePhone.errors.unknown'));
22339
+ break;
22340
+ }
22341
+ };
22342
+ var onSubmit = function (event) {
22343
+ event.preventDefault();
22344
+ setOpenConfirm(true);
22345
+ };
22346
+ var buttonDisabled = function () {
22347
+ return loading || formData.newPhone.length < 8;
22348
+ };
22349
+ return (jsxs(Dialog, __assign({ open: open, title: t('changePhone.title'), onClose: handleClose, ariaLabelledBy: "changePhoneDialogTitle" }, { children: [jsx("div", __assign({ className: clsx(defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: jsxs("form", __assign({ onSubmit: onSubmit }, { children: [jsx(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) {
22350
+ var value = event.target.value;
22351
+ setFormData(function (prev) { return __assign(__assign({}, prev), { newPhone: value }); });
22352
+ } }, void 0), jsx(AlertBox, { type: "info", content: t('changePhone.info') }, void 0), jsx(AlertBox, { type: "danger", className: "mt-2", hide: !error, closable: true, useIcon: true, onClose: function () { return setError(""); }, 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('changePhone.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsx(DialogBtn, { className: "mt-2", type: "submit", color: "primary", loading: loading, disabled: buttonDisabled(), label: t('changePhone.confirmBtn') }, void 0)] }), void 0)] }), void 0) }), void 0), jsx(ConfirmDialog, __assign({ open: openConfirm, title: t('changePhone.warningDialog.title'), onConfirm: function () {
22353
+ setOpenConfirm(false);
22354
+ changePhone();
22355
+ }, color: "warning", onClose: function () { return setOpenConfirm(false); }, cancelText: t('changePhone.warningDialog.cancelBtn'), confirmText: t('changePhone.warningDialog.confirmBtn') }, { children: jsx(AlertBox, { type: "warning", content: t('changePhone.warningDialog.content') }, void 0) }), void 0)] }), void 0));
22356
+ };
22357
+
22358
+ var DeletePhone = function (props) {
22359
+ var _a;
22360
+ var t = useTranslation(['dialogs']).t;
22361
+ var dispatch = useDispatch();
22362
+ var dialogState = useSelector(function (state) { return state.dialog; });
22363
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'deletePhone';
22364
+ useSelector(function (state) { return state.user; });
22365
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
22366
+ var _c = useState(''), error = _c[0], setError = _c[1];
22367
+ var handleClose = function () {
22368
+ setError('');
22369
+ setLoading(false);
22370
+ dispatch(dialogActions.closeDialog());
22371
+ };
22372
+ var onDeletePhone = function () { return __awaiter(void 0, void 0, void 0, function () {
22373
+ var response, userData_1, userData, e_1, err;
22374
+ return __generator$1(this, function (_a) {
22375
+ switch (_a.label) {
22376
+ case 0:
22377
+ setLoading(true);
22378
+ _a.label = 1;
22379
+ case 1:
22380
+ _a.trys.push([1, 7, , 8]);
22381
+ return [4 /*yield*/, deletePhoneReq()];
22382
+ case 2:
22383
+ response = _a.sent();
22384
+ if (!(response.status === 200)) return [3 /*break*/, 5];
22385
+ if (!response.data) return [3 /*break*/, 3];
22386
+ dispatch(userActions.setUser(response.data));
22387
+ return [3 /*break*/, 5];
22388
+ case 3: return [4 /*yield*/, getUserReq()];
22389
+ case 4:
22390
+ userData_1 = (_a.sent()).data;
22391
+ dispatch(userActions.setUser(userData_1));
22392
+ _a.label = 5;
22393
+ case 5:
22394
+ dispatch(dialogActions.openAlertDialog({
22395
+ type: 'alertDialog',
22396
+ payload: {
22397
+ color: 'success',
22398
+ title: t('dialogs:deletePhone.successDialog.title'),
22399
+ content: t('dialogs:deletePhone.successDialog.content'),
22400
+ btn: t('dialogs:deletePhone.successDialog.btn'),
22401
+ }
22402
+ }));
22403
+ return [4 /*yield*/, getUserReq()];
22404
+ case 6:
22405
+ userData = (_a.sent()).data;
22406
+ dispatch(userActions.setUser(userData));
22407
+ return [3 /*break*/, 8];
22408
+ case 7:
22409
+ e_1 = _a.sent();
22410
+ err = getErrorMsg(e_1);
22411
+ setError(err);
22412
+ setLoading(false);
22413
+ return [3 /*break*/, 8];
22414
+ case 8: return [2 /*return*/];
22415
+ }
22416
+ });
22417
+ }); };
22418
+ return (jsx(Dialog, __assign({ open: open, title: t('deletePhone.title'), color: "danger", onClose: handleClose, ariaLabelledBy: "deletePhoneDialogTitle" }, { children: jsxs("div", __assign({ className: clsx(defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: [jsx(AlertBox, { type: "danger", content: t('dialogs:deletePhone.info') }, void 0), jsx(AlertBox, { className: "mt-2", type: "danger", hide: !error, closable: true, onClose: function () { return setError(''); }, content: error }, void 0), jsxs("div", __assign({ className: "d-flex flex-wrap" }, { children: [jsx(DialogBtn, { className: "mt-2 me-2", type: "button", color: "primary", label: t('deletePhone.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsx(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));
22419
+ };
22420
+
22421
+ var AddPhone = function () {
22422
+ var _a;
22423
+ var t = useTranslation(['dialogs']).t;
22424
+ var dispatch = useDispatch();
22425
+ var dialogState = useSelector(function (state) { return state.dialog; });
22426
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'addPhone';
22427
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
22428
+ var _c = useState(''), error = _c[0], setError = _c[1];
22429
+ var _d = useState(false), openConfirm = _d[0], setOpenConfirm = _d[1];
22430
+ var _e = useState({
22431
+ newPhone: ''
22432
+ }), formData = _e[0], setFormData = _e[1];
22433
+ useEffect(function () {
22434
+ if (!open) {
22435
+ resetForm();
22436
+ }
22437
+ }, [open]);
22438
+ var resetForm = function () {
22439
+ setLoading(false);
22440
+ setError('');
22441
+ setFormData({
22442
+ newPhone: ''
22443
+ });
22444
+ };
22445
+ var handleClose = function () {
22446
+ dispatch(dialogActions.closeDialog());
22447
+ };
22448
+ var addPhone = function () { return __awaiter(void 0, void 0, void 0, function () {
22449
+ var response, userData, e_1, errorResponse;
22450
+ var _a, _b;
22451
+ return __generator$1(this, function (_c) {
22452
+ switch (_c.label) {
22453
+ case 0:
22454
+ setLoading(true);
22455
+ setError("");
22456
+ _c.label = 1;
22457
+ case 1:
22458
+ _c.trys.push([1, 7, 8, 9]);
22459
+ return [4 /*yield*/, newAccountPhoneReq(formData.newPhone)];
22460
+ case 2:
22461
+ response = _c.sent();
22462
+ if (!(response.status === 200)) return [3 /*break*/, 6];
22463
+ renewToken();
22464
+ if (!response.data) return [3 /*break*/, 3];
22465
+ dispatch(userActions.setUser(response.data));
22466
+ return [3 /*break*/, 5];
22467
+ case 3: return [4 /*yield*/, getUserReq()];
22468
+ case 4:
22469
+ userData = (_c.sent()).data;
22470
+ dispatch(userActions.setUser(userData));
22471
+ _c.label = 5;
22472
+ case 5:
22473
+ dispatch(dialogActions.openVerifyWhatsAppDialog({
22474
+ type: 'verifyWhatsApp',
22475
+ payload: {
22476
+ phoneNumber: formData.newPhone,
22477
+ }
22478
+ }));
22479
+ _c.label = 6;
22480
+ case 6: return [3 /*break*/, 9];
22481
+ case 7:
22482
+ e_1 = _c.sent();
22483
+ console.error(e_1);
22484
+ errorResponse = e_1;
22485
+ handleError((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error);
22486
+ return [3 /*break*/, 9];
22487
+ case 8:
22488
+ setLoading(false);
22489
+ return [7 /*endfinally*/];
22490
+ case 9: return [2 /*return*/];
22491
+ }
22492
+ });
22493
+ }); };
22494
+ var handleError = function (errorMsg) {
22495
+ switch (errorMsg) {
22496
+ case 'action failed':
22497
+ setError(t('addPhone.errors.wrongPasswordOrAccountId'));
22498
+ break;
22499
+ case 'phone not valid':
22500
+ setError(t('addPhone.errors.wrongPhoneFormat'));
22501
+ break;
22502
+ default:
22503
+ setError(t('addPhone.errors.unknown'));
22504
+ break;
22505
+ }
22506
+ };
22507
+ var onSubmit = function (event) {
22508
+ event.preventDefault();
22509
+ setOpenConfirm(true);
22510
+ };
22511
+ var buttonDisabled = function () {
22512
+ return loading || formData.newPhone.length < 8;
22513
+ };
22514
+ return (jsxs(Dialog, __assign({ open: open, title: t('addPhone.title'), onClose: handleClose, ariaLabelledBy: "addPhoneDialogTitle" }, { children: [jsx("div", __assign({ className: clsx(defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: jsxs("form", __assign({ onSubmit: onSubmit }, { children: [jsx(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) {
22515
+ var value = event.target.value;
22516
+ setFormData(function (prev) { return __assign(__assign({}, prev), { newPhone: value }); });
22517
+ } }, void 0), jsx(AlertBox, { type: "info", content: t('addPhone.info') }, void 0), jsx(AlertBox, { type: "danger", className: "mt-2", hide: !error, closable: true, useIcon: true, onClose: function () { return setError(""); }, 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('addPhone.cancelBtn'), onClick: function () { return handleClose(); } }, void 0), jsx(DialogBtn, { className: "mt-2", type: "submit", color: "primary", loading: loading, disabled: buttonDisabled(), label: t('addPhone.confirmBtn') }, void 0)] }), void 0)] }), void 0) }), void 0), jsx(ConfirmDialog, __assign({ open: openConfirm, title: t('addPhone.warningDialog.title'), onConfirm: function () {
22518
+ setOpenConfirm(false);
22519
+ addPhone();
22520
+ }, color: "warning", onClose: function () { return setOpenConfirm(false); }, cancelText: t('addPhone.warningDialog.cancelBtn'), confirmText: t('addPhone.warningDialog.confirmBtn') }, { children: jsx(AlertBox, { type: "warning", content: t('addPhone.warningDialog.content') }, void 0) }), void 0)] }), void 0));
22521
+ };
22522
+
22523
+ var VerifyWhatsApp = function () {
22524
+ var _a;
22525
+ var dispatch = useDispatch();
22526
+ var t = useTranslation(['dialogs']).t;
22527
+ var dialogState = useSelector(function (state) { return state.dialog; });
22528
+ var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'verifyWhatsApp';
22529
+ var dialogContent = open ? dialogState.config.payload : undefined;
22530
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
22531
+ var _c = useState(''), error = _c[0], setError = _c[1];
22532
+ var _d = useState(''), verificationCode = _d[0], setVerificationCode = _d[1];
22533
+ var phoneNumber = (dialogContent === null || dialogContent === void 0 ? void 0 : dialogContent.phoneNumber) || '';
22534
+ var close = function () {
22535
+ dispatch(dialogActions.closeDialog());
22536
+ setVerificationCode('');
22537
+ setError('');
22538
+ };
22539
+ var verifyCode = function () { return __awaiter(void 0, void 0, void 0, function () {
22540
+ var response, userData, e_1, errorResponse;
22541
+ var _a, _b;
22542
+ return __generator$1(this, function (_c) {
22543
+ switch (_c.label) {
22544
+ case 0:
22545
+ if (!verificationCode.trim()) {
22546
+ setError(t('verifyWhatsApp.errors.codeRequired'));
22547
+ return [2 /*return*/];
22548
+ }
22549
+ setLoading(true);
22550
+ setError('');
22551
+ _c.label = 1;
22552
+ case 1:
22553
+ _c.trys.push([1, 7, 8, 9]);
22554
+ return [4 /*yield*/, verifyWhatsAppCodeReq(verificationCode)];
22555
+ case 2:
22556
+ response = _c.sent();
22557
+ if (!(response.status === 200)) return [3 /*break*/, 6];
22558
+ renewToken();
22559
+ if (!response.data) return [3 /*break*/, 3];
22560
+ dispatch(userActions.setUser(response.data));
22561
+ return [3 /*break*/, 5];
22562
+ case 3: return [4 /*yield*/, getUserReq()];
22563
+ case 4:
22564
+ userData = (_c.sent()).data;
22565
+ dispatch(userActions.setUser(userData));
22566
+ _c.label = 5;
22567
+ case 5:
22568
+ // Show success message
22569
+ dispatch(dialogActions.openAlertDialog({
22570
+ type: 'alertDialog',
22571
+ payload: {
22572
+ color: 'success',
22573
+ title: t('verifyWhatsApp.successDialog.title'),
22574
+ content: t('verifyWhatsApp.successDialog.content'),
22575
+ btn: t('verifyWhatsApp.successDialog.btn'),
22576
+ }
22577
+ }));
22578
+ _c.label = 6;
22579
+ case 6: return [3 /*break*/, 9];
22580
+ case 7:
22581
+ e_1 = _c.sent();
22582
+ console.error(e_1);
22583
+ errorResponse = e_1;
22584
+ 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'));
22585
+ return [3 /*break*/, 9];
22586
+ case 8:
22587
+ setLoading(false);
22588
+ return [7 /*endfinally*/];
22589
+ case 9: return [2 /*return*/];
22590
+ }
22591
+ });
22592
+ }); };
22593
+ if (!open) {
22594
+ return null;
22595
+ }
22596
+ return (jsxs(Dialog, __assign({ open: open, title: t('verifyWhatsApp.title'), ariaLabelledBy: "verify-whatsapp-title", onClose: close, size: "sm" }, { children: [jsxs("div", __assign({ className: defaultDialogPaddingXClass }, { children: [jsx("div", __assign({ className: "mb-3" }, { children: jsx("p", { children: t('verifyWhatsApp.description', { phoneNumber: phoneNumber }) }, void 0) }), void 0), error && (jsx(AlertBox, { type: "danger", content: error, className: "mb-3" }, void 0)), jsx(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), jsxs("div", __assign({ className: "d-flex justify-content-end gap-2 p-3" }, { children: [jsx(DialogBtn, { type: "button", onClick: close, label: t('buttons.cancel'), disabled: loading }, void 0), jsx(DialogBtn, { type: "button", onClick: verifyCode, color: "primary", label: t('verifyWhatsApp.form.submit'), loading: loading, disabled: !verificationCode.trim() }, void 0)] }), void 0)] }), void 0));
22597
+ };
22598
+
22377
22599
  var GlobalDialogs = function (props) {
22378
22600
  var isAuth = useIsAuthenticated();
22379
22601
  var hasToken = useAuthTokenCheck();
22380
22602
  var authDialogs = function () {
22381
- return jsxs(React__default$1.Fragment, { children: [jsx(ChangeEmail, {}, void 0), jsx(ChangePassword, {}, void 0), jsx(ChangeLanguage, { onChangeLanguage: props.onChangeLanguage }, void 0), jsx(ChangeNotifications, {}, void 0), jsx(DeleteAccount$1, {}, void 0)] }, void 0);
22603
+ return jsxs(React__default$1.Fragment, { children: [jsx(ChangeEmail, {}, void 0), jsx(ChangePhone, {}, void 0), jsx(AddPhone, {}, void 0), jsx(VerifyWhatsApp, {}, void 0), jsx(ChangePassword, {}, void 0), jsx(ChangeLanguage, { onChangeLanguage: props.onChangeLanguage }, void 0), jsx(ChangeNotifications, {}, void 0), jsx(DeleteAccount$1, {}, void 0), jsx(DeletePhone, {}, void 0)] }, void 0);
22382
22604
  };
22383
22605
  return (jsxs(React__default$1.Fragment, { children: [jsx(Login, { defaultRoutes: props.defaultRoutes }, void 0), jsx(Signup, {}, void 0), jsx(SignupSuccess, {}, void 0), jsx(PasswordForgotten, {}, void 0), jsx(AlertDialog, {}, void 0), hasToken ? jsx(ManageProfiles, {}, void 0) : null, isAuth ? authDialogs() : null] }, void 0));
22384
22606
  };
@@ -23689,6 +23911,13 @@ var blurEmail = function (email) {
23689
23911
  return items[0][0] + '****@' + items.slice(1).join('');
23690
23912
  };
23691
23913
 
23914
+ var blurPhone = function (phone) {
23915
+ if (phone.length < 4) {
23916
+ return '****';
23917
+ }
23918
+ return phone.slice(0, 2) + '****' + phone.slice(-2);
23919
+ };
23920
+
23692
23921
  var AccountSettings = function (props) {
23693
23922
  var t = useTranslation(['settings']).t;
23694
23923
  var isAuth = useIsAuthenticated();
@@ -23697,13 +23926,16 @@ var AccountSettings = function (props) {
23697
23926
  if (!isAuth) {
23698
23927
  return jsx("div", __assign({ className: "bg-warning-light p-3" }, { children: 'authentication needed' }), void 0);
23699
23928
  }
23929
+ var phoneInfo = currentUser.contactInfos.find(function (info) { return info.type === 'phone'; });
23700
23930
  var renderProfileSettings = function () {
23701
23931
  if (props.hideProfileSettings === true) {
23702
23932
  return null;
23703
23933
  }
23704
23934
  return jsxs(React__default$1.Fragment, { children: [jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".profiles.title")) }), void 0), jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".profiles.info")) }), void 0), jsx(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);
23705
23935
  };
23706
- return (jsxs("div", __assign({ className: "border-primary border-top-2 pt-2" }, { children: [jsx("h2", { children: t("".concat(props.itemKey, ".title")) }, void 0), jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".email.title")) }), void 0), jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".email.info")) }), void 0), jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changeEmail' })); } }, { children: blurEmail(currentUser.account.accountId) }), void 0), jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".password.title")) }), void 0), jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".password.info")) }), void 0), jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changePassword' })); } }, { children: "••••••••••••••" }), void 0), renderProfileSettings()] }), void 0));
23936
+ return (jsxs("div", __assign({ className: "border-primary border-top-2 pt-2" }, { children: [jsx("h2", { children: t("".concat(props.itemKey, ".title")) }, void 0), jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".email.title")) }), void 0), jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".email.info")) }), void 0), jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changeEmail' })); } }, { children: blurEmail(currentUser.account.accountId) }), void 0), jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".phone.title")) }), void 0), phoneInfo ? (jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".phone.info")) }), void 0)) : (jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".phone.infoAdd")) }), void 0)), jsxs("div", __assign({ className: "m-0 d-flex align-items-center py-2" }, { children: [phoneInfo ? (jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changePhone' })); } }, { children: blurPhone(phoneInfo.phone) }), void 0)) : (jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'addPhone' })); } }, { children: t("".concat(props.itemKey, ".phone.btn")) }), void 0)), phoneInfo && (jsx("button", __assign({ className: "btn btn-danger-light", onClick: function () {
23937
+ dispatch(dialogActions.openDialogWithoutPayload({ type: 'deletePhone' }));
23938
+ } }, { children: jsx("i", { className: "fas fa-trash text-grey-5" }, void 0) }), void 0))] }), void 0), jsx("h4", __assign({ className: "fw-bold mt-2" }, { children: t("".concat(props.itemKey, ".password.title")) }), void 0), jsx("p", __assign({ className: "mb-1 text-grey-7" }, { children: t("".concat(props.itemKey, ".password.info")) }), void 0), jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changePassword' })); } }, { children: "••••••••••••••" }), void 0), renderProfileSettings()] }), void 0));
23707
23939
  };
23708
23940
 
23709
23941
  var CommunicationSettings = function (props) {