@influenzanet/case-web-app-core 2.8.0 → 2.8.1-staging

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,3 +22,4 @@ export declare const revokeAllRefreshTokensReq: () => Promise<import("axios").Ax
22
22
  export declare const deleteAccountReq: (userId: string) => Promise<import("axios").AxiosResponse<ServiceStatus, any>>;
23
23
  export declare const deletePhoneReq: () => Promise<import("axios").AxiosResponse<User, any>>;
24
24
  export declare const verifyWhatsAppCodeReq: (code: string) => Promise<import("axios").AxiosResponse<User, any>>;
25
+ export declare const resendWhatsAppCodeReq: () => Promise<import("axios").AxiosResponse<ServiceStatus, any>>;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ export declare const COUNTRY_CODES: {
3
+ code: string;
4
+ country: string;
5
+ name: string;
6
+ }[];
7
+ interface PhoneNumberInputProps {
8
+ value: string;
9
+ onChange: (fullPhoneNumber: string) => void;
10
+ label?: string;
11
+ placeholder?: string;
12
+ className?: string;
13
+ autoFocus?: boolean;
14
+ disabled?: boolean;
15
+ error?: string;
16
+ onBlur?: () => void;
17
+ }
18
+ declare const PhoneNumberInput: React.FC<PhoneNumberInputProps>;
19
+ export default PhoneNumberInput;
@@ -0,0 +1 @@
1
+ export { default as PhoneNumberInput } from './PhoneNumberInput';
package/build/index.d.ts CHANGED
@@ -11,6 +11,9 @@ import { HeaderConfig } from './types/headerConfig';
11
11
  import { FooterConfig } from './types/footerConfig';
12
12
  import { NavbarConfig } from './types/navbarConfig';
13
13
  import { PageConfig, PagesConfig } from './types/pagesConfig';
14
+ import AccountSettings from './components/settings/AccountSettings';
15
+ import CommunicationSettings from './components/settings/CommunicationSettings';
16
+ import { PhoneNumberInput } from './components/inputs';
14
17
  declare const coreReduxActions: {
15
18
  appActions: import("@reduxjs/toolkit").CaseReducerActions<{
16
19
  reset: (state: import("immer/dist/internal").WritableDraft<import("./store/appSlice").AppState>) => import("immer/dist/internal").WritableDraft<import("./store/appSlice").AppState>;
@@ -89,4 +92,4 @@ declare const coreReduxActions: {
89
92
  declare const coreReduxThunks: {
90
93
  enterStudiesThunk: import("@reduxjs/toolkit").AsyncThunk<import("./store/actions/studiesActions").EnterStudiesPayload, import("./store/thunks/studiesThunks").EnterStudiesRequest, {}>;
91
94
  };
92
- export { AppCore, initI18n, store, reducersManager, localStorageManager, studyAPI, userAPI, coreReduxActions, coreReduxThunks, useAuthTokenCheck, PreventAccidentalNavigationPrompt, InternalNavigator, type AppConfig, type HeaderConfig, type FooterConfig, type NavbarConfig, type PageConfig, type PagesConfig };
95
+ export { AppCore, initI18n, store, reducersManager, localStorageManager, studyAPI, userAPI, coreReduxActions, coreReduxThunks, useAuthTokenCheck, PreventAccidentalNavigationPrompt, InternalNavigator, AccountSettings, CommunicationSettings, PhoneNumberInput, type AppConfig, type HeaderConfig, type FooterConfig, type NavbarConfig, type PageConfig, type PagesConfig };
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, 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';
4
+ import { LoadingPlaceholder, SimpleHeader, Footer, Avatar, containerClassName, ChevronUp, ChevronDown, Dialog, defaultDialogPaddingXClass, Checkbox, AlertBox, TextField, DialogBtn, useFetchTextFile, SelectField, TextLink, ConsentDialog, ConfirmDialog, 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';
@@ -20720,6 +20720,65 @@ var parseBooleanFlag = function (v, empty, other) {
20720
20720
  return other;
20721
20721
  };
20722
20722
 
20723
+ // Lista dei prefissi internazionali più comuni
20724
+ var COUNTRY_CODES$1 = [
20725
+ { code: '+39', country: 'IT', name: 'Italy' },
20726
+ { code: '+1', country: 'US', name: 'United States' },
20727
+ { code: '+44', country: 'GB', name: 'United Kingdom' },
20728
+ { code: '+33', country: 'FR', name: 'France' },
20729
+ { code: '+49', country: 'DE', name: 'Germany' },
20730
+ { code: '+34', country: 'ES', name: 'Spain' },
20731
+ { code: '+31', country: 'NL', name: 'Netherlands' },
20732
+ { code: '+41', country: 'CH', name: 'Switzerland' },
20733
+ { code: '+43', country: 'AT', name: 'Austria' },
20734
+ { code: '+32', country: 'BE', name: 'Belgium' },
20735
+ { code: '+351', country: 'PT', name: 'Portugal' },
20736
+ { code: '+30', country: 'GR', name: 'Greece' },
20737
+ { code: '+46', country: 'SE', name: 'Sweden' },
20738
+ { code: '+47', country: 'NO', name: 'Norway' },
20739
+ { code: '+45', country: 'DK', name: 'Denmark' },
20740
+ { code: '+358', country: 'FI', name: 'Finland' },
20741
+ { code: '+48', country: 'PL', name: 'Poland' },
20742
+ { code: '+420', country: 'CZ', name: 'Czech Republic' },
20743
+ { code: '+36', country: 'HU', name: 'Hungary' },
20744
+ { code: '+40', country: 'RO', name: 'Romania' },
20745
+ { code: '+359', country: 'BG', name: 'Bulgaria' },
20746
+ { code: '+385', country: 'HR', name: 'Croatia' },
20747
+ { code: '+386', country: 'SI', name: 'Slovenia' },
20748
+ { code: '+372', country: 'EE', name: 'Estonia' },
20749
+ { code: '+371', country: 'LV', name: 'Latvia' },
20750
+ { code: '+370', country: 'LT', name: 'Lithuania' },
20751
+ ];
20752
+ var PhoneNumberInput = function (_a) {
20753
+ var value = _a.value, onChange = _a.onChange, label = _a.label, placeholder = _a.placeholder, className = _a.className, autoFocus = _a.autoFocus, disabled = _a.disabled, error = _a.error, onBlur = _a.onBlur;
20754
+ var t = useTranslation(['dialogs']).t;
20755
+ // Estrai il prefisso e il numero dal valore completo
20756
+ var _b = useState(function () {
20757
+ // Cerca quale prefisso corrisponde al valore attuale
20758
+ var matchingCode = COUNTRY_CODES$1.find(function (country) { return value.startsWith(country.code); });
20759
+ return (matchingCode === null || matchingCode === void 0 ? void 0 : matchingCode.code) || '+39'; // Default Italia
20760
+ }), countryCode = _b[0], setCountryCode = _b[1];
20761
+ var _c = useState(function () {
20762
+ // Rimuovi il prefisso dal numero
20763
+ var matchingCode = COUNTRY_CODES$1.find(function (country) { return value.startsWith(country.code); });
20764
+ return matchingCode ? value.substring(matchingCode.code.length) : value;
20765
+ }), phoneNumber = _c[0], setPhoneNumber = _c[1];
20766
+ var handleCountryCodeChange = function (newCode) {
20767
+ setCountryCode(newCode);
20768
+ onChange(newCode + phoneNumber);
20769
+ };
20770
+ var handlePhoneNumberChange = function (newNumber) {
20771
+ // Rimuovi caratteri non numerici (eccetto spazi e trattini per leggibilità)
20772
+ var cleanNumber = newNumber.replace(/[^\d\s-]/g, '');
20773
+ setPhoneNumber(cleanNumber);
20774
+ onChange(countryCode + cleanNumber);
20775
+ };
20776
+ return (jsxs("div", __assign({ className: className }, { children: [label && (jsx("label", __assign({ className: "form-label mb-1" }, { children: label }), void 0)), jsxs("div", __assign({ className: "d-flex" }, { children: [jsx(SelectField, { className: "me-2", style: { width: '120px', flexShrink: 0 }, value: countryCode, onChange: function (event) { return handleCountryCodeChange(event.target.value); }, disabled: disabled, values: COUNTRY_CODES$1.map(function (country) { return ({
20777
+ code: country.code,
20778
+ label: "".concat(country.code, " ").concat(country.country)
20779
+ }); }) }, void 0), jsx(TextField, { type: "text", placeholder: placeholder || t('addPhone.phoneInputPlaceholder'), value: phoneNumber, autoFocus: autoFocus, autoComplete: "tel", disabled: disabled, className: "flex-grow-1", onChange: function (event) { return handlePhoneNumberChange(event.target.value); }, onBlur: onBlur, style: { marginBottom: 0 } }, void 0)] }), void 0), jsxs("small", __assign({ className: "text-muted mt-1 d-block" }, { children: [t('addPhone.completeNumber'), ": ", countryCode + phoneNumber] }), void 0), error && (jsx("div", __assign({ className: "text-danger mt-1 small" }, { children: error }), void 0))] }), void 0));
20780
+ };
20781
+
20723
20782
  var marginBottomClass = "mb-2";
20724
20783
  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
20784
  var phoneFormatRegexp = new RegExp(/^\+\d{1,3}[-\s]?(\(?\d+\)?[-\s]?)*\d{4,}$/);
@@ -20784,7 +20843,7 @@ var SignupForm = function (props) {
20784
20843
  };
20785
20844
  var isDisabled = function () {
20786
20845
  var emailOk = checkEmailFormat(signupData.email);
20787
- var phoneOk = checkPhoneFormat(signupData.phone);
20846
+ var phoneOk = signupData.phone === "" || checkPhoneFormat(signupData.phone); // Phone is optional
20788
20847
  var passwordRuleOk = checkPasswordRules(signupData.password);
20789
20848
  return !(!props.isLoading && (!useRecaptcha || reCaptchaAccepted) && acceptedPrivacyPolicy && emailOk && passwordRuleOk && phoneOk && passwordsMatch());
20790
20849
  };
@@ -20849,12 +20908,11 @@ var SignupForm = function (props) {
20849
20908
  }, onChange: function (event) {
20850
20909
  var value = event.target.value;
20851
20910
  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 () {
20911
+ } }, void 0), jsx(PhoneNumberInput, { className: marginBottomClass, value: signupData.phone, label: phoneInputLabel + " (opzionale)", placeholder: phoneInputPlaceholder + " (opzionale per notifiche WhatsApp)", autoFocus: false, onChange: function (fullPhoneNumber) {
20912
+ setSignupData(function (prev) { return __assign(__assign({}, prev), { phone: fullPhoneNumber }); });
20913
+ }, onBlur: function () {
20853
20914
  setShowPhoneError(true);
20854
- }, onChange: function (event) {
20855
- var value = event.target.value;
20856
- setSignupData(function (prev) { return __assign(__assign({}, prev), { phone: value }); });
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) {
20915
+ }, error: signupData.phone !== "" && !checkPhoneFormat(signupData.phone) && showPhoneError ? t("dialogs:signup.errors.phone") : undefined }, 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) {
20858
20916
  var value = event.target.value;
20859
20917
  setSignupData(function (prev) { return __assign(__assign({}, prev), { infoCheck: value }); });
20860
20918
  } }, void 0), jsx(Checkbox, __assign({ className: marginBottomClass, id: "acceptPrivacyConsent", name: "privacyConsent", checked: acceptedPrivacyPolicy, onClick: function () {
@@ -20976,7 +21034,7 @@ var Signup = function () {
20976
21034
  return [3 /*break*/, 5];
20977
21035
  case 3:
20978
21036
  e_1 = _a.sent();
20979
- console.log(e_1.response);
21037
+ // Error handled through error state mechanism
20980
21038
  if (!e_1.response) {
20981
21039
  handleError('request failed');
20982
21040
  }
@@ -21117,9 +21175,12 @@ var deletePhoneReq = function () {
21117
21175
  };
21118
21176
  // WhatsApp Verification API
21119
21177
  var verifyWhatsAppCodeReq = function (code) {
21120
- return authApiInstance.post("/v1/user/contact/verify-whatsapp", {
21178
+ return authApiInstance.post("/v1/user/contact/verify-whatsapp-code", {
21121
21179
  code: code,
21122
21180
  });
21181
+ };
21182
+ var resendWhatsAppCodeReq = function () {
21183
+ return authApiInstance.post("/v1/user/contact/resend-whatsapp-code", {});
21123
21184
  };
21124
21185
 
21125
21186
  var userAPI = /*#__PURE__*/Object.freeze({
@@ -21137,6 +21198,7 @@ var userAPI = /*#__PURE__*/Object.freeze({
21137
21198
  removeEmailReq: removeEmailReq,
21138
21199
  removeProfileReq: removeProfileReq,
21139
21200
  resendVerificationEmailReq: resendVerificationEmailReq,
21201
+ resendWhatsAppCodeReq: resendWhatsAppCodeReq,
21140
21202
  resetPasswordReq: resetPasswordReq,
21141
21203
  revokeAllRefreshTokensReq: revokeAllRefreshTokensReq,
21142
21204
  saveProfileReq: saveProfileReq,
@@ -22346,9 +22408,8 @@ var ChangePhone = function () {
22346
22408
  var buttonDisabled = function () {
22347
22409
  return loading || formData.newPhone.length < 8;
22348
22410
  };
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 }); });
22411
+ 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(PhoneNumberInput, { className: "mb-2", value: formData.newPhone, label: t('dialogs:changePhone.phoneInputLabel'), placeholder: t('dialogs:changePhone.phoneInputPlaceholder'), autoFocus: true, onChange: function (fullPhoneNumber) {
22412
+ setFormData(function (prev) { return __assign(__assign({}, prev), { newPhone: fullPhoneNumber }); });
22352
22413
  } }, 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
22414
  setOpenConfirm(false);
22354
22415
  changePhone();
@@ -22418,6 +22479,29 @@ var DeletePhone = function (props) {
22418
22479
  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
22480
  };
22420
22481
 
22482
+ // Lista dei prefissi internazionali più comuni
22483
+ var COUNTRY_CODES = [
22484
+ { code: '+39', country: 'IT', name: 'Italy' },
22485
+ { code: '+1', country: 'US', name: 'United States' },
22486
+ { code: '+44', country: 'GB', name: 'United Kingdom' },
22487
+ { code: '+33', country: 'FR', name: 'France' },
22488
+ { code: '+49', country: 'DE', name: 'Germany' },
22489
+ { code: '+34', country: 'ES', name: 'Spain' },
22490
+ { code: '+31', country: 'NL', name: 'Netherlands' },
22491
+ { code: '+41', country: 'CH', name: 'Switzerland' },
22492
+ { code: '+43', country: 'AT', name: 'Austria' },
22493
+ { code: '+32', country: 'BE', name: 'Belgium' },
22494
+ { code: '+351', country: 'PT', name: 'Portugal' },
22495
+ { code: '+30', country: 'GR', name: 'Greece' },
22496
+ { code: '+46', country: 'SE', name: 'Sweden' },
22497
+ { code: '+47', country: 'NO', name: 'Norway' },
22498
+ { code: '+45', country: 'DK', name: 'Denmark' },
22499
+ { code: '+358', country: 'FI', name: 'Finland' },
22500
+ { code: '+48', country: 'PL', name: 'Poland' },
22501
+ { code: '+420', country: 'CZ', name: 'Czech Republic' },
22502
+ { code: '+36', country: 'HU', name: 'Hungary' },
22503
+ { code: '+40', country: 'RO', name: 'Romania' },
22504
+ ];
22421
22505
  var AddPhone = function () {
22422
22506
  var _a;
22423
22507
  var t = useTranslation(['dialogs']).t;
@@ -22428,7 +22512,9 @@ var AddPhone = function () {
22428
22512
  var _c = useState(''), error = _c[0], setError = _c[1];
22429
22513
  var _d = useState(false), openConfirm = _d[0], setOpenConfirm = _d[1];
22430
22514
  var _e = useState({
22431
- newPhone: ''
22515
+ countryCode: '+39',
22516
+ phoneNumber: '',
22517
+ newPhone: '' // Numero completo con prefisso
22432
22518
  }), formData = _e[0], setFormData = _e[1];
22433
22519
  useEffect(function () {
22434
22520
  if (!open) {
@@ -22439,9 +22525,24 @@ var AddPhone = function () {
22439
22525
  setLoading(false);
22440
22526
  setError('');
22441
22527
  setFormData({
22528
+ countryCode: '+39',
22529
+ phoneNumber: '',
22442
22530
  newPhone: ''
22443
22531
  });
22444
22532
  };
22533
+ var updateFullPhoneNumber = function (countryCode, phoneNumber) {
22534
+ var cleanNumber = phoneNumber.replace(/[^\d\s-]/g, '');
22535
+ var fullPhone = countryCode + cleanNumber;
22536
+ setFormData(function (prev) { return (__assign(__assign({}, prev), { countryCode: countryCode, phoneNumber: cleanNumber, newPhone: fullPhone })); });
22537
+ };
22538
+ var handleCountryCodeChange = function (event) {
22539
+ var newCountryCode = event.target.value;
22540
+ updateFullPhoneNumber(newCountryCode, formData.phoneNumber);
22541
+ };
22542
+ var handlePhoneNumberChange = function (event) {
22543
+ var newPhoneNumber = event.target.value;
22544
+ updateFullPhoneNumber(formData.countryCode, newPhoneNumber);
22545
+ };
22445
22546
  var handleClose = function () {
22446
22547
  dispatch(dialogActions.closeDialog());
22447
22548
  };
@@ -22509,12 +22610,12 @@ var AddPhone = function () {
22509
22610
  setOpenConfirm(true);
22510
22611
  };
22511
22612
  var buttonDisabled = function () {
22512
- return loading || formData.newPhone.length < 8;
22613
+ return loading || formData.phoneNumber.length < 8;
22513
22614
  };
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 () {
22615
+ 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("label", __assign({ className: "form-label mb-1" }, { children: t('dialogs:addPhone.phoneInputLabel') }), void 0), jsxs("div", __assign({ className: "d-flex mb-2" }, { children: [jsx(SelectField, { className: "me-2", style: { width: '120px', flexShrink: 0 }, value: formData.countryCode, onChange: handleCountryCodeChange, values: COUNTRY_CODES.map(function (country) { return ({
22616
+ code: country.code,
22617
+ label: "".concat(country.code, " ").concat(country.country)
22618
+ }); }) }, void 0), jsx(TextField, { type: "text", placeholder: t('dialogs:addPhone.phoneInputPlaceholder'), value: formData.phoneNumber, autoFocus: true, autoComplete: "tel", className: "flex-grow-1", onChange: handlePhoneNumberChange, style: { marginBottom: 0 } }, void 0)] }), void 0), jsxs("small", __assign({ className: "text-muted mb-2 d-block" }, { children: [t('dialogs:addPhone.completeNumber'), ": ", formData.newPhone] }), 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
22619
  setOpenConfirm(false);
22519
22620
  addPhone();
22520
22621
  }, 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));
@@ -22528,16 +22629,53 @@ var VerifyWhatsApp = function () {
22528
22629
  var open = ((_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.type) === 'verifyWhatsApp';
22529
22630
  var dialogContent = open ? dialogState.config.payload : undefined;
22530
22631
  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];
22632
+ var _c = useState(false), resendLoading = _c[0], setResendLoading = _c[1];
22633
+ var _d = useState(''), error = _d[0], setError = _d[1];
22634
+ var _e = useState(''), verificationCode = _e[0], setVerificationCode = _e[1];
22533
22635
  var phoneNumber = (dialogContent === null || dialogContent === void 0 ? void 0 : dialogContent.phoneNumber) || '';
22534
22636
  var close = function () {
22535
22637
  dispatch(dialogActions.closeDialog());
22536
22638
  setVerificationCode('');
22537
22639
  setError('');
22538
22640
  };
22641
+ var resendCode = function () { return __awaiter(void 0, void 0, void 0, function () {
22642
+ var e_1, errorResponse;
22643
+ var _a, _b;
22644
+ return __generator$1(this, function (_c) {
22645
+ switch (_c.label) {
22646
+ case 0:
22647
+ setResendLoading(true);
22648
+ setError('');
22649
+ _c.label = 1;
22650
+ case 1:
22651
+ _c.trys.push([1, 4, 5, 6]);
22652
+ // First delete existing phone number
22653
+ return [4 /*yield*/, deletePhoneReq()];
22654
+ case 2:
22655
+ // First delete existing phone number
22656
+ _c.sent();
22657
+ // Then re-add it (this will send the WhatsApp code)
22658
+ return [4 /*yield*/, newAccountPhoneReq(phoneNumber)];
22659
+ case 3:
22660
+ // Then re-add it (this will send the WhatsApp code)
22661
+ _c.sent();
22662
+ setError('');
22663
+ return [3 /*break*/, 6];
22664
+ case 4:
22665
+ e_1 = _c.sent();
22666
+ console.error(e_1);
22667
+ errorResponse = e_1;
22668
+ setError(((_b = (_a = errorResponse.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) || t('verifyWhatsApp.errors.unknown'));
22669
+ return [3 /*break*/, 6];
22670
+ case 5:
22671
+ setResendLoading(false);
22672
+ return [7 /*endfinally*/];
22673
+ case 6: return [2 /*return*/];
22674
+ }
22675
+ });
22676
+ }); };
22539
22677
  var verifyCode = function () { return __awaiter(void 0, void 0, void 0, function () {
22540
- var response, userData, e_1, errorResponse;
22678
+ var response, userData, e_2, errorResponse;
22541
22679
  var _a, _b;
22542
22680
  return __generator$1(this, function (_c) {
22543
22681
  switch (_c.label) {
@@ -22578,9 +22716,9 @@ var VerifyWhatsApp = function () {
22578
22716
  _c.label = 6;
22579
22717
  case 6: return [3 /*break*/, 9];
22580
22718
  case 7:
22581
- e_1 = _c.sent();
22582
- console.error(e_1);
22583
- errorResponse = e_1;
22719
+ e_2 = _c.sent();
22720
+ console.error(e_2);
22721
+ errorResponse = e_2;
22584
22722
  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
22723
  return [3 /*break*/, 9];
22586
22724
  case 8:
@@ -22593,7 +22731,7 @@ var VerifyWhatsApp = function () {
22593
22731
  if (!open) {
22594
22732
  return null;
22595
22733
  }
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));
22734
+ return (jsxs(Dialog, __assign({ open: open, title: t('verifyWhatsApp.title'), ariaLabelledBy: "verify-whatsapp-title", onClose: close, size: "lg" }, { children: [jsxs("div", __assign({ className: "".concat(defaultDialogPaddingXClass, " py-4") }, { children: [jsx("div", __assign({ className: "mb-4" }, { children: jsx("p", __assign({ className: "mb-3" }, { children: t("verifyWhatsApp.info") }), void 0) }), void 0), error && (jsx(AlertBox, { type: "danger", content: error, className: "mb-4" }, void 0)), jsx("div", __assign({ className: "mb-4" }, { children: jsx(TextField, { id: "verification-code", name: "verificationCode", label: t('verifyWhatsApp.codeInputLabel'), placeholder: t('verifyWhatsApp.codeInputPlaceholder'), value: verificationCode, onChange: function (event) { return setVerificationCode(event.target.value); }, maxLength: 6, autoComplete: "off" }, void 0) }), void 0)] }), void 0), jsxs("div", __assign({ className: "d-flex justify-content-between align-items-center gap-3 p-4 border-top" }, { children: [jsx(DialogBtn, { type: "button", onClick: resendCode, label: t('verifyWhatsApp.resendBtn'), loading: resendLoading, disabled: loading || !phoneNumber }, void 0), jsxs("div", __assign({ className: "d-flex gap-2" }, { children: [jsx(DialogBtn, { type: "button", onClick: close, label: t('verifyWhatsApp.cancelBtn'), disabled: loading || resendLoading }, void 0), jsx(DialogBtn, { type: "button", onClick: verifyCode, color: "primary", label: t('verifyWhatsApp.submitBtn'), loading: loading, disabled: !verificationCode.trim() || resendLoading }, void 0)] }), void 0)] }), void 0)] }), void 0));
22597
22735
  };
22598
22736
 
22599
22737
  var GlobalDialogs = function (props) {
@@ -34361,5 +34499,5 @@ var coreReduxThunks = {
34361
34499
  enterStudiesThunk: enterStudiesThunk,
34362
34500
  };
34363
34501
 
34364
- export { AppCore, InternalNavigator, PreventAccidentalNavigationPrompt, coreReduxActions, coreReduxThunks, initI18n, localStorageManager, reducersManager, store, studyAPI, useAuthTokenCheck, userAPI };
34502
+ export { AccountSettings, AppCore, CommunicationSettings, InternalNavigator, PhoneNumberInput, PreventAccidentalNavigationPrompt, coreReduxActions, coreReduxThunks, initI18n, localStorageManager, reducersManager, store, studyAPI, useAuthTokenCheck, userAPI };
34365
34503
  //# sourceMappingURL=index.es.js.map