@openedx/frontend-app-authn 1.0.0-alpha.0 → 1.0.0-alpha.10
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/dist/Main.d.ts +3 -0
- package/dist/Main.js +10 -0
- package/dist/Main.js.map +1 -0
- package/dist/app.d.ts +3 -0
- package/dist/app.js +41 -0
- package/dist/app.js.map +1 -0
- package/dist/app.scss +2 -0
- package/dist/base-container/components/default-layout/LargeLayout.d.ts +2 -0
- package/dist/base-container/components/default-layout/LargeLayout.js +11 -0
- package/dist/base-container/components/default-layout/LargeLayout.js.map +1 -0
- package/dist/base-container/components/default-layout/MediumLayout.d.ts +2 -0
- package/dist/base-container/components/default-layout/MediumLayout.js +11 -0
- package/dist/base-container/components/default-layout/MediumLayout.js.map +1 -0
- package/dist/base-container/components/default-layout/SmallLayout.d.ts +2 -0
- package/dist/base-container/components/default-layout/SmallLayout.js +11 -0
- package/dist/base-container/components/default-layout/SmallLayout.js.map +1 -0
- package/dist/base-container/components/default-layout/index.d.ts +3 -0
- package/{src/base-container/components/default-layout/index.jsx → dist/base-container/components/default-layout/index.js} +1 -0
- package/dist/base-container/components/default-layout/index.js.map +1 -0
- package/dist/base-container/components/default-layout/messages.d.ts +13 -0
- package/dist/base-container/components/default-layout/messages.js +15 -0
- package/dist/base-container/components/default-layout/messages.js.map +1 -0
- package/dist/base-container/components/image-layout/ExtraSmallLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/ExtraSmallLayout.js +10 -0
- package/dist/base-container/components/image-layout/ExtraSmallLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/LargeLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/LargeLayout.js +11 -0
- package/dist/base-container/components/image-layout/LargeLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/MediumLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/MediumLayout.js +11 -0
- package/dist/base-container/components/image-layout/MediumLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/SmallLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/SmallLayout.js +10 -0
- package/dist/base-container/components/image-layout/SmallLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/index.d.ts +4 -0
- package/{src/base-container/components/image-layout/index.jsx → dist/base-container/components/image-layout/index.js} +1 -0
- package/dist/base-container/components/image-layout/index.js.map +1 -0
- package/dist/base-container/components/image-layout/messages.d.ts +13 -0
- package/dist/base-container/components/image-layout/messages.js +15 -0
- package/dist/base-container/components/image-layout/messages.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/LargeLayout.d.ts +10 -0
- package/dist/base-container/components/welcome-page-layout/LargeLayout.js +14 -0
- package/dist/base-container/components/welcome-page-layout/LargeLayout.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/MediumLayout.d.ts +10 -0
- package/dist/base-container/components/welcome-page-layout/MediumLayout.js +14 -0
- package/dist/base-container/components/welcome-page-layout/MediumLayout.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/SmallLayout.d.ts +10 -0
- package/dist/base-container/components/welcome-page-layout/SmallLayout.js +14 -0
- package/dist/base-container/components/welcome-page-layout/SmallLayout.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/index.d.ts +3 -0
- package/{src/base-container/components/welcome-page-layout/index.jsx → dist/base-container/components/welcome-page-layout/index.js} +1 -0
- package/dist/base-container/components/welcome-page-layout/index.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/messages.d.ts +18 -0
- package/dist/base-container/components/welcome-page-layout/messages.js +20 -0
- package/dist/base-container/components/welcome-page-layout/messages.js.map +1 -0
- package/dist/base-container/index.d.ts +20 -0
- package/dist/base-container/index.js +27 -0
- package/dist/base-container/index.js.map +1 -0
- package/dist/common-components/EmbeddedRegistrationRoute.d.ts +14 -0
- package/dist/common-components/EmbeddedRegistrationRoute.js +22 -0
- package/dist/common-components/EmbeddedRegistrationRoute.js.map +1 -0
- package/dist/common-components/EnterpriseSSO.d.ts +29 -0
- package/dist/common-components/EnterpriseSSO.js +58 -0
- package/dist/common-components/EnterpriseSSO.js.map +1 -0
- package/dist/common-components/FormGroup.d.ts +60 -0
- package/dist/common-components/FormGroup.js +66 -0
- package/dist/common-components/FormGroup.js.map +1 -0
- package/dist/common-components/InstitutionLogistration.d.ts +34 -0
- package/dist/common-components/InstitutionLogistration.js +38 -0
- package/dist/common-components/InstitutionLogistration.js.map +1 -0
- package/dist/common-components/NotFoundPage.d.ts +2 -0
- package/dist/common-components/NotFoundPage.js +5 -0
- package/dist/common-components/NotFoundPage.js.map +1 -0
- package/dist/common-components/PasswordField.d.ts +47 -0
- package/dist/common-components/PasswordField.js +98 -0
- package/dist/common-components/PasswordField.js.map +1 -0
- package/dist/common-components/RedirectLogistration.d.ts +39 -0
- package/dist/common-components/RedirectLogistration.js +72 -0
- package/dist/common-components/RedirectLogistration.js.map +1 -0
- package/dist/common-components/RegisterFaIcons.d.ts +1 -0
- package/dist/common-components/RegisterFaIcons.js +6 -0
- package/dist/common-components/RegisterFaIcons.js.map +1 -0
- package/dist/common-components/SocialAuthProviders.d.ts +23 -0
- package/dist/common-components/SocialAuthProviders.js +43 -0
- package/dist/common-components/SocialAuthProviders.js.map +1 -0
- package/dist/common-components/ThirdPartyAuth.d.ts +42 -0
- package/dist/common-components/ThirdPartyAuth.js +57 -0
- package/dist/common-components/ThirdPartyAuth.js.map +1 -0
- package/dist/common-components/ThirdPartyAuthAlert.d.ts +15 -0
- package/dist/common-components/ThirdPartyAuthAlert.js +32 -0
- package/dist/common-components/ThirdPartyAuthAlert.js.map +1 -0
- package/dist/common-components/UnAuthOnlyRoute.d.ts +14 -0
- package/dist/common-components/UnAuthOnlyRoute.js +32 -0
- package/dist/common-components/UnAuthOnlyRoute.js.map +1 -0
- package/dist/common-components/components/ThirdPartyAuthContext.d.ts +31 -0
- package/dist/common-components/components/ThirdPartyAuthContext.js +84 -0
- package/dist/common-components/components/ThirdPartyAuthContext.js.map +1 -0
- package/dist/common-components/data/api.d.ts +6 -0
- package/dist/common-components/data/api.js +26 -0
- package/dist/common-components/data/api.js.map +1 -0
- package/dist/common-components/data/apiHook.d.ts +9 -0
- package/dist/common-components/data/apiHook.js +14 -0
- package/dist/common-components/data/apiHook.js.map +1 -0
- package/dist/common-components/data/queryKeys.d.ts +4 -0
- package/dist/common-components/data/queryKeys.js +6 -0
- package/dist/common-components/data/queryKeys.js.map +1 -0
- package/dist/common-components/index.d.ts +10 -0
- package/{src/common-components/index.jsx → dist/common-components/index.js} +1 -3
- package/dist/common-components/index.js.map +1 -0
- package/dist/common-components/messages.d.ts +113 -0
- package/dist/common-components/messages.js +126 -0
- package/dist/common-components/messages.js.map +1 -0
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +17 -0
- package/dist/constants.js.map +1 -0
- package/dist/data/constants.d.ts +16 -0
- package/{src → dist}/data/constants.js +4 -17
- package/dist/data/constants.js.map +1 -0
- package/dist/data/countries.d.ts +26 -0
- package/{src/data/countries.ts → dist/data/countries.js} +6 -9
- package/dist/data/countries.js.map +1 -0
- package/dist/data/oneTrust.d.ts +2 -0
- package/dist/data/oneTrust.js +3 -0
- package/dist/data/oneTrust.js.map +1 -0
- package/dist/data/utils/cookies.d.ts +1 -0
- package/dist/data/utils/cookies.js +12 -0
- package/dist/data/utils/cookies.js.map +1 -0
- package/dist/data/utils/dataUtils.d.ts +12 -0
- package/dist/data/utils/dataUtils.js +81 -0
- package/dist/data/utils/dataUtils.js.map +1 -0
- package/dist/data/utils/index.d.ts +2 -0
- package/dist/data/utils/index.js +3 -0
- package/dist/data/utils/index.js.map +1 -0
- package/dist/data/utils/useMobileResponsive.d.ts +7 -0
- package/dist/data/utils/useMobileResponsive.js +22 -0
- package/dist/data/utils/useMobileResponsive.js.map +1 -0
- package/dist/field-renderer/FieldRenderer.d.ts +34 -0
- package/dist/field-renderer/FieldRenderer.js +70 -0
- package/dist/field-renderer/FieldRenderer.js.map +1 -0
- package/dist/field-renderer/index.d.ts +1 -0
- package/{src/field-renderer/index.jsx → dist/field-renderer/index.js} +1 -0
- package/dist/field-renderer/index.js.map +1 -0
- package/dist/forgot-password/ForgotPasswordAlert.d.ts +16 -0
- package/dist/forgot-password/ForgotPasswordAlert.js +66 -0
- package/dist/forgot-password/ForgotPasswordAlert.js.map +1 -0
- package/dist/forgot-password/ForgotPasswordPage.d.ts +2 -0
- package/dist/forgot-password/ForgotPasswordPage.js +92 -0
- package/dist/forgot-password/ForgotPasswordPage.js.map +1 -0
- package/dist/forgot-password/data/api.d.ts +2 -0
- package/dist/forgot-password/data/api.js +25 -0
- package/dist/forgot-password/data/api.js.map +1 -0
- package/dist/forgot-password/data/apiHook.d.ts +16 -0
- package/dist/forgot-password/data/apiHook.js +26 -0
- package/dist/forgot-password/data/apiHook.js.map +1 -0
- package/dist/forgot-password/index.d.ts +1 -0
- package/dist/forgot-password/index.js +2 -0
- package/dist/forgot-password/index.js.map +1 -0
- package/dist/forgot-password/messages.d.ts +123 -0
- package/dist/forgot-password/messages.js +128 -0
- package/dist/forgot-password/messages.js.map +1 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +1 -0
- package/{src/index.ts → dist/index.d.ts} +0 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/login/AccountActivationMessage.d.ts +14 -0
- package/dist/login/AccountActivationMessage.js +49 -0
- package/dist/login/AccountActivationMessage.js.map +1 -0
- package/dist/login/ChangePasswordPrompt.d.ts +18 -0
- package/dist/login/ChangePasswordPrompt.js +51 -0
- package/dist/login/ChangePasswordPrompt.js.map +1 -0
- package/dist/login/LoginFailure.d.ts +25 -0
- package/dist/login/LoginFailure.js +109 -0
- package/dist/login/LoginFailure.js.map +1 -0
- package/dist/login/LoginPage.d.ts +12 -0
- package/dist/login/LoginPage.js +174 -0
- package/dist/login/LoginPage.js.map +1 -0
- package/dist/login/components/LoginContext.d.ts +21 -0
- package/dist/login/components/LoginContext.js +28 -0
- package/dist/login/components/LoginContext.js.map +1 -0
- package/dist/login/data/api.d.ts +2 -0
- package/dist/login/data/api.js +27 -0
- package/dist/login/data/api.js.map +1 -0
- package/dist/login/data/apiHook.d.ts +13 -0
- package/dist/login/data/apiHook.js +57 -0
- package/dist/login/data/apiHook.js.map +1 -0
- package/dist/login/data/constants.d.ts +17 -0
- package/{src → dist}/login/data/constants.js +4 -4
- package/dist/login/data/constants.js.map +1 -0
- package/dist/login/index.d.ts +1 -0
- package/dist/login/index.js +2 -0
- package/dist/login/index.js.map +1 -0
- package/dist/login/messages.d.ts +198 -0
- package/dist/login/messages.js +210 -0
- package/dist/login/messages.js.map +1 -0
- package/dist/logistration/Logistration.d.ts +5 -0
- package/dist/logistration/Logistration.js +80 -0
- package/dist/logistration/Logistration.js.map +1 -0
- package/dist/progressive-profiling/ProgressiveProfiling.d.ts +2 -0
- package/dist/progressive-profiling/ProgressiveProfiling.js +143 -0
- package/dist/progressive-profiling/ProgressiveProfiling.js.map +1 -0
- package/dist/progressive-profiling/ProgressiveProfilingPageModal.d.ts +13 -0
- package/dist/progressive-profiling/ProgressiveProfilingPageModal.js +31 -0
- package/dist/progressive-profiling/ProgressiveProfilingPageModal.js.map +1 -0
- package/dist/progressive-profiling/components/ProgressiveProfilingContext.d.ts +18 -0
- package/dist/progressive-profiling/components/ProgressiveProfilingContext.js +52 -0
- package/dist/progressive-profiling/components/ProgressiveProfilingContext.js.map +1 -0
- package/dist/progressive-profiling/data/api.d.ts +2 -0
- package/dist/progressive-profiling/data/api.js +22 -0
- package/dist/progressive-profiling/data/api.js.map +1 -0
- package/dist/progressive-profiling/data/apiHook.d.ts +10 -0
- package/dist/progressive-profiling/data/apiHook.js +36 -0
- package/dist/progressive-profiling/data/apiHook.js.map +1 -0
- package/dist/progressive-profiling/index.d.ts +2 -0
- package/{src → dist}/progressive-profiling/index.js +1 -3
- package/dist/progressive-profiling/index.js.map +1 -0
- package/dist/progressive-profiling/messages.d.ts +53 -0
- package/dist/progressive-profiling/messages.js +57 -0
- package/dist/progressive-profiling/messages.js.map +1 -0
- package/dist/provides.d.ts +4 -0
- package/dist/provides.js +7 -0
- package/dist/provides.js.map +1 -0
- package/dist/register/RegistrationFields/CountryField/CountryField.d.ts +38 -0
- package/dist/register/RegistrationFields/CountryField/CountryField.js +93 -0
- package/dist/register/RegistrationFields/CountryField/CountryField.js.map +1 -0
- package/dist/register/RegistrationFields/CountryField/validator.d.ts +8 -0
- package/dist/register/RegistrationFields/CountryField/validator.js +29 -0
- package/dist/register/RegistrationFields/CountryField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/EmailField/EmailField.d.ts +30 -0
- package/dist/register/RegistrationFields/EmailField/EmailField.js +88 -0
- package/dist/register/RegistrationFields/EmailField/EmailField.js.map +1 -0
- package/dist/register/RegistrationFields/EmailField/constants.d.ts +3 -0
- package/dist/register/RegistrationFields/EmailField/constants.js +130 -0
- package/dist/register/RegistrationFields/EmailField/constants.js.map +1 -0
- package/dist/register/RegistrationFields/EmailField/validator.d.ts +17 -0
- package/dist/register/RegistrationFields/EmailField/validator.js +107 -0
- package/dist/register/RegistrationFields/EmailField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/HonorCodeField/HonorCode.d.ts +21 -0
- package/dist/register/RegistrationFields/HonorCodeField/HonorCode.js +40 -0
- package/dist/register/RegistrationFields/HonorCodeField/HonorCode.js.map +1 -0
- package/dist/register/RegistrationFields/NameField/NameField.d.ts +29 -0
- package/dist/register/RegistrationFields/NameField/NameField.js +59 -0
- package/dist/register/RegistrationFields/NameField/NameField.js.map +1 -0
- package/dist/register/RegistrationFields/NameField/validator.d.ts +6 -0
- package/dist/register/RegistrationFields/NameField/validator.js +23 -0
- package/dist/register/RegistrationFields/NameField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/TermsOfServiceField/TermsOfService.d.ts +16 -0
- package/dist/register/RegistrationFields/TermsOfServiceField/TermsOfService.js +24 -0
- package/dist/register/RegistrationFields/TermsOfServiceField/TermsOfService.js.map +1 -0
- package/dist/register/RegistrationFields/UsernameField/UsernameField.d.ts +31 -0
- package/dist/register/RegistrationFields/UsernameField/UsernameField.js +119 -0
- package/dist/register/RegistrationFields/UsernameField/UsernameField.js.map +1 -0
- package/dist/register/RegistrationFields/UsernameField/validator.d.ts +4 -0
- package/dist/register/RegistrationFields/UsernameField/validator.js +15 -0
- package/dist/register/RegistrationFields/UsernameField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/index.d.ts +6 -0
- package/{src → dist}/register/RegistrationFields/index.js +1 -0
- package/dist/register/RegistrationFields/index.js.map +1 -0
- package/dist/register/RegistrationPage.d.ts +18 -0
- package/dist/register/RegistrationPage.js +259 -0
- package/dist/register/RegistrationPage.js.map +1 -0
- package/dist/register/components/ConfigurableRegistrationForm.d.ts +37 -0
- package/dist/register/components/ConfigurableRegistrationForm.js +145 -0
- package/dist/register/components/ConfigurableRegistrationForm.js.map +1 -0
- package/dist/register/components/RegisterContext.d.ts +8 -0
- package/dist/register/components/RegisterContext.js +167 -0
- package/dist/register/components/RegisterContext.js.map +1 -0
- package/dist/register/components/RegistrationFailure.d.ts +19 -0
- package/dist/register/components/RegistrationFailure.js +60 -0
- package/dist/register/components/RegistrationFailure.js.map +1 -0
- package/dist/register/data/api.d.ts +9 -0
- package/dist/register/data/api.js +45 -0
- package/dist/register/data/api.js.map +1 -0
- package/dist/register/data/apiHook.d.ts +33 -0
- package/dist/register/data/apiHook.js +66 -0
- package/dist/register/data/apiHook.js.map +1 -0
- package/dist/register/data/constants.d.ts +11 -0
- package/{src → dist}/register/data/constants.js +5 -4
- package/dist/register/data/constants.js.map +1 -0
- package/dist/register/data/utils.d.ts +6 -0
- package/dist/register/data/utils.js +128 -0
- package/dist/register/data/utils.js.map +1 -0
- package/dist/register/index.d.ts +1 -0
- package/dist/register/index.js +2 -0
- package/dist/register/index.js.map +1 -0
- package/dist/register/messages.d.ts +203 -0
- package/dist/register/messages.js +215 -0
- package/dist/register/messages.js.map +1 -0
- package/dist/register/types.d.ts +74 -0
- package/dist/register/types.js +2 -0
- package/dist/register/types.js.map +1 -0
- package/dist/reset-password/ResetPasswordFailure.d.ts +15 -0
- package/dist/reset-password/ResetPasswordFailure.js +44 -0
- package/dist/reset-password/ResetPasswordFailure.js.map +1 -0
- package/dist/reset-password/ResetPasswordPage.d.ts +2 -0
- package/dist/reset-password/ResetPasswordPage.js +182 -0
- package/dist/reset-password/ResetPasswordPage.js.map +1 -0
- package/dist/reset-password/ResetPasswordSuccess.d.ts +2 -0
- package/dist/reset-password/ResetPasswordSuccess.js +10 -0
- package/dist/reset-password/ResetPasswordSuccess.js.map +1 -0
- package/dist/reset-password/data/api.d.ts +4 -0
- package/dist/reset-password/data/api.js +57 -0
- package/dist/reset-password/data/api.js.map +1 -0
- package/dist/reset-password/data/apiHook.d.ts +31 -0
- package/dist/reset-password/data/apiHook.js +74 -0
- package/dist/reset-password/data/apiHook.js.map +1 -0
- package/dist/reset-password/data/constants.d.ts +13 -0
- package/{src → dist}/reset-password/data/constants.js +6 -7
- package/dist/reset-password/data/constants.js.map +1 -0
- package/dist/reset-password/index.d.ts +1 -0
- package/dist/reset-password/index.js +2 -0
- package/dist/reset-password/index.js.map +1 -0
- package/dist/reset-password/messages.d.ts +83 -0
- package/dist/reset-password/messages.js +87 -0
- package/dist/reset-password/messages.js.map +1 -0
- package/dist/routes.d.ts +19 -0
- package/dist/routes.js +76 -0
- package/dist/routes.js.map +1 -0
- package/{src → dist}/sass/_base_component.scss +57 -54
- package/{src → dist}/sass/_progressive_profiling_page.scss +1 -3
- package/{src → dist}/sass/_registration.scss +15 -18
- package/{src → dist}/sass/_style.scss +40 -43
- package/dist/slots/LoginComponentSlot/index.d.ts +12 -0
- package/dist/slots/LoginComponentSlot/index.js +11 -0
- package/dist/slots/LoginComponentSlot/index.js.map +1 -0
- package/package.json +38 -16
- package/src/Main.tsx +0 -23
- package/src/__mocks__/file.js +0 -1
- package/src/__mocks__/svg.js +0 -1
- package/src/app.scss +0 -6
- package/src/app.ts +0 -43
- package/src/base-container/components/default-layout/DefaultLayout.test.jsx +0 -48
- package/src/base-container/components/default-layout/LargeLayout.jsx +0 -42
- package/src/base-container/components/default-layout/MediumLayout.jsx +0 -49
- package/src/base-container/components/default-layout/SmallLayout.jsx +0 -37
- package/src/base-container/components/default-layout/messages.js +0 -16
- package/src/base-container/components/image-layout/ExtraSmallLayout.jsx +0 -31
- package/src/base-container/components/image-layout/LargeLayout.jsx +0 -32
- package/src/base-container/components/image-layout/MediumLayout.jsx +0 -32
- package/src/base-container/components/image-layout/SmallLayout.jsx +0 -31
- package/src/base-container/components/image-layout/messages.js +0 -16
- package/src/base-container/components/welcome-page-layout/LargeLayout.jsx +0 -46
- package/src/base-container/components/welcome-page-layout/MediumLayout.jsx +0 -49
- package/src/base-container/components/welcome-page-layout/SmallLayout.jsx +0 -38
- package/src/base-container/components/welcome-page-layout/messages.js +0 -21
- package/src/base-container/index.jsx +0 -70
- package/src/base-container/tests/BaseContainer.test.jsx +0 -44
- package/src/common-components/EmbeddedRegistrationRoute.jsx +0 -26
- package/src/common-components/EnterpriseSSO.jsx +0 -110
- package/src/common-components/FormGroup.jsx +0 -106
- package/src/common-components/InstitutionLogistration.jsx +0 -102
- package/src/common-components/NotFoundPage.jsx +0 -15
- package/src/common-components/PasswordField.jsx +0 -175
- package/src/common-components/RedirectLogistration.jsx +0 -94
- package/src/common-components/RegisterFaIcons.jsx +0 -8
- package/src/common-components/SocialAuthProviders.jsx +0 -75
- package/src/common-components/ThirdPartyAuth.jsx +0 -123
- package/src/common-components/ThirdPartyAuthAlert.jsx +0 -49
- package/src/common-components/UnAuthOnlyRoute.jsx +0 -41
- package/src/common-components/data/actions.js +0 -27
- package/src/common-components/data/reducers.js +0 -63
- package/src/common-components/data/sagas.js +0 -32
- package/src/common-components/data/selectors.js +0 -28
- package/src/common-components/data/service.js +0 -23
- package/src/common-components/data/tests/reducer.test.js +0 -82
- package/src/common-components/data/tests/sagas.test.js +0 -71
- package/src/common-components/messages.jsx +0 -127
- package/src/common-components/tests/EmbeddedRegistrationRoute.test.jsx +0 -76
- package/src/common-components/tests/FormField.test.jsx +0 -289
- package/src/common-components/tests/SocialAuthProviders.test.jsx +0 -75
- package/src/common-components/tests/ThirdPartyAuthAlert.test.jsx +0 -39
- package/src/common-components/tests/UnAuthOnlyRoute.test.jsx +0 -73
- package/src/common-components/tests/__snapshots__/SocialAuthProviders.test.jsx.snap +0 -156
- package/src/common-components/tests/__snapshots__/ThirdPartyAuthAlert.test.jsx.snap +0 -53
- package/src/constants.ts +0 -1
- package/src/data/configureStore.js +0 -33
- package/src/data/oneTrust.js +0 -3
- package/src/data/reducers.js +0 -36
- package/src/data/sagas.js +0 -19
- package/src/data/tests/cookies.test.js +0 -42
- package/src/data/tests/dataUtils.test.js +0 -19
- package/src/data/tests/reduxUtils.test.js +0 -14
- package/src/data/utils/cookies.js +0 -12
- package/src/data/utils/dataUtils.js +0 -81
- package/src/data/utils/index.js +0 -11
- package/src/data/utils/reduxUtils.js +0 -34
- package/src/data/utils/useMobileResponsive.js +0 -24
- package/src/field-renderer/FieldRenderer.jsx +0 -156
- package/src/field-renderer/tests/FieldRenderer.test.jsx +0 -201
- package/src/forgot-password/ForgotPasswordAlert.jsx +0 -97
- package/src/forgot-password/ForgotPasswordPage.jsx +0 -193
- package/src/forgot-password/data/actions.js +0 -32
- package/src/forgot-password/data/reducers.js +0 -58
- package/src/forgot-password/data/sagas.js +0 -35
- package/src/forgot-password/data/selectors.js +0 -10
- package/src/forgot-password/data/service.js +0 -21
- package/src/forgot-password/data/tests/reducers.test.js +0 -34
- package/src/forgot-password/data/tests/sagas.test.js +0 -67
- package/src/forgot-password/index.js +0 -5
- package/src/forgot-password/messages.js +0 -128
- package/src/forgot-password/tests/ForgotPasswordPage.test.jsx +0 -269
- package/src/i18n/index.js +0 -25
- package/src/login/AccountActivationMessage.jsx +0 -78
- package/src/login/ChangePasswordPrompt.jsx +0 -91
- package/src/login/LoginFailure.jsx +0 -231
- package/src/login/LoginPage.jsx +0 -368
- package/src/login/data/actions.js +0 -39
- package/src/login/data/reducers.js +0 -76
- package/src/login/data/sagas.js +0 -45
- package/src/login/data/service.js +0 -24
- package/src/login/data/tests/reducers.test.js +0 -155
- package/src/login/data/tests/sagas.test.js +0 -110
- package/src/login/index.js +0 -5
- package/src/login/messages.jsx +0 -211
- package/src/login/tests/AccountActivationMessage.test.jsx +0 -122
- package/src/login/tests/ChangePasswordPrompt.test.jsx +0 -75
- package/src/login/tests/LoginFailure.test.jsx +0 -323
- package/src/login/tests/LoginPage.test.jsx +0 -839
- package/src/logistration/Logistration.jsx +0 -189
- package/src/logistration/Logistration.test.jsx +0 -275
- package/src/progressive-profiling/ProgressiveProfiling.jsx +0 -313
- package/src/progressive-profiling/ProgressiveProfilingPageModal.jsx +0 -56
- package/src/progressive-profiling/data/actions.js +0 -22
- package/src/progressive-profiling/data/reducers.js +0 -38
- package/src/progressive-profiling/data/sagas.js +0 -24
- package/src/progressive-profiling/data/selectors.js +0 -14
- package/src/progressive-profiling/data/service.js +0 -17
- package/src/progressive-profiling/messages.jsx +0 -57
- package/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx +0 -322
- package/src/register/RegistrationFields/CountryField/CountryField.jsx +0 -164
- package/src/register/RegistrationFields/CountryField/CountryField.test.jsx +0 -204
- package/src/register/RegistrationFields/CountryField/validator.js +0 -32
- package/src/register/RegistrationFields/EmailField/EmailField.jsx +0 -140
- package/src/register/RegistrationFields/EmailField/EmailField.test.jsx +0 -236
- package/src/register/RegistrationFields/EmailField/constants.js +0 -131
- package/src/register/RegistrationFields/EmailField/validator.js +0 -126
- package/src/register/RegistrationFields/EmailField/validator.test.js +0 -39
- package/src/register/RegistrationFields/HonorCodeField/HonorCode.jsx +0 -104
- package/src/register/RegistrationFields/HonorCodeField/HonorCode.test.jsx +0 -70
- package/src/register/RegistrationFields/NameField/NameField.jsx +0 -68
- package/src/register/RegistrationFields/NameField/NameField.test.jsx +0 -146
- package/src/register/RegistrationFields/NameField/validator.js +0 -22
- package/src/register/RegistrationFields/TermsOfServiceField/TermsOfService.jsx +0 -58
- package/src/register/RegistrationFields/TermsOfServiceField/TermsOfService.test.jsx +0 -55
- package/src/register/RegistrationFields/UsernameField/UsernameField.jsx +0 -162
- package/src/register/RegistrationFields/UsernameField/UsernameField.test.jsx +0 -319
- package/src/register/RegistrationFields/UsernameField/validator.js +0 -16
- package/src/register/RegistrationPage.jsx +0 -428
- package/src/register/RegistrationPage.test.jsx +0 -854
- package/src/register/components/ConfigurableRegistrationForm.jsx +0 -244
- package/src/register/components/RegistrationFailure.jsx +0 -80
- package/src/register/components/tests/ConfigurableRegistrationForm.test.jsx +0 -401
- package/src/register/components/tests/RegistrationFailure.test.jsx +0 -212
- package/src/register/components/tests/ThirdPartyAuth.test.jsx +0 -439
- package/src/register/data/actions.js +0 -85
- package/src/register/data/reducers.js +0 -140
- package/src/register/data/sagas.js +0 -58
- package/src/register/data/selectors.js +0 -34
- package/src/register/data/service.js +0 -45
- package/src/register/data/tests/reducers.test.js +0 -277
- package/src/register/data/tests/sagas.test.js +0 -239
- package/src/register/data/tests/utils.test.js +0 -98
- package/src/register/data/utils.js +0 -153
- package/src/register/index.js +0 -4
- package/src/register/messages.jsx +0 -206
- package/src/reset-password/ResetPasswordFailure.jsx +0 -55
- package/src/reset-password/ResetPasswordPage.jsx +0 -224
- package/src/reset-password/ResetPasswordSuccess.jsx +0 -19
- package/src/reset-password/data/actions.js +0 -50
- package/src/reset-password/data/reducers.js +0 -44
- package/src/reset-password/data/sagas.js +0 -67
- package/src/reset-password/data/selectors.js +0 -10
- package/src/reset-password/data/service.js +0 -61
- package/src/reset-password/data/tests/sagas.test.js +0 -185
- package/src/reset-password/index.js +0 -5
- package/src/reset-password/messages.js +0 -88
- package/src/reset-password/tests/ResetPasswordPage.test.jsx +0 -241
- package/src/routes.jsx +0 -79
- package/src/setupTest.js +0 -68
- /package/{src → dist}/base-container/components/image-layout/index.scss +0 -0
- /package/{src → dist}/sass/_forgot_password.scss +0 -0
- /package/{src → dist}/sass/_login_page.scss +0 -0
- /package/{src → dist}/sass/_reset_password.scss +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { createContext, useCallback, useContext, useMemo, useReducer, } from 'react';
|
|
14
|
+
const RegisterContext = createContext(null);
|
|
15
|
+
const initialState = {
|
|
16
|
+
validations: null,
|
|
17
|
+
usernameSuggestions: [],
|
|
18
|
+
validationApiRateLimited: false,
|
|
19
|
+
registrationResult: { success: false, redirectUrl: '', authenticatedUser: null },
|
|
20
|
+
registrationError: {},
|
|
21
|
+
backendCountryCode: '',
|
|
22
|
+
registrationFormData: {
|
|
23
|
+
configurableFormFields: {
|
|
24
|
+
marketingEmailsOptIn: true,
|
|
25
|
+
},
|
|
26
|
+
formFields: {
|
|
27
|
+
name: '', email: '', username: '', password: '',
|
|
28
|
+
},
|
|
29
|
+
emailSuggestion: {
|
|
30
|
+
suggestion: '', type: '',
|
|
31
|
+
},
|
|
32
|
+
errors: {
|
|
33
|
+
name: '', email: '', username: '', password: '',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const registerReducer = (state, action) => {
|
|
38
|
+
switch (action.type) {
|
|
39
|
+
case 'SET_VALIDATIONS_SUCCESS': {
|
|
40
|
+
const _a = action.payload, { usernameSuggestions: newUsernameSuggestions } = _a, validationWithoutUsernameSuggestions = __rest(_a, ["usernameSuggestions"]);
|
|
41
|
+
return Object.assign(Object.assign({}, state), { validations: validationWithoutUsernameSuggestions, usernameSuggestions: newUsernameSuggestions || state.usernameSuggestions, validationApiRateLimited: false });
|
|
42
|
+
}
|
|
43
|
+
case 'SET_VALIDATIONS_FAILURE':
|
|
44
|
+
return Object.assign(Object.assign({}, state), { validationApiRateLimited: true, validations: null });
|
|
45
|
+
case 'CLEAR_USERNAME_SUGGESTIONS':
|
|
46
|
+
return Object.assign(Object.assign({}, state), { usernameSuggestions: [] });
|
|
47
|
+
case 'CLEAR_REGISTRATION_BACKEND_ERROR': {
|
|
48
|
+
const rest = Object.assign({}, state.registrationError);
|
|
49
|
+
delete rest[action.payload];
|
|
50
|
+
return Object.assign(Object.assign({}, state), { registrationError: rest });
|
|
51
|
+
}
|
|
52
|
+
case 'SET_BACKEND_COUNTRY_CODE':
|
|
53
|
+
return Object.assign(Object.assign({}, state), { backendCountryCode: !state.registrationFormData.configurableFormFields.country
|
|
54
|
+
? action.payload
|
|
55
|
+
: state.backendCountryCode });
|
|
56
|
+
case 'SET_EMAIL_SUGGESTION':
|
|
57
|
+
return Object.assign(Object.assign({}, state), { registrationFormData: Object.assign(Object.assign({}, state.registrationFormData), { emailSuggestion: { suggestion: action.payload.suggestion, type: action.payload.type } }) });
|
|
58
|
+
case 'UPDATE_REGISTRATION_FORM_DATA':
|
|
59
|
+
return Object.assign(Object.assign({}, state), { registrationFormData: Object.assign(Object.assign({}, state.registrationFormData), action.payload) });
|
|
60
|
+
case 'SET_REGISTRATION_FORM_DATA':
|
|
61
|
+
return Object.assign(Object.assign({}, state), { registrationFormData: typeof action.payload === 'function'
|
|
62
|
+
? action.payload(state.registrationFormData)
|
|
63
|
+
: action.payload });
|
|
64
|
+
case 'SET_REGISTRATION_RESULT':
|
|
65
|
+
return Object.assign(Object.assign({}, state), { registrationResult: action.payload });
|
|
66
|
+
case 'SET_REGISTRATION_ERROR':
|
|
67
|
+
return Object.assign(Object.assign({}, state), { registrationError: action.payload });
|
|
68
|
+
default:
|
|
69
|
+
return state;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export const RegisterProvider = ({ children }) => {
|
|
73
|
+
const [state, dispatch] = useReducer(registerReducer, initialState);
|
|
74
|
+
const setValidationsSuccess = useCallback((validationData) => {
|
|
75
|
+
dispatch({ type: 'SET_VALIDATIONS_SUCCESS', payload: validationData });
|
|
76
|
+
}, []);
|
|
77
|
+
const setValidationsFailure = useCallback(() => {
|
|
78
|
+
dispatch({ type: 'SET_VALIDATIONS_FAILURE' });
|
|
79
|
+
}, []);
|
|
80
|
+
const clearUsernameSuggestions = useCallback(() => {
|
|
81
|
+
dispatch({ type: 'CLEAR_USERNAME_SUGGESTIONS' });
|
|
82
|
+
}, []);
|
|
83
|
+
const clearRegistrationBackendError = useCallback((field) => {
|
|
84
|
+
dispatch({ type: 'CLEAR_REGISTRATION_BACKEND_ERROR', payload: field });
|
|
85
|
+
}, []);
|
|
86
|
+
const setBackendCountryCode = useCallback((countryCode) => {
|
|
87
|
+
dispatch({ type: 'SET_BACKEND_COUNTRY_CODE', payload: countryCode });
|
|
88
|
+
}, []);
|
|
89
|
+
const setEmailSuggestionContext = useCallback((suggestion, type) => {
|
|
90
|
+
dispatch({ type: 'SET_EMAIL_SUGGESTION', payload: { suggestion, type } });
|
|
91
|
+
}, []);
|
|
92
|
+
const updateRegistrationFormData = useCallback((newData) => {
|
|
93
|
+
dispatch({ type: 'UPDATE_REGISTRATION_FORM_DATA', payload: newData });
|
|
94
|
+
}, []);
|
|
95
|
+
const setRegistrationResult = useCallback((result) => {
|
|
96
|
+
dispatch({ type: 'SET_REGISTRATION_RESULT', payload: result });
|
|
97
|
+
}, []);
|
|
98
|
+
const setRegistrationFormData = useCallback((data) => {
|
|
99
|
+
dispatch({ type: 'SET_REGISTRATION_FORM_DATA', payload: data });
|
|
100
|
+
}, []);
|
|
101
|
+
const setRegistrationError = useCallback((error) => {
|
|
102
|
+
dispatch({ type: 'SET_REGISTRATION_ERROR', payload: error });
|
|
103
|
+
}, []);
|
|
104
|
+
const backendValidations = useMemo(() => {
|
|
105
|
+
if (state.registrationError && Object.keys(state.registrationError).length > 0) {
|
|
106
|
+
const fields = Object.keys(state.registrationError).filter((fieldName) => !(['errorCode', 'usernameSuggestions'].includes(fieldName)));
|
|
107
|
+
const validationDecisions = {};
|
|
108
|
+
fields.forEach(field => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
validationDecisions[field] = ((_b = (_a = state.registrationError[field]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.userMessage) || '';
|
|
111
|
+
});
|
|
112
|
+
return validationDecisions;
|
|
113
|
+
}
|
|
114
|
+
if (state.validations) {
|
|
115
|
+
return state.validations.validationDecisions;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}, [state.validations, state.registrationError]);
|
|
119
|
+
const contextValue = useMemo(() => ({
|
|
120
|
+
validations: state.validations,
|
|
121
|
+
registrationFormData: state.registrationFormData,
|
|
122
|
+
registrationError: state.registrationError,
|
|
123
|
+
registrationResult: state.registrationResult,
|
|
124
|
+
backendCountryCode: state.backendCountryCode,
|
|
125
|
+
usernameSuggestions: state.usernameSuggestions,
|
|
126
|
+
validationApiRateLimited: state.validationApiRateLimited,
|
|
127
|
+
backendValidations,
|
|
128
|
+
setValidationsSuccess,
|
|
129
|
+
setValidationsFailure,
|
|
130
|
+
clearUsernameSuggestions,
|
|
131
|
+
clearRegistrationBackendError,
|
|
132
|
+
setRegistrationFormData,
|
|
133
|
+
setEmailSuggestionContext,
|
|
134
|
+
updateRegistrationFormData,
|
|
135
|
+
setBackendCountryCode,
|
|
136
|
+
setRegistrationError,
|
|
137
|
+
setRegistrationResult,
|
|
138
|
+
}), [
|
|
139
|
+
state.validations,
|
|
140
|
+
state.registrationFormData,
|
|
141
|
+
state.backendCountryCode,
|
|
142
|
+
state.usernameSuggestions,
|
|
143
|
+
state.validationApiRateLimited,
|
|
144
|
+
state.registrationError,
|
|
145
|
+
state.registrationResult,
|
|
146
|
+
backendValidations,
|
|
147
|
+
setValidationsSuccess,
|
|
148
|
+
setValidationsFailure,
|
|
149
|
+
clearUsernameSuggestions,
|
|
150
|
+
clearRegistrationBackendError,
|
|
151
|
+
setRegistrationFormData,
|
|
152
|
+
setEmailSuggestionContext,
|
|
153
|
+
updateRegistrationFormData,
|
|
154
|
+
setBackendCountryCode,
|
|
155
|
+
setRegistrationError,
|
|
156
|
+
setRegistrationResult,
|
|
157
|
+
]);
|
|
158
|
+
return (_jsx(RegisterContext.Provider, { value: contextValue, children: children }));
|
|
159
|
+
};
|
|
160
|
+
export const useRegisterContext = () => {
|
|
161
|
+
const context = useContext(RegisterContext);
|
|
162
|
+
if (!context) {
|
|
163
|
+
throw new Error('useRegisterContext must be used within a RegisterProvider');
|
|
164
|
+
}
|
|
165
|
+
return context;
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=RegisterContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisterContext.js","sourceRoot":"","sources":["../../../src/register/components/RegisterContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,aAAa,EAAiB,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAC3E,MAAM,OAAO,CAAC;AAMf,MAAM,eAAe,GAAG,aAAa,CAA6B,IAAI,CAAC,CAAC;AAExE,MAAM,YAAY,GAAkB;IAClC,WAAW,EAAE,IAAI;IACjB,mBAAmB,EAAE,EAAE;IACvB,wBAAwB,EAAE,KAAK;IAC/B,kBAAkB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE;IAChF,iBAAiB,EAAE,EAAE;IACrB,kBAAkB,EAAE,EAAE;IACtB,oBAAoB,EAAE;QACpB,sBAAsB,E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,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import {\n createContext, FC, ReactNode, useCallback, useContext, useMemo, useReducer,\n} from 'react';\n\nimport {\n RegisterContextType, RegisterState, RegistrationFormData, RegistrationResult, ValidationData,\n} from '../types';\n\nconst RegisterContext = createContext<RegisterContextType | null>(null);\n\nconst initialState: RegisterState = {\n validations: null,\n usernameSuggestions: [],\n validationApiRateLimited: false,\n registrationResult: { success: false, redirectUrl: '', authenticatedUser: null },\n registrationError: {},\n backendCountryCode: '',\n registrationFormData: {\n configurableFormFields: {\n marketingEmailsOptIn: true,\n },\n formFields: {\n name: '', email: '', username: '', password: '',\n },\n emailSuggestion: {\n suggestion: '', type: '',\n },\n errors: {\n name: '', email: '', username: '', password: '',\n },\n },\n};\n\nconst registerReducer = (state: RegisterState, action: any): RegisterState => {\n switch (action.type) {\n case 'SET_VALIDATIONS_SUCCESS': {\n const { usernameSuggestions: newUsernameSuggestions, ...validationWithoutUsernameSuggestions } = action.payload;\n return {\n ...state,\n validations: validationWithoutUsernameSuggestions,\n usernameSuggestions: newUsernameSuggestions || state.usernameSuggestions,\n validationApiRateLimited: false,\n };\n }\n case 'SET_VALIDATIONS_FAILURE':\n return {\n ...state,\n validationApiRateLimited: true,\n validations: null,\n };\n case 'CLEAR_USERNAME_SUGGESTIONS':\n return { ...state, usernameSuggestions: [] };\n case 'CLEAR_REGISTRATION_BACKEND_ERROR': {\n const rest = { ...state.registrationError };\n delete rest[action.payload];\n return { ...state, registrationError: rest };\n }\n case 'SET_BACKEND_COUNTRY_CODE':\n return {\n ...state,\n backendCountryCode: !state.registrationFormData.configurableFormFields.country\n ? action.payload\n : state.backendCountryCode,\n };\n case 'SET_EMAIL_SUGGESTION':\n return {\n ...state,\n registrationFormData: {\n ...state.registrationFormData,\n emailSuggestion: { suggestion: action.payload.suggestion, type: action.payload.type },\n },\n };\n case 'UPDATE_REGISTRATION_FORM_DATA':\n return {\n ...state,\n registrationFormData: { ...state.registrationFormData, ...action.payload },\n };\n case 'SET_REGISTRATION_FORM_DATA':\n return {\n ...state,\n registrationFormData: typeof action.payload === 'function'\n ? action.payload(state.registrationFormData)\n : action.payload,\n };\n case 'SET_REGISTRATION_RESULT':\n return { ...state, registrationResult: action.payload };\n case 'SET_REGISTRATION_ERROR':\n return { ...state, registrationError: action.payload };\n default:\n return state;\n }\n};\n\ninterface RegisterProviderProps {\n children: ReactNode,\n}\n\nexport const RegisterProvider: FC<RegisterProviderProps> = ({ children }) => {\n const [state, dispatch] = useReducer(registerReducer, initialState);\n\n const setValidationsSuccess = useCallback((validationData: ValidationData) => {\n dispatch({ type: 'SET_VALIDATIONS_SUCCESS', payload: validationData });\n }, []);\n\n const setValidationsFailure = useCallback(() => {\n dispatch({ type: 'SET_VALIDATIONS_FAILURE' });\n }, []);\n\n const clearUsernameSuggestions = useCallback(() => {\n dispatch({ type: 'CLEAR_USERNAME_SUGGESTIONS' });\n }, []);\n\n const clearRegistrationBackendError = useCallback((field: string) => {\n dispatch({ type: 'CLEAR_REGISTRATION_BACKEND_ERROR', payload: field });\n }, []);\n\n const setBackendCountryCode = useCallback((countryCode: string) => {\n dispatch({ type: 'SET_BACKEND_COUNTRY_CODE', payload: countryCode });\n }, []);\n\n const setEmailSuggestionContext = useCallback((suggestion: string, type: string) => {\n dispatch({ type: 'SET_EMAIL_SUGGESTION', payload: { suggestion, type } });\n }, []);\n\n const updateRegistrationFormData = useCallback((newData: Partial<RegistrationFormData>) => {\n dispatch({ type: 'UPDATE_REGISTRATION_FORM_DATA', payload: newData });\n }, []);\n\n const setRegistrationResult = useCallback((result: RegistrationResult) => {\n dispatch({ type: 'SET_REGISTRATION_RESULT', payload: result });\n }, []);\n\n const setRegistrationFormData = useCallback((data: RegistrationFormData |\n ((prev: RegistrationFormData) => RegistrationFormData)) => {\n dispatch({ type: 'SET_REGISTRATION_FORM_DATA', payload: data });\n }, []);\n\n const setRegistrationError = useCallback((error: Record<string, { userMessage: string }[]>) => {\n dispatch({ type: 'SET_REGISTRATION_ERROR', payload: error });\n }, []);\n\n const backendValidations = useMemo(() => {\n if (state.registrationError && Object.keys(state.registrationError).length > 0) {\n const fields = Object.keys(state.registrationError).filter(\n (fieldName) => !(['errorCode', 'usernameSuggestions'].includes(fieldName)),\n );\n\n const validationDecisions: Record<string, string> = {};\n fields.forEach(field => {\n validationDecisions[field] = state.registrationError[field]?.[0]?.userMessage || '';\n });\n return validationDecisions;\n }\n\n if (state.validations) {\n return state.validations.validationDecisions;\n }\n\n return null;\n }, [state.validations, state.registrationError]);\n\n const contextValue = useMemo(() => ({\n validations: state.validations,\n registrationFormData: state.registrationFormData,\n registrationError: state.registrationError,\n registrationResult: state.registrationResult,\n backendCountryCode: state.backendCountryCode,\n usernameSuggestions: state.usernameSuggestions,\n validationApiRateLimited: state.validationApiRateLimited,\n backendValidations,\n setValidationsSuccess,\n setValidationsFailure,\n clearUsernameSuggestions,\n clearRegistrationBackendError,\n setRegistrationFormData,\n setEmailSuggestionContext,\n updateRegistrationFormData,\n setBackendCountryCode,\n setRegistrationError,\n setRegistrationResult,\n }), [\n state.validations,\n state.registrationFormData,\n state.backendCountryCode,\n state.usernameSuggestions,\n state.validationApiRateLimited,\n state.registrationError,\n state.registrationResult,\n backendValidations,\n setValidationsSuccess,\n setValidationsFailure,\n clearUsernameSuggestions,\n clearRegistrationBackendError,\n setRegistrationFormData,\n setEmailSuggestionContext,\n updateRegistrationFormData,\n setBackendCountryCode,\n setRegistrationError,\n setRegistrationResult,\n ]);\n\n return (\n <RegisterContext.Provider value={contextValue}>\n {children}\n </RegisterContext.Provider>\n );\n};\n\nexport const useRegisterContext = () => {\n const context = useContext(RegisterContext);\n if (!context) {\n throw new Error('useRegisterContext must be used within a RegisterProvider');\n }\n return context;\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default RegistrationFailureMessage;
|
|
2
|
+
declare function RegistrationFailureMessage(props: any): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
declare namespace RegistrationFailureMessage {
|
|
4
|
+
namespace defaultProps {
|
|
5
|
+
namespace context {
|
|
6
|
+
let errorMessage: null;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
namespace propTypes {
|
|
10
|
+
let context_1: PropTypes.Requireable<PropTypes.InferProps<{
|
|
11
|
+
provider: PropTypes.Requireable<string>;
|
|
12
|
+
errorMessage: PropTypes.Requireable<string>;
|
|
13
|
+
}>>;
|
|
14
|
+
export { context_1 as context };
|
|
15
|
+
export let errorCode: PropTypes.Validator<string>;
|
|
16
|
+
export let failureCount: PropTypes.Validator<number>;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { getSiteConfig, useIntl } from '@openedx/frontend-base';
|
|
4
|
+
import { Alert } from '@openedx/paragon';
|
|
5
|
+
import { Error } from '@openedx/paragon/icons';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { windowScrollTo } from '../../data/utils';
|
|
8
|
+
import { FORBIDDEN_REQUEST, FORBIDDEN_USERNAME, INTERNAL_SERVER_ERROR, TPA_AUTHENTICATION_FAILURE, TPA_SESSION_EXPIRED, } from '../data/constants';
|
|
9
|
+
import messages from '../messages';
|
|
10
|
+
const RegistrationFailureMessage = (props) => {
|
|
11
|
+
const { formatMessage } = useIntl();
|
|
12
|
+
const { context, errorCode, failureCount, } = props;
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
windowScrollTo({ left: 0, top: 0, behavior: 'smooth' });
|
|
15
|
+
}, [errorCode, failureCount]);
|
|
16
|
+
if (!errorCode) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
let errorMessage;
|
|
20
|
+
switch (errorCode) {
|
|
21
|
+
case INTERNAL_SERVER_ERROR:
|
|
22
|
+
errorMessage = formatMessage(messages['registration.request.server.error']);
|
|
23
|
+
break;
|
|
24
|
+
case FORBIDDEN_REQUEST:
|
|
25
|
+
errorMessage = formatMessage(messages['registration.rate.limit.error']);
|
|
26
|
+
break;
|
|
27
|
+
case TPA_AUTHENTICATION_FAILURE:
|
|
28
|
+
errorMessage = formatMessage(messages['registration.tpa.authentication.failure'], {
|
|
29
|
+
platform_name: getSiteConfig().siteName,
|
|
30
|
+
lineBreak: _jsx("br", {}),
|
|
31
|
+
errorMessage: context.errorMessage,
|
|
32
|
+
});
|
|
33
|
+
break;
|
|
34
|
+
case TPA_SESSION_EXPIRED:
|
|
35
|
+
errorMessage = formatMessage(messages['registration.tpa.session.expired'], { provider: context.provider });
|
|
36
|
+
break;
|
|
37
|
+
case FORBIDDEN_USERNAME:
|
|
38
|
+
errorMessage = formatMessage(messages['registration.forbidden.username']);
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
errorMessage = formatMessage(messages['registration.empty.form.submission.error']);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
return (_jsxs(Alert, { id: "validation-errors", className: "mb-5", variant: "danger", icon: Error, children: [_jsx(Alert.Heading, { children: formatMessage(messages['registration.request.failure.header']) }), _jsx("p", { children: errorMessage })] }));
|
|
45
|
+
};
|
|
46
|
+
RegistrationFailureMessage.defaultProps = {
|
|
47
|
+
context: {
|
|
48
|
+
errorMessage: null,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
RegistrationFailureMessage.propTypes = {
|
|
52
|
+
context: PropTypes.shape({
|
|
53
|
+
provider: PropTypes.string,
|
|
54
|
+
errorMessage: PropTypes.string,
|
|
55
|
+
}),
|
|
56
|
+
errorCode: PropTypes.string.isRequired,
|
|
57
|
+
failureCount: PropTypes.number.isRequired,
|
|
58
|
+
};
|
|
59
|
+
export default RegistrationFailureMessage;
|
|
60
|
+
//# sourceMappingURL=RegistrationFailure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistrationFailure.js","sourceRoot":"","sources":["../../../src/register/components/RegistrationFailure.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,MAAM,0BAA0B,GAAG,CAAC,KAAK,EAAE,EAAE;IAC3C,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,EACJ,OAAO,EAAE,SAAS,EAAE,YAAY,GACjC,GAAG,KAAK,CAAC;IAEV,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1D,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAE9B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,YAAY,CAAC;IACjB,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,qBAAqB;YACxB,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,mCAAmC,CAAC,CAAC,CAAC;YAC5E,MAAM;QACR,KAAK,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AAU;IACtC,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;CAC1C,CAAC;AAEF,eAAe,0BAA0B,CAAC","sourcesContent":["import { useEffect } from 'react';\n\nimport { getSiteConfig, useIntl } from '@openedx/frontend-base';\nimport { Alert } from '@openedx/paragon';\nimport { Error } from '@openedx/paragon/icons';\nimport PropTypes from 'prop-types';\n\nimport { windowScrollTo } from '../../data/utils';\nimport {\n FORBIDDEN_REQUEST,\n FORBIDDEN_USERNAME,\n INTERNAL_SERVER_ERROR,\n TPA_AUTHENTICATION_FAILURE,\n TPA_SESSION_EXPIRED,\n} from '../data/constants';\nimport messages from '../messages';\n\nconst RegistrationFailureMessage = (props) => {\n const { formatMessage } = useIntl();\n const {\n context, errorCode, failureCount,\n } = props;\n\n useEffect(() => {\n windowScrollTo({ left: 0, top: 0, behavior: 'smooth' });\n }, [errorCode, failureCount]);\n\n if (!errorCode) {\n return null;\n }\n\n let errorMessage;\n switch (errorCode) {\n case INTERNAL_SERVER_ERROR:\n errorMessage = formatMessage(messages['registration.request.server.error']);\n break;\n case FORBIDDEN_REQUEST:\n errorMessage = formatMessage(messages['registration.rate.limit.error']);\n break;\n case TPA_AUTHENTICATION_FAILURE:\n errorMessage = formatMessage(\n messages['registration.tpa.authentication.failure'],\n {\n platform_name: getSiteConfig().siteName,\n lineBreak: <br />,\n errorMessage: context.errorMessage,\n }\n );\n break;\n case TPA_SESSION_EXPIRED:\n errorMessage = formatMessage(messages['registration.tpa.session.expired'], { provider: context.provider });\n break;\n case FORBIDDEN_USERNAME:\n errorMessage = formatMessage(messages['registration.forbidden.username']);\n break;\n default:\n errorMessage = formatMessage(messages['registration.empty.form.submission.error']);\n break;\n }\n\n return (\n <Alert id=\"validation-errors\" className=\"mb-5\" variant=\"danger\" icon={Error}>\n <Alert.Heading>{formatMessage(messages['registration.request.failure.header'])}</Alert.Heading>\n <p>{errorMessage}</p>\n </Alert>\n );\n};\n\nRegistrationFailureMessage.defaultProps = {\n context: {\n errorMessage: null,\n },\n};\n\nRegistrationFailureMessage.propTypes = {\n context: PropTypes.shape({\n provider: PropTypes.string,\n errorMessage: PropTypes.string,\n }),\n errorCode: PropTypes.string.isRequired,\n failureCount: PropTypes.number.isRequired,\n};\n\nexport default RegistrationFailureMessage;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const registerNewUserApi: (registrationInformation: any) => Promise<{
|
|
2
|
+
redirectUrl: any;
|
|
3
|
+
success: any;
|
|
4
|
+
authenticatedUser: any;
|
|
5
|
+
}>;
|
|
6
|
+
declare const getFieldsValidations: (formPayload: any) => Promise<{
|
|
7
|
+
fieldValidations: any;
|
|
8
|
+
}>;
|
|
9
|
+
export { registerNewUserApi, getFieldsValidations, };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { getAuthenticatedHttpClient, getHttpClient, getSiteConfig } from '@openedx/frontend-base';
|
|
11
|
+
import * as QueryString from 'query-string';
|
|
12
|
+
import { normalizeRedirectUrl } from '../../data/utils';
|
|
13
|
+
const registerNewUserApi = (registrationInformation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const requestConfig = {
|
|
15
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
16
|
+
isPublic: true,
|
|
17
|
+
};
|
|
18
|
+
const url = `${getSiteConfig().lmsBaseUrl}/api/user/v2/account/registration/`;
|
|
19
|
+
const { data } = yield getAuthenticatedHttpClient()
|
|
20
|
+
.post(url, QueryString.stringify(registrationInformation), requestConfig)
|
|
21
|
+
.catch((e) => {
|
|
22
|
+
throw (e);
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
redirectUrl: normalizeRedirectUrl(data.redirect_url || ''),
|
|
26
|
+
success: data.success || false,
|
|
27
|
+
authenticatedUser: data.authenticated_user,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
const getFieldsValidations = (formPayload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const requestConfig = {
|
|
32
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
33
|
+
};
|
|
34
|
+
const url = `${getSiteConfig().lmsBaseUrl}/api/user/v1/validation/registration`;
|
|
35
|
+
const { data } = yield getHttpClient()
|
|
36
|
+
.post(url, QueryString.stringify(formPayload), requestConfig)
|
|
37
|
+
.catch((e) => {
|
|
38
|
+
throw (e);
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
fieldValidations: data,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
export { registerNewUserApi, getFieldsValidations, };
|
|
45
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/register/data/api.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,kBAAkB,GAAG,CAAO,uBAAuB,EAAE,EAAE;IAC3D,MAAM,aAAa,GAAG;QACpB,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,EAAE;QAChE,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,MAAM,GAAG,GAAG,GAAG,aAAa,EAAE,CAAC,UAAU,oCAAoC,CAAC;IAC9E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,0BAA0B,EAAE;SAChD,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,aAAa,CAAC;SACxE,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE;QAChB,MAAM,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;IAEL,OAAO;QACL,WAAW,EAAE,oBAAoB,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;QAC1D,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,KAAK;QAC9B,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;KAC3C,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAO,WAAW,EAAE,EAAE;IACjD,MAAM,aAAa,GAAG;QACpB,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,EAAE;KACjE,CAAC;IACF,MAAM,GAAG,GAAG,GAAG,aAAa,EAAE,CAAC,UAAU,sCAAsC,CAAC;IAChF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,aAAa,EAAE;SACnC,IAAI,CACH,GAAG,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;SACxD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACX,MAAM,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;IAEL,OAAO;QACL,gBAAgB,EAAE,IAAI;KACvB,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GACrB,CAAC","sourcesContent":["import { getAuthenticatedHttpClient, getHttpClient, getSiteConfig } from '@openedx/frontend-base';\nimport * as QueryString from 'query-string';\n\nimport { normalizeRedirectUrl } from '../../data/utils';\n\nconst registerNewUserApi = async (registrationInformation) => {\n const requestConfig = {\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n isPublic: true,\n };\n const url = `${getSiteConfig().lmsBaseUrl}/api/user/v2/account/registration/`;\n const { data } = await getAuthenticatedHttpClient()\n .post(url, QueryString.stringify(registrationInformation), requestConfig)\n .catch((e: any) => {\n throw (e);\n });\n\n return {\n redirectUrl: normalizeRedirectUrl(data.redirect_url || ''),\n success: data.success || false,\n authenticatedUser: data.authenticated_user,\n };\n};\n\nconst getFieldsValidations = async (formPayload) => {\n const requestConfig = {\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n };\n const url = `${getSiteConfig().lmsBaseUrl}/api/user/v1/validation/registration`;\n const { data } = await getHttpClient()\n .post(\n url, QueryString.stringify(formPayload), requestConfig)\n .catch((e) => {\n throw (e);\n });\n\n return {\n fieldValidations: data,\n };\n};\n\nexport {\n registerNewUserApi,\n getFieldsValidations,\n};\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type RegistrationPayload = Record<string, unknown>;
|
|
2
|
+
interface AuthenticatedUser {
|
|
3
|
+
username: string;
|
|
4
|
+
full_name: string;
|
|
5
|
+
user_id: number;
|
|
6
|
+
}
|
|
7
|
+
interface RegistrationResponse {
|
|
8
|
+
redirectUrl: string;
|
|
9
|
+
success: boolean;
|
|
10
|
+
authenticatedUser: AuthenticatedUser;
|
|
11
|
+
}
|
|
12
|
+
interface UseRegistrationOptions {
|
|
13
|
+
onSuccess?: (data: RegistrationResponse) => void;
|
|
14
|
+
onError?: (error: unknown) => void;
|
|
15
|
+
}
|
|
16
|
+
interface ApiError extends Error {
|
|
17
|
+
response?: {
|
|
18
|
+
status: number;
|
|
19
|
+
data?: unknown;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
type FieldValidationsPayload = Record<string, unknown>;
|
|
23
|
+
interface UseFieldValidationsOptions {
|
|
24
|
+
onSuccess?: (data: unknown) => void;
|
|
25
|
+
onError?: (error: unknown) => void;
|
|
26
|
+
}
|
|
27
|
+
declare const useRegistration: (options?: UseRegistrationOptions) => import("@tanstack/react-query").UseMutationResult<{
|
|
28
|
+
redirectUrl: any;
|
|
29
|
+
success: any;
|
|
30
|
+
authenticatedUser: any;
|
|
31
|
+
}, ApiError, RegistrationPayload, unknown>;
|
|
32
|
+
declare const useFieldValidations: (options?: UseFieldValidationsOptions) => import("@tanstack/react-query").UseMutationResult<unknown, ApiError, FieldValidationsPayload, unknown>;
|
|
33
|
+
export { useRegistration, useFieldValidations, };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { camelCaseObject, logError, logInfo } from '@openedx/frontend-base';
|
|
2
|
+
import { useMutation } from '@tanstack/react-query';
|
|
3
|
+
import { getFieldsValidations, registerNewUserApi } from './api';
|
|
4
|
+
import { INTERNAL_SERVER_ERROR } from './constants';
|
|
5
|
+
const useRegistration = (options = {}) => useMutation({
|
|
6
|
+
mutationFn: (registrationPayload) => (registerNewUserApi(registrationPayload)),
|
|
7
|
+
onSuccess: (data) => {
|
|
8
|
+
if (options.onSuccess) {
|
|
9
|
+
options.onSuccess(data);
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
onError: (error) => {
|
|
13
|
+
const statusCodes = [400, 403, 409];
|
|
14
|
+
let errorData;
|
|
15
|
+
if (error.response) {
|
|
16
|
+
if (error.response.status && statusCodes.includes(error.response.status)) {
|
|
17
|
+
errorData = camelCaseObject(error.response.data || {});
|
|
18
|
+
logInfo(error);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
errorData = { errorCode: INTERNAL_SERVER_ERROR };
|
|
22
|
+
logError(error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
errorData = { errorCode: INTERNAL_SERVER_ERROR };
|
|
27
|
+
logError(error);
|
|
28
|
+
}
|
|
29
|
+
if (options.onError) {
|
|
30
|
+
options.onError(errorData);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const useFieldValidations = (options = {}) => useMutation({
|
|
35
|
+
mutationFn: (payload) => (getFieldsValidations(payload)),
|
|
36
|
+
onSuccess: (data) => {
|
|
37
|
+
const transformedData = camelCaseObject(data.fieldValidations);
|
|
38
|
+
if (options.onSuccess) {
|
|
39
|
+
options.onSuccess(transformedData);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
onError: (error) => {
|
|
43
|
+
if (error.response) {
|
|
44
|
+
if (error.response.status === 403) {
|
|
45
|
+
logInfo(error);
|
|
46
|
+
if (options.onError) {
|
|
47
|
+
options.onError({ validationApiRateLimited: true });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
logError(error);
|
|
52
|
+
if (options.onError) {
|
|
53
|
+
options.onError(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
logError(error);
|
|
59
|
+
if (options.onError) {
|
|
60
|
+
options.onError(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
export { useRegistration, useFieldValidations, };
|
|
66
|
+
//# sourceMappingURL=apiHook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiHook.js","sourceRoot":"","sources":["../../../src/register/data/apiHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAmCpD,MAAM,eAAe,GAAG,CAAC,UAAkC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC;IAC5E,UAAU,EAAE,CAAC,mBAAwC,EAAE,EAAE,CAAC,CACxD,kBAAkB,CAAC,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Ae,CAAE,IAAsC,CAAC,gBAAgB,CAAC,CAAC;QAClG,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACtB,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC,KAAe,EAAE,EAAE;QAC3B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAClC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACf,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBACpB,OAAO,CAAC,OAAO,CAAC,EAAE,wBAAwB,EAAE,IAAI,EAAE,CAAC,CAAC;gBACtD,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAChB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBACpB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,CAAC","sourcesContent":["import { camelCaseObject, logError, logInfo } from '@openedx/frontend-base';\nimport { useMutation } from '@tanstack/react-query';\n\nimport { getFieldsValidations, registerNewUserApi } from './api';\nimport { INTERNAL_SERVER_ERROR } from './constants';\n\ntype RegistrationPayload = Record<string, unknown>;\n\ninterface AuthenticatedUser {\n username: string,\n full_name: string,\n user_id: number,\n}\n\ninterface RegistrationResponse {\n redirectUrl: string,\n success: boolean,\n authenticatedUser: AuthenticatedUser,\n}\n\ninterface UseRegistrationOptions {\n onSuccess?: (data: RegistrationResponse) => void,\n onError?: (error: unknown) => void,\n}\n\ninterface ApiError extends Error {\n response?: {\n status: number,\n data?: unknown,\n },\n}\n\ntype FieldValidationsPayload = Record<string, unknown>;\n\ninterface UseFieldValidationsOptions {\n onSuccess?: (data: unknown) => void,\n onError?: (error: unknown) => void,\n}\n\nconst useRegistration = (options: UseRegistrationOptions = {}) => useMutation({\n mutationFn: (registrationPayload: RegistrationPayload) => (\n registerNewUserApi(registrationPayload)\n ),\n onSuccess: (data: RegistrationResponse) => {\n if (options.onSuccess) {\n options.onSuccess(data);\n }\n },\n onError: (error: ApiError) => {\n const statusCodes = [400, 403, 409];\n let errorData: unknown;\n\n if (error.response) {\n if (error.response.status && statusCodes.includes(error.response.status)) {\n errorData = camelCaseObject(error.response.data || {});\n logInfo(error);\n } else {\n errorData = { errorCode: INTERNAL_SERVER_ERROR };\n logError(error);\n }\n } else {\n errorData = { errorCode: INTERNAL_SERVER_ERROR };\n logError(error);\n }\n\n if (options.onError) {\n options.onError(errorData);\n }\n },\n});\n\nconst useFieldValidations = (options: UseFieldValidationsOptions = {}) => useMutation({\n mutationFn: (payload: FieldValidationsPayload) => (\n getFieldsValidations(payload)\n ),\n onSuccess: (data: unknown) => {\n const transformedData = camelCaseObject((data as { fieldValidations: unknown }).fieldValidations);\n if (options.onSuccess) {\n options.onSuccess(transformedData);\n }\n },\n onError: (error: ApiError) => {\n if (error.response) {\n if (error.response.status === 403) {\n logInfo(error);\n if (options.onError) {\n options.onError({ validationApiRateLimited: true });\n }\n } else {\n logError(error);\n if (options.onError) {\n options.onError(error);\n }\n }\n } else {\n logError(error);\n if (options.onError) {\n options.onError(error);\n }\n }\n },\n});\n\nexport {\n useRegistration,\n useFieldValidations,\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export namespace FIELDS {
|
|
2
|
+
let COUNTRY: string;
|
|
3
|
+
let HONOR_CODE: string;
|
|
4
|
+
let TERMS_OF_SERVICE: string;
|
|
5
|
+
}
|
|
6
|
+
export const FORBIDDEN_REQUEST: "forbidden-request";
|
|
7
|
+
export const FORM_SUBMISSION_ERROR: "form-submission-error";
|
|
8
|
+
export const INTERNAL_SERVER_ERROR: "internal-server-error";
|
|
9
|
+
export const TPA_AUTHENTICATION_FAILURE: "tpa-authentication-failure";
|
|
10
|
+
export const TPA_SESSION_EXPIRED: "tpa-session-expired";
|
|
11
|
+
export const FORBIDDEN_USERNAME: "forbidden-username";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// Registration Fields
|
|
2
2
|
export const FIELDS = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
COUNTRY: 'country',
|
|
4
|
+
HONOR_CODE: 'honor_code',
|
|
5
|
+
TERMS_OF_SERVICE: 'terms_of_service',
|
|
6
6
|
};
|
|
7
|
-
|
|
8
7
|
// Registration Error Codes
|
|
9
8
|
export const FORBIDDEN_REQUEST = 'forbidden-request';
|
|
10
9
|
export const FORM_SUBMISSION_ERROR = 'form-submission-error';
|
|
11
10
|
export const INTERNAL_SERVER_ERROR = 'internal-server-error';
|
|
12
11
|
export const TPA_AUTHENTICATION_FAILURE = 'tpa-authentication-failure';
|
|
13
12
|
export const TPA_SESSION_EXPIRED = 'tpa-session-expired';
|
|
13
|
+
export const FORBIDDEN_USERNAME = 'forbidden-username';
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/register/data/constants.js"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,gBAAgB,EAAE,kBAAkB;CACrC,CAAC;AAEF,2BAA2B;AAC3B,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AACrD,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAC7D,MAAM,CAAC,MAAM,0BAA0B,GAAG,4BAA4B,CAAC;AACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC","sourcesContent":["// Registration Fields\nexport const FIELDS = {\n COUNTRY: 'country',\n HONOR_CODE: 'honor_code',\n TERMS_OF_SERVICE: 'terms_of_service',\n};\n\n// Registration Error Codes\nexport const FORBIDDEN_REQUEST = 'forbidden-request';\nexport const FORM_SUBMISSION_ERROR = 'form-submission-error';\nexport const INTERNAL_SERVER_ERROR = 'internal-server-error';\nexport const TPA_AUTHENTICATION_FAILURE = 'tpa-authentication-failure';\nexport const TPA_SESSION_EXPIRED = 'tpa-session-expired';\nexport const FORBIDDEN_USERNAME = 'forbidden-username';\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function validatePasswordField(value: any, formatMessage: any): string;
|
|
2
|
+
export function isFormValid(payload: any, errors: any, configurableFormFields: any, fieldDescriptions: any, formatMessage: any): {
|
|
3
|
+
fieldErrors: any;
|
|
4
|
+
isValid: boolean;
|
|
5
|
+
};
|
|
6
|
+
export function prepareRegistrationPayload(initPayload: any, configurableFormFields: any, showMarketingEmailOptInCheckbox: any, totalRegistrationTime: any, queryParams: any): any;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { snakeCaseObject } from '@openedx/frontend-base';
|
|
2
|
+
import { LETTER_REGEX, NUMBER_REGEX } from '../../data/constants';
|
|
3
|
+
import messages from '../messages';
|
|
4
|
+
import validateEmail from '../RegistrationFields/EmailField/validator';
|
|
5
|
+
import validateName from '../RegistrationFields/NameField/validator';
|
|
6
|
+
import validateUsername from '../RegistrationFields/UsernameField/validator';
|
|
7
|
+
/**
|
|
8
|
+
* It validates the password field value
|
|
9
|
+
* @param value
|
|
10
|
+
* @param formatMessage
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
export const validatePasswordField = (value, formatMessage) => {
|
|
14
|
+
let fieldError = '';
|
|
15
|
+
if (!value || !LETTER_REGEX.test(value) || !NUMBER_REGEX.test(value) || value.length < 8) {
|
|
16
|
+
fieldError = formatMessage(messages['password.validation.message']);
|
|
17
|
+
}
|
|
18
|
+
return fieldError;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* It accepts complete registration data as payload and checks if the form is valid.
|
|
22
|
+
* @param payload
|
|
23
|
+
* @param errors
|
|
24
|
+
* @param configurableFormFields
|
|
25
|
+
* @param fieldDescriptions
|
|
26
|
+
* @param formatMessage
|
|
27
|
+
* @returns {{fieldErrors, isValid: boolean}}
|
|
28
|
+
*/
|
|
29
|
+
export const isFormValid = (payload, errors, configurableFormFields, fieldDescriptions, formatMessage) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const fieldErrors = Object.assign({}, errors);
|
|
32
|
+
let isValid = true;
|
|
33
|
+
let emailSuggestion = { suggestion: '', type: '' };
|
|
34
|
+
Object.keys(payload).forEach(key => {
|
|
35
|
+
switch (key) {
|
|
36
|
+
case 'name':
|
|
37
|
+
fieldErrors.name || (fieldErrors.name = validateName(payload.name, formatMessage));
|
|
38
|
+
if (fieldErrors.name) {
|
|
39
|
+
isValid = false;
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case 'email': {
|
|
43
|
+
if (!fieldErrors.email) {
|
|
44
|
+
const { fieldError, confirmEmailError, suggestion, } = validateEmail(payload.email, configurableFormFields === null || configurableFormFields === void 0 ? void 0 : configurableFormFields.confirm_email, formatMessage);
|
|
45
|
+
if (fieldError) {
|
|
46
|
+
fieldErrors.email = fieldError;
|
|
47
|
+
isValid = false;
|
|
48
|
+
}
|
|
49
|
+
if (confirmEmailError) {
|
|
50
|
+
fieldErrors.confirm_email = confirmEmailError;
|
|
51
|
+
isValid = false;
|
|
52
|
+
}
|
|
53
|
+
emailSuggestion = suggestion;
|
|
54
|
+
}
|
|
55
|
+
if (fieldErrors.email) {
|
|
56
|
+
isValid = false;
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
case 'username':
|
|
61
|
+
fieldErrors.username || (fieldErrors.username = validateUsername(payload.username, formatMessage));
|
|
62
|
+
if (fieldErrors.username) {
|
|
63
|
+
isValid = false;
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case 'password':
|
|
67
|
+
fieldErrors.password || (fieldErrors.password = validatePasswordField(payload.password, formatMessage));
|
|
68
|
+
if (fieldErrors.password) {
|
|
69
|
+
isValid = false;
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// Don't validate when country field is optional or hidden and not present on registration form
|
|
77
|
+
if ((configurableFormFields === null || configurableFormFields === void 0 ? void 0 : configurableFormFields.country) && !((_a = configurableFormFields.country) === null || _a === void 0 ? void 0 : _a.displayValue)) {
|
|
78
|
+
fieldErrors.country = formatMessage(messages['empty.country.field.error']);
|
|
79
|
+
isValid = false;
|
|
80
|
+
}
|
|
81
|
+
else if ((configurableFormFields === null || configurableFormFields === void 0 ? void 0 : configurableFormFields.country) && !((_b = configurableFormFields.country) === null || _b === void 0 ? void 0 : _b.countryCode)) {
|
|
82
|
+
fieldErrors.country = formatMessage(messages['invalid.country.field.error']);
|
|
83
|
+
isValid = false;
|
|
84
|
+
}
|
|
85
|
+
Object.keys(fieldDescriptions).forEach(key => {
|
|
86
|
+
var _a;
|
|
87
|
+
if (key === 'country' && !((_a = configurableFormFields === null || configurableFormFields === void 0 ? void 0 : configurableFormFields.country) === null || _a === void 0 ? void 0 : _a.displayValue)) {
|
|
88
|
+
fieldErrors[key] = formatMessage(messages['empty.country.field.error']);
|
|
89
|
+
}
|
|
90
|
+
else if (!configurableFormFields[key]) {
|
|
91
|
+
fieldErrors[key] = fieldDescriptions[key].error_message;
|
|
92
|
+
}
|
|
93
|
+
if (fieldErrors[key]) {
|
|
94
|
+
isValid = false;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return { isValid, fieldErrors, emailSuggestion };
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* It prepares a payload for registration data that can be passed to registration API endpoint.
|
|
101
|
+
* @param initPayload
|
|
102
|
+
* @param configurableFormFields
|
|
103
|
+
* @param showMarketingEmailOptInCheckbox
|
|
104
|
+
* @param totalRegistrationTime
|
|
105
|
+
* @param queryParams
|
|
106
|
+
* @returns {*}
|
|
107
|
+
*/
|
|
108
|
+
export const prepareRegistrationPayload = (initPayload, configurableFormFields, showMarketingEmailOptInCheckbox, totalRegistrationTime, queryParams) => {
|
|
109
|
+
let payload = Object.assign({}, initPayload);
|
|
110
|
+
Object.keys(configurableFormFields).forEach((fieldName) => {
|
|
111
|
+
if (fieldName === 'country') {
|
|
112
|
+
payload[fieldName] = configurableFormFields[fieldName].countryCode;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
payload[fieldName] = configurableFormFields[fieldName];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
// Don't send the marketing email opt-in value if the flag is turned off
|
|
119
|
+
if (!showMarketingEmailOptInCheckbox) {
|
|
120
|
+
delete payload.marketingEmailsOptIn;
|
|
121
|
+
}
|
|
122
|
+
payload.totalRegistrationTime = totalRegistrationTime;
|
|
123
|
+
payload = snakeCaseObject(payload);
|
|
124
|
+
// add query params to the payload
|
|
125
|
+
payload = Object.assign(Object.assign({}, payload), queryParams);
|
|
126
|
+
return payload;
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=utils.js.map
|