@openedx/frontend-app-authn 1.0.0-alpha.6 → 1.0.0-alpha.7

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.
Files changed (254) hide show
  1. package/dist/Main.js +1 -3
  2. package/dist/Main.js.map +1 -1
  3. package/dist/common-components/EmbeddedRegistrationRoute.js +2 -2
  4. package/dist/common-components/EmbeddedRegistrationRoute.js.map +1 -1
  5. package/dist/common-components/EnterpriseSSO.js +6 -3
  6. package/dist/common-components/EnterpriseSSO.js.map +1 -1
  7. package/dist/common-components/PasswordField.d.ts +17 -9
  8. package/dist/common-components/PasswordField.js +10 -6
  9. package/dist/common-components/PasswordField.js.map +1 -1
  10. package/dist/common-components/RedirectLogistration.js +7 -3
  11. package/dist/common-components/RedirectLogistration.js.map +1 -1
  12. package/dist/common-components/SocialAuthProviders.d.ts +2 -2
  13. package/dist/common-components/SocialAuthProviders.js +5 -4
  14. package/dist/common-components/SocialAuthProviders.js.map +1 -1
  15. package/dist/common-components/ThirdPartyAuth.js +3 -2
  16. package/dist/common-components/ThirdPartyAuth.js.map +1 -1
  17. package/dist/common-components/ThirdPartyAuthAlert.d.ts +2 -2
  18. package/dist/common-components/ThirdPartyAuthAlert.js +4 -4
  19. package/dist/common-components/ThirdPartyAuthAlert.js.map +1 -1
  20. package/dist/common-components/UnAuthOnlyRoute.js +5 -4
  21. package/dist/common-components/UnAuthOnlyRoute.js.map +1 -1
  22. package/dist/common-components/components/ThirdPartyAuthContext.d.ts +31 -0
  23. package/dist/common-components/components/ThirdPartyAuthContext.js +84 -0
  24. package/dist/common-components/components/ThirdPartyAuthContext.js.map +1 -0
  25. package/dist/common-components/data/api.d.ts +6 -0
  26. package/dist/common-components/data/api.js +26 -0
  27. package/dist/common-components/data/api.js.map +1 -0
  28. package/dist/common-components/data/apiHook.d.ts +9 -0
  29. package/dist/common-components/data/apiHook.js +14 -0
  30. package/dist/common-components/data/apiHook.js.map +1 -0
  31. package/dist/common-components/data/queryKeys.d.ts +4 -0
  32. package/dist/common-components/data/queryKeys.js +6 -0
  33. package/dist/common-components/data/queryKeys.js.map +1 -0
  34. package/dist/common-components/index.d.ts +0 -3
  35. package/dist/common-components/index.js +0 -3
  36. package/dist/common-components/index.js.map +1 -1
  37. package/dist/constants.d.ts +13 -0
  38. package/dist/constants.js +15 -0
  39. package/dist/constants.js.map +1 -1
  40. package/dist/data/constants.d.ts +0 -8
  41. package/dist/data/constants.js +0 -9
  42. package/dist/data/constants.js.map +1 -1
  43. package/dist/data/utils/dataUtils.d.ts +1 -0
  44. package/dist/data/utils/dataUtils.js +14 -0
  45. package/dist/data/utils/dataUtils.js.map +1 -1
  46. package/dist/data/utils/index.d.ts +1 -2
  47. package/dist/data/utils/index.js +1 -2
  48. package/dist/data/utils/index.js.map +1 -1
  49. package/dist/forgot-password/ForgotPasswordPage.d.ts +2 -36
  50. package/dist/forgot-password/ForgotPasswordPage.js +45 -44
  51. package/dist/forgot-password/ForgotPasswordPage.js.map +1 -1
  52. package/dist/forgot-password/data/api.d.ts +2 -0
  53. package/dist/forgot-password/data/{service.js → api.js} +13 -14
  54. package/dist/forgot-password/data/api.js.map +1 -0
  55. package/dist/forgot-password/data/apiHook.d.ts +16 -0
  56. package/dist/forgot-password/data/apiHook.js +26 -0
  57. package/dist/forgot-password/data/apiHook.js.map +1 -0
  58. package/dist/forgot-password/index.d.ts +0 -4
  59. package/dist/forgot-password/index.js +0 -4
  60. package/dist/forgot-password/index.js.map +1 -1
  61. package/dist/forgot-password/messages.js +1 -1
  62. package/dist/forgot-password/messages.js.map +1 -1
  63. package/dist/login/ChangePasswordPrompt.js +11 -5
  64. package/dist/login/ChangePasswordPrompt.js.map +1 -1
  65. package/dist/login/LoginPage.d.ts +12 -10
  66. package/dist/login/LoginPage.js +85 -127
  67. package/dist/login/LoginPage.js.map +1 -1
  68. package/dist/login/components/LoginContext.d.ts +21 -0
  69. package/dist/login/components/LoginContext.js +28 -0
  70. package/dist/login/components/LoginContext.js.map +1 -0
  71. package/dist/login/data/api.d.ts +2 -0
  72. package/dist/login/data/api.js +27 -0
  73. package/dist/login/data/api.js.map +1 -0
  74. package/dist/login/data/apiHook.d.ts +13 -0
  75. package/dist/login/data/apiHook.js +57 -0
  76. package/dist/login/data/apiHook.js.map +1 -0
  77. package/dist/login/index.d.ts +0 -3
  78. package/dist/login/index.js +0 -3
  79. package/dist/login/index.js.map +1 -1
  80. package/dist/logistration/Logistration.d.ts +5 -32
  81. package/dist/logistration/Logistration.js +28 -54
  82. package/dist/logistration/Logistration.js.map +1 -1
  83. package/dist/progressive-profiling/ProgressiveProfiling.d.ts +2 -46
  84. package/dist/progressive-profiling/ProgressiveProfiling.js +47 -71
  85. package/dist/progressive-profiling/ProgressiveProfiling.js.map +1 -1
  86. package/dist/progressive-profiling/ProgressiveProfilingPageModal.js +8 -1
  87. package/dist/progressive-profiling/ProgressiveProfilingPageModal.js.map +1 -1
  88. package/dist/progressive-profiling/components/ProgressiveProfilingContext.d.ts +18 -0
  89. package/dist/progressive-profiling/components/ProgressiveProfilingContext.js +52 -0
  90. package/dist/progressive-profiling/components/ProgressiveProfilingContext.js.map +1 -0
  91. package/dist/progressive-profiling/data/api.d.ts +2 -0
  92. package/dist/progressive-profiling/data/{service.js → api.js} +11 -12
  93. package/dist/progressive-profiling/data/api.js.map +1 -0
  94. package/dist/progressive-profiling/data/apiHook.d.ts +10 -0
  95. package/dist/progressive-profiling/data/apiHook.js +36 -0
  96. package/dist/progressive-profiling/data/apiHook.js.map +1 -0
  97. package/dist/progressive-profiling/index.d.ts +0 -2
  98. package/dist/progressive-profiling/index.js +0 -2
  99. package/dist/progressive-profiling/index.js.map +1 -1
  100. package/dist/register/RegistrationFields/CountryField/CountryField.d.ts +1 -1
  101. package/dist/register/RegistrationFields/CountryField/CountryField.js +5 -7
  102. package/dist/register/RegistrationFields/CountryField/CountryField.js.map +1 -1
  103. package/dist/register/RegistrationFields/EmailField/EmailField.js +17 -9
  104. package/dist/register/RegistrationFields/EmailField/EmailField.js.map +1 -1
  105. package/dist/register/RegistrationFields/NameField/NameField.js +14 -7
  106. package/dist/register/RegistrationFields/NameField/NameField.js.map +1 -1
  107. package/dist/register/RegistrationFields/NameField/validator.d.ts +1 -0
  108. package/dist/register/RegistrationFields/NameField/validator.js +4 -0
  109. package/dist/register/RegistrationFields/NameField/validator.js.map +1 -1
  110. package/dist/register/RegistrationFields/UsernameField/UsernameField.js +20 -14
  111. package/dist/register/RegistrationFields/UsernameField/UsernameField.js.map +1 -1
  112. package/dist/register/RegistrationPage.d.ts +1 -1
  113. package/dist/register/RegistrationPage.js +102 -59
  114. package/dist/register/RegistrationPage.js.map +1 -1
  115. package/dist/register/components/RegisterContext.d.ts +8 -0
  116. package/dist/register/components/RegisterContext.js +167 -0
  117. package/dist/register/components/RegisterContext.js.map +1 -0
  118. package/dist/register/components/RegistrationFailure.js +4 -1
  119. package/dist/register/components/RegistrationFailure.js.map +1 -1
  120. package/dist/register/data/api.d.ts +9 -0
  121. package/dist/register/data/api.js +45 -0
  122. package/dist/register/data/api.js.map +1 -0
  123. package/dist/register/data/apiHook.d.ts +33 -0
  124. package/dist/register/data/apiHook.js +66 -0
  125. package/dist/register/data/apiHook.js.map +1 -0
  126. package/dist/register/data/constants.d.ts +1 -0
  127. package/dist/register/data/constants.js +1 -0
  128. package/dist/register/data/constants.js.map +1 -1
  129. package/dist/register/index.d.ts +0 -2
  130. package/dist/register/index.js +0 -3
  131. package/dist/register/index.js.map +1 -1
  132. package/dist/register/messages.d.ts +10 -0
  133. package/dist/register/messages.js +10 -0
  134. package/dist/register/messages.js.map +1 -1
  135. package/dist/register/types.d.ts +74 -0
  136. package/dist/register/types.js +2 -0
  137. package/dist/register/types.js.map +1 -0
  138. package/dist/reset-password/ResetPasswordPage.d.ts +2 -32
  139. package/dist/reset-password/ResetPasswordPage.js +90 -58
  140. package/dist/reset-password/ResetPasswordPage.js.map +1 -1
  141. package/dist/reset-password/data/api.d.ts +4 -0
  142. package/dist/reset-password/data/api.js +57 -0
  143. package/dist/reset-password/data/api.js.map +1 -0
  144. package/dist/reset-password/data/apiHook.d.ts +31 -0
  145. package/dist/reset-password/data/apiHook.js +74 -0
  146. package/dist/reset-password/data/apiHook.js.map +1 -0
  147. package/dist/reset-password/index.d.ts +0 -4
  148. package/dist/reset-password/index.js +0 -4
  149. package/dist/reset-password/index.js.map +1 -1
  150. package/dist/routes.d.ts +1 -0
  151. package/dist/routes.js +15 -14
  152. package/dist/routes.js.map +1 -1
  153. package/dist/sass/_registration.scss +8 -10
  154. package/dist/slots/LoginComponentSlot/index.d.ts +12 -0
  155. package/dist/slots/LoginComponentSlot/index.js +11 -0
  156. package/dist/slots/LoginComponentSlot/index.js.map +1 -0
  157. package/package.json +18 -14
  158. package/dist/common-components/data/actions.d.ts +0 -26
  159. package/dist/common-components/data/actions.js +0 -22
  160. package/dist/common-components/data/actions.js.map +0 -1
  161. package/dist/common-components/data/reducers.d.ts +0 -62
  162. package/dist/common-components/data/reducers.js +0 -39
  163. package/dist/common-components/data/reducers.js.map +0 -1
  164. package/dist/common-components/data/sagas.d.ts +0 -12
  165. package/dist/common-components/data/sagas.js +0 -21
  166. package/dist/common-components/data/sagas.js.map +0 -1
  167. package/dist/common-components/data/selectors.d.ts +0 -98
  168. package/dist/common-components/data/selectors.js +0 -11
  169. package/dist/common-components/data/selectors.js.map +0 -1
  170. package/dist/common-components/data/service.d.ts +0 -5
  171. package/dist/common-components/data/service.js +0 -31
  172. package/dist/common-components/data/service.js.map +0 -1
  173. package/dist/data/configureStore.d.ts +0 -3
  174. package/dist/data/configureStore.js +0 -24
  175. package/dist/data/configureStore.js.map +0 -1
  176. package/dist/data/reducers.d.ts +0 -254
  177. package/dist/data/reducers.js +0 -17
  178. package/dist/data/reducers.js.map +0 -1
  179. package/dist/data/sagas.d.ts +0 -1
  180. package/dist/data/sagas.js +0 -18
  181. package/dist/data/sagas.js.map +0 -1
  182. package/dist/data/utils/reduxUtils.d.ts +0 -15
  183. package/dist/data/utils/reduxUtils.js +0 -29
  184. package/dist/data/utils/reduxUtils.js.map +0 -1
  185. package/dist/forgot-password/data/actions.d.ts +0 -30
  186. package/dist/forgot-password/data/actions.js +0 -26
  187. package/dist/forgot-password/data/actions.js.map +0 -1
  188. package/dist/forgot-password/data/reducers.d.ts +0 -13
  189. package/dist/forgot-password/data/reducers.js +0 -46
  190. package/dist/forgot-password/data/reducers.js.map +0 -1
  191. package/dist/forgot-password/data/sagas.d.ts +0 -4
  192. package/dist/forgot-password/data/sagas.js +0 -28
  193. package/dist/forgot-password/data/sagas.js.map +0 -1
  194. package/dist/forgot-password/data/selectors.d.ts +0 -23
  195. package/dist/forgot-password/data/selectors.js +0 -5
  196. package/dist/forgot-password/data/selectors.js.map +0 -1
  197. package/dist/forgot-password/data/service.d.ts +0 -1
  198. package/dist/forgot-password/data/service.js.map +0 -1
  199. package/dist/login/data/actions.d.ts +0 -36
  200. package/dist/login/data/actions.js +0 -32
  201. package/dist/login/data/actions.js.map +0 -1
  202. package/dist/login/data/reducers.d.ts +0 -82
  203. package/dist/login/data/reducers.js +0 -44
  204. package/dist/login/data/reducers.js.map +0 -1
  205. package/dist/login/data/sagas.d.ts +0 -10
  206. package/dist/login/data/sagas.js +0 -34
  207. package/dist/login/data/sagas.js.map +0 -1
  208. package/dist/login/data/service.d.ts +0 -4
  209. package/dist/login/data/service.js +0 -32
  210. package/dist/login/data/service.js.map +0 -1
  211. package/dist/progressive-profiling/data/actions.d.ts +0 -19
  212. package/dist/progressive-profiling/data/actions.js +0 -18
  213. package/dist/progressive-profiling/data/actions.js.map +0 -1
  214. package/dist/progressive-profiling/data/reducers.d.ts +0 -22
  215. package/dist/progressive-profiling/data/reducers.js +0 -23
  216. package/dist/progressive-profiling/data/reducers.js.map +0 -1
  217. package/dist/progressive-profiling/data/sagas.d.ts +0 -4
  218. package/dist/progressive-profiling/data/sagas.js +0 -17
  219. package/dist/progressive-profiling/data/sagas.js.map +0 -1
  220. package/dist/progressive-profiling/data/selectors.d.ts +0 -39
  221. package/dist/progressive-profiling/data/selectors.js +0 -9
  222. package/dist/progressive-profiling/data/selectors.js.map +0 -1
  223. package/dist/progressive-profiling/data/service.d.ts +0 -1
  224. package/dist/progressive-profiling/data/service.js.map +0 -1
  225. package/dist/register/data/actions.d.ts +0 -80
  226. package/dist/register/data/actions.js +0 -69
  227. package/dist/register/data/actions.js.map +0 -1
  228. package/dist/register/data/reducers.d.ts +0 -237
  229. package/dist/register/data/reducers.js +0 -86
  230. package/dist/register/data/reducers.js.map +0 -1
  231. package/dist/register/data/sagas.d.ts +0 -19
  232. package/dist/register/data/sagas.js +0 -45
  233. package/dist/register/data/sagas.js.map +0 -1
  234. package/dist/register/data/selectors.d.ts +0 -26
  235. package/dist/register/data/selectors.js +0 -25
  236. package/dist/register/data/selectors.js.map +0 -1
  237. package/dist/register/data/service.d.ts +0 -8
  238. package/dist/register/data/service.js +0 -46
  239. package/dist/register/data/service.js.map +0 -1
  240. package/dist/reset-password/data/actions.d.ts +0 -56
  241. package/dist/reset-password/data/actions.js +0 -41
  242. package/dist/reset-password/data/actions.js.map +0 -1
  243. package/dist/reset-password/data/reducers.d.ts +0 -19
  244. package/dist/reset-password/data/reducers.js +0 -25
  245. package/dist/reset-password/data/reducers.js.map +0 -1
  246. package/dist/reset-password/data/sagas.d.ts +0 -7
  247. package/dist/reset-password/data/sagas.js +0 -63
  248. package/dist/reset-password/data/sagas.js.map +0 -1
  249. package/dist/reset-password/data/selectors.d.ts +0 -23
  250. package/dist/reset-password/data/selectors.js +0 -5
  251. package/dist/reset-password/data/selectors.js.map +0 -1
  252. package/dist/reset-password/data/service.d.ts +0 -3
  253. package/dist/reset-password/data/service.js +0 -62
  254. package/dist/reset-password/data/service.js.map +0 -1
@@ -1,25 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
- import { connect } from 'react-redux';
4
- import { useAppConfig, getAuthService, getSiteConfig, sendPageEvent, sendTrackEvent, useIntl } from '@openedx/frontend-base';
3
+ import { useAppConfig, getAuthService, getSiteConfig, getUrlByRouteRole, sendPageEvent, sendTrackEvent, useIntl, } from '@openedx/frontend-base';
5
4
  import { Icon, Tab, Tabs, } from '@openedx/paragon';
6
5
  import { ChevronLeft } from '@openedx/paragon/icons';
7
6
  import PropTypes from 'prop-types';
8
7
  import { Navigate, useNavigate } from 'react-router-dom';
9
8
  import BaseContainer from '../base-container';
10
- import { clearThirdPartyAuthContextErrorMessage } from '../common-components/data/actions';
11
- import { tpaProvidersSelector, } from '../common-components/data/selectors';
9
+ import { ThirdPartyAuthProvider, useThirdPartyAuthContext } from '../common-components/components/ThirdPartyAuthContext';
12
10
  import messages from '../common-components/messages';
13
- import { LOGIN_PAGE, REGISTER_PAGE } from '../data/constants';
11
+ import { loginPath, loginRole, registerPath, registerRole } from '../constants';
14
12
  import { getTpaHint, getTpaProvider, updatePathWithQueryParams, } from '../data/utils';
15
- import { LoginPage } from '../login';
16
- import { backupLoginForm } from '../login/data/actions';
13
+ import { LoginProvider } from '../login/components/LoginContext';
17
14
  import { RegistrationPage } from '../register';
18
- import { backupRegistrationForm } from '../register/data/actions';
19
- const Logistration = (props) => {
20
- const { selectedPage, tpaProviders } = props;
15
+ import { RegisterProvider } from '../register/components/RegisterContext';
16
+ import LoginComponentSlot from '../slots/LoginComponentSlot';
17
+ const LogistrationPageInner = ({ selectedPage, }) => {
21
18
  const tpaHint = getTpaHint();
22
- const { providers, secondaryProviders, } = tpaProviders;
19
+ const { thirdPartyAuthContext, clearThirdPartyAuthErrorMessage, } = useThirdPartyAuthContext();
20
+ const { providers, secondaryProviders, } = thirdPartyAuthContext;
23
21
  const { formatMessage } = useIntl();
24
22
  const [institutionLogin, setInstitutionLogin] = useState(false);
25
23
  const [key, setKey] = useState('');
@@ -29,18 +27,19 @@ const Logistration = (props) => {
29
27
  useEffect(() => {
30
28
  const authService = getAuthService();
31
29
  if (authService) {
32
- authService.getCsrfTokenService().getCsrfToken(getSiteConfig().lmsBaseUrl);
30
+ authService.getCsrfTokenService()
31
+ .getCsrfToken(getSiteConfig().lmsBaseUrl);
33
32
  }
34
- });
33
+ }, []);
35
34
  useEffect(() => {
36
35
  if (disablePublicAccountCreation) {
37
- navigate(updatePathWithQueryParams(LOGIN_PAGE));
36
+ navigate(updatePathWithQueryParams(getUrlByRouteRole(loginRole)));
38
37
  }
39
38
  }, [navigate, disablePublicAccountCreation]);
40
39
  const handleInstitutionLogin = (e) => {
41
40
  sendTrackEvent('edx.bi.institution_login_form.toggled', { category: 'user-engagement' });
42
41
  if (typeof e === 'string') {
43
- sendPageEvent('login_and_registration', e === '/login' ? 'login' : 'register');
42
+ sendPageEvent('login_and_registration', e === loginPath ? 'login' : 'register');
44
43
  }
45
44
  else {
46
45
  sendPageEvent('login_and_registration', e.target.dataset.eventName);
@@ -51,17 +50,11 @@ const Logistration = (props) => {
51
50
  if (tabKey === currentTab) {
52
51
  return;
53
52
  }
54
- sendTrackEvent(`edx.bi.${tabKey.replace('/', '')}_form.toggled`, { category: 'user-engagement' });
55
- props.clearThirdPartyAuthContextErrorMessage();
56
- if (tabKey === LOGIN_PAGE) {
57
- props.backupRegistrationForm();
58
- }
59
- else if (tabKey === REGISTER_PAGE) {
60
- props.backupLoginForm();
61
- }
53
+ sendTrackEvent(`edx.bi.${tabKey}_form.toggled`, { category: 'user-engagement' });
54
+ clearThirdPartyAuthErrorMessage();
62
55
  setKey(tabKey);
63
56
  };
64
- const tabTitle = (_jsxs("div", { className: "d-flex", children: [_jsx(Icon, { src: ChevronLeft, className: "left-icon" }), _jsx("span", { className: "ml-2", children: selectedPage === LOGIN_PAGE
57
+ const tabTitle = (_jsxs("div", { className: "d-flex", children: [_jsx(Icon, { src: ChevronLeft, className: "left-icon" }), _jsx("span", { className: "ml-2", children: selectedPage === loginPath
65
58
  ? formatMessage(messages['logistration.sign.in'])
66
59
  : formatMessage(messages['logistration.register']) })] }));
67
60
  const isValidTpaHint = () => {
@@ -69,38 +62,19 @@ const Logistration = (props) => {
69
62
  return !!provider;
70
63
  };
71
64
  return (_jsx(BaseContainer, { children: _jsx("div", { children: disablePublicAccountCreation
72
- ? (_jsxs(_Fragment, { children: [institutionLogin && (_jsx(Tabs, { defaultActiveKey: "", id: "controlled-tab", onSelect: handleInstitutionLogin, children: _jsx(Tab, { title: tabTitle, eventKey: LOGIN_PAGE }) })), _jsxs("div", { id: "main-content", className: "main-content", children: [!institutionLogin && (_jsx("h3", { className: "mb-4.5", children: formatMessage(messages['logistration.sign.in']) })), _jsx(LoginPage, { institutionLogin: institutionLogin, handleInstitutionLogin: handleInstitutionLogin })] })] }))
65
+ ? (_jsxs(_Fragment, { children: [institutionLogin && (_jsx(Tabs, { defaultActiveKey: "", id: "controlled-tab", onSelect: handleInstitutionLogin, children: _jsx(Tab, { title: tabTitle, eventKey: loginPath }) })), _jsxs("div", { id: "main-content", className: "main-content", children: [!institutionLogin && (_jsx("h3", { className: "mb-4.5", children: formatMessage(messages['logistration.sign.in']) })), _jsx(LoginComponentSlot, { institutionLogin: institutionLogin, handleInstitutionLogin: handleInstitutionLogin })] })] }))
73
66
  : (_jsxs("div", { children: [institutionLogin
74
- ? (_jsx(Tabs, { defaultActiveKey: "", id: "controlled-tab", onSelect: handleInstitutionLogin, children: _jsx(Tab, { title: tabTitle, eventKey: selectedPage === LOGIN_PAGE ? LOGIN_PAGE : REGISTER_PAGE }) }))
75
- : (!isValidTpaHint() && !hideRegistrationLink && (_jsxs(Tabs, { defaultActiveKey: selectedPage, id: "controlled-tab", onSelect: (tabKey) => handleOnSelect(tabKey, selectedPage), children: [_jsx(Tab, { title: formatMessage(messages['logistration.register']), eventKey: REGISTER_PAGE }), _jsx(Tab, { title: formatMessage(messages['logistration.sign.in']), eventKey: LOGIN_PAGE })] }))), key && (_jsx(Navigate, { to: updatePathWithQueryParams(key), replace: true })), _jsxs("div", { id: "main-content", className: "main-content", children: [!institutionLogin && !isValidTpaHint() && hideRegistrationLink && (_jsx("h3", { className: "mb-4.5", children: formatMessage(messages[selectedPage === LOGIN_PAGE ? 'logistration.sign.in' : 'logistration.register']) })), selectedPage === LOGIN_PAGE
76
- ? _jsx(LoginPage, { institutionLogin: institutionLogin, handleInstitutionLogin: handleInstitutionLogin })
67
+ ? (_jsx(Tabs, { defaultActiveKey: "", id: "controlled-tab", onSelect: handleInstitutionLogin, children: _jsx(Tab, { title: tabTitle, eventKey: selectedPage === loginPath ? loginPath : registerPath }) }))
68
+ : (!isValidTpaHint() && !hideRegistrationLink && (_jsxs(Tabs, { defaultActiveKey: selectedPage, id: "controlled-tab", onSelect: (tabKey) => handleOnSelect(tabKey, selectedPage), children: [_jsx(Tab, { title: formatMessage(messages['logistration.register']), eventKey: registerPath }), _jsx(Tab, { title: formatMessage(messages['logistration.sign.in']), eventKey: loginPath })] }))), key && (_jsx(Navigate, { to: updatePathWithQueryParams(getUrlByRouteRole(key === loginPath ? loginRole : registerRole)), replace: true })), _jsxs("div", { id: "main-content", className: "main-content", children: [!institutionLogin && !isValidTpaHint() && hideRegistrationLink && (_jsx("h3", { className: "mb-4.5", children: formatMessage(messages[selectedPage === loginPath ? 'logistration.sign.in' : 'logistration.register']) })), selectedPage === loginPath
69
+ ? (_jsx(LoginComponentSlot, { institutionLogin: institutionLogin, handleInstitutionLogin: handleInstitutionLogin }))
77
70
  : (_jsx(RegistrationPage, { institutionLogin: institutionLogin, handleInstitutionLogin: handleInstitutionLogin }))] })] })) }) }));
78
71
  };
79
- Logistration.propTypes = {
80
- selectedPage: PropTypes.string,
81
- backupLoginForm: PropTypes.func.isRequired,
82
- backupRegistrationForm: PropTypes.func.isRequired,
83
- clearThirdPartyAuthContextErrorMessage: PropTypes.func.isRequired,
84
- tpaProviders: PropTypes.shape({
85
- providers: PropTypes.arrayOf(PropTypes.shape({})),
86
- secondaryProviders: PropTypes.arrayOf(PropTypes.shape({})),
87
- }),
88
- };
89
- Logistration.defaultProps = {
90
- tpaProviders: {
91
- providers: [],
92
- secondaryProviders: [],
93
- },
94
- };
95
- Logistration.defaultProps = {
96
- selectedPage: REGISTER_PAGE,
72
+ LogistrationPageInner.propTypes = {
73
+ selectedPage: PropTypes.string.isRequired,
97
74
  };
98
- const mapStateToProps = state => ({
99
- tpaProviders: tpaProvidersSelector(state),
100
- });
101
- export default connect(mapStateToProps, {
102
- backupLoginForm,
103
- backupRegistrationForm,
104
- clearThirdPartyAuthContextErrorMessage,
105
- })(Logistration);
75
+ /**
76
+ * Main Logistration Page component wrapped with providers
77
+ */
78
+ const LogistrationPage = (props) => (_jsx(ThirdPartyAuthProvider, { children: _jsx(RegisterProvider, { children: _jsx(LoginProvider, { children: _jsx(LogistrationPageInner, Object.assign({}, props)) }) }) }));
79
+ export default LogistrationPage;
106
80
  //# sourceMappingURL=Logistration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Logistration.js","sourceRoot":"","sources":["../../src/logistration/Logistration.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EACL,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EACpF,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,IAAI,EACJ,GAAG,EACH,IAAI,GACL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,sCAAsC,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,EACL,oBAAoB,GACrB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,QAAQ,MAAM,+BAA+B,CAAC;AACrD,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ACvB,YAAY,EAAE,SAAS,CAAC,MAAM;IAC9B,eAAe,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IAC1C,sBAAsB,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACjD,sCAAsC,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACjE,YAAY,EAAE,SAAS,CAAC,KAAK,CAAC;QAC5B,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,kBAAkB,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KAC3D,CAAC;CACH,CAAC;AAEF,YAAY,CAAC,YAAY,GAAG;IAC1B,YAAY,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,kBAAkB,EAAE,EAAE;KACvB;CACF,CAAC;AAEF,YAAY,CAAC,YAAY,GAAG;IAC1B,YAAY,EAAE,aAAa;CAC5B,CAAC;AAEF,MAAM,eAAe,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;IAChC,YAAY,EAAE,oBAAoB,CAAC,KAAK,CAAC;CAC1C,CAAC,CAAC;AAEH,eAAe,OAAO,CACpB,eAAe,EACf;IACE,eAAe;IACf,sBAAsB;IACtB,sCAAsC;CACvC,CACF,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { connect } from 'react-redux';\n\nimport {\n useAppConfig, getAuthService, getSiteConfig, sendPageEvent, sendTrackEvent, useIntl\n} from '@openedx/frontend-base';\nimport {\n Icon,\n Tab,\n Tabs,\n} from '@openedx/paragon';\nimport { ChevronLeft } from '@openedx/paragon/icons';\nimport PropTypes from 'prop-types';\nimport { Navigate, useNavigate } from 'react-router-dom';\n\nimport BaseContainer from '../base-container';\nimport { clearThirdPartyAuthContextErrorMessage } from '../common-components/data/actions';\nimport {\n tpaProvidersSelector,\n} from '../common-components/data/selectors';\nimport messages from '../common-components/messages';\nimport { LOGIN_PAGE, REGISTER_PAGE } from '../data/constants';\nimport {\n getTpaHint, getTpaProvider, updatePathWithQueryParams,\n} from '../data/utils';\nimport { LoginPage } from '../login';\nimport { backupLoginForm } from '../login/data/actions';\nimport { RegistrationPage } from '../register';\nimport { backupRegistrationForm } from '../register/data/actions';\n\nconst Logistration = (props) => {\n const { selectedPage, tpaProviders } = props;\n const tpaHint = getTpaHint();\n const {\n providers, secondaryProviders,\n } = tpaProviders;\n const { formatMessage } = useIntl();\n const [institutionLogin, setInstitutionLogin] = useState(false);\n const [key, setKey] = useState('');\n const navigate = useNavigate();\n const disablePublicAccountCreation = useAppConfig().ALLOW_PUBLIC_ACCOUNT_CREATION === false;\n const hideRegistrationLink = useAppConfig().SHOW_REGISTRATION_LINKS === false;\n\n useEffect(() => {\n const authService = getAuthService();\n if (authService) {\n authService.getCsrfTokenService().getCsrfToken(getSiteConfig().lmsBaseUrl);\n }\n });\n\n useEffect(() => {\n if (disablePublicAccountCreation) {\n navigate(updatePathWithQueryParams(LOGIN_PAGE));\n }\n }, [navigate, disablePublicAccountCreation]);\n\n const handleInstitutionLogin = (e) => {\n sendTrackEvent('edx.bi.institution_login_form.toggled', { category: 'user-engagement' });\n if (typeof e === 'string') {\n sendPageEvent('login_and_registration', e === '/login' ? 'login' : 'register');\n } else {\n sendPageEvent('login_and_registration', e.target.dataset.eventName);\n }\n\n setInstitutionLogin(!institutionLogin);\n };\n\n const handleOnSelect = (tabKey, currentTab) => {\n if (tabKey === currentTab) {\n return;\n }\n sendTrackEvent(`edx.bi.${tabKey.replace('/', '')}_form.toggled`, { category: 'user-engagement' });\n props.clearThirdPartyAuthContextErrorMessage();\n if (tabKey === LOGIN_PAGE) {\n props.backupRegistrationForm();\n } else if (tabKey === REGISTER_PAGE) {\n props.backupLoginForm();\n }\n setKey(tabKey);\n };\n\n const tabTitle = (\n <div className=\"d-flex\">\n <Icon src={ChevronLeft} className=\"left-icon\" />\n <span className=\"ml-2\">\n {selectedPage === LOGIN_PAGE\n ? formatMessage(messages['logistration.sign.in'])\n : formatMessage(messages['logistration.register'])}\n </span>\n </div>\n );\n\n const isValidTpaHint = () => {\n const { provider } = getTpaProvider(tpaHint, providers, secondaryProviders);\n return !!provider;\n };\n\n return (\n <BaseContainer>\n <div>\n {disablePublicAccountCreation\n ? (\n <>\n {institutionLogin && (\n <Tabs defaultActiveKey=\"\" id=\"controlled-tab\" onSelect={handleInstitutionLogin}>\n <Tab title={tabTitle} eventKey={LOGIN_PAGE} />\n </Tabs>\n )}\n <div id=\"main-content\" className=\"main-content\">\n {!institutionLogin && (\n <h3 className=\"mb-4.5\">{formatMessage(messages['logistration.sign.in'])}</h3>\n )}\n <LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />\n </div>\n </>\n )\n : (\n <div>\n {institutionLogin\n ? (\n <Tabs defaultActiveKey=\"\" id=\"controlled-tab\" onSelect={handleInstitutionLogin}>\n <Tab title={tabTitle} eventKey={selectedPage === LOGIN_PAGE ? LOGIN_PAGE : REGISTER_PAGE} />\n </Tabs>\n )\n : (!isValidTpaHint() && !hideRegistrationLink && (\n <Tabs defaultActiveKey={selectedPage} id=\"controlled-tab\" onSelect={(tabKey) => handleOnSelect(tabKey, selectedPage)}>\n <Tab title={formatMessage(messages['logistration.register'])} eventKey={REGISTER_PAGE} />\n <Tab title={formatMessage(messages['logistration.sign.in'])} eventKey={LOGIN_PAGE} />\n </Tabs>\n ))}\n {key && (\n <Navigate to={updatePathWithQueryParams(key)} replace />\n )}\n <div id=\"main-content\" className=\"main-content\">\n {!institutionLogin && !isValidTpaHint() && hideRegistrationLink && (\n <h3 className=\"mb-4.5\">\n {formatMessage(messages[selectedPage === LOGIN_PAGE ? 'logistration.sign.in' : 'logistration.register'])}\n </h3>\n )}\n {selectedPage === LOGIN_PAGE\n ? <LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />\n : (\n <RegistrationPage\n institutionLogin={institutionLogin}\n handleInstitutionLogin={handleInstitutionLogin}\n />\n )}\n </div>\n </div>\n )}\n </div>\n </BaseContainer>\n );\n};\n\nLogistration.propTypes = {\n selectedPage: PropTypes.string,\n backupLoginForm: PropTypes.func.isRequired,\n backupRegistrationForm: PropTypes.func.isRequired,\n clearThirdPartyAuthContextErrorMessage: PropTypes.func.isRequired,\n tpaProviders: PropTypes.shape({\n providers: PropTypes.arrayOf(PropTypes.shape({})),\n secondaryProviders: PropTypes.arrayOf(PropTypes.shape({})),\n }),\n};\n\nLogistration.defaultProps = {\n tpaProviders: {\n providers: [],\n secondaryProviders: [],\n },\n};\n\nLogistration.defaultProps = {\n selectedPage: REGISTER_PAGE,\n};\n\nconst mapStateToProps = state => ({\n tpaProviders: tpaProvidersSelector(state),\n});\n\nexport default connect(\n mapStateToProps,\n {\n backupLoginForm,\n backupRegistrationForm,\n clearThirdPartyAuthContextErrorMessage,\n },\n)(Logistration);\n"]}
1
+ {"version":3,"file":"Logistration.js","sourceRoot":"","sources":["../../src/logistration/Logistration.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EACL,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAC9D,aAAa,EAAE,cAAc,EAAE,OAAO,GACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,IAAI,EACJ,GAAG,EACH,IAAI,GACL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACzH,OAAO,QAAQ,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,SAAS,EA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AAC,KAAK,EAAE,EAAE,CAAC,CAClC,KAAC,sBAAsB,cACrB,KAAC,gBAAgB,cACf,KAAC,aAAa,cACZ,KAAC,qBAAqB,oBAAK,KAAK,EAAI,GACtB,GACC,GACI,CAC1B,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport {\n useAppConfig, getAuthService, getSiteConfig, getUrlByRouteRole,\n sendPageEvent, sendTrackEvent, useIntl,\n} from '@openedx/frontend-base';\nimport {\n Icon,\n Tab,\n Tabs,\n} from '@openedx/paragon';\nimport { ChevronLeft } from '@openedx/paragon/icons';\nimport PropTypes from 'prop-types';\nimport { Navigate, useNavigate } from 'react-router-dom';\n\nimport BaseContainer from '../base-container';\nimport { ThirdPartyAuthProvider, useThirdPartyAuthContext } from '../common-components/components/ThirdPartyAuthContext';\nimport messages from '../common-components/messages';\nimport { loginPath, loginRole, registerPath, registerRole } from '../constants';\nimport {\n getTpaHint, getTpaProvider, updatePathWithQueryParams,\n} from '../data/utils';\nimport { LoginProvider } from '../login/components/LoginContext';\nimport { RegistrationPage } from '../register';\nimport { RegisterProvider } from '../register/components/RegisterContext';\nimport LoginComponentSlot from '../slots/LoginComponentSlot';\n\nconst LogistrationPageInner = ({\n selectedPage,\n}) => {\n const tpaHint = getTpaHint();\n const {\n thirdPartyAuthContext,\n clearThirdPartyAuthErrorMessage,\n } = useThirdPartyAuthContext();\n\n const {\n providers,\n secondaryProviders,\n } = thirdPartyAuthContext;\n const { formatMessage } = useIntl();\n const [institutionLogin, setInstitutionLogin] = useState(false);\n const [key, setKey] = useState('');\n const navigate = useNavigate();\n const disablePublicAccountCreation = useAppConfig().ALLOW_PUBLIC_ACCOUNT_CREATION === false;\n const hideRegistrationLink = useAppConfig().SHOW_REGISTRATION_LINKS === false;\n\n useEffect(() => {\n const authService = getAuthService();\n if (authService) {\n authService.getCsrfTokenService()\n .getCsrfToken(getSiteConfig().lmsBaseUrl);\n }\n }, []);\n\n useEffect(() => {\n if (disablePublicAccountCreation) {\n navigate(updatePathWithQueryParams(getUrlByRouteRole(loginRole)));\n }\n }, [navigate, disablePublicAccountCreation]);\n\n const handleInstitutionLogin = (e) => {\n sendTrackEvent('edx.bi.institution_login_form.toggled', { category: 'user-engagement' });\n if (typeof e === 'string') {\n sendPageEvent('login_and_registration', e === loginPath ? 'login' : 'register');\n } else {\n sendPageEvent('login_and_registration', e.target.dataset.eventName);\n }\n setInstitutionLogin(!institutionLogin);\n };\n\n const handleOnSelect = (tabKey, currentTab) => {\n if (tabKey === currentTab) {\n return;\n }\n sendTrackEvent(`edx.bi.${tabKey}_form.toggled`, { category: 'user-engagement' });\n clearThirdPartyAuthErrorMessage();\n setKey(tabKey);\n };\n\n const tabTitle = (\n <div className=\"d-flex\">\n <Icon src={ChevronLeft} className=\"left-icon\" />\n <span className=\"ml-2\">\n {selectedPage === loginPath\n ? formatMessage(messages['logistration.sign.in'])\n : formatMessage(messages['logistration.register'])}\n </span>\n </div>\n );\n\n const isValidTpaHint = () => {\n const { provider } = getTpaProvider(tpaHint, providers, secondaryProviders);\n return !!provider;\n };\n\n return (\n <BaseContainer>\n <div>\n {disablePublicAccountCreation\n ? (\n <>\n {institutionLogin && (\n <Tabs defaultActiveKey=\"\" id=\"controlled-tab\" onSelect={handleInstitutionLogin}>\n <Tab title={tabTitle} eventKey={loginPath} />\n </Tabs>\n )}\n <div id=\"main-content\" className=\"main-content\">\n {!institutionLogin && (\n <h3 className=\"mb-4.5\">{formatMessage(messages['logistration.sign.in'])}</h3>\n )}\n <LoginComponentSlot\n institutionLogin={institutionLogin}\n handleInstitutionLogin={handleInstitutionLogin}\n />\n </div>\n </>\n )\n : (\n <div>\n {institutionLogin\n ? (\n <Tabs defaultActiveKey=\"\" id=\"controlled-tab\" onSelect={handleInstitutionLogin}>\n <Tab title={tabTitle} eventKey={selectedPage === loginPath ? loginPath : registerPath} />\n </Tabs>\n )\n : (!isValidTpaHint() && !hideRegistrationLink && (\n <Tabs\n defaultActiveKey={selectedPage}\n id=\"controlled-tab\"\n onSelect={(tabKey) => handleOnSelect(tabKey, selectedPage)}\n >\n <Tab title={formatMessage(messages['logistration.register'])} eventKey={registerPath} />\n <Tab title={formatMessage(messages['logistration.sign.in'])} eventKey={loginPath} />\n </Tabs>\n ))}\n {key && (\n <Navigate to={updatePathWithQueryParams(getUrlByRouteRole(key === loginPath ? loginRole : registerRole))} replace />\n )}\n <div id=\"main-content\" className=\"main-content\">\n {!institutionLogin && !isValidTpaHint() && hideRegistrationLink && (\n <h3 className=\"mb-4.5\">\n {formatMessage(messages[selectedPage === loginPath ? 'logistration.sign.in' : 'logistration.register'])}\n </h3>\n )}\n {selectedPage === loginPath\n ? (\n <LoginComponentSlot\n institutionLogin={institutionLogin}\n handleInstitutionLogin={handleInstitutionLogin}\n />\n )\n : (\n <RegistrationPage\n institutionLogin={institutionLogin}\n handleInstitutionLogin={handleInstitutionLogin}\n />\n )}\n </div>\n </div>\n )}\n </div>\n </BaseContainer>\n );\n};\n\nLogistrationPageInner.propTypes = {\n selectedPage: PropTypes.string.isRequired,\n};\n\n/**\n * Main Logistration Page component wrapped with providers\n */\nconst LogistrationPage = (props) => (\n <ThirdPartyAuthProvider>\n <RegisterProvider>\n <LoginProvider>\n <LogistrationPageInner {...props} />\n </LoginProvider>\n </RegisterProvider>\n </ThirdPartyAuthProvider>\n);\n\nexport default LogistrationPage;\n"]}
@@ -1,46 +1,2 @@
1
- declare const _default: import("react-redux").ConnectedComponent<{
2
- (props: any): import("react/jsx-runtime").JSX.Element | null;
3
- propTypes: {
4
- authenticatedUser: PropTypes.Requireable<PropTypes.InferProps<{
5
- username: PropTypes.Requireable<string>;
6
- userId: PropTypes.Requireable<number>;
7
- fullName: PropTypes.Requireable<string>;
8
- }>>;
9
- showError: PropTypes.Requireable<boolean>;
10
- shouldRedirect: PropTypes.Requireable<boolean>;
11
- submitState: PropTypes.Requireable<string>;
12
- welcomePageContext: PropTypes.Requireable<PropTypes.InferProps<{
13
- extended_profile: PropTypes.Requireable<(string | null | undefined)[]>;
14
- fields: PropTypes.Requireable<PropTypes.InferProps<{}>>;
15
- nextUrl: PropTypes.Requireable<string>;
16
- }>>;
17
- welcomePageContextApiStatus: PropTypes.Requireable<string>;
18
- getFieldDataFromBackend: PropTypes.Validator<(...args: any[]) => any>;
19
- saveUserProfile: PropTypes.Validator<(...args: any[]) => any>;
20
- };
21
- defaultProps: {
22
- authenticatedUser: {};
23
- shouldRedirect: boolean;
24
- showError: boolean;
25
- submitState: string;
26
- welcomePageContext: {};
27
- welcomePageContextApiStatus: string;
28
- };
29
- }, {
30
- authenticatedUser?: PropTypes.InferProps<{
31
- username: PropTypes.Requireable<string>;
32
- userId: PropTypes.Requireable<number>;
33
- fullName: PropTypes.Requireable<string>;
34
- }> | null | undefined;
35
- context?: import("react-redux/es/components/Context").ReactReduxContextInstance | undefined;
36
- store?: import("redux").Store | undefined;
37
- } | {
38
- authenticatedUser?: PropTypes.InferProps<{
39
- username: PropTypes.Requireable<string>;
40
- userId: PropTypes.Requireable<number>;
41
- fullName: PropTypes.Requireable<string>;
42
- }> | null | undefined;
43
- store?: import("redux").Store | undefined;
44
- }>;
45
- export default _default;
46
- import PropTypes from 'prop-types';
1
+ export default ProgressiveProfiling;
2
+ declare function ProgressiveProfiling(props: any): import("react/jsx-runtime").JSX.Element;
@@ -1,28 +1,32 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
- import { connect } from 'react-redux';
4
- import { AxiosJwtAuthService, configureAuth, useAppConfig, getAuthenticatedUser, getSiteConfig, getLoggingService, identifyAuthenticatedUser, sendPageEvent, sendTrackEvent, snakeCaseObject, useIntl } from '@openedx/frontend-base';
3
+ import { AxiosJwtAuthService, configureAuth, getAuthenticatedUser, getLoggingService, getSiteConfig, getUrlByRouteRole, identifyAuthenticatedUser, sendPageEvent, sendTrackEvent, snakeCaseObject, useAppConfig, useIntl, } from '@openedx/frontend-base';
5
4
  import { Alert, Form, Hyperlink, Spinner, StatefulButton, } from '@openedx/paragon';
6
5
  import { Error } from '@openedx/paragon/icons';
7
- import PropTypes from 'prop-types';
8
6
  import { Helmet } from 'react-helmet';
9
- import { useLocation } from 'react-router-dom';
7
+ import { Navigate, useLocation } from 'react-router-dom';
8
+ import { ProgressiveProfilingProvider, useProgressiveProfilingContext } from './components/ProgressiveProfilingContext';
9
+ import messages from './messages';
10
+ import ProgressiveProfilingPageModal from './ProgressiveProfilingPageModal';
10
11
  import BaseContainer from '../base-container';
11
12
  import { RedirectLogistration } from '../common-components';
12
- import { getThirdPartyAuthContext } from '../common-components/data/actions';
13
- import { COMPLETE_STATE, DEFAULT_REDIRECT_URL, DEFAULT_STATE, FAILURE_STATE, PENDING_STATE, } from '../data/constants';
13
+ import { useSaveUserProfile } from './data/apiHook';
14
+ import { ThirdPartyAuthProvider, useThirdPartyAuthContext } from '../common-components/components/ThirdPartyAuthContext';
15
+ import { useThirdPartyAuthHook } from '../common-components/data/apiHook';
16
+ import { dashboardRole, welcomePath } from '../constants';
17
+ import { COMPLETE_STATE, FAILURE_STATE, PENDING_STATE, } from '../data/constants';
14
18
  import isOneTrustFunctionalCookieEnabled from '../data/oneTrust';
15
19
  import { getAllPossibleQueryParams, isHostAvailableInQueryParams } from '../data/utils';
16
20
  import { FormFieldRenderer } from '../field-renderer';
17
- import { saveUserProfile } from './data/actions';
18
- import { welcomePageContextSelector } from './data/selectors';
19
- import messages from './messages';
20
- import ProgressiveProfilingPageModal from './ProgressiveProfilingPageModal';
21
- const ProgressiveProfiling = (props) => {
22
- var _a, _b;
21
+ const ProgressiveProfilingInner = () => {
22
+ var _a, _b, _c, _d;
23
23
  const { formatMessage } = useIntl();
24
- const { getFieldDataFromBackend, submitState, showError, welcomePageContext, welcomePageContextApiStatus, } = props;
25
- const { SEARCH_CATALOG_URL, AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK } = useAppConfig();
24
+ const appConfig = useAppConfig();
25
+ const { thirdPartyAuthApiStatus, setThirdPartyAuthContextSuccess, setThirdPartyAuthContextFailure, optionalFields, } = useThirdPartyAuthContext();
26
+ const welcomePageContext = optionalFields;
27
+ const { submitState, showError, success, } = useProgressiveProfilingContext();
28
+ // Hook for saving user profile
29
+ const saveUserProfileMutation = useSaveUserProfile();
26
30
  const location = useLocation();
27
31
  const registrationEmbedded = isHostAvailableInQueryParams();
28
32
  const queryParams = getAllPossibleQueryParams();
@@ -32,35 +36,42 @@ const ProgressiveProfiling = (props) => {
32
36
  const [formFieldData, setFormFieldData] = useState({ fields: {}, extendedProfile: [] });
33
37
  const [values, setValues] = useState({});
34
38
  const [showModal, setShowModal] = useState(false);
39
+ const { data, isSuccess, error } = useThirdPartyAuthHook(welcomePath, { is_welcome_page: true, next: queryParams === null || queryParams === void 0 ? void 0 : queryParams.next }, { enabled: registrationEmbedded });
35
40
  useEffect(() => {
36
41
  if (registrationEmbedded) {
37
- getFieldDataFromBackend({ is_welcome_page: true, next: queryParams === null || queryParams === void 0 ? void 0 : queryParams.next });
42
+ if (isSuccess && data) {
43
+ setThirdPartyAuthContextSuccess(data.fieldDescriptions, data.optionalFields, data.thirdPartyAuthContext);
44
+ }
45
+ if (error) {
46
+ setThirdPartyAuthContextFailure();
47
+ }
38
48
  }
39
49
  else {
40
- configureAuth(AxiosJwtAuthService, { mockLoggingService: getLoggingService(), config: getSiteConfig() });
50
+ configureAuth(AxiosJwtAuthService, { loggingService: getLoggingService(), config: getSiteConfig() });
41
51
  }
42
- }, [registrationEmbedded, getFieldDataFromBackend, queryParams === null || queryParams === void 0 ? void 0 : queryParams.next]);
52
+ }, [registrationEmbedded, queryParams === null || queryParams === void 0 ? void 0 : queryParams.next, isSuccess, data, error,
53
+ setThirdPartyAuthContextSuccess, setThirdPartyAuthContextFailure]);
43
54
  useEffect(() => {
44
55
  var _a, _b, _c;
45
56
  const registrationResponse = (_a = location.state) === null || _a === void 0 ? void 0 : _a.registrationResult;
46
57
  if (registrationResponse) {
47
58
  setRegistrationResult(registrationResponse);
48
59
  setFormFieldData({
49
- fields: (_b = location.state) === null || _b === void 0 ? void 0 : _b.optionalFields.fields,
50
- extendedProfile: (_c = location.state) === null || _c === void 0 ? void 0 : _c.optionalFields.extended_profile,
60
+ fields: ((_b = location.state) === null || _b === void 0 ? void 0 : _b.optionalFields.fields) || {},
61
+ extendedProfile: ((_c = location.state) === null || _c === void 0 ? void 0 : _c.optionalFields.extended_profile) || [],
51
62
  });
52
63
  }
53
- }, [location.state]);
64
+ }, [(_b = location.state) === null || _b === void 0 ? void 0 : _b.registrationResult, (_c = location.state) === null || _c === void 0 ? void 0 : _c.optionalFields]);
54
65
  useEffect(() => {
55
- if (registrationEmbedded && Object.keys(welcomePageContext).includes('fields')) {
66
+ if (registrationEmbedded && welcomePageContext && Object.keys(welcomePageContext).includes('fields')) {
56
67
  setFormFieldData({
57
68
  fields: welcomePageContext.fields,
58
69
  extendedProfile: welcomePageContext.extended_profile,
59
70
  });
60
- const nextUrl = welcomePageContext.nextUrl ? welcomePageContext.nextUrl : SEARCH_CATALOG_URL;
71
+ const nextUrl = welcomePageContext.nextUrl ? welcomePageContext.nextUrl : appConfig.SEARCH_CATALOG_URL;
61
72
  setRegistrationResult({ redirectUrl: nextUrl });
62
73
  }
63
- }, [registrationEmbedded, welcomePageContext]);
74
+ }, [registrationEmbedded, welcomePageContext, appConfig.SEARCH_CATALOG_URL]);
64
75
  useEffect(() => {
65
76
  if (authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.userId) {
66
77
  identifyAuthenticatedUser(authenticatedUser.userId);
@@ -68,11 +79,14 @@ const ProgressiveProfiling = (props) => {
68
79
  }
69
80
  }, [authenticatedUser]);
70
81
  if (!authenticatedUser
71
- || !(((_b = location.state) === null || _b === void 0 ? void 0 : _b.registrationResult) || registrationEmbedded)
72
- || welcomePageContextApiStatus === FAILURE_STATE
73
- || (welcomePageContextApiStatus === COMPLETE_STATE && !Object.keys(welcomePageContext).includes('fields'))) {
74
- const DASHBOARD_URL = getSiteConfig().lmsBaseUrl.concat(DEFAULT_REDIRECT_URL);
75
- global.location.assign(DASHBOARD_URL);
82
+ || !(((_d = location.state) === null || _d === void 0 ? void 0 : _d.registrationResult) || registrationEmbedded)
83
+ || thirdPartyAuthApiStatus === FAILURE_STATE
84
+ || (thirdPartyAuthApiStatus === COMPLETE_STATE && !Object.keys(welcomePageContext).includes('fields'))) {
85
+ const dashboardUrl = getUrlByRouteRole(dashboardRole) || '/';
86
+ if (dashboardUrl.startsWith('/')) {
87
+ return _jsx(Navigate, { to: dashboardUrl, replace: true });
88
+ }
89
+ window.location.href = dashboardUrl;
76
90
  return null;
77
91
  }
78
92
  const handleSubmit = (e) => {
@@ -87,7 +101,7 @@ const ProgressiveProfiling = (props) => {
87
101
  delete payload[fieldName];
88
102
  });
89
103
  }
90
- props.saveUserProfile(authenticatedUser.username, snakeCaseObject(payload));
104
+ saveUserProfileMutation.mutate({ username: authenticatedUser.username, data: snakeCaseObject(payload) });
91
105
  sendTrackEvent('edx.bi.welcome.page.submit.clicked', {
92
106
  isGenderSelected: !!values.gender,
93
107
  isYearOfBirthSelected: !!values.year_of_birth,
@@ -116,52 +130,14 @@ const ProgressiveProfiling = (props) => {
116
130
  const fieldData = formFieldData.fields[fieldName];
117
131
  return (_jsx("span", { children: _jsx(FormFieldRenderer, { fieldData: fieldData, value: values[fieldData.name], onChangeHandler: onChangeHandler }) }, fieldData.name));
118
132
  });
119
- return (_jsxs(BaseContainer, { showWelcomeBanner: true, fullName: (authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.fullName) || (authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.name), children: [_jsx(Helmet, { children: _jsx("title", { children: formatMessage(messages['progressive.profiling.page.title'], { siteName: getSiteConfig().siteName }) }) }), _jsx(ProgressiveProfilingPageModal, { isOpen: showModal, redirectUrl: registrationResult.redirectUrl }), (props.shouldRedirect && welcomePageContext.nextUrl) && (_jsx(RedirectLogistration, { success: true, redirectUrl: registrationResult.redirectUrl })), props.shouldRedirect && (_jsx(RedirectLogistration, { success: true, redirectUrl: registrationResult.redirectUrl, educationLevel: values === null || values === void 0 ? void 0 : values.level_of_education, userId: authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.userId })), _jsx("div", { className: "mw-xs m-4 pp-page-content", children: registrationEmbedded && welcomePageContextApiStatus === PENDING_STATE ? (_jsx(Spinner, { animation: "border", variant: "primary", id: "tpa-spinner" })) : (_jsxs(_Fragment, { children: [_jsx("div", { children: _jsx("h2", { className: "pp-page__heading text-primary", children: formatMessage(messages['progressive.profiling.page.heading']) }) }), _jsx("hr", { className: "border-light-700 mb-4" }), showError ? (_jsxs(Alert, { id: "pp-page-errors", className: "mb-3", variant: "danger", icon: Error, children: [_jsx(Alert.Heading, { children: formatMessage(messages['welcome.page.error.heading']) }), _jsx("p", { children: formatMessage(messages['welcome.page.error.message']) })] })) : null, _jsxs(Form, { children: [formFields, (AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && (_jsx("span", { className: "pp-page__support-link", children: _jsx(Hyperlink, { isInline: true, variant: "muted", destination: AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK, target: "_blank", showLaunchIcon: false, onClick: () => (sendTrackEvent('edx.bi.welcome.page.support.link.clicked')), children: formatMessage(messages['optional.fields.information.link']) }) })), _jsxs("div", { className: "d-flex mt-4 mb-3", children: [_jsx(StatefulButton, { type: "submit", variant: "brand", className: "pp-page__button-width", state: submitState, labels: {
133
+ const shouldRedirect = success;
134
+ return (_jsxs(BaseContainer, { showWelcomeBanner: true, fullName: (authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.fullName) || (authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.name), children: [_jsx(Helmet, { children: _jsx("title", { children: formatMessage(messages['progressive.profiling.page.title'], { siteName: getSiteConfig().siteName }) }) }), _jsx(ProgressiveProfilingPageModal, { isOpen: showModal, redirectUrl: registrationResult.redirectUrl }), shouldRedirect && (_jsx(RedirectLogistration, { success: true, redirectUrl: registrationResult.redirectUrl, educationLevel: values === null || values === void 0 ? void 0 : values.level_of_education, userId: authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.userId })), _jsx("div", { className: "mw-xs m-4 pp-page-content", children: registrationEmbedded && thirdPartyAuthApiStatus === PENDING_STATE ? (_jsx(Spinner, { animation: "border", variant: "primary", id: "tpa-spinner" })) : (_jsxs(_Fragment, { children: [_jsx("div", { children: _jsx("h2", { className: "pp-page__heading text-primary", children: formatMessage(messages['progressive.profiling.page.heading']) }) }), _jsx("hr", { className: "border-light-700 mb-4" }), showError ? (_jsxs(Alert, { id: "pp-page-errors", className: "mb-3", variant: "danger", icon: Error, children: [_jsx(Alert.Heading, { children: formatMessage(messages['welcome.page.error.heading']) }), _jsx("p", { children: formatMessage(messages['welcome.page.error.message']) })] })) : null, _jsxs(Form, { children: [formFields, (appConfig.AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && (_jsx("span", { className: "pp-page__support-link", children: _jsx(Hyperlink, { isInline: true, variant: "muted", destination: appConfig.AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK, target: "_blank", showLaunchIcon: false, onClick: () => (sendTrackEvent('edx.bi.welcome.page.support.link.clicked')), children: formatMessage(messages['optional.fields.information.link']) }) })), _jsxs("div", { className: "d-flex mt-4 mb-3", children: [_jsx(StatefulButton, { type: "submit", variant: "brand", className: "pp-page__button-width", state: submitState, labels: {
120
135
  default: formatMessage(messages['optional.fields.submit.button']),
121
136
  pending: '',
122
137
  }, onClick: handleSubmit, onMouseDown: (e) => e.preventDefault() }), _jsx(StatefulButton, { className: "text-gray-700 font-weight-500", type: "submit", variant: "link", labels: {
123
138
  default: formatMessage(messages['optional.fields.skip.button']),
124
139
  }, onClick: handleSkip, onMouseDown: (e) => e.preventDefault() })] })] })] })) })] }));
125
140
  };
126
- ProgressiveProfiling.propTypes = {
127
- authenticatedUser: PropTypes.shape({
128
- username: PropTypes.string,
129
- userId: PropTypes.number,
130
- fullName: PropTypes.string,
131
- }),
132
- showError: PropTypes.bool,
133
- shouldRedirect: PropTypes.bool,
134
- submitState: PropTypes.string,
135
- welcomePageContext: PropTypes.shape({
136
- extended_profile: PropTypes.arrayOf(PropTypes.string),
137
- fields: PropTypes.shape({}),
138
- nextUrl: PropTypes.string,
139
- }),
140
- welcomePageContextApiStatus: PropTypes.string,
141
- // Actions
142
- getFieldDataFromBackend: PropTypes.func.isRequired,
143
- saveUserProfile: PropTypes.func.isRequired,
144
- };
145
- ProgressiveProfiling.defaultProps = {
146
- authenticatedUser: {},
147
- shouldRedirect: false,
148
- showError: false,
149
- submitState: DEFAULT_STATE,
150
- welcomePageContext: {},
151
- welcomePageContextApiStatus: PENDING_STATE,
152
- };
153
- const mapStateToProps = state => {
154
- const welcomePageStore = state.welcomePage;
155
- return {
156
- shouldRedirect: welcomePageStore.success,
157
- showError: welcomePageStore.showError,
158
- submitState: welcomePageStore.submitState,
159
- welcomePageContext: welcomePageContextSelector(state),
160
- welcomePageContextApiStatus: state.commonComponents.thirdPartyAuthApiStatus,
161
- };
162
- };
163
- export default connect(mapStateToProps, {
164
- saveUserProfile,
165
- getFieldDataFromBackend: getThirdPartyAuthContext,
166
- })(ProgressiveProfiling);
141
+ const ProgressiveProfiling = (props) => (_jsx(ThirdPartyAuthProvider, { children: _jsx(ProgressiveProfilingProvider, { children: _jsx(ProgressiveProfilingInner, Object.assign({}, props)) }) }));
142
+ export default ProgressiveProfiling;
167
143
  //# sourceMappingURL=ProgressiveProfiling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProgressiveProfiling.js","sourceRoot":"","sources":["../../src/progressive-profiling/ProgressiveProfiling.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,E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AC;AAEF,MAAM,eAAe,GAAG,KAAK,CAAC,EAAE;IAC9B,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC;IAE3C,OAAO;QACL,cAAc,EAAE,gBAAgB,CAAC,OAAO;QACxC,SAAS,EAAE,gBAAgB,CAAC,SAAS;QACrC,WAAW,EAAE,gBAAgB,CAAC,WAAW;QACzC,kBAAkB,EAAE,0BAA0B,CAAC,KAAK,CAAC;QACrD,2BAA2B,EAAE,KAAK,CAAC,gBAAgB,CAAC,uBAAuB;KAC5E,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CACpB,eAAe,EACf;IACE,eAAe;IACf,uBAAuB,EAAE,wBAAwB;CAClD,CACF,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { connect } from 'react-redux';\n\nimport {\n AxiosJwtAuthService,\n configureAuth,\n useAppConfig,\n getAuthenticatedUser,\n getSiteConfig,\n getLoggingService,\n identifyAuthenticatedUser,\n sendPageEvent,\n sendTrackEvent,\n snakeCaseObject,\n useIntl\n} from '@openedx/frontend-base';\nimport {\n Alert,\n Form,\n Hyperlink,\n Spinner,\n StatefulButton,\n} from '@openedx/paragon';\nimport { Error } from '@openedx/paragon/icons';\nimport PropTypes from 'prop-types';\nimport { Helmet } from 'react-helmet';\nimport { useLocation } from 'react-router-dom';\n\nimport BaseContainer from '../base-container';\nimport { RedirectLogistration } from '../common-components';\nimport { getThirdPartyAuthContext } from '../common-components/data/actions';\nimport {\n COMPLETE_STATE,\n DEFAULT_REDIRECT_URL,\n DEFAULT_STATE,\n FAILURE_STATE,\n PENDING_STATE,\n} from '../data/constants';\nimport isOneTrustFunctionalCookieEnabled from '../data/oneTrust';\nimport { getAllPossibleQueryParams, isHostAvailableInQueryParams } from '../data/utils';\nimport { FormFieldRenderer } from '../field-renderer';\nimport { saveUserProfile } from './data/actions';\nimport { welcomePageContextSelector } from './data/selectors';\nimport messages from './messages';\nimport ProgressiveProfilingPageModal from './ProgressiveProfilingPageModal';\n\nconst ProgressiveProfiling = (props) => {\n const { formatMessage } = useIntl();\n const {\n getFieldDataFromBackend,\n submitState,\n showError,\n welcomePageContext,\n welcomePageContextApiStatus,\n } = props;\n const {\n SEARCH_CATALOG_URL,\n AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK\n } = useAppConfig();\n const location = useLocation();\n const registrationEmbedded = isHostAvailableInQueryParams();\n\n const queryParams = getAllPossibleQueryParams();\n const authenticatedUser = getAuthenticatedUser() || location.state?.authenticatedUser;\n const functionalCookiesConsent = isOneTrustFunctionalCookieEnabled();\n\n const [registrationResult, setRegistrationResult] = useState({ redirectUrl: '' });\n const [formFieldData, setFormFieldData] = useState({ fields: {}, extendedProfile: [] });\n const [values, setValues] = useState({});\n const [showModal, setShowModal] = useState(false);\n\n useEffect(() => {\n if (registrationEmbedded) {\n getFieldDataFromBackend({ is_welcome_page: true, next: queryParams?.next });\n } else {\n configureAuth(AxiosJwtAuthService, { mockLoggingService: getLoggingService(), config: getSiteConfig() });\n }\n }, [registrationEmbedded, getFieldDataFromBackend, queryParams?.next]);\n\n useEffect(() => {\n const registrationResponse = location.state?.registrationResult;\n if (registrationResponse) {\n setRegistrationResult(registrationResponse);\n setFormFieldData({\n fields: location.state?.optionalFields.fields,\n extendedProfile: location.state?.optionalFields.extended_profile,\n });\n }\n }, [location.state]);\n\n useEffect(() => {\n if (registrationEmbedded && Object.keys(welcomePageContext).includes('fields')) {\n setFormFieldData({\n fields: welcomePageContext.fields,\n extendedProfile: welcomePageContext.extended_profile,\n });\n const nextUrl = welcomePageContext.nextUrl ? welcomePageContext.nextUrl : SEARCH_CATALOG_URL;\n setRegistrationResult({ redirectUrl: nextUrl });\n }\n }, [registrationEmbedded, welcomePageContext]);\n\n useEffect(() => {\n if (authenticatedUser?.userId) {\n identifyAuthenticatedUser(authenticatedUser.userId);\n sendPageEvent('login_and_registration', 'welcome');\n }\n }, [authenticatedUser]);\n\n if (\n !authenticatedUser\n || !(location.state?.registrationResult || registrationEmbedded)\n || welcomePageContextApiStatus === FAILURE_STATE\n || (welcomePageContextApiStatus === COMPLETE_STATE && !Object.keys(welcomePageContext).includes('fields'))\n ) {\n const DASHBOARD_URL = getSiteConfig().lmsBaseUrl.concat(DEFAULT_REDIRECT_URL);\n global.location.assign(DASHBOARD_URL);\n return null;\n }\n\n const handleSubmit = (e) => {\n e.preventDefault();\n window.history.replaceState(location.state, null, '');\n const payload = { ...values, extendedProfile: [] };\n if (Object.keys(formFieldData.extendedProfile).length > 0) {\n formFieldData.extendedProfile.forEach(fieldName => {\n if (values[fieldName]) {\n payload.extendedProfile.push({ fieldName, fieldValue: values[fieldName] });\n }\n delete payload[fieldName];\n });\n }\n props.saveUserProfile(authenticatedUser.username, snakeCaseObject(payload));\n\n sendTrackEvent(\n 'edx.bi.welcome.page.submit.clicked',\n {\n isGenderSelected: !!values.gender,\n isYearOfBirthSelected: !!values.year_of_birth,\n isLevelOfEducationSelected: !!values.level_of_education,\n isWorkExperienceSelected: !!values.work_experience,\n host: queryParams?.host || '',\n },\n );\n };\n\n const handleSkip = (e) => {\n e.preventDefault();\n window.history.replaceState(location.state, null, '');\n setShowModal(true);\n sendTrackEvent(\n 'edx.bi.welcome.page.skip.link.clicked',\n {\n host: queryParams?.host || '',\n },\n );\n };\n\n const onChangeHandler = (e) => {\n if (e.target.type === 'checkbox') {\n setValues({ ...values, [e.target.name]: e.target.checked });\n } else {\n setValues({ ...values, [e.target.name]: e.target.value });\n }\n };\n\n const formFields = Object.keys(formFieldData.fields).map((fieldName) => {\n const fieldData = formFieldData.fields[fieldName];\n return (\n <span key={fieldData.name}>\n <FormFieldRenderer\n fieldData={fieldData}\n value={values[fieldData.name]}\n onChangeHandler={onChangeHandler}\n />\n </span>\n );\n });\n\n return (\n <BaseContainer showWelcomeBanner fullName={authenticatedUser?.fullName || authenticatedUser?.name}>\n <Helmet>\n <title>{formatMessage(\n messages['progressive.profiling.page.title'],\n { siteName: getSiteConfig().siteName }\n )}\n </title>\n </Helmet>\n <ProgressiveProfilingPageModal isOpen={showModal} redirectUrl={registrationResult.redirectUrl} />\n {(props.shouldRedirect && welcomePageContext.nextUrl) && (\n <RedirectLogistration\n success\n redirectUrl={registrationResult.redirectUrl}\n />\n )}\n {props.shouldRedirect && (\n <RedirectLogistration\n success\n redirectUrl={registrationResult.redirectUrl}\n educationLevel={values?.level_of_education}\n userId={authenticatedUser?.userId}\n />\n )}\n <div className=\"mw-xs m-4 pp-page-content\">\n {registrationEmbedded && welcomePageContextApiStatus === PENDING_STATE ? (\n <Spinner animation=\"border\" variant=\"primary\" id=\"tpa-spinner\" />\n ) : (\n <>\n <div>\n <h2 className=\"pp-page__heading text-primary\">{formatMessage(messages['progressive.profiling.page.heading'])}</h2>\n </div><hr className=\"border-light-700 mb-4\" />\n {showError ? (\n <Alert id=\"pp-page-errors\" className=\"mb-3\" variant=\"danger\" icon={Error}>\n <Alert.Heading>{formatMessage(messages['welcome.page.error.heading'])}</Alert.Heading>\n <p>{formatMessage(messages['welcome.page.error.message'])}</p>\n </Alert>\n ) : null}\n <Form>\n {formFields}\n {(AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && (\n <span className=\"pp-page__support-link\">\n <Hyperlink\n isInline\n variant=\"muted\"\n destination={AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK}\n target=\"_blank\"\n showLaunchIcon={false}\n onClick={() => (sendTrackEvent('edx.bi.welcome.page.support.link.clicked'))}\n >\n {formatMessage(messages['optional.fields.information.link'])}\n </Hyperlink>\n </span>\n )}\n <div className=\"d-flex mt-4 mb-3\">\n <StatefulButton\n type=\"submit\"\n variant=\"brand\"\n className=\"pp-page__button-width\"\n state={submitState}\n labels={{\n default: formatMessage(messages['optional.fields.submit.button']),\n pending: '',\n }}\n onClick={handleSubmit}\n onMouseDown={(e) => e.preventDefault()}\n />\n <StatefulButton\n className=\"text-gray-700 font-weight-500\"\n type=\"submit\"\n variant=\"link\"\n labels={{\n default: formatMessage(messages['optional.fields.skip.button']),\n }}\n onClick={handleSkip}\n onMouseDown={(e) => e.preventDefault()}\n />\n </div>\n </Form>\n </>\n )}\n\n </div>\n </BaseContainer>\n );\n};\n\nProgressiveProfiling.propTypes = {\n authenticatedUser: PropTypes.shape({\n username: PropTypes.string,\n userId: PropTypes.number,\n fullName: PropTypes.string,\n }),\n showError: PropTypes.bool,\n shouldRedirect: PropTypes.bool,\n submitState: PropTypes.string,\n welcomePageContext: PropTypes.shape({\n extended_profile: PropTypes.arrayOf(PropTypes.string),\n fields: PropTypes.shape({}),\n nextUrl: PropTypes.string,\n }),\n welcomePageContextApiStatus: PropTypes.string,\n // Actions\n getFieldDataFromBackend: PropTypes.func.isRequired,\n saveUserProfile: PropTypes.func.isRequired,\n};\n\nProgressiveProfiling.defaultProps = {\n authenticatedUser: {},\n shouldRedirect: false,\n showError: false,\n submitState: DEFAULT_STATE,\n welcomePageContext: {},\n welcomePageContextApiStatus: PENDING_STATE,\n};\n\nconst mapStateToProps = state => {\n const welcomePageStore = state.welcomePage;\n\n return {\n shouldRedirect: welcomePageStore.success,\n showError: welcomePageStore.showError,\n submitState: welcomePageStore.submitState,\n welcomePageContext: welcomePageContextSelector(state),\n welcomePageContextApiStatus: state.commonComponents.thirdPartyAuthApiStatus,\n };\n};\n\nexport default connect(\n mapStateToProps,\n {\n saveUserProfile,\n getFieldDataFromBackend: getThirdPartyAuthContext,\n },\n)(ProgressiveProfiling);\n"]}
1
+ {"version":3,"file":"ProgressiveProfiling.js","sourceRoot":"","sources":["../../src/progressive-profiling/ProgressiveProfiling.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,OAAO,GACR,MAAM,wBA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} from 'react';\n\nimport {\n AxiosJwtAuthService,\n configureAuth,\n getAuthenticatedUser,\n getLoggingService,\n getSiteConfig,\n getUrlByRouteRole,\n identifyAuthenticatedUser,\n sendPageEvent,\n sendTrackEvent,\n snakeCaseObject,\n useAppConfig,\n useIntl,\n} from '@openedx/frontend-base';\nimport {\n Alert,\n Form,\n Hyperlink,\n Spinner,\n StatefulButton,\n} from '@openedx/paragon';\nimport { Error } from '@openedx/paragon/icons';\nimport { Helmet } from 'react-helmet';\nimport { Navigate, useLocation } from 'react-router-dom';\n\nimport { ProgressiveProfilingProvider, useProgressiveProfilingContext } from './components/ProgressiveProfilingContext';\nimport messages from './messages';\nimport ProgressiveProfilingPageModal from './ProgressiveProfilingPageModal';\nimport BaseContainer from '../base-container';\nimport { RedirectLogistration } from '../common-components';\nimport { useSaveUserProfile } from './data/apiHook';\nimport { ThirdPartyAuthProvider, useThirdPartyAuthContext } from '../common-components/components/ThirdPartyAuthContext';\nimport { useThirdPartyAuthHook } from '../common-components/data/apiHook';\nimport { dashboardRole, welcomePath } from '../constants';\nimport {\n COMPLETE_STATE,\n FAILURE_STATE,\n PENDING_STATE,\n} from '../data/constants';\nimport isOneTrustFunctionalCookieEnabled from '../data/oneTrust';\nimport { getAllPossibleQueryParams, isHostAvailableInQueryParams } from '../data/utils';\nimport { FormFieldRenderer } from '../field-renderer';\n\nconst ProgressiveProfilingInner = () => {\n const { formatMessage } = useIntl();\n const appConfig = useAppConfig();\n\n const {\n thirdPartyAuthApiStatus,\n setThirdPartyAuthContextSuccess,\n setThirdPartyAuthContextFailure,\n optionalFields,\n } = useThirdPartyAuthContext();\n\n const welcomePageContext = optionalFields;\n const {\n submitState,\n showError,\n success,\n } = useProgressiveProfilingContext();\n\n // Hook for saving user profile\n const saveUserProfileMutation = useSaveUserProfile();\n\n const location = useLocation();\n const registrationEmbedded = isHostAvailableInQueryParams();\n\n const queryParams = getAllPossibleQueryParams();\n const authenticatedUser = getAuthenticatedUser() || location.state?.authenticatedUser;\n const functionalCookiesConsent = isOneTrustFunctionalCookieEnabled();\n\n const [registrationResult, setRegistrationResult] = useState({ redirectUrl: '' });\n const [formFieldData, setFormFieldData] = useState({ fields: {}, extendedProfile: [] });\n const [values, setValues] = useState({});\n const [showModal, setShowModal] = useState(false);\n\n const { data, isSuccess, error } = useThirdPartyAuthHook(welcomePath,\n { is_welcome_page: true, next: queryParams?.next }, { enabled: registrationEmbedded });\n\n useEffect(() => {\n if (registrationEmbedded) {\n if (isSuccess && data) {\n setThirdPartyAuthContextSuccess(\n data.fieldDescriptions,\n data.optionalFields,\n data.thirdPartyAuthContext,\n );\n }\n if (error) {\n setThirdPartyAuthContextFailure();\n }\n } else {\n configureAuth(AxiosJwtAuthService, { loggingService: getLoggingService(), config: getSiteConfig() });\n }\n }, [registrationEmbedded, queryParams?.next, isSuccess, data, error,\n setThirdPartyAuthContextSuccess, setThirdPartyAuthContextFailure]);\n\n useEffect(() => {\n const registrationResponse = location.state?.registrationResult;\n if (registrationResponse) {\n setRegistrationResult(registrationResponse);\n setFormFieldData({\n fields: location.state?.optionalFields.fields || {},\n extendedProfile: location.state?.optionalFields.extended_profile || [],\n });\n }\n }, [location.state?.registrationResult, location.state?.optionalFields]);\n\n useEffect(() => {\n if (registrationEmbedded && welcomePageContext && Object.keys(welcomePageContext).includes('fields')) {\n setFormFieldData({\n fields: welcomePageContext.fields,\n extendedProfile: welcomePageContext.extended_profile,\n });\n const nextUrl = welcomePageContext.nextUrl ? welcomePageContext.nextUrl : appConfig.SEARCH_CATALOG_URL;\n setRegistrationResult({ redirectUrl: nextUrl });\n }\n }, [registrationEmbedded, welcomePageContext, appConfig.SEARCH_CATALOG_URL]);\n\n useEffect(() => {\n if (authenticatedUser?.userId) {\n identifyAuthenticatedUser(authenticatedUser.userId);\n sendPageEvent('login_and_registration', 'welcome');\n }\n }, [authenticatedUser]);\n\n if (\n !authenticatedUser\n || !(location.state?.registrationResult || registrationEmbedded)\n || thirdPartyAuthApiStatus === FAILURE_STATE\n || (thirdPartyAuthApiStatus === COMPLETE_STATE && !Object.keys(welcomePageContext).includes('fields'))\n ) {\n const dashboardUrl = getUrlByRouteRole(dashboardRole) || '/';\n if (dashboardUrl.startsWith('/')) {\n return <Navigate to={dashboardUrl} replace />;\n }\n window.location.href = dashboardUrl;\n return null;\n }\n\n const handleSubmit = (e) => {\n e.preventDefault();\n window.history.replaceState(location.state, null, '');\n const payload = { ...values, extendedProfile: [] };\n if (Object.keys(formFieldData.extendedProfile).length > 0) {\n formFieldData.extendedProfile.forEach(fieldName => {\n if (values[fieldName]) {\n payload.extendedProfile.push({ fieldName, fieldValue: values[fieldName] });\n }\n delete payload[fieldName];\n });\n }\n saveUserProfileMutation.mutate({ username: authenticatedUser.username, data: snakeCaseObject(payload) });\n\n sendTrackEvent(\n 'edx.bi.welcome.page.submit.clicked',\n {\n isGenderSelected: !!values.gender,\n isYearOfBirthSelected: !!values.year_of_birth,\n isLevelOfEducationSelected: !!values.level_of_education,\n isWorkExperienceSelected: !!values.work_experience,\n host: queryParams?.host || '',\n },\n );\n };\n\n const handleSkip = (e) => {\n e.preventDefault();\n window.history.replaceState(location.state, null, '');\n setShowModal(true);\n sendTrackEvent(\n 'edx.bi.welcome.page.skip.link.clicked',\n {\n host: queryParams?.host || '',\n },\n );\n };\n\n const onChangeHandler = (e) => {\n if (e.target.type === 'checkbox') {\n setValues({ ...values, [e.target.name]: e.target.checked });\n } else {\n setValues({ ...values, [e.target.name]: e.target.value });\n }\n };\n\n const formFields = Object.keys(formFieldData.fields).map((fieldName) => {\n const fieldData = formFieldData.fields[fieldName];\n return (\n <span key={fieldData.name}>\n <FormFieldRenderer\n fieldData={fieldData}\n value={values[fieldData.name]}\n onChangeHandler={onChangeHandler}\n />\n </span>\n );\n });\n\n const shouldRedirect = success;\n return (\n <BaseContainer showWelcomeBanner fullName={authenticatedUser?.fullName || authenticatedUser?.name}>\n <Helmet>\n <title>{formatMessage(messages['progressive.profiling.page.title'],\n { siteName: getSiteConfig().siteName })}\n </title>\n </Helmet>\n <ProgressiveProfilingPageModal isOpen={showModal} redirectUrl={registrationResult.redirectUrl} />\n {shouldRedirect && (\n <RedirectLogistration\n success\n redirectUrl={registrationResult.redirectUrl}\n educationLevel={values?.level_of_education}\n userId={authenticatedUser?.userId}\n />\n )}\n <div className=\"mw-xs m-4 pp-page-content\">\n {registrationEmbedded && thirdPartyAuthApiStatus === PENDING_STATE ? (\n <Spinner animation=\"border\" variant=\"primary\" id=\"tpa-spinner\" />\n ) : (\n <>\n <div>\n <h2 className=\"pp-page__heading text-primary\">{formatMessage(messages['progressive.profiling.page.heading'])}</h2>\n </div><hr className=\"border-light-700 mb-4\" />\n {showError ? (\n <Alert id=\"pp-page-errors\" className=\"mb-3\" variant=\"danger\" icon={Error}>\n <Alert.Heading>{formatMessage(messages['welcome.page.error.heading'])}</Alert.Heading>\n <p>{formatMessage(messages['welcome.page.error.message'])}</p>\n </Alert>\n ) : null}\n <Form>\n {formFields}\n {(appConfig.AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && (\n <span className=\"pp-page__support-link\">\n <Hyperlink\n isInline\n variant=\"muted\"\n destination={appConfig.AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK}\n target=\"_blank\"\n showLaunchIcon={false}\n onClick={() => (sendTrackEvent('edx.bi.welcome.page.support.link.clicked'))}\n >\n {formatMessage(messages['optional.fields.information.link'])}\n </Hyperlink>\n </span>\n )}\n <div className=\"d-flex mt-4 mb-3\">\n <StatefulButton\n type=\"submit\"\n variant=\"brand\"\n className=\"pp-page__button-width\"\n state={submitState}\n labels={{\n default: formatMessage(messages['optional.fields.submit.button']),\n pending: '',\n }}\n onClick={handleSubmit}\n onMouseDown={(e) => e.preventDefault()}\n />\n <StatefulButton\n className=\"text-gray-700 font-weight-500\"\n type=\"submit\"\n variant=\"link\"\n labels={{\n default: formatMessage(messages['optional.fields.skip.button']),\n }}\n onClick={handleSkip}\n onMouseDown={(e) => e.preventDefault()}\n />\n </div>\n </Form>\n </>\n )}\n\n </div>\n </BaseContainer>\n );\n};\n\nconst ProgressiveProfiling = (props) => (\n <ThirdPartyAuthProvider>\n <ProgressiveProfilingProvider>\n <ProgressiveProfilingInner {...props} />\n </ProgressiveProfilingProvider>\n </ThirdPartyAuthProvider>\n);\n\nexport default ProgressiveProfiling;\n"]}
@@ -2,14 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getSiteConfig, useIntl } from '@openedx/frontend-base';
3
3
  import { ActionRow, Button, ModalDialog } from '@openedx/paragon';
4
4
  import PropTypes from 'prop-types';
5
+ import { useNavigate } from 'react-router-dom';
5
6
  import messages from './messages';
6
7
  const ProgressiveProfilingPageModal = (props) => {
7
8
  const { formatMessage } = useIntl();
9
+ const navigate = useNavigate();
8
10
  const { isOpen, redirectUrl } = props;
9
11
  const platformName = getSiteConfig().siteName;
10
12
  const handleSubmit = (e) => {
11
13
  e.preventDefault();
12
- window.location.href = redirectUrl;
14
+ if (redirectUrl.startsWith('/')) {
15
+ navigate(redirectUrl);
16
+ }
17
+ else {
18
+ window.location.href = redirectUrl;
19
+ }
13
20
  };
14
21
  return (_jsxs(ModalDialog, { title: formatMessage(messages['modal.title']), isOpen: isOpen, onClose: () => { }, size: "sm", variant: "default", hasCloseButton: false, children: [_jsx(ModalDialog.Header, { children: _jsx(ModalDialog.Title, { children: formatMessage(messages['modal.title']) }) }), _jsx(ModalDialog.Body, { children: formatMessage(messages['modal.description']) }), _jsx(ModalDialog.Footer, { children: _jsx(ActionRow, { children: _jsx(Button, { onClick: handleSubmit, variant: "primary", children: formatMessage(messages['continue.to.platform'], { platformName }) }) }) })] }));
15
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ProgressiveProfilingPageModal.js","sourceRoot":"","sources":["../../src/progressive-profiling/ProgressiveProfilingPageModal.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO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MAAM,EAAE,SAAS,CAAC,IAAI;IACtB,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;CACzC,CAAC;AAEF,6BAA6B,CAAC,YAAY,GAAG;IAC3C,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,eAAe,6BAA6B,CAAC","sourcesContent":["import { getSiteConfig, useIntl } from '@openedx/frontend-base';\nimport { ActionRow, Button, ModalDialog } from '@openedx/paragon';\nimport PropTypes from 'prop-types';\n\nimport messages from './messages';\n\nconst ProgressiveProfilingPageModal = (props) => {\n const { formatMessage } = useIntl();\n const { isOpen, redirectUrl } = props;\n const platformName = getSiteConfig().siteName;\n\n const handleSubmit = (e) => {\n e.preventDefault();\n window.location.href = redirectUrl;\n };\n\n return (\n <ModalDialog\n title={formatMessage(messages['modal.title'])}\n isOpen={isOpen}\n onClose={() => { }}\n size=\"sm\"\n variant=\"default\"\n hasCloseButton={false}\n >\n <ModalDialog.Header>\n <ModalDialog.Title>\n {formatMessage(messages['modal.title'])}\n </ModalDialog.Title>\n </ModalDialog.Header>\n\n <ModalDialog.Body>\n {formatMessage(messages['modal.description'])}\n </ModalDialog.Body>\n\n <ModalDialog.Footer>\n <ActionRow>\n <Button onClick={handleSubmit} variant=\"primary\">\n {formatMessage(messages['continue.to.platform'], { platformName })}\n </Button>\n </ActionRow>\n </ModalDialog.Footer>\n </ModalDialog>\n );\n};\n\nProgressiveProfilingPageModal.propTypes = {\n isOpen: PropTypes.bool,\n redirectUrl: PropTypes.string.isRequired,\n};\n\nProgressiveProfilingPageModal.defaultProps = {\n isOpen: false,\n};\n\nexport default ProgressiveProfilingPageModal;\n"]}
1
+ {"version":3,"file":"ProgressiveProfilingPageModal.js","sourceRoot":"","sources":["../../src/progressive-profiling/ProgressiveProfilingPageModal.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,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AAO,EAAC,SAAS,YAC7C,aAAa,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,EAAE,YAAY,EAAE,CAAC,GAC3D,GACC,GACO,IACT,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,6BAA6B,CAAC,SAAS,GAAG;IACxC,MAAM,EAAE,SAAS,CAAC,IAAI;IACtB,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;CACzC,CAAC;AAEF,6BAA6B,CAAC,YAAY,GAAG;IAC3C,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,eAAe,6BAA6B,CAAC","sourcesContent":["import { getSiteConfig, useIntl } from '@openedx/frontend-base';\nimport { ActionRow, Button, ModalDialog } from '@openedx/paragon';\nimport PropTypes from 'prop-types';\nimport { useNavigate } from 'react-router-dom';\n\nimport messages from './messages';\n\nconst ProgressiveProfilingPageModal = (props) => {\n const { formatMessage } = useIntl();\n const navigate = useNavigate();\n const { isOpen, redirectUrl } = props;\n const platformName = getSiteConfig().siteName;\n\n const handleSubmit = (e) => {\n e.preventDefault();\n if (redirectUrl.startsWith('/')) {\n navigate(redirectUrl);\n } else {\n window.location.href = redirectUrl;\n }\n };\n\n return (\n <ModalDialog\n title={formatMessage(messages['modal.title'])}\n isOpen={isOpen}\n onClose={() => { }}\n size=\"sm\"\n variant=\"default\"\n hasCloseButton={false}\n >\n <ModalDialog.Header>\n <ModalDialog.Title>\n {formatMessage(messages['modal.title'])}\n </ModalDialog.Title>\n </ModalDialog.Header>\n\n <ModalDialog.Body>\n {formatMessage(messages['modal.description'])}\n </ModalDialog.Body>\n\n <ModalDialog.Footer>\n <ActionRow>\n <Button onClick={handleSubmit} variant=\"primary\">\n {formatMessage(messages['continue.to.platform'], { platformName })}\n </Button>\n </ActionRow>\n </ModalDialog.Footer>\n </ModalDialog>\n );\n};\n\nProgressiveProfilingPageModal.propTypes = {\n isOpen: PropTypes.bool,\n redirectUrl: PropTypes.string.isRequired,\n};\n\nProgressiveProfilingPageModal.defaultProps = {\n isOpen: false,\n};\n\nexport default ProgressiveProfilingPageModal;\n"]}
@@ -0,0 +1,18 @@
1
+ import { FC, ReactNode } from 'react';
2
+ interface ProgressiveProfilingContextType {
3
+ isLoading: boolean;
4
+ showError: boolean;
5
+ success: boolean;
6
+ submitState?: string;
7
+ setLoading: (loading: boolean) => void;
8
+ setShowError: (showError: boolean) => void;
9
+ setSuccess: (success: boolean) => void;
10
+ setSubmitState: (state: string) => void;
11
+ clearState: () => void;
12
+ }
13
+ interface ProgressiveProfilingProviderProps {
14
+ children: ReactNode;
15
+ }
16
+ export declare const ProgressiveProfilingProvider: FC<ProgressiveProfilingProviderProps>;
17
+ export declare const useProgressiveProfilingContext: () => ProgressiveProfilingContextType;
18
+ export {};