@openedx/frontend-app-authn 1.0.0-alpha.5 → 1.0.0-alpha.6
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/{src/Main.tsx → dist/Main.js} +4 -15
- 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/{src → dist}/app.scss +1 -1
- 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/{src/common-components/EmbeddedRegistrationRoute.jsx → dist/common-components/EmbeddedRegistrationRoute.js} +9 -13
- package/dist/common-components/EmbeddedRegistrationRoute.js.map +1 -0
- package/dist/common-components/EnterpriseSSO.d.ts +29 -0
- package/dist/common-components/EnterpriseSSO.js +55 -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 +39 -0
- package/dist/common-components/PasswordField.js +94 -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 +68 -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 +42 -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 +56 -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 +31 -0
- package/dist/common-components/UnAuthOnlyRoute.js.map +1 -0
- package/dist/common-components/data/actions.d.ts +26 -0
- package/{src → dist}/common-components/data/actions.js +8 -13
- package/dist/common-components/data/actions.js.map +1 -0
- package/dist/common-components/data/reducers.d.ts +62 -0
- package/dist/common-components/data/reducers.js +39 -0
- package/dist/common-components/data/reducers.js.map +1 -0
- package/dist/common-components/data/sagas.d.ts +12 -0
- package/dist/common-components/data/sagas.js +21 -0
- package/dist/common-components/data/sagas.js.map +1 -0
- package/dist/common-components/data/selectors.d.ts +98 -0
- package/dist/common-components/data/selectors.js +11 -0
- package/dist/common-components/data/selectors.js.map +1 -0
- package/dist/common-components/data/service.d.ts +5 -0
- package/dist/common-components/data/service.js +31 -0
- package/dist/common-components/data/service.js.map +1 -0
- package/dist/common-components/index.d.ts +13 -0
- package/{src/common-components/index.jsx → dist/common-components/index.js} +1 -0
- 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 +1 -0
- package/{src/constants.ts → dist/constants.js} +1 -0
- package/dist/constants.js.map +1 -0
- package/dist/data/configureStore.d.ts +3 -0
- package/{src → dist}/data/configureStore.js +11 -20
- package/dist/data/configureStore.js.map +1 -0
- package/dist/data/constants.d.ts +24 -0
- package/{src → dist}/data/constants.js +4 -8
- 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/reducers.d.ts +254 -0
- package/dist/data/reducers.js +17 -0
- package/dist/data/reducers.js.map +1 -0
- package/dist/data/sagas.d.ts +1 -0
- package/{src → dist}/data/sagas.js +9 -10
- package/dist/data/sagas.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 +11 -0
- package/dist/data/utils/dataUtils.js +67 -0
- package/dist/data/utils/dataUtils.js.map +1 -0
- package/dist/data/utils/index.d.ts +3 -0
- package/dist/data/utils/index.js +4 -0
- package/dist/data/utils/index.js.map +1 -0
- package/dist/data/utils/reduxUtils.d.ts +15 -0
- package/dist/data/utils/reduxUtils.js +29 -0
- package/dist/data/utils/reduxUtils.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 +36 -0
- package/dist/forgot-password/ForgotPasswordPage.js +91 -0
- package/dist/forgot-password/ForgotPasswordPage.js.map +1 -0
- package/dist/forgot-password/data/actions.d.ts +30 -0
- package/{src → dist}/forgot-password/data/actions.js +10 -16
- package/dist/forgot-password/data/actions.js.map +1 -0
- package/dist/forgot-password/data/reducers.d.ts +13 -0
- package/dist/forgot-password/data/reducers.js +46 -0
- package/dist/forgot-password/data/reducers.js.map +1 -0
- package/dist/forgot-password/data/sagas.d.ts +4 -0
- package/dist/forgot-password/data/sagas.js +28 -0
- package/dist/forgot-password/data/sagas.js.map +1 -0
- package/dist/forgot-password/data/selectors.d.ts +23 -0
- package/dist/forgot-password/data/selectors.js +5 -0
- package/dist/forgot-password/data/selectors.js.map +1 -0
- package/dist/forgot-password/data/service.d.ts +1 -0
- package/dist/forgot-password/data/service.js +26 -0
- package/dist/forgot-password/data/service.js.map +1 -0
- package/dist/forgot-password/index.d.ts +5 -0
- package/{src → dist}/forgot-password/index.js +1 -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 +25 -0
- package/dist/i18n/index.js +26 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.js +4 -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 +45 -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 +10 -0
- package/dist/login/LoginPage.js +216 -0
- package/dist/login/LoginPage.js.map +1 -0
- package/dist/login/data/actions.d.ts +36 -0
- package/{src → dist}/login/data/actions.js +12 -19
- package/dist/login/data/actions.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/data/reducers.d.ts +82 -0
- package/dist/login/data/reducers.js +44 -0
- package/dist/login/data/reducers.js.map +1 -0
- package/dist/login/data/sagas.d.ts +10 -0
- package/dist/login/data/sagas.js +34 -0
- package/dist/login/data/sagas.js.map +1 -0
- package/dist/login/data/service.d.ts +4 -0
- package/dist/login/data/service.js +32 -0
- package/dist/login/data/service.js.map +1 -0
- package/dist/login/index.d.ts +4 -0
- package/{src → dist}/login/index.js +1 -1
- 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 +32 -0
- package/dist/logistration/Logistration.js +106 -0
- package/dist/logistration/Logistration.js.map +1 -0
- package/dist/progressive-profiling/ProgressiveProfiling.d.ts +46 -0
- package/dist/progressive-profiling/ProgressiveProfiling.js +167 -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 +24 -0
- package/dist/progressive-profiling/ProgressiveProfilingPageModal.js.map +1 -0
- package/dist/progressive-profiling/data/actions.d.ts +19 -0
- package/{src → dist}/progressive-profiling/data/actions.js +6 -10
- package/dist/progressive-profiling/data/actions.js.map +1 -0
- package/dist/progressive-profiling/data/reducers.d.ts +22 -0
- package/dist/progressive-profiling/data/reducers.js +23 -0
- package/dist/progressive-profiling/data/reducers.js.map +1 -0
- package/dist/progressive-profiling/data/sagas.d.ts +4 -0
- package/dist/progressive-profiling/data/sagas.js +17 -0
- package/dist/progressive-profiling/data/sagas.js.map +1 -0
- package/dist/progressive-profiling/data/selectors.d.ts +39 -0
- package/{src → dist}/progressive-profiling/data/selectors.js +4 -9
- package/dist/progressive-profiling/data/selectors.js.map +1 -0
- package/dist/progressive-profiling/data/service.d.ts +1 -0
- package/dist/progressive-profiling/data/service.js +23 -0
- package/dist/progressive-profiling/data/service.js.map +1 -0
- package/dist/progressive-profiling/index.d.ts +4 -0
- package/{src → dist}/progressive-profiling/index.js +1 -1
- 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/register/RegistrationFields/CountryField/CountryField.d.ts +38 -0
- package/dist/register/RegistrationFields/CountryField/CountryField.js +95 -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 +80 -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 +52 -0
- package/dist/register/RegistrationFields/NameField/NameField.js.map +1 -0
- package/dist/register/RegistrationFields/NameField/validator.d.ts +5 -0
- package/{src → dist}/register/RegistrationFields/NameField/validator.js +9 -12
- 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 +113 -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 +216 -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/RegistrationFailure.d.ts +19 -0
- package/dist/register/components/RegistrationFailure.js +57 -0
- package/dist/register/components/RegistrationFailure.js.map +1 -0
- package/dist/register/data/actions.d.ts +80 -0
- package/{src → dist}/register/data/actions.js +26 -42
- package/dist/register/data/actions.js.map +1 -0
- package/dist/register/data/constants.d.ts +10 -0
- package/{src → dist}/register/data/constants.js +4 -4
- package/dist/register/data/constants.js.map +1 -0
- package/dist/register/data/reducers.d.ts +237 -0
- package/dist/register/data/reducers.js +86 -0
- package/dist/register/data/reducers.js.map +1 -0
- package/dist/register/data/sagas.d.ts +19 -0
- package/dist/register/data/sagas.js +45 -0
- package/dist/register/data/sagas.js.map +1 -0
- package/dist/register/data/selectors.d.ts +26 -0
- package/dist/register/data/selectors.js +25 -0
- package/dist/register/data/selectors.js.map +1 -0
- package/dist/register/data/service.d.ts +8 -0
- package/dist/register/data/service.js +46 -0
- package/dist/register/data/service.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 +3 -0
- package/{src → dist}/register/index.js +1 -0
- package/dist/register/index.js.map +1 -0
- package/dist/register/messages.d.ts +193 -0
- package/dist/register/messages.js +205 -0
- package/dist/register/messages.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 +32 -0
- package/dist/reset-password/ResetPasswordPage.js +150 -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/actions.d.ts +56 -0
- package/{src → dist}/reset-password/data/actions.js +17 -26
- package/dist/reset-password/data/actions.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/data/reducers.d.ts +19 -0
- package/dist/reset-password/data/reducers.js +25 -0
- package/dist/reset-password/data/reducers.js.map +1 -0
- package/dist/reset-password/data/sagas.d.ts +7 -0
- package/dist/reset-password/data/sagas.js +63 -0
- package/dist/reset-password/data/sagas.js.map +1 -0
- package/dist/reset-password/data/selectors.d.ts +23 -0
- package/dist/reset-password/data/selectors.js +5 -0
- package/dist/reset-password/data/selectors.js.map +1 -0
- package/dist/reset-password/data/service.d.ts +3 -0
- package/dist/reset-password/data/service.js +62 -0
- package/dist/reset-password/data/service.js.map +1 -0
- package/dist/reset-password/index.d.ts +5 -0
- package/{src → dist}/reset-password/index.js +1 -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 +18 -0
- package/dist/routes.js +75 -0
- package/dist/routes.js.map +1 -0
- package/package.json +12 -5
- package/src/__mocks__/file.js +0 -1
- package/src/__mocks__/svg.js +0 -1
- 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/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/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/data/oneTrust.js +0 -3
- package/src/data/reducers.js +0 -36
- 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/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/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/reducers.js +0 -76
- package/src/login/data/sagas.js +0 -45
- package/src/login/data/service.js +0 -27
- package/src/login/data/tests/reducers.test.js +0 -155
- package/src/login/data/tests/sagas.test.js +0 -110
- 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/reducers.js +0 -38
- package/src/progressive-profiling/data/sagas.js +0 -24
- 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/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/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 -147
- 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/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/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/index.ts → dist/index.d.ts} +0 -0
- /package/{src → dist}/sass/_base_component.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/_progressive_profiling_page.scss +0 -0
- /package/{src → dist}/sass/_registration.scss +0 -0
- /package/{src → dist}/sass/_reset_password.scss +0 -0
- /package/{src → dist}/sass/_style.scss +0 -0
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { createSelector } from 'reselect';
|
|
2
|
-
|
|
3
2
|
export const storeName = 'commonComponents';
|
|
4
|
-
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
export const welcomePageContextSelector = createSelector(
|
|
8
|
-
commonComponentsSelector,
|
|
9
|
-
commonComponents => ({
|
|
3
|
+
export const commonComponentsSelector = state => (Object.assign({}, state[storeName]));
|
|
4
|
+
export const welcomePageContextSelector = createSelector(commonComponentsSelector, commonComponents => ({
|
|
10
5
|
fields: commonComponents.optionalFields.fields,
|
|
11
6
|
extended_profile: commonComponents.optionalFields.extended_profile,
|
|
12
7
|
nextUrl: commonComponents.thirdPartyAuthContext.welcomePageRedirectUrl,
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
}));
|
|
9
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/progressive-profiling/data/selectors.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAE5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC,EAAE,CAAC,mBAAM,KAAK,CAAC,SAAS,CAAC,EAAG,CAAC;AAE3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,cAAc,CACtD,wBAAwB,EACxB,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC,cAAc,CAAC,MAAM;IAC9C,gBAAgB,EAAE,gBAAgB,CAAC,cAAc,CAAC,gBAAgB;IAClE,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,sBAAsB;CACvE,CAAC,CACH,CAAC","sourcesContent":["import { createSelector } from 'reselect';\n\nexport const storeName = 'commonComponents';\n\nexport const commonComponentsSelector = state => ({ ...state[storeName] });\n\nexport const welcomePageContextSelector = createSelector(\n commonComponentsSelector,\n commonComponents => ({\n fields: commonComponents.optionalFields.fields,\n extended_profile: commonComponents.optionalFields.extended_profile,\n nextUrl: commonComponents.thirdPartyAuthContext.welcomePageRedirectUrl,\n }),\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function patchAccount(username: any, commitValues: any): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
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, getSiteConfig } from '@openedx/frontend-base';
|
|
11
|
+
export function patchAccount(username, commitValues) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const requestConfig = {
|
|
14
|
+
headers: { 'Content-Type': 'application/merge-patch+json' },
|
|
15
|
+
};
|
|
16
|
+
yield getAuthenticatedHttpClient()
|
|
17
|
+
.patch(`${getSiteConfig().lmsBaseUrl}/api/user/v1/accounts/${username}`, commitValues, requestConfig)
|
|
18
|
+
.catch((error) => {
|
|
19
|
+
throw (error);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/progressive-profiling/data/service.js"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEnF,MAAM,UAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY;;QACvD,MAAM,aAAa,GAAG;YACpB,OAAO,EAAE,EAAE,cAAc,EAAE,8BAA8B,EAAE;SAC5D,CAAC;QAEF,MAAM,0BAA0B,EAAE;aAC/B,KAAK,CACJ,GAAG,aAAa,EAAE,CAAC,UAAU,yBAAyB,QAAQ,EAAE,EAChE,YAAY,EACZ,aAAa,CACd;aACA,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CAAA","sourcesContent":["import { getAuthenticatedHttpClient, getSiteConfig } from '@openedx/frontend-base';\n\nexport async function patchAccount(username, commitValues) {\n const requestConfig = {\n headers: { 'Content-Type': 'application/merge-patch+json' },\n };\n\n await getAuthenticatedHttpClient()\n .patch(\n `${getSiteConfig().lmsBaseUrl}/api/user/v1/accounts/${username}`,\n commitValues,\n requestConfig,\n )\n .catch((error) => {\n throw (error);\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/progressive-profiling/index.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export const storeName = 'welcomePage';\n\nexport { default as ProgressiveProfiling } from './ProgressiveProfiling';\nexport { default as reducer } from './data/reducers';\nexport { default as saga } from './data/sagas';\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export default messages;
|
|
2
|
+
declare const messages: {
|
|
3
|
+
'progressive.profiling.page.title': {
|
|
4
|
+
id: string;
|
|
5
|
+
defaultMessage: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
'progressive.profiling.page.heading': {
|
|
9
|
+
id: string;
|
|
10
|
+
defaultMessage: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
'optional.fields.information.link': {
|
|
14
|
+
id: string;
|
|
15
|
+
defaultMessage: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
'optional.fields.submit.button': {
|
|
19
|
+
id: string;
|
|
20
|
+
defaultMessage: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
'optional.fields.skip.button': {
|
|
24
|
+
id: string;
|
|
25
|
+
defaultMessage: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
'continue.to.platform': {
|
|
29
|
+
id: string;
|
|
30
|
+
defaultMessage: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
'modal.title': {
|
|
34
|
+
id: string;
|
|
35
|
+
defaultMessage: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
'modal.description': {
|
|
39
|
+
id: string;
|
|
40
|
+
defaultMessage: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
'welcome.page.error.heading': {
|
|
44
|
+
id: string;
|
|
45
|
+
defaultMessage: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
'welcome.page.error.message': {
|
|
49
|
+
id: string;
|
|
50
|
+
defaultMessage: string;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineMessages } from '@openedx/frontend-base';
|
|
2
|
+
const messages = defineMessages({
|
|
3
|
+
'progressive.profiling.page.title': {
|
|
4
|
+
id: 'progressive.profiling.page.title',
|
|
5
|
+
defaultMessage: 'Welcome | {siteName}',
|
|
6
|
+
description: 'progressive profiling page title',
|
|
7
|
+
},
|
|
8
|
+
'progressive.profiling.page.heading': {
|
|
9
|
+
id: 'progressive.profiling.page.heading',
|
|
10
|
+
defaultMessage: 'A few questions for you will help us get smarter.',
|
|
11
|
+
description: 'The page heading for the progressive profiling page.',
|
|
12
|
+
},
|
|
13
|
+
'optional.fields.information.link': {
|
|
14
|
+
id: 'optional.fields.information.link',
|
|
15
|
+
defaultMessage: 'Learn more about how we use this information.',
|
|
16
|
+
description: 'Optional fields page information link',
|
|
17
|
+
},
|
|
18
|
+
'optional.fields.submit.button': {
|
|
19
|
+
id: 'optional.fields.submit.button',
|
|
20
|
+
defaultMessage: 'Submit',
|
|
21
|
+
description: 'Submit button text',
|
|
22
|
+
},
|
|
23
|
+
'optional.fields.skip.button': {
|
|
24
|
+
id: 'optional.fields.skip.button',
|
|
25
|
+
defaultMessage: 'Skip for now',
|
|
26
|
+
description: 'Skip button text',
|
|
27
|
+
},
|
|
28
|
+
// modal dialog box
|
|
29
|
+
'continue.to.platform': {
|
|
30
|
+
id: 'continue.to.platform',
|
|
31
|
+
defaultMessage: 'Continue to {platformName}',
|
|
32
|
+
description: 'Button text for modal when user chooses "skip for now" option',
|
|
33
|
+
},
|
|
34
|
+
'modal.title': {
|
|
35
|
+
id: 'modal.title',
|
|
36
|
+
defaultMessage: 'Thanks for letting us know.',
|
|
37
|
+
description: 'Heading for welcome page modal',
|
|
38
|
+
},
|
|
39
|
+
'modal.description': {
|
|
40
|
+
id: 'modal.description',
|
|
41
|
+
defaultMessage: 'You can complete your profile in settings at any time if you change your mind.',
|
|
42
|
+
description: 'Modal body text',
|
|
43
|
+
},
|
|
44
|
+
// error message
|
|
45
|
+
'welcome.page.error.heading': {
|
|
46
|
+
id: 'welcome.page.error.heading',
|
|
47
|
+
defaultMessage: 'We couldn\'t update your profile',
|
|
48
|
+
description: 'Error message heading',
|
|
49
|
+
},
|
|
50
|
+
'welcome.page.error.message': {
|
|
51
|
+
id: 'welcome.page.error.message',
|
|
52
|
+
defaultMessage: 'An error occurred. You can complete your profile in settings at any time.',
|
|
53
|
+
description: 'Error message body',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export default messages;
|
|
57
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/progressive-profiling/messages.jsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,kCAAkC,EAAE;QAClC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,sBAAsB;QACtC,WAAW,EAAE,kCAAkC;KAChD;IACD,oCAAoC,EAAE;QACpC,EAAE,EAAE,oCAAoC;QACxC,cAAc,EAAE,mDAAmD;QACnE,WAAW,EAAE,sDAAsD;KACpE;IACD,kCAAkC,EAAE;QAClC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,+CAA+C;QAC/D,WAAW,EAAE,uCAAuC;KACrD;IACD,+BAA+B,EAAE;QAC/B,EAAE,EAAE,+BAA+B;QACnC,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,oBAAoB;KAClC;IACD,6BAA6B,EAAE;QAC7B,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,kBAAkB;KAChC;IACD,mBAAmB;IACnB,sBAAsB,EAAE;QACtB,EAAE,EAAE,sBAAsB;QAC1B,cAAc,EAAE,4BAA4B;QAC5C,WAAW,EAAE,+DAA+D;KAC7E;IACD,aAAa,EAAE;QACb,EAAE,EAAE,aAAa;QACjB,cAAc,EAAE,6BAA6B;QAC7C,WAAW,EAAE,gCAAgC;KAC9C;IACD,mBAAmB,EAAE;QACnB,EAAE,EAAE,mBAAmB;QACvB,cAAc,EAAE,gFAAgF;QAChG,WAAW,EAAE,iBAAiB;KAC/B;IACD,gBAAgB;IAChB,4BAA4B,EAAE;QAC5B,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,kCAAkC;QAClD,WAAW,EAAE,uBAAuB;KACrC;IACD,4BAA4B,EAAE;QAC5B,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,2EAA2E;QAC3F,WAAW,EAAE,oBAAoB;KAClC;CACF,CAAC,CAAC;AACH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n 'progressive.profiling.page.title': {\n id: 'progressive.profiling.page.title',\n defaultMessage: 'Welcome | {siteName}',\n description: 'progressive profiling page title',\n },\n 'progressive.profiling.page.heading': {\n id: 'progressive.profiling.page.heading',\n defaultMessage: 'A few questions for you will help us get smarter.',\n description: 'The page heading for the progressive profiling page.',\n },\n 'optional.fields.information.link': {\n id: 'optional.fields.information.link',\n defaultMessage: 'Learn more about how we use this information.',\n description: 'Optional fields page information link',\n },\n 'optional.fields.submit.button': {\n id: 'optional.fields.submit.button',\n defaultMessage: 'Submit',\n description: 'Submit button text',\n },\n 'optional.fields.skip.button': {\n id: 'optional.fields.skip.button',\n defaultMessage: 'Skip for now',\n description: 'Skip button text',\n },\n // modal dialog box\n 'continue.to.platform': {\n id: 'continue.to.platform',\n defaultMessage: 'Continue to {platformName}',\n description: 'Button text for modal when user chooses \"skip for now\" option',\n },\n 'modal.title': {\n id: 'modal.title',\n defaultMessage: 'Thanks for letting us know.',\n description: 'Heading for welcome page modal',\n },\n 'modal.description': {\n id: 'modal.description',\n defaultMessage: 'You can complete your profile in settings at any time if you change your mind.',\n description: 'Modal body text',\n },\n // error message\n 'welcome.page.error.heading': {\n id: 'welcome.page.error.heading',\n defaultMessage: 'We couldn\\'t update your profile',\n description: 'Error message heading',\n },\n 'welcome.page.error.message': {\n id: 'welcome.page.error.message',\n defaultMessage: 'An error occurred. You can complete your profile in settings at any time.',\n description: 'Error message body',\n },\n});\nexport default messages;\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default CountryField;
|
|
2
|
+
/**
|
|
3
|
+
* Country field wrapper. It accepts following handlers
|
|
4
|
+
* - handleChange for setting value change and
|
|
5
|
+
* - handleErrorChange for setting error
|
|
6
|
+
*
|
|
7
|
+
* It is responsible for
|
|
8
|
+
* - Auto populating country field if backendCountryCode is available in redux
|
|
9
|
+
* - Performing country field validations
|
|
10
|
+
* - clearing error on focus
|
|
11
|
+
* - setting value on change and selection
|
|
12
|
+
*/
|
|
13
|
+
declare function CountryField(props: any): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare namespace CountryField {
|
|
15
|
+
namespace propTypes {
|
|
16
|
+
let countryList: PropTypes.Validator<(PropTypes.InferProps<{
|
|
17
|
+
code: PropTypes.Requireable<string>;
|
|
18
|
+
name: PropTypes.Requireable<string>;
|
|
19
|
+
}> | null | undefined)[]>;
|
|
20
|
+
let errorMessage: PropTypes.Requireable<string>;
|
|
21
|
+
let onChangeHandler: PropTypes.Validator<(...args: any[]) => any>;
|
|
22
|
+
let handleErrorChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
23
|
+
let onFocusHandler: PropTypes.Validator<(...args: any[]) => any>;
|
|
24
|
+
let selectedCountry: PropTypes.Requireable<PropTypes.InferProps<{
|
|
25
|
+
displayValue: PropTypes.Requireable<string>;
|
|
26
|
+
countryCode: PropTypes.Requireable<string>;
|
|
27
|
+
}>>;
|
|
28
|
+
}
|
|
29
|
+
namespace defaultProps {
|
|
30
|
+
let errorMessage_1: null;
|
|
31
|
+
export { errorMessage_1 as errorMessage };
|
|
32
|
+
export namespace selectedCountry_1 {
|
|
33
|
+
let value: string;
|
|
34
|
+
}
|
|
35
|
+
export { selectedCountry_1 as selectedCountry };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
import { FormAutosuggest, FormAutosuggestOption, FormControlFeedback } from '@openedx/paragon';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { clearRegistrationBackendError } from '../../data/actions';
|
|
9
|
+
import messages from '../../messages';
|
|
10
|
+
import validateCountryField, { COUNTRY_CODE_KEY, COUNTRY_DISPLAY_KEY } from './validator';
|
|
11
|
+
/**
|
|
12
|
+
* Country field wrapper. It accepts following handlers
|
|
13
|
+
* - handleChange for setting value change and
|
|
14
|
+
* - handleErrorChange for setting error
|
|
15
|
+
*
|
|
16
|
+
* It is responsible for
|
|
17
|
+
* - Auto populating country field if backendCountryCode is available in redux
|
|
18
|
+
* - Performing country field validations
|
|
19
|
+
* - clearing error on focus
|
|
20
|
+
* - setting value on change and selection
|
|
21
|
+
*/
|
|
22
|
+
const CountryField = (props) => {
|
|
23
|
+
const { countryList, selectedCountry, onChangeHandler, handleErrorChange, onFocusHandler, } = props;
|
|
24
|
+
const { formatMessage } = useIntl();
|
|
25
|
+
const dispatch = useDispatch();
|
|
26
|
+
const countryFieldValue = {
|
|
27
|
+
userProvidedText: selectedCountry.displayValue,
|
|
28
|
+
selectionValue: selectedCountry.displayValue,
|
|
29
|
+
selectionId: selectedCountry.countryCode,
|
|
30
|
+
};
|
|
31
|
+
const backendCountryCode = useSelector(state => state.register.backendCountryCode);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (backendCountryCode && backendCountryCode !== (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.countryCode)) {
|
|
34
|
+
let countryCode = '';
|
|
35
|
+
let countryDisplayValue = '';
|
|
36
|
+
const countryVal = countryList.find((country) => (country[COUNTRY_CODE_KEY].toLowerCase() === backendCountryCode.toLowerCase()));
|
|
37
|
+
if (countryVal) {
|
|
38
|
+
countryCode = countryVal[COUNTRY_CODE_KEY];
|
|
39
|
+
countryDisplayValue = countryVal[COUNTRY_DISPLAY_KEY];
|
|
40
|
+
}
|
|
41
|
+
onChangeHandler({ target: { name: 'country' } }, { countryCode, displayValue: countryDisplayValue });
|
|
42
|
+
}
|
|
43
|
+
else if (!selectedCountry.displayValue) {
|
|
44
|
+
onChangeHandler({ target: { name: 'country' } }, { countryCode: '', displayValue: '' });
|
|
45
|
+
}
|
|
46
|
+
}, [backendCountryCode, countryList]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
47
|
+
const handleOnBlur = (event) => {
|
|
48
|
+
// Do not run validations when drop-down arrow is clicked
|
|
49
|
+
if (event.relatedTarget && event.relatedTarget.className.includes('pgn__form-autosuggest__icon-button')) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const { value } = event.target;
|
|
53
|
+
const { error } = validateCountryField(value.trim(), countryList, formatMessage(messages['empty.country.field.error']), formatMessage(messages['invalid.country.field.error']));
|
|
54
|
+
handleErrorChange('country', error);
|
|
55
|
+
};
|
|
56
|
+
const handleOnFocus = (event) => {
|
|
57
|
+
handleErrorChange('country', '');
|
|
58
|
+
dispatch(clearRegistrationBackendError('country'));
|
|
59
|
+
onFocusHandler(event);
|
|
60
|
+
};
|
|
61
|
+
const handleOnChange = (value) => {
|
|
62
|
+
onChangeHandler({ target: { name: 'country' } }, { countryCode: value.selectionId, displayValue: value.userProvidedText });
|
|
63
|
+
// We have put this check because proviously we also had onSelected event handler and we call
|
|
64
|
+
// the onBlur on that event handler but now there is no such handler and we only have
|
|
65
|
+
// onChange so we check the is there is proper sectionId which only be
|
|
66
|
+
// proper one when we select it from dropdown's item otherwise its null.
|
|
67
|
+
if (value.selectionId !== '') {
|
|
68
|
+
handleOnBlur({ target: { name: 'country', value: value.userProvidedText } });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const getCountryList = () => countryList.map((country) => (_jsx(FormAutosuggestOption, { id: country[COUNTRY_CODE_KEY], children: country[COUNTRY_DISPLAY_KEY] }, country[COUNTRY_DISPLAY_KEY])));
|
|
72
|
+
return (_jsxs("div", { className: "mb-4", children: [_jsx(FormAutosuggest, { floatingLabel: formatMessage(messages['registration.country.label']), "aria-label": "form autosuggest", name: "country", value: countryFieldValue || {}, className: classNames({ 'form-field-error': props.errorMessage }), onFocus: (e) => handleOnFocus(e), onBlur: (e) => handleOnBlur(e), onChange: (value) => handleOnChange(value), children: getCountryList() }), props.errorMessage !== '' && (_jsx(FormControlFeedback, { className: "form-text-size", hasIcon: false, "feedback-for": "country", type: "invalid", children: props.errorMessage }, "error"))] }));
|
|
73
|
+
};
|
|
74
|
+
CountryField.propTypes = {
|
|
75
|
+
countryList: PropTypes.arrayOf(PropTypes.shape({
|
|
76
|
+
code: PropTypes.string,
|
|
77
|
+
name: PropTypes.string,
|
|
78
|
+
})).isRequired,
|
|
79
|
+
errorMessage: PropTypes.string,
|
|
80
|
+
onChangeHandler: PropTypes.func.isRequired,
|
|
81
|
+
handleErrorChange: PropTypes.func.isRequired,
|
|
82
|
+
onFocusHandler: PropTypes.func.isRequired,
|
|
83
|
+
selectedCountry: PropTypes.shape({
|
|
84
|
+
displayValue: PropTypes.string,
|
|
85
|
+
countryCode: PropTypes.string,
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
CountryField.defaultProps = {
|
|
89
|
+
errorMessage: null,
|
|
90
|
+
selectedCountry: {
|
|
91
|
+
value: '',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
export default CountryField;
|
|
95
|
+
//# sourceMappingURL=CountryField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CountryField.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/CountryField/CountryField.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,oBAAoB,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE1F;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,EAAE;IAC7B,MAAM,E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OAAO,CAC5B,SAAS,CAAC,KAAK,CAAC;QACd,IAAI,EAAE,SAAS,CAAC,MAAM;QACtB,IAAI,EAAE,SAAS,CAAC,MAAM;KACvB,CAAC,CACH,CAAC,UAAU;IACZ,YAAY,EAAE,SAAS,CAAC,MAAM;IAC9B,eAAe,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IAC1C,iBAAiB,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IAC5C,cAAc,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACzC,eAAe,EAAE,SAAS,CAAC,KAAK,CAAC;QAC/B,YAAY,EAAE,SAAS,CAAC,MAAM;QAC9B,WAAW,EAAE,SAAS,CAAC,MAAM;KAC9B,CAAC;CACH,CAAC;AAEF,YAAY,CAAC,YAAY,GAAG;IAC1B,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE;QACf,KAAK,EAAE,EAAE;KACV;CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\n\nimport { useIntl } from '@openedx/frontend-base';\nimport { FormAutosuggest, FormAutosuggestOption, FormControlFeedback } from '@openedx/paragon';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\n\nimport { clearRegistrationBackendError } from '../../data/actions';\nimport messages from '../../messages';\nimport validateCountryField, { COUNTRY_CODE_KEY, COUNTRY_DISPLAY_KEY } from './validator';\n\n/**\n * Country field wrapper. It accepts following handlers\n * - handleChange for setting value change and\n * - handleErrorChange for setting error\n *\n * It is responsible for\n * - Auto populating country field if backendCountryCode is available in redux\n * - Performing country field validations\n * - clearing error on focus\n * - setting value on change and selection\n */\nconst CountryField = (props) => {\n const {\n countryList,\n selectedCountry,\n onChangeHandler,\n handleErrorChange,\n onFocusHandler,\n } = props;\n const { formatMessage } = useIntl();\n const dispatch = useDispatch();\n\n const countryFieldValue = {\n userProvidedText: selectedCountry.displayValue,\n selectionValue: selectedCountry.displayValue,\n selectionId: selectedCountry.countryCode,\n };\n\n const backendCountryCode = useSelector(state => state.register.backendCountryCode);\n\n useEffect(() => {\n if (backendCountryCode && backendCountryCode !== selectedCountry?.countryCode) {\n let countryCode = '';\n let countryDisplayValue = '';\n\n const countryVal = countryList.find(\n (country) => (country[COUNTRY_CODE_KEY].toLowerCase() === backendCountryCode.toLowerCase()),\n );\n if (countryVal) {\n countryCode = countryVal[COUNTRY_CODE_KEY];\n countryDisplayValue = countryVal[COUNTRY_DISPLAY_KEY];\n }\n onChangeHandler(\n { target: { name: 'country' } },\n { countryCode, displayValue: countryDisplayValue },\n );\n } else if (!selectedCountry.displayValue) {\n onChangeHandler(\n { target: { name: 'country' } },\n { countryCode: '', displayValue: '' },\n );\n }\n }, [backendCountryCode, countryList]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleOnBlur = (event) => {\n // Do not run validations when drop-down arrow is clicked\n if (event.relatedTarget && event.relatedTarget.className.includes('pgn__form-autosuggest__icon-button')) {\n return;\n }\n\n const { value } = event.target;\n\n const { error } = validateCountryField(\n value.trim(),\n countryList,\n formatMessage(messages['empty.country.field.error']),\n formatMessage(messages['invalid.country.field.error'])\n );\n handleErrorChange('country', error);\n };\n\n const handleOnFocus = (event) => {\n handleErrorChange('country', '');\n dispatch(clearRegistrationBackendError('country'));\n onFocusHandler(event);\n };\n\n const handleOnChange = (value) => {\n onChangeHandler(\n { target: { name: 'country' } },\n { countryCode: value.selectionId, displayValue: value.userProvidedText }\n );\n\n // We have put this check because proviously we also had onSelected event handler and we call\n // the onBlur on that event handler but now there is no such handler and we only have\n // onChange so we check the is there is proper sectionId which only be\n // proper one when we select it from dropdown's item otherwise its null.\n if (value.selectionId !== '') {\n handleOnBlur({ target: { name: 'country', value: value.userProvidedText } });\n }\n };\n\n const getCountryList = () => countryList.map((country) => (\n <FormAutosuggestOption key={country[COUNTRY_DISPLAY_KEY]} id={country[COUNTRY_CODE_KEY]}>\n {country[COUNTRY_DISPLAY_KEY]}\n </FormAutosuggestOption>\n ));\n\n return (\n <div className=\"mb-4\">\n <FormAutosuggest\n floatingLabel={formatMessage(messages['registration.country.label'])}\n aria-label=\"form autosuggest\"\n name=\"country\"\n value={countryFieldValue || {}}\n className={classNames({ 'form-field-error': props.errorMessage })}\n onFocus={(e) => handleOnFocus(e)}\n onBlur={(e) => handleOnBlur(e)}\n onChange={(value) => handleOnChange(value)}\n >\n {getCountryList()}\n </FormAutosuggest>\n {props.errorMessage !== '' && (\n <FormControlFeedback\n key=\"error\"\n className=\"form-text-size\"\n hasIcon={false}\n feedback-for=\"country\"\n type=\"invalid\"\n >\n {props.errorMessage}\n </FormControlFeedback>\n )}\n </div>\n );\n};\n\nCountryField.propTypes = {\n countryList: PropTypes.arrayOf(\n PropTypes.shape({\n code: PropTypes.string,\n name: PropTypes.string,\n }),\n ).isRequired,\n errorMessage: PropTypes.string,\n onChangeHandler: PropTypes.func.isRequired,\n handleErrorChange: PropTypes.func.isRequired,\n onFocusHandler: PropTypes.func.isRequired,\n selectedCountry: PropTypes.shape({\n displayValue: PropTypes.string,\n countryCode: PropTypes.string,\n }),\n};\n\nCountryField.defaultProps = {\n errorMessage: null,\n selectedCountry: {\n value: '',\n },\n};\n\nexport default CountryField;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const COUNTRY_CODE_KEY: "code";
|
|
2
|
+
export const COUNTRY_DISPLAY_KEY: "name";
|
|
3
|
+
export default validateCountryField;
|
|
4
|
+
declare function validateCountryField(value: any, countryList: any, emptyErrorMessage: any, invalidCountryErrorMessage: any): {
|
|
5
|
+
error: string;
|
|
6
|
+
countryCode: string;
|
|
7
|
+
displayValue: any;
|
|
8
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const COUNTRY_CODE_KEY = 'code';
|
|
2
|
+
export const COUNTRY_DISPLAY_KEY = 'name';
|
|
3
|
+
const validateCountryField = (value, countryList, emptyErrorMessage, invalidCountryErrorMessage) => {
|
|
4
|
+
let countryCode = '';
|
|
5
|
+
let displayValue = value;
|
|
6
|
+
let error = '';
|
|
7
|
+
if (value) {
|
|
8
|
+
const normalizedValue = value.toLowerCase();
|
|
9
|
+
// Handling a case here where user enters a valid country code that needs to be
|
|
10
|
+
// evaluated and set its value as a valid value.
|
|
11
|
+
const selectedCountry = countryList.find((country) => (
|
|
12
|
+
// When translations are applied, extra space added in country value, so we should trim that.
|
|
13
|
+
country[COUNTRY_DISPLAY_KEY].toLowerCase().trim() === normalizedValue
|
|
14
|
+
|| country[COUNTRY_CODE_KEY].toLowerCase().trim() === normalizedValue));
|
|
15
|
+
if (selectedCountry) {
|
|
16
|
+
countryCode = selectedCountry[COUNTRY_CODE_KEY];
|
|
17
|
+
displayValue = selectedCountry[COUNTRY_DISPLAY_KEY];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
error = invalidCountryErrorMessage;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
error = emptyErrorMessage;
|
|
25
|
+
}
|
|
26
|
+
return { error, countryCode, displayValue };
|
|
27
|
+
};
|
|
28
|
+
export default validateCountryField;
|
|
29
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/CountryField/validator.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,EAAE;IACjG,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,KAAK,GAAG,EAAE,CAAC;IAEf,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAC5C,+EAA+E;QAC/E,gDAAgD;QAChD,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CACtC,CAAC,OAAO,EAAE,EAAE,CAAC;QACX,6FAA6F;QAC7F,OAAO,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,eAAe;eAClE,OAAO,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,eAAe,CACtE,CACF,CAAC;QACF,IAAI,eAAe,EAAE,CAAC;YACpB,WAAW,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC;YAChD,YAAY,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,0BAA0B,CAAC;QACrC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,iBAAiB,CAAC;IAC5B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;AAC9C,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["export const COUNTRY_CODE_KEY = 'code';\nexport const COUNTRY_DISPLAY_KEY = 'name';\n\nconst validateCountryField = (value, countryList, emptyErrorMessage, invalidCountryErrorMessage) => {\n let countryCode = '';\n let displayValue = value;\n let error = '';\n\n if (value) {\n const normalizedValue = value.toLowerCase();\n // Handling a case here where user enters a valid country code that needs to be\n // evaluated and set its value as a valid value.\n const selectedCountry = countryList.find(\n (country) => (\n // When translations are applied, extra space added in country value, so we should trim that.\n country[COUNTRY_DISPLAY_KEY].toLowerCase().trim() === normalizedValue\n || country[COUNTRY_CODE_KEY].toLowerCase().trim() === normalizedValue\n ),\n );\n if (selectedCountry) {\n countryCode = selectedCountry[COUNTRY_CODE_KEY];\n displayValue = selectedCountry[COUNTRY_DISPLAY_KEY];\n } else {\n error = invalidCountryErrorMessage;\n }\n } else {\n error = emptyErrorMessage;\n }\n return { error, countryCode, displayValue };\n};\n\nexport default validateCountryField;\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default EmailField;
|
|
2
|
+
/**
|
|
3
|
+
* Email field wrapper. It accepts following handlers
|
|
4
|
+
* - handleChange for setting value change and
|
|
5
|
+
* - handleErrorChange for setting error
|
|
6
|
+
*
|
|
7
|
+
* It is responsible for
|
|
8
|
+
* - Generating email warning and error suggestions
|
|
9
|
+
* - Setting and clearing email suggestions
|
|
10
|
+
* - Performing email field validations
|
|
11
|
+
* - clearing error on focus
|
|
12
|
+
* - setting value on change
|
|
13
|
+
*/
|
|
14
|
+
declare function EmailField(props: any): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare namespace EmailField {
|
|
16
|
+
namespace defaultProps {
|
|
17
|
+
let errorMessage: string;
|
|
18
|
+
let confirmEmailValue: null;
|
|
19
|
+
}
|
|
20
|
+
namespace propTypes {
|
|
21
|
+
let errorMessage_1: PropTypes.Requireable<string>;
|
|
22
|
+
export { errorMessage_1 as errorMessage };
|
|
23
|
+
export let value: PropTypes.Validator<string>;
|
|
24
|
+
export let handleChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
25
|
+
export let handleErrorChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
26
|
+
let confirmEmailValue_1: PropTypes.Requireable<string>;
|
|
27
|
+
export { confirmEmailValue_1 as confirmEmailValue };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
import { Alert, Icon } from '@openedx/paragon';
|
|
6
|
+
import { Close, Error } from '@openedx/paragon/icons';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { FormGroup } from '../../../common-components';
|
|
9
|
+
import { clearRegistrationBackendError, fetchRealtimeValidations, setEmailSuggestionInStore, } from '../../data/actions';
|
|
10
|
+
import messages from '../../messages';
|
|
11
|
+
import validateEmail from './validator';
|
|
12
|
+
/**
|
|
13
|
+
* Email field wrapper. It accepts following handlers
|
|
14
|
+
* - handleChange for setting value change and
|
|
15
|
+
* - handleErrorChange for setting error
|
|
16
|
+
*
|
|
17
|
+
* It is responsible for
|
|
18
|
+
* - Generating email warning and error suggestions
|
|
19
|
+
* - Setting and clearing email suggestions
|
|
20
|
+
* - Performing email field validations
|
|
21
|
+
* - clearing error on focus
|
|
22
|
+
* - setting value on change
|
|
23
|
+
*/
|
|
24
|
+
const EmailField = (props) => {
|
|
25
|
+
const { formatMessage } = useIntl();
|
|
26
|
+
const dispatch = useDispatch();
|
|
27
|
+
const { handleChange, handleErrorChange, confirmEmailValue, } = props;
|
|
28
|
+
const backedUpFormData = useSelector(state => state.register.registrationFormData);
|
|
29
|
+
const validationApiRateLimited = useSelector(state => state.register.validationApiRateLimited);
|
|
30
|
+
const [emailSuggestion, setEmailSuggestion] = useState(Object.assign({}, backedUpFormData === null || backedUpFormData === void 0 ? void 0 : backedUpFormData.emailSuggestion));
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setEmailSuggestion(backedUpFormData.emailSuggestion);
|
|
33
|
+
}, [backedUpFormData.emailSuggestion]);
|
|
34
|
+
const handleOnBlur = (e) => {
|
|
35
|
+
const { value } = e.target;
|
|
36
|
+
const { fieldError, confirmEmailError, suggestion } = validateEmail(value, confirmEmailValue, formatMessage);
|
|
37
|
+
if (confirmEmailError) {
|
|
38
|
+
handleErrorChange('confirm_email', confirmEmailError);
|
|
39
|
+
}
|
|
40
|
+
dispatch(setEmailSuggestionInStore(suggestion));
|
|
41
|
+
setEmailSuggestion(suggestion);
|
|
42
|
+
if (fieldError) {
|
|
43
|
+
handleErrorChange('email', fieldError);
|
|
44
|
+
}
|
|
45
|
+
else if (!validationApiRateLimited) {
|
|
46
|
+
dispatch(fetchRealtimeValidations({ email: value }));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const handleOnFocus = () => {
|
|
50
|
+
handleErrorChange('email', '');
|
|
51
|
+
dispatch(clearRegistrationBackendError('email'));
|
|
52
|
+
};
|
|
53
|
+
const handleSuggestionClick = (event) => {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
handleErrorChange('email', '');
|
|
56
|
+
handleChange({ target: { name: 'email', value: emailSuggestion.suggestion } });
|
|
57
|
+
setEmailSuggestion({ suggestion: '', type: '' });
|
|
58
|
+
};
|
|
59
|
+
const handleSuggestionClosed = () => setEmailSuggestion({ suggestion: '', type: '' });
|
|
60
|
+
const renderEmailFeedback = () => {
|
|
61
|
+
if (emailSuggestion.type === 'error') {
|
|
62
|
+
return (_jsx(Alert, { variant: "danger", className: "email-suggestion-alert-error mt-1", icon: Error, children: _jsxs("span", { className: "email-suggestion__text", children: [formatMessage(messages['did.you.mean.alert.text']), ' ', _jsx(Alert.Link, { href: "#", name: "email", onClick: handleSuggestionClick, children: emailSuggestion.suggestion }), "?", _jsx(Icon, { src: Close, className: "email-suggestion__close", onClick: handleSuggestionClosed, tabIndex: "0" })] }) }));
|
|
63
|
+
}
|
|
64
|
+
return (_jsxs("span", { id: "email-warning", className: "small", children: [formatMessage(messages['did.you.mean.alert.text']), ":", ' ', _jsx(Alert.Link, { href: "#", name: "email", className: "email-suggestion-alert-warning", onClick: handleSuggestionClick, children: emailSuggestion.suggestion }), "?"] }));
|
|
65
|
+
};
|
|
66
|
+
return (_jsx(FormGroup, Object.assign({ borderClass: emailSuggestion.type === 'warning' ? 'yellow-border' : '', maxLength: 254 }, props, { handleBlur: handleOnBlur, handleFocus: handleOnFocus, children: emailSuggestion.suggestion ? renderEmailFeedback() : null })));
|
|
67
|
+
};
|
|
68
|
+
EmailField.defaultProps = {
|
|
69
|
+
errorMessage: '',
|
|
70
|
+
confirmEmailValue: null,
|
|
71
|
+
};
|
|
72
|
+
EmailField.propTypes = {
|
|
73
|
+
errorMessage: PropTypes.string,
|
|
74
|
+
value: PropTypes.string.isRequired,
|
|
75
|
+
handleChange: PropTypes.func.isRequired,
|
|
76
|
+
handleErrorChange: PropTypes.func.isRequired,
|
|
77
|
+
confirmEmailValue: PropTypes.string,
|
|
78
|
+
};
|
|
79
|
+
export default EmailField;
|
|
80
|
+
//# sourceMappingURL=EmailField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailField.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/EmailField/EmailField.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,EAAE;IAC3B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAE/B,MAAM,EACJ,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,GAAG,KAAK,CAAC;IAEV,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ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KAAK,CAAC,IAAI,IACT,IAAI,EAAC,GAAG,EACR,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,gCAAgC,EAC1C,OAAO,EAAE,qBAAqB,YAE7B,eAAe,CAAC,UAAU,GAChB,SACR,CACR,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,SAAS,kBACR,WAAW,EAAE,eAAe,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EACtE,SAAS,EAAE,GAAG,IACV,KAAK,IACT,UAAU,EAAE,YAAY,EACxB,WAAW,EAAE,aAAa,YAEzB,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,IAAI,IAChD,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,UAAU,CAAC,YAAY,GAAG;IACxB,YAAY,EAAE,EAAE;IAChB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEF,UAAU,CAAC,SAAS,GAAG;IACrB,YAAY,EAAE,SAAS,CAAC,MAAM;IAC9B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACvC,iBAAiB,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IAC5C,iBAAiB,EAAE,SAAS,CAAC,MAAM;CACpC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\n\nimport { useIntl } from '@openedx/frontend-base';\nimport { Alert, Icon } from '@openedx/paragon';\nimport { Close, Error } from '@openedx/paragon/icons';\nimport PropTypes from 'prop-types';\n\nimport { FormGroup } from '../../../common-components';\nimport {\n clearRegistrationBackendError,\n fetchRealtimeValidations,\n setEmailSuggestionInStore,\n} from '../../data/actions';\nimport messages from '../../messages';\nimport validateEmail from './validator';\n\n/**\n * Email field wrapper. It accepts following handlers\n * - handleChange for setting value change and\n * - handleErrorChange for setting error\n *\n * It is responsible for\n * - Generating email warning and error suggestions\n * - Setting and clearing email suggestions\n * - Performing email field validations\n * - clearing error on focus\n * - setting value on change\n */\nconst EmailField = (props) => {\n const { formatMessage } = useIntl();\n const dispatch = useDispatch();\n\n const {\n handleChange,\n handleErrorChange,\n confirmEmailValue,\n } = props;\n\n const backedUpFormData = useSelector(state => state.register.registrationFormData);\n const validationApiRateLimited = useSelector(state => state.register.validationApiRateLimited);\n\n const [emailSuggestion, setEmailSuggestion] = useState({ ...backedUpFormData?.emailSuggestion });\n\n useEffect(() => {\n setEmailSuggestion(backedUpFormData.emailSuggestion);\n }, [backedUpFormData.emailSuggestion]);\n\n const handleOnBlur = (e) => {\n const { value } = e.target;\n const { fieldError, confirmEmailError, suggestion } = validateEmail(value, confirmEmailValue, formatMessage);\n\n if (confirmEmailError) {\n handleErrorChange('confirm_email', confirmEmailError);\n }\n\n dispatch(setEmailSuggestionInStore(suggestion));\n setEmailSuggestion(suggestion);\n\n if (fieldError) {\n handleErrorChange('email', fieldError);\n } else if (!validationApiRateLimited) {\n dispatch(fetchRealtimeValidations({ email: value }));\n }\n };\n\n const handleOnFocus = () => {\n handleErrorChange('email', '');\n dispatch(clearRegistrationBackendError('email'));\n };\n\n const handleSuggestionClick = (event) => {\n event.preventDefault();\n handleErrorChange('email', '');\n handleChange({ target: { name: 'email', value: emailSuggestion.suggestion } });\n setEmailSuggestion({ suggestion: '', type: '' });\n };\n\n const handleSuggestionClosed = () => setEmailSuggestion({ suggestion: '', type: '' });\n\n const renderEmailFeedback = () => {\n if (emailSuggestion.type === 'error') {\n return (\n <Alert variant=\"danger\" className=\"email-suggestion-alert-error mt-1\" icon={Error}>\n <span className=\"email-suggestion__text\">\n {formatMessage(messages['did.you.mean.alert.text'])}{' '}\n <Alert.Link\n href=\"#\"\n name=\"email\"\n onClick={handleSuggestionClick}\n >\n {emailSuggestion.suggestion}\n </Alert.Link>?\n <Icon src={Close} className=\"email-suggestion__close\" onClick={handleSuggestionClosed} tabIndex=\"0\" />\n </span>\n </Alert>\n );\n }\n return (\n <span id=\"email-warning\" className=\"small\">\n {formatMessage(messages['did.you.mean.alert.text'])}:{' '}\n <Alert.Link\n href=\"#\"\n name=\"email\"\n className=\"email-suggestion-alert-warning\"\n onClick={handleSuggestionClick}\n >\n {emailSuggestion.suggestion}\n </Alert.Link>?\n </span>\n );\n };\n\n return (\n <FormGroup\n borderClass={emailSuggestion.type === 'warning' ? 'yellow-border' : ''}\n maxLength={254} // Limit per RFCs is 254\n {...props}\n handleBlur={handleOnBlur}\n handleFocus={handleOnFocus}\n >\n {emailSuggestion.suggestion ? renderEmailFeedback() : null}\n </FormGroup>\n );\n};\n\nEmailField.defaultProps = {\n errorMessage: '',\n confirmEmailValue: null,\n};\n\nEmailField.propTypes = {\n errorMessage: PropTypes.string,\n value: PropTypes.string.isRequired,\n handleChange: PropTypes.func.isRequired,\n handleErrorChange: PropTypes.func.isRequired,\n confirmEmailValue: PropTypes.string,\n};\n\nexport default EmailField;\n"]}
|