@influenzanet/case-web-app-core 2.8.1-staging → 2.8.3-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.
- package/build/index.es.js +195 -167
- package/build/index.es.js.map +1 -1
- package/build/index.js +195 -167
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.es.js
CHANGED
|
@@ -20709,6 +20709,143 @@ var RecaptchaWrapper = makeAsyncScript(getURL, {
|
|
|
20709
20709
|
globalName: globalName
|
|
20710
20710
|
})(ReCAPTCHA);
|
|
20711
20711
|
|
|
20712
|
+
// Password Reset API
|
|
20713
|
+
var initiatePasswordResetReq = function (instanceId, accountId) {
|
|
20714
|
+
return apiInstance.post("/v1/user/password-reset/initiate", {
|
|
20715
|
+
instanceId: instanceId,
|
|
20716
|
+
accountId: accountId,
|
|
20717
|
+
});
|
|
20718
|
+
};
|
|
20719
|
+
var getInfosForPasswordResetReq = function (token) {
|
|
20720
|
+
return apiInstance.post("/v1/user/password-reset/get-infos", {
|
|
20721
|
+
token: token,
|
|
20722
|
+
});
|
|
20723
|
+
};
|
|
20724
|
+
var resetPasswordReq = function (token, newPassword) {
|
|
20725
|
+
return apiInstance.post("/v1/user/password-reset/reset-with", {
|
|
20726
|
+
token: token,
|
|
20727
|
+
newPassword: newPassword,
|
|
20728
|
+
});
|
|
20729
|
+
};
|
|
20730
|
+
// User management API
|
|
20731
|
+
var getUserReq = function () { return authApiInstance.get("/v1/user"); };
|
|
20732
|
+
var changePasswordReq = function (oldPassword, newPassword) {
|
|
20733
|
+
return authApiInstance.post("/v1/user/change-password", {
|
|
20734
|
+
oldPassword: oldPassword,
|
|
20735
|
+
newPassword: newPassword,
|
|
20736
|
+
});
|
|
20737
|
+
};
|
|
20738
|
+
var changeAccountEmailReq = function (newEmail, keepOldEmail, password) {
|
|
20739
|
+
return authApiInstance.post("/v1/user/change-account-email", {
|
|
20740
|
+
newEmail: newEmail,
|
|
20741
|
+
keepOldEmail: keepOldEmail,
|
|
20742
|
+
password: password,
|
|
20743
|
+
});
|
|
20744
|
+
};
|
|
20745
|
+
var changeAccountPhoneReq = function (newPhone) {
|
|
20746
|
+
return authApiInstance.post("/v1/user/contact/change-phone", {
|
|
20747
|
+
newPhone: newPhone
|
|
20748
|
+
});
|
|
20749
|
+
};
|
|
20750
|
+
var newAccountPhoneReq = function (newPhone) {
|
|
20751
|
+
return authApiInstance.post("/v1/user/contact/add-phone", {
|
|
20752
|
+
newPhone: newPhone
|
|
20753
|
+
});
|
|
20754
|
+
};
|
|
20755
|
+
var setPreferredLanguageReq = function (languageCode) {
|
|
20756
|
+
return authApiInstance.post("/v1/user/set-language", { languageCode: languageCode });
|
|
20757
|
+
};
|
|
20758
|
+
// Profiles:
|
|
20759
|
+
var saveProfileReq = function (profile) {
|
|
20760
|
+
return authApiInstance.post("/v1/user/profile/save", {
|
|
20761
|
+
/**
|
|
20762
|
+
*
|
|
20763
|
+
* this is an awful workaround we have to use because
|
|
20764
|
+
* of the comment in ./types/user.ts
|
|
20765
|
+
*
|
|
20766
|
+
* Could have used some form of type assertion
|
|
20767
|
+
*/
|
|
20768
|
+
profile: omit$1(profile, "studies", "activeSurveys"),
|
|
20769
|
+
});
|
|
20770
|
+
};
|
|
20771
|
+
var removeProfileReq = function (profileId) {
|
|
20772
|
+
return authApiInstance.post("/v1/user/profile/remove", {
|
|
20773
|
+
profile: { id: profileId },
|
|
20774
|
+
});
|
|
20775
|
+
};
|
|
20776
|
+
// Contact settings:
|
|
20777
|
+
var resendVerificationEmailReq = function (address) {
|
|
20778
|
+
return authApiInstance.post("/v1/user/resend-verification-message", {
|
|
20779
|
+
type: "email",
|
|
20780
|
+
address: address,
|
|
20781
|
+
});
|
|
20782
|
+
};
|
|
20783
|
+
var verifyContactReq = function (token) {
|
|
20784
|
+
return apiInstance.post("/v1/user/contact-verification", { token: token });
|
|
20785
|
+
};
|
|
20786
|
+
var unsubscribeNewsletterReq = function (token) {
|
|
20787
|
+
return apiInstance.get("/v1/user/unsubscribe-newsletter", {
|
|
20788
|
+
params: { token: token },
|
|
20789
|
+
});
|
|
20790
|
+
};
|
|
20791
|
+
var updateContactPreferencesReq = function (contactPrefs) {
|
|
20792
|
+
return authApiInstance.post("/v1/user/contact-preferences", {
|
|
20793
|
+
contactPreferences: contactPrefs,
|
|
20794
|
+
});
|
|
20795
|
+
};
|
|
20796
|
+
var addEmailReq = function (contactInfo) {
|
|
20797
|
+
return authApiInstance.post("/v1/user/contact/add-email", { contactInfo: contactInfo });
|
|
20798
|
+
};
|
|
20799
|
+
var removeEmailReq = function (contactInfoID) {
|
|
20800
|
+
return authApiInstance.post("/v1/user/contact/remove-email", {
|
|
20801
|
+
contactInfo: { id: contactInfoID },
|
|
20802
|
+
});
|
|
20803
|
+
};
|
|
20804
|
+
var revokeAllRefreshTokensReq = function () {
|
|
20805
|
+
return authApiInstance.post("/v1/user/revoke-refresh-tokens", {});
|
|
20806
|
+
};
|
|
20807
|
+
var deleteAccountReq = function (userId) {
|
|
20808
|
+
return authApiInstance.post("/v1/user/delete", { userId: userId });
|
|
20809
|
+
};
|
|
20810
|
+
var deletePhoneReq = function () {
|
|
20811
|
+
return authApiInstance.delete("/v1/user/contact/delete-phone");
|
|
20812
|
+
};
|
|
20813
|
+
// WhatsApp Verification API
|
|
20814
|
+
var verifyWhatsAppCodeReq = function (code) {
|
|
20815
|
+
return authApiInstance.post("/v1/user/contact/verify-whatsapp-code", {
|
|
20816
|
+
code: code,
|
|
20817
|
+
});
|
|
20818
|
+
};
|
|
20819
|
+
var resendWhatsAppCodeReq = function () {
|
|
20820
|
+
return authApiInstance.post("/v1/user/contact/resend-whatsapp-code", {});
|
|
20821
|
+
};
|
|
20822
|
+
|
|
20823
|
+
var userAPI = /*#__PURE__*/Object.freeze({
|
|
20824
|
+
__proto__: null,
|
|
20825
|
+
addEmailReq: addEmailReq,
|
|
20826
|
+
changeAccountEmailReq: changeAccountEmailReq,
|
|
20827
|
+
changeAccountPhoneReq: changeAccountPhoneReq,
|
|
20828
|
+
changePasswordReq: changePasswordReq,
|
|
20829
|
+
deleteAccountReq: deleteAccountReq,
|
|
20830
|
+
deletePhoneReq: deletePhoneReq,
|
|
20831
|
+
getInfosForPasswordResetReq: getInfosForPasswordResetReq,
|
|
20832
|
+
getUserReq: getUserReq,
|
|
20833
|
+
initiatePasswordResetReq: initiatePasswordResetReq,
|
|
20834
|
+
newAccountPhoneReq: newAccountPhoneReq,
|
|
20835
|
+
removeEmailReq: removeEmailReq,
|
|
20836
|
+
removeProfileReq: removeProfileReq,
|
|
20837
|
+
resendVerificationEmailReq: resendVerificationEmailReq,
|
|
20838
|
+
resendWhatsAppCodeReq: resendWhatsAppCodeReq,
|
|
20839
|
+
resetPasswordReq: resetPasswordReq,
|
|
20840
|
+
revokeAllRefreshTokensReq: revokeAllRefreshTokensReq,
|
|
20841
|
+
saveProfileReq: saveProfileReq,
|
|
20842
|
+
setPreferredLanguageReq: setPreferredLanguageReq,
|
|
20843
|
+
unsubscribeNewsletterReq: unsubscribeNewsletterReq,
|
|
20844
|
+
updateContactPreferencesReq: updateContactPreferencesReq,
|
|
20845
|
+
verifyContactReq: verifyContactReq,
|
|
20846
|
+
verifyWhatsAppCodeReq: verifyWhatsAppCodeReq
|
|
20847
|
+
});
|
|
20848
|
+
|
|
20712
20849
|
var parseBooleanFlag = function (v, empty, other) {
|
|
20713
20850
|
var b = (v !== null && v !== void 0 ? v : '').toLowerCase().trim();
|
|
20714
20851
|
if (b === '') {
|
|
@@ -20959,7 +21096,6 @@ var Signup = function () {
|
|
|
20959
21096
|
var _c = useState(false), loading = _c[0], setLoading = _c[1];
|
|
20960
21097
|
var _d = useState(''), error = _d[0], setError = _d[1];
|
|
20961
21098
|
var dispatch = useDispatch();
|
|
20962
|
-
var setAuthState = useSetAuthState();
|
|
20963
21099
|
var logout = useLogout();
|
|
20964
21100
|
var handleClose = function () {
|
|
20965
21101
|
setError('');
|
|
@@ -20978,7 +21114,7 @@ var Signup = function () {
|
|
|
20978
21114
|
}
|
|
20979
21115
|
};
|
|
20980
21116
|
var handleSignup = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
20981
|
-
var response, tokenRefreshedAt, e_1, errMsg;
|
|
21117
|
+
var response, tokenRefreshedAt, userResponse, e_1, errMsg;
|
|
20982
21118
|
return __generator$1(this, function (_a) {
|
|
20983
21119
|
switch (_a.label) {
|
|
20984
21120
|
case 0:
|
|
@@ -20987,7 +21123,7 @@ var Signup = function () {
|
|
|
20987
21123
|
logout(true);
|
|
20988
21124
|
_a.label = 1;
|
|
20989
21125
|
case 1:
|
|
20990
|
-
_a.trys.push([1,
|
|
21126
|
+
_a.trys.push([1, 4, 5, 6]);
|
|
20991
21127
|
setLoading(true);
|
|
20992
21128
|
return [4 /*yield*/, signupWithEmailRequest({
|
|
20993
21129
|
email: data.email,
|
|
@@ -21001,26 +21137,6 @@ var Signup = function () {
|
|
|
21001
21137
|
}, data.captchaToken)];
|
|
21002
21138
|
case 2:
|
|
21003
21139
|
response = _a.sent();
|
|
21004
|
-
// TODO: update user correctly
|
|
21005
|
-
setAuthState(response.data, {
|
|
21006
|
-
id: '',
|
|
21007
|
-
account: {
|
|
21008
|
-
type: 'email',
|
|
21009
|
-
accountId: data.email,
|
|
21010
|
-
accountConfirmedAt: 0,
|
|
21011
|
-
preferredLanguage: "en",
|
|
21012
|
-
},
|
|
21013
|
-
roles: [],
|
|
21014
|
-
contactPreferences: { subscribedToNewsletter: false, sendNewsletterTo: [], subscribedToWeekly: true, receiveWeeklyMessageDayOfWeek: 0 },
|
|
21015
|
-
contactInfos: [],
|
|
21016
|
-
profiles: response.data.profiles,
|
|
21017
|
-
timestamps: {
|
|
21018
|
-
createdAt: 0,
|
|
21019
|
-
updatedAt: 0,
|
|
21020
|
-
lastLogin: 0,
|
|
21021
|
-
lastTokenRefresh: 0,
|
|
21022
|
-
},
|
|
21023
|
-
});
|
|
21024
21140
|
tokenRefreshedAt = new Date().getTime();
|
|
21025
21141
|
dispatch(setAppAuth({
|
|
21026
21142
|
accessToken: response.data.accessToken,
|
|
@@ -21028,11 +21144,16 @@ var Signup = function () {
|
|
|
21028
21144
|
expiresAt: tokenRefreshedAt + response.data.expiresIn * minuteToMillisecondFactor,
|
|
21029
21145
|
}));
|
|
21030
21146
|
setDefaultAccessTokenHeader(response.data.accessToken);
|
|
21147
|
+
return [4 /*yield*/, getUserReq()];
|
|
21148
|
+
case 3:
|
|
21149
|
+
userResponse = _a.sent();
|
|
21150
|
+
// Set user data with contactInfos
|
|
21151
|
+
dispatch(userActions.setUser(userResponse.data));
|
|
21031
21152
|
dispatch(userActions.setFromTokenResponse(response.data));
|
|
21032
21153
|
setLoading(false);
|
|
21033
21154
|
closeWithSuccess();
|
|
21034
|
-
return [3 /*break*/,
|
|
21035
|
-
case
|
|
21155
|
+
return [3 /*break*/, 6];
|
|
21156
|
+
case 4:
|
|
21036
21157
|
e_1 = _a.sent();
|
|
21037
21158
|
// Error handled through error state mechanism
|
|
21038
21159
|
if (!e_1.response) {
|
|
@@ -21045,11 +21166,11 @@ var Signup = function () {
|
|
|
21045
21166
|
errMsg = getErrorMsg(e_1);
|
|
21046
21167
|
handleError(errMsg);
|
|
21047
21168
|
}
|
|
21048
|
-
return [3 /*break*/,
|
|
21049
|
-
case
|
|
21169
|
+
return [3 /*break*/, 6];
|
|
21170
|
+
case 5:
|
|
21050
21171
|
setLoading(false);
|
|
21051
21172
|
return [7 /*endfinally*/];
|
|
21052
|
-
case
|
|
21173
|
+
case 6: return [2 /*return*/];
|
|
21053
21174
|
}
|
|
21054
21175
|
});
|
|
21055
21176
|
}); };
|
|
@@ -21064,6 +21185,12 @@ var Signup = function () {
|
|
|
21064
21185
|
case 'not found':
|
|
21065
21186
|
setError(t("dialogs:signup.errors.noRegistrationAllowed"));
|
|
21066
21187
|
break;
|
|
21188
|
+
case 'phone number already registered':
|
|
21189
|
+
setError(t("dialogs:signup.errors.phoneAlreadyRegistered"));
|
|
21190
|
+
break;
|
|
21191
|
+
case 'phone not valid':
|
|
21192
|
+
setError(t("dialogs:signup.errors.invalidPhone"));
|
|
21193
|
+
break;
|
|
21067
21194
|
default:
|
|
21068
21195
|
setError(t("dialogs:signup.errors.unknown"));
|
|
21069
21196
|
break;
|
|
@@ -21072,143 +21199,6 @@ var Signup = function () {
|
|
|
21072
21199
|
return (jsx(Dialog, __assign({ open: open, title: t('signup.title'), onClose: handleClose, ariaLabelledBy: "signupDialogTitle" }, { children: jsx("div", __assign({ className: clsx(defaultDialogPaddingXClass, 'py-3', 'bg-grey-1') }, { children: jsx(SignupForm, { isLoading: loading, onSubmit: function (data) { return handleSignup(data); }, onOpenDialog: function (dialog) { var _a; return dispatch(dialogActions.openDialogWithoutPayload({ type: dialog, origin: (_a = dialogState.config) === null || _a === void 0 ? void 0 : _a.origin })); }, error: error, clearError: function () { return setError(''); } }, void 0) }), void 0) }), void 0));
|
|
21073
21200
|
};
|
|
21074
21201
|
|
|
21075
|
-
// Password Reset API
|
|
21076
|
-
var initiatePasswordResetReq = function (instanceId, accountId) {
|
|
21077
|
-
return apiInstance.post("/v1/user/password-reset/initiate", {
|
|
21078
|
-
instanceId: instanceId,
|
|
21079
|
-
accountId: accountId,
|
|
21080
|
-
});
|
|
21081
|
-
};
|
|
21082
|
-
var getInfosForPasswordResetReq = function (token) {
|
|
21083
|
-
return apiInstance.post("/v1/user/password-reset/get-infos", {
|
|
21084
|
-
token: token,
|
|
21085
|
-
});
|
|
21086
|
-
};
|
|
21087
|
-
var resetPasswordReq = function (token, newPassword) {
|
|
21088
|
-
return apiInstance.post("/v1/user/password-reset/reset-with", {
|
|
21089
|
-
token: token,
|
|
21090
|
-
newPassword: newPassword,
|
|
21091
|
-
});
|
|
21092
|
-
};
|
|
21093
|
-
// User management API
|
|
21094
|
-
var getUserReq = function () { return authApiInstance.get("/v1/user"); };
|
|
21095
|
-
var changePasswordReq = function (oldPassword, newPassword) {
|
|
21096
|
-
return authApiInstance.post("/v1/user/change-password", {
|
|
21097
|
-
oldPassword: oldPassword,
|
|
21098
|
-
newPassword: newPassword,
|
|
21099
|
-
});
|
|
21100
|
-
};
|
|
21101
|
-
var changeAccountEmailReq = function (newEmail, keepOldEmail, password) {
|
|
21102
|
-
return authApiInstance.post("/v1/user/change-account-email", {
|
|
21103
|
-
newEmail: newEmail,
|
|
21104
|
-
keepOldEmail: keepOldEmail,
|
|
21105
|
-
password: password,
|
|
21106
|
-
});
|
|
21107
|
-
};
|
|
21108
|
-
var changeAccountPhoneReq = function (newPhone) {
|
|
21109
|
-
return authApiInstance.post("/v1/user/contact/change-phone", {
|
|
21110
|
-
newPhone: newPhone
|
|
21111
|
-
});
|
|
21112
|
-
};
|
|
21113
|
-
var newAccountPhoneReq = function (newPhone) {
|
|
21114
|
-
return authApiInstance.post("/v1/user/contact/add-phone", {
|
|
21115
|
-
newPhone: newPhone
|
|
21116
|
-
});
|
|
21117
|
-
};
|
|
21118
|
-
var setPreferredLanguageReq = function (languageCode) {
|
|
21119
|
-
return authApiInstance.post("/v1/user/set-language", { languageCode: languageCode });
|
|
21120
|
-
};
|
|
21121
|
-
// Profiles:
|
|
21122
|
-
var saveProfileReq = function (profile) {
|
|
21123
|
-
return authApiInstance.post("/v1/user/profile/save", {
|
|
21124
|
-
/**
|
|
21125
|
-
*
|
|
21126
|
-
* this is an awful workaround we have to use because
|
|
21127
|
-
* of the comment in ./types/user.ts
|
|
21128
|
-
*
|
|
21129
|
-
* Could have used some form of type assertion
|
|
21130
|
-
*/
|
|
21131
|
-
profile: omit$1(profile, "studies", "activeSurveys"),
|
|
21132
|
-
});
|
|
21133
|
-
};
|
|
21134
|
-
var removeProfileReq = function (profileId) {
|
|
21135
|
-
return authApiInstance.post("/v1/user/profile/remove", {
|
|
21136
|
-
profile: { id: profileId },
|
|
21137
|
-
});
|
|
21138
|
-
};
|
|
21139
|
-
// Contact settings:
|
|
21140
|
-
var resendVerificationEmailReq = function (address) {
|
|
21141
|
-
return authApiInstance.post("/v1/user/resend-verification-message", {
|
|
21142
|
-
type: "email",
|
|
21143
|
-
address: address,
|
|
21144
|
-
});
|
|
21145
|
-
};
|
|
21146
|
-
var verifyContactReq = function (token) {
|
|
21147
|
-
return apiInstance.post("/v1/user/contact-verification", { token: token });
|
|
21148
|
-
};
|
|
21149
|
-
var unsubscribeNewsletterReq = function (token) {
|
|
21150
|
-
return apiInstance.get("/v1/user/unsubscribe-newsletter", {
|
|
21151
|
-
params: { token: token },
|
|
21152
|
-
});
|
|
21153
|
-
};
|
|
21154
|
-
var updateContactPreferencesReq = function (contactPrefs) {
|
|
21155
|
-
return authApiInstance.post("/v1/user/contact-preferences", {
|
|
21156
|
-
contactPreferences: contactPrefs,
|
|
21157
|
-
});
|
|
21158
|
-
};
|
|
21159
|
-
var addEmailReq = function (contactInfo) {
|
|
21160
|
-
return authApiInstance.post("/v1/user/contact/add-email", { contactInfo: contactInfo });
|
|
21161
|
-
};
|
|
21162
|
-
var removeEmailReq = function (contactInfoID) {
|
|
21163
|
-
return authApiInstance.post("/v1/user/contact/remove-email", {
|
|
21164
|
-
contactInfo: { id: contactInfoID },
|
|
21165
|
-
});
|
|
21166
|
-
};
|
|
21167
|
-
var revokeAllRefreshTokensReq = function () {
|
|
21168
|
-
return authApiInstance.post("/v1/user/revoke-refresh-tokens", {});
|
|
21169
|
-
};
|
|
21170
|
-
var deleteAccountReq = function (userId) {
|
|
21171
|
-
return authApiInstance.post("/v1/user/delete", { userId: userId });
|
|
21172
|
-
};
|
|
21173
|
-
var deletePhoneReq = function () {
|
|
21174
|
-
return authApiInstance.delete("/v1/user/contact/delete-phone");
|
|
21175
|
-
};
|
|
21176
|
-
// WhatsApp Verification API
|
|
21177
|
-
var verifyWhatsAppCodeReq = function (code) {
|
|
21178
|
-
return authApiInstance.post("/v1/user/contact/verify-whatsapp-code", {
|
|
21179
|
-
code: code,
|
|
21180
|
-
});
|
|
21181
|
-
};
|
|
21182
|
-
var resendWhatsAppCodeReq = function () {
|
|
21183
|
-
return authApiInstance.post("/v1/user/contact/resend-whatsapp-code", {});
|
|
21184
|
-
};
|
|
21185
|
-
|
|
21186
|
-
var userAPI = /*#__PURE__*/Object.freeze({
|
|
21187
|
-
__proto__: null,
|
|
21188
|
-
addEmailReq: addEmailReq,
|
|
21189
|
-
changeAccountEmailReq: changeAccountEmailReq,
|
|
21190
|
-
changeAccountPhoneReq: changeAccountPhoneReq,
|
|
21191
|
-
changePasswordReq: changePasswordReq,
|
|
21192
|
-
deleteAccountReq: deleteAccountReq,
|
|
21193
|
-
deletePhoneReq: deletePhoneReq,
|
|
21194
|
-
getInfosForPasswordResetReq: getInfosForPasswordResetReq,
|
|
21195
|
-
getUserReq: getUserReq,
|
|
21196
|
-
initiatePasswordResetReq: initiatePasswordResetReq,
|
|
21197
|
-
newAccountPhoneReq: newAccountPhoneReq,
|
|
21198
|
-
removeEmailReq: removeEmailReq,
|
|
21199
|
-
removeProfileReq: removeProfileReq,
|
|
21200
|
-
resendVerificationEmailReq: resendVerificationEmailReq,
|
|
21201
|
-
resendWhatsAppCodeReq: resendWhatsAppCodeReq,
|
|
21202
|
-
resetPasswordReq: resetPasswordReq,
|
|
21203
|
-
revokeAllRefreshTokensReq: revokeAllRefreshTokensReq,
|
|
21204
|
-
saveProfileReq: saveProfileReq,
|
|
21205
|
-
setPreferredLanguageReq: setPreferredLanguageReq,
|
|
21206
|
-
unsubscribeNewsletterReq: unsubscribeNewsletterReq,
|
|
21207
|
-
updateContactPreferencesReq: updateContactPreferencesReq,
|
|
21208
|
-
verifyContactReq: verifyContactReq,
|
|
21209
|
-
verifyWhatsAppCodeReq: verifyWhatsAppCodeReq
|
|
21210
|
-
});
|
|
21211
|
-
|
|
21212
21202
|
var SignupSuccess = function () {
|
|
21213
21203
|
var _a;
|
|
21214
21204
|
var t = useTranslation(['dialogs']).t;
|
|
@@ -24061,19 +24051,57 @@ var AccountSettings = function (props) {
|
|
|
24061
24051
|
var isAuth = useIsAuthenticated();
|
|
24062
24052
|
var dispatch = useDispatch();
|
|
24063
24053
|
var currentUser = useSelector(function (state) { return state.user.currentUser; });
|
|
24054
|
+
var _a = useState(false), isResending = _a[0], setIsResending = _a[1];
|
|
24055
|
+
var _b = useState(null), resendMessage = _b[0], setResendMessage = _b[1];
|
|
24064
24056
|
if (!isAuth) {
|
|
24065
24057
|
return jsx("div", __assign({ className: "bg-warning-light p-3" }, { children: 'authentication needed' }), void 0);
|
|
24066
24058
|
}
|
|
24067
24059
|
var phoneInfo = currentUser.contactInfos.find(function (info) { return info.type === 'phone'; });
|
|
24060
|
+
console.log('phoneInfo:', phoneInfo);
|
|
24061
|
+
console.log('confirmedAt:', phoneInfo === null || phoneInfo === void 0 ? void 0 : phoneInfo.confirmedAt);
|
|
24062
|
+
var handleResendCode = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24063
|
+
var error_1;
|
|
24064
|
+
return __generator$1(this, function (_a) {
|
|
24065
|
+
switch (_a.label) {
|
|
24066
|
+
case 0:
|
|
24067
|
+
setIsResending(true);
|
|
24068
|
+
setResendMessage(null);
|
|
24069
|
+
_a.label = 1;
|
|
24070
|
+
case 1:
|
|
24071
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
24072
|
+
return [4 /*yield*/, resendWhatsAppCodeReq()];
|
|
24073
|
+
case 2:
|
|
24074
|
+
_a.sent();
|
|
24075
|
+
setResendMessage({
|
|
24076
|
+
type: 'success',
|
|
24077
|
+
text: t("".concat(props.itemKey, ".phone.resendSuccess"), 'Codice inviato con successo!')
|
|
24078
|
+
});
|
|
24079
|
+
return [3 /*break*/, 5];
|
|
24080
|
+
case 3:
|
|
24081
|
+
error_1 = _a.sent();
|
|
24082
|
+
console.error('Error resending WhatsApp code:', error_1);
|
|
24083
|
+
setResendMessage({
|
|
24084
|
+
type: 'error',
|
|
24085
|
+
text: t("".concat(props.itemKey, ".phone.resendError"), 'Errore nell\'invio del codice. Riprova.')
|
|
24086
|
+
});
|
|
24087
|
+
return [3 /*break*/, 5];
|
|
24088
|
+
case 4:
|
|
24089
|
+
setIsResending(false);
|
|
24090
|
+
setTimeout(function () { return setResendMessage(null); }, 5000); // Clear message after 5 seconds
|
|
24091
|
+
return [7 /*endfinally*/];
|
|
24092
|
+
case 5: return [2 /*return*/];
|
|
24093
|
+
}
|
|
24094
|
+
});
|
|
24095
|
+
}); };
|
|
24068
24096
|
var renderProfileSettings = function () {
|
|
24069
24097
|
if (props.hideProfileSettings === true) {
|
|
24070
24098
|
return null;
|
|
24071
24099
|
}
|
|
24072
24100
|
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);
|
|
24073
24101
|
};
|
|
24074
|
-
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
|
|
24102
|
+
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), jsxs("div", __assign({ className: "d-flex align-items-center mt-2" }, { children: [jsx("h4", __assign({ className: "fw-bold mb-0" }, { children: t("".concat(props.itemKey, ".phone.title")) }), void 0), phoneInfo && (!phoneInfo.confirmedAt || phoneInfo.confirmedAt === 0) && (jsx("span", __assign({ className: "badge bg-warning text-dark ms-2" }, { children: t("".concat(props.itemKey, ".phone.notConfirmed")) }), void 0)), phoneInfo && phoneInfo.confirmedAt && phoneInfo.confirmedAt > 0 && (jsxs("span", __assign({ className: "badge bg-success ms-2" }, { children: [jsx("i", { className: "fas fa-check me-1" }, void 0), t("".concat(props.itemKey, ".phone.confirmed"))] }), void 0))] }), 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 ? (jsxs(Fragment, { children: [jsx(EditBtn, __assign({ onClick: function () { return dispatch(dialogActions.openDialogWithoutPayload({ type: 'changePhone' })); } }, { children: blurPhone(phoneInfo.phone) }), void 0), phoneInfo.confirmedAt === 0 && (jsx("button", __assign({ className: "btn btn-sm btn-primary ms-2", onClick: handleResendCode, disabled: isResending }, { children: isResending ? (jsxs(Fragment, { children: [jsx("span", { className: "spinner-border spinner-border-sm me-2", role: "status", "aria-hidden": "true" }, void 0), t("".concat(props.itemKey, ".phone.resending"), 'Invio...')] }, void 0)) : (jsxs(Fragment, { children: [jsx("i", { className: "fas fa-paper-plane me-2" }, void 0), t("".concat(props.itemKey, ".phone.resendBtn"), 'Invia di nuovo codice')] }, void 0)) }), void 0))] }, 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 ms-2", onClick: function () {
|
|
24075
24103
|
dispatch(dialogActions.openDialogWithoutPayload({ type: 'deletePhone' }));
|
|
24076
|
-
} }, { 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));
|
|
24104
|
+
} }, { children: jsx("i", { className: "fas fa-trash text-grey-5" }, void 0) }), void 0))] }), void 0), resendMessage && (jsx("div", __assign({ className: "alert alert-".concat(resendMessage.type === 'success' ? 'success' : 'danger', " mt-2") }, { children: resendMessage.text }), 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));
|
|
24077
24105
|
};
|
|
24078
24106
|
|
|
24079
24107
|
var CommunicationSettings = function (props) {
|