@edx/frontend-plugin-learner-dashboard 3.3.5 → 3.5.0
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/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/package.json +6 -3
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingEntry.js +38 -0
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingEntry.js.map +1 -0
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingModal.js +117 -0
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingModal.js.map +1 -0
- package/dist/progressive-profiling-dashboard/api/service.js +37 -0
- package/dist/progressive-profiling-dashboard/api/service.js.map +1 -0
- package/dist/progressive-profiling-dashboard/data/progressiveProfilingFields.js +25 -0
- package/dist/progressive-profiling-dashboard/data/progressiveProfilingFields.js.map +1 -0
- package/dist/progressive-profiling-dashboard/field-renderer/FieldRenderer.js +86 -0
- package/dist/progressive-profiling-dashboard/field-renderer/FieldRenderer.js.map +1 -0
- package/dist/progressive-profiling-dashboard/field-renderer/index.js +14 -0
- package/dist/progressive-profiling-dashboard/field-renderer/index.js.map +1 -0
- package/dist/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.js +16 -0
- package/dist/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.js.map +1 -0
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.js +58 -0
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.js.map +1 -0
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.js +14 -0
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.js.map +1 -0
- package/dist/progressive-profiling-dashboard/index.js +9 -0
- package/dist/progressive-profiling-dashboard/index.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfiling.js +157 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfiling.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfilingPageModal.js +62 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfilingPageModal.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/LargeLayout.js +101 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/LargeLayout.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/MediumLayout.js +125 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/MediumLayout.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/SmallLayout.js +106 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/SmallLayout.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/index.js +28 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/index.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/messages.js +40 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/messages.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/index.js +59 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/index.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.js +14 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.scss +269 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/messages.js +68 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/messages.js.map +1 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/service/getThirdPartyAuthContext.js +28 -0
- package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/service/getThirdPartyAuthContext.js.map +1 -0
- package/dist/progressive-profiling-dashboard/utils/constants.js +12 -0
- package/dist/progressive-profiling-dashboard/utils/constants.js.map +1 -0
- package/dist/tracking/constants.js +2 -1
- package/dist/tracking/constants.js.map +1 -1
- package/dist/tracking/trackers/progressiveProfiling.js +47 -0
- package/dist/tracking/trackers/progressiveProfiling.js.map +1 -0
- package/dist/tracking/utils.js +15 -2
- package/dist/tracking/utils.js.map +1 -1
- package/package.json +7 -4
- package/src/index.jsx +4 -0
- package/src/progressive-profiling-dashboard/ProgressiveProfilingEntry.jsx +33 -0
- package/src/progressive-profiling-dashboard/ProgressiveProfilingModal.jsx +110 -0
- package/src/progressive-profiling-dashboard/api/service.js +32 -0
- package/src/progressive-profiling-dashboard/data/progressiveProfilingFields.js +32 -0
- package/src/progressive-profiling-dashboard/field-renderer/FieldRenderer.jsx +87 -0
- package/src/progressive-profiling-dashboard/field-renderer/index.jsx +1 -0
- package/src/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.jsx +12 -0
- package/src/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.jsx +55 -0
- package/src/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.jsx +9 -0
- package/src/progressive-profiling-dashboard/index.jsx +3 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfiling.jsx +156 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfilingPageModal.jsx +59 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/LargeLayout.jsx +105 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/MediumLayout.jsx +95 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/SmallLayout.jsx +85 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/index.jsx +3 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/messages.js +35 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/index.jsx +46 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/tests/BaseContainer.test.jsx +76 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.jsx +1 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.scss +269 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/messages.jsx +62 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/service/getThirdPartyAuthContext.js +24 -0
- package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/tests/ProgressiveProfiling.test.jsx +165 -0
- package/src/progressive-profiling-dashboard/utils/constants.jsx +5 -0
- package/src/tracking/constants.js +2 -0
- package/src/tracking/trackers/progressiveProfiling.js +45 -0
- package/src/tracking/utils.js +16 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.trackProgressiveProfilingSupportLinkClick = exports.trackProgressiveProfilingSubmitClick = exports.trackProgressiveProfilingSkipLinkClick = exports.trackProgressiveProfilingQuestionaireModalFormOpened = exports.trackProgressiveProfilingPageViewed = exports.trackDisablePostRegistrationRecommendations = exports.eventNames = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable function-paren-newline */
|
|
13
|
+
const eventNames = exports.eventNames = {
|
|
14
|
+
progressiveProfilingSubmitClick: 'edx.bi.welcome.page.submit.clicked',
|
|
15
|
+
progressiveProfilingSkipLinkClick: 'edx.bi.welcome.page.skip.link.clicked',
|
|
16
|
+
disablePostRegistrationRecommendations: 'edx.bi.user.recommendations.not.enabled',
|
|
17
|
+
progressiveProfilingSupportLinkClick: 'edx.bi.welcome.page.support.link.clicked',
|
|
18
|
+
loginAndRegistration: 'login_and_registration',
|
|
19
|
+
progressiveProfilingQuestionaireModalFormOpened: 'edx.bi.welcome.page.questionaire.modal.opened'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Event link tracker for Progressive profiling skip button click
|
|
23
|
+
const trackProgressiveProfilingSkipLinkClick = evenProperties => (0, _utils.createEventTracker)(eventNames.progressiveProfilingSkipLinkClick, _objectSpread({}, evenProperties))();
|
|
24
|
+
|
|
25
|
+
// Event tracker for progressive profiling submit button click
|
|
26
|
+
exports.trackProgressiveProfilingSkipLinkClick = trackProgressiveProfilingSkipLinkClick;
|
|
27
|
+
const trackProgressiveProfilingSubmitClick = evenProperties => (0, _utils.createEventTracker)(eventNames.progressiveProfilingSubmitClick, _objectSpread({}, evenProperties))();
|
|
28
|
+
|
|
29
|
+
// Event tracker for progressive profiling submit button click
|
|
30
|
+
exports.trackProgressiveProfilingSubmitClick = trackProgressiveProfilingSubmitClick;
|
|
31
|
+
const trackDisablePostRegistrationRecommendations = evenProperties => (0, _utils.createEventTracker)(eventNames.disablePostRegistrationRecommendations, _objectSpread({}, evenProperties))();
|
|
32
|
+
|
|
33
|
+
// Tracks the progressive profiling page event.
|
|
34
|
+
exports.trackDisablePostRegistrationRecommendations = trackDisablePostRegistrationRecommendations;
|
|
35
|
+
const trackProgressiveProfilingPageViewed = () => {
|
|
36
|
+
(0, _utils.createPageEventTracker)(eventNames.loginAndRegistration, 'welcome')();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Tracks the progressive profiling support link click.
|
|
40
|
+
exports.trackProgressiveProfilingPageViewed = trackProgressiveProfilingPageViewed;
|
|
41
|
+
const trackProgressiveProfilingSupportLinkClick = () => (0, _utils.createEventTracker)(eventNames.progressiveProfilingSupportLinkClick, {})();
|
|
42
|
+
|
|
43
|
+
// Tracks the progressive profiling modal opened with the questionaire form.
|
|
44
|
+
exports.trackProgressiveProfilingSupportLinkClick = trackProgressiveProfilingSupportLinkClick;
|
|
45
|
+
const trackProgressiveProfilingQuestionaireModalFormOpened = evenProperties => (0, _utils.createEventTracker)(eventNames.progressiveProfilingQuestionaireModalFormOpened, _objectSpread({}, evenProperties))();
|
|
46
|
+
exports.trackProgressiveProfilingQuestionaireModalFormOpened = trackProgressiveProfilingQuestionaireModalFormOpened;
|
|
47
|
+
//# sourceMappingURL=progressiveProfiling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressiveProfiling.js","names":["_utils","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","eventNames","exports","progressiveProfilingSubmitClick","progressiveProfilingSkipLinkClick","disablePostRegistrationRecommendations","progressiveProfilingSupportLinkClick","loginAndRegistration","progressiveProfilingQuestionaireModalFormOpened","trackProgressiveProfilingSkipLinkClick","evenProperties","createEventTracker","trackProgressiveProfilingSubmitClick","trackDisablePostRegistrationRecommendations","trackProgressiveProfilingPageViewed","createPageEventTracker","trackProgressiveProfilingSupportLinkClick","trackProgressiveProfilingQuestionaireModalFormOpened"],"sources":["../../../src/tracking/trackers/progressiveProfiling.js"],"sourcesContent":["/* eslint-disable function-paren-newline */\nimport { createEventTracker, createPageEventTracker } from '../utils';\n\nexport const eventNames = {\n progressiveProfilingSubmitClick: 'edx.bi.welcome.page.submit.clicked',\n progressiveProfilingSkipLinkClick: 'edx.bi.welcome.page.skip.link.clicked',\n disablePostRegistrationRecommendations: 'edx.bi.user.recommendations.not.enabled',\n progressiveProfilingSupportLinkClick: 'edx.bi.welcome.page.support.link.clicked',\n loginAndRegistration: 'login_and_registration',\n progressiveProfilingQuestionaireModalFormOpened: 'edx.bi.welcome.page.questionaire.modal.opened',\n};\n\n// Event link tracker for Progressive profiling skip button click\nexport const trackProgressiveProfilingSkipLinkClick = evenProperties => createEventTracker(\n eventNames.progressiveProfilingSkipLinkClick, { ...evenProperties },\n)();\n\n// Event tracker for progressive profiling submit button click\nexport const trackProgressiveProfilingSubmitClick = (evenProperties) => createEventTracker(\n eventNames.progressiveProfilingSubmitClick,\n { ...evenProperties },\n)();\n\n// Event tracker for progressive profiling submit button click\nexport const trackDisablePostRegistrationRecommendations = (evenProperties) => createEventTracker(\n eventNames.disablePostRegistrationRecommendations,\n { ...evenProperties },\n)();\n\n// Tracks the progressive profiling page event.\nexport const trackProgressiveProfilingPageViewed = () => {\n createPageEventTracker(eventNames.loginAndRegistration, 'welcome')();\n};\n\n// Tracks the progressive profiling support link click.\nexport const trackProgressiveProfilingSupportLinkClick = () => createEventTracker(\n eventNames.progressiveProfilingSupportLinkClick,\n {},\n)();\n\n// Tracks the progressive profiling modal opened with the questionaire form.\nexport const trackProgressiveProfilingQuestionaireModalFormOpened = (evenProperties) => createEventTracker(\n eventNames.progressiveProfilingQuestionaireModalFormOpened,\n { ...evenProperties },\n)();\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAAsE,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,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AAO6B,cAAc,CACnE,CAAC,CAAC,CAAC;;AAEH;AAAAR,OAAA,CAAAO,sCAAA,GAAAA,sCAAA;AACO,MAAMG,oCAAoC,GAAIF,cAAc,IAAK,IAAAC,yBAAkB,EACxFV,UAAU,CAACE,+BAA+B,EAAAtB,aAAA,KACrC6B,cAAc,CACrB,CAAC,CAAC,CAAC;;AAEH;AAAAR,OAAA,CAAAU,oCAAA,GAAAA,oCAAA;AACO,MAAMC,2CAA2C,GAAIH,cAAc,IAAK,IAAAC,yBAAkB,EAC/FV,UAAU,CAACI,sCAAsC,EAAAxB,aAAA,KAC5C6B,cAAc,CACrB,CAAC,CAAC,CAAC;;AAEH;AAAAR,OAAA,CAAAW,2CAAA,GAAAA,2CAAA;AACO,MAAMC,mCAAmC,GAAGA,CAAA,KAAM;EACvD,IAAAC,6BAAsB,EAACd,UAAU,CAACM,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC;AACtE,CAAC;;AAED;AAAAL,OAAA,CAAAY,mCAAA,GAAAA,mCAAA;AACO,MAAME,yCAAyC,GAAGA,CAAA,KAAM,IAAAL,yBAAkB,EAC/EV,UAAU,CAACK,oCAAoC,EAC/C,CAAC,CACH,CAAC,CAAC,CAAC;;AAEH;AAAAJ,OAAA,CAAAc,yCAAA,GAAAA,yCAAA;AACO,MAAMC,oDAAoD,GAAIP,cAAc,IAAK,IAAAC,yBAAkB,EACxGV,UAAU,CAACO,+CAA+C,EAAA3B,aAAA,KACrD6B,cAAc,CACrB,CAAC,CAAC,CAAC;AAACR,OAAA,CAAAe,oDAAA,GAAAA,oDAAA","ignoreList":[]}
|
package/dist/tracking/utils.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.logEvent = exports.createLinkTracker = exports.createEventTracker = void 0;
|
|
6
|
+
exports.logEvent = exports.createPageEventTracker = exports.createLinkTracker = exports.createEventTracker = void 0;
|
|
7
7
|
var _frontendPlatform = require("@edx/frontend-platform");
|
|
8
8
|
var _auth = require("@edx/frontend-platform/auth");
|
|
9
9
|
var _analytics = require("@edx/frontend-platform/analytics");
|
|
10
|
+
var _constants = require("./constants");
|
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
13
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -28,9 +29,21 @@ const logEvent = ({
|
|
|
28
29
|
});
|
|
29
30
|
exports.logEvent = logEvent;
|
|
30
31
|
const createEventTracker = (name, options = {}) => () => (0, _analytics.sendTrackEvent)(name, _objectSpread(_objectSpread({}, options), {}, {
|
|
31
|
-
app_name:
|
|
32
|
+
app_name: _constants.LEARNER_HOME_APP_NAME
|
|
32
33
|
}));
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates an event tracker function that sends a tracking event with the given name and options.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} name - The name of the event to be tracked.
|
|
39
|
+
* @param {object} [options={}] - Additional options to be included with the event.
|
|
40
|
+
* @returns {function} - A function that, when called, sends the tracking event.
|
|
41
|
+
*/
|
|
33
42
|
exports.createEventTracker = createEventTracker;
|
|
43
|
+
const createPageEventTracker = (name, options = null) => () => (0, _analytics.sendPageEvent)(name, options, {
|
|
44
|
+
app_name: _constants.LEARNER_HOME_APP_NAME
|
|
45
|
+
});
|
|
46
|
+
exports.createPageEventTracker = createPageEventTracker;
|
|
34
47
|
const createLinkTracker = (tracker, href) => e => {
|
|
35
48
|
e.preventDefault();
|
|
36
49
|
tracker();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_frontendPlatform","require","_auth","_analytics","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LINK_TIMEOUT","eventUrl","getConfig","LMS_BASE_URL","logEvent","eventName","data","courseId","getAuthenticatedHttpClient","post","courserun_key","event_type","page","window","location","href","event","JSON","stringify","exports","createEventTracker","name","options","sendTrackEvent","app_name","createLinkTracker","tracker","preventDefault","setTimeout","global"],"sources":["../../src/tracking/utils.js"],"sourcesContent":["import { getConfig } from '@edx/frontend-platform';\nimport { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';\nimport { sendTrackEvent } from '@edx/frontend-platform/analytics';\n\nconst LINK_TIMEOUT = 300;\n\nconst eventUrl = `${getConfig().LMS_BASE_URL}/event`;\n\n// Utils/Helpers\nexport const logEvent = ({ eventName, data, courseId }) => getAuthenticatedHttpClient().post(eventUrl, {\n courserun_key: courseId,\n event_type: eventName,\n page: window.location.href,\n event: JSON.stringify(data),\n});\n\nexport const createEventTracker = (name, options = {}) => () => sendTrackEvent(\n name,\n { ...options, app_name:
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_frontendPlatform","require","_auth","_analytics","_constants","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LINK_TIMEOUT","eventUrl","getConfig","LMS_BASE_URL","logEvent","eventName","data","courseId","getAuthenticatedHttpClient","post","courserun_key","event_type","page","window","location","href","event","JSON","stringify","exports","createEventTracker","name","options","sendTrackEvent","app_name","LEARNER_HOME_APP_NAME","createPageEventTracker","sendPageEvent","createLinkTracker","tracker","preventDefault","setTimeout","global"],"sources":["../../src/tracking/utils.js"],"sourcesContent":["import { getConfig } from '@edx/frontend-platform';\nimport { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';\nimport { sendTrackEvent, sendPageEvent } from '@edx/frontend-platform/analytics';\nimport { LEARNER_HOME_APP_NAME } from './constants';\n\nconst LINK_TIMEOUT = 300;\n\nconst eventUrl = `${getConfig().LMS_BASE_URL}/event`;\n\n// Utils/Helpers\nexport const logEvent = ({ eventName, data, courseId }) => getAuthenticatedHttpClient().post(eventUrl, {\n courserun_key: courseId,\n event_type: eventName,\n page: window.location.href,\n event: JSON.stringify(data),\n});\n\nexport const createEventTracker = (name, options = {}) => () => sendTrackEvent(\n name,\n { ...options, app_name: LEARNER_HOME_APP_NAME },\n);\n\n/**\n * Creates an event tracker function that sends a tracking event with the given name and options.\n *\n * @param {string} name - The name of the event to be tracked.\n * @param {object} [options={}] - Additional options to be included with the event.\n * @returns {function} - A function that, when called, sends the tracking event.\n */\nexport const createPageEventTracker = (name, options = null) => () => sendPageEvent(\n name,\n options,\n { app_name: LEARNER_HOME_APP_NAME },\n);\n\nexport const createLinkTracker = (tracker, href) => (e) => {\n e.preventDefault();\n tracker();\n return setTimeout(() => { global.location.href = href; }, LINK_TIMEOUT);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAoD,SAAAI,QAAAC,CAAA,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MM,sBAAsB,GAAGA,CAACL,IAAI,EAAEC,OAAO,GAAG,IAAI,KAAK,MAAM,IAAAK,wBAAa,EACjFN,IAAI,EACJC,OAAO,EACP;EAAEE,QAAQ,EAAEC;AAAsB,CACpC,CAAC;AAACN,OAAA,CAAAO,sBAAA,GAAAA,sBAAA;AAEK,MAAME,iBAAiB,GAAGA,CAACC,OAAO,EAAEd,IAAI,KAAM/C,CAAC,IAAK;EACzDA,CAAC,CAAC8D,cAAc,CAAC,CAAC;EAClBD,OAAO,CAAC,CAAC;EACT,OAAOE,UAAU,CAAC,MAAM;IAAEC,MAAM,CAAClB,QAAQ,CAACC,IAAI,GAAGA,IAAI;EAAE,CAAC,EAAEf,YAAY,CAAC;AACzE,CAAC;AAACmB,OAAA,CAAAS,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edx/frontend-plugin-learner-dashboard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Repository for Learner Dashboard MFE frontend plugins",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"@edx/browserslist-config": "^1.1.1",
|
|
46
46
|
"@edx/react-unit-test-utils": "^4.0.0",
|
|
47
47
|
"@edx/reactifex": "^2.1.1",
|
|
48
|
-
"@openedx/frontend-build": "14.6.
|
|
48
|
+
"@openedx/frontend-build": "14.6.6",
|
|
49
49
|
"@testing-library/jest-dom": "^6.6.3",
|
|
50
50
|
"@testing-library/react": "^16.2.0",
|
|
51
|
-
"jest": "30.
|
|
51
|
+
"jest": "30.4.2",
|
|
52
52
|
"react-error-boundary": "^6.1.0",
|
|
53
53
|
"rosie": "2.1.1",
|
|
54
54
|
"semantic-release": "^25.0.0",
|
|
@@ -57,9 +57,12 @@
|
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@edx/frontend-platform": "^8.3.1",
|
|
59
59
|
"@openedx/paragon": "^23.0.0",
|
|
60
|
+
"classnames": "^2.5.1",
|
|
60
61
|
"moment": "^2.30.1",
|
|
61
62
|
"prop-types": "15.8.1",
|
|
62
63
|
"react": "^18.3.1",
|
|
63
|
-
"react-dom": "^18.3.1"
|
|
64
|
+
"react-dom": "^18.3.1",
|
|
65
|
+
"react-helmet": "^6.1.0",
|
|
66
|
+
"react-router-dom": "^6.30.2"
|
|
64
67
|
}
|
|
65
68
|
}
|
package/src/index.jsx
CHANGED
|
@@ -9,6 +9,8 @@ import NoticesRedirect from './notices-redirect/index';
|
|
|
9
9
|
import UpgradeButton from './upgrade-button';
|
|
10
10
|
import UserCareerMenu from './career-menu/index';
|
|
11
11
|
import UserDashboardMenu from './dashboard-menu/index';
|
|
12
|
+
import ProgressiveProfilingEntry from './progressive-profiling-dashboard';
|
|
13
|
+
import { ProgressiveProfiling } from './progressive-profiling-dashboard/progressive-profiling-authn-replica';
|
|
12
14
|
|
|
13
15
|
export {
|
|
14
16
|
CohesionWrapper,
|
|
@@ -22,4 +24,6 @@ export {
|
|
|
22
24
|
UpgradeButton,
|
|
23
25
|
UserCareerMenu,
|
|
24
26
|
UserDashboardMenu,
|
|
27
|
+
ProgressiveProfilingEntry,
|
|
28
|
+
ProgressiveProfiling,
|
|
25
29
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
|
|
3
|
+
|
|
4
|
+
import ProgressiveProfilingModal from './ProgressiveProfilingModal';
|
|
5
|
+
import useProgressiveProfilingTrigger from './hooks/useProgressiveProfilingTrigger';
|
|
6
|
+
import useClearProgressiveProfilingQueryParams from './hooks/useClearProgressiveProfilingQueryParams';
|
|
7
|
+
import { trackProgressiveProfilingQuestionaireModalFormOpened } from '../tracking/trackers/progressiveProfiling';
|
|
8
|
+
|
|
9
|
+
const ProgressiveProfilingEntry = () => {
|
|
10
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
+
|
|
12
|
+
const username = getAuthenticatedUser()?.username;
|
|
13
|
+
|
|
14
|
+
const { shouldOpen } = useProgressiveProfilingTrigger();
|
|
15
|
+
const clearTrigger = useClearProgressiveProfilingQueryParams();
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (shouldOpen && username) {
|
|
19
|
+
setIsOpen(true);
|
|
20
|
+
trackProgressiveProfilingQuestionaireModalFormOpened({ host: window.location.origin });
|
|
21
|
+
}
|
|
22
|
+
}, [shouldOpen, username]);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ProgressiveProfilingModal
|
|
26
|
+
isOpen={isOpen}
|
|
27
|
+
onClose={() => setIsOpen(false)}
|
|
28
|
+
clearTrigger={clearTrigger}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { ProgressiveProfilingEntry };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { getConfig } from '@edx/frontend-platform';
|
|
4
|
+
import { useIntl } from '@edx/frontend-platform/i18n';
|
|
5
|
+
import {
|
|
6
|
+
Alert, Button, Form, Hyperlink, ModalDialog,
|
|
7
|
+
} from '@openedx/paragon';
|
|
8
|
+
|
|
9
|
+
import { FormFieldRenderer } from './field-renderer';
|
|
10
|
+
import useProgressiveProfilingForm from './hooks/useProgressiveProfilingForm';
|
|
11
|
+
import { COMPLETE_STATE, PENDING_STATE } from './utils/constants';
|
|
12
|
+
import messages from './progressive-profiling-authn-replica/messages';
|
|
13
|
+
import {
|
|
14
|
+
trackProgressiveProfilingSkipLinkClick, trackProgressiveProfilingSubmitClick,
|
|
15
|
+
trackProgressiveProfilingSupportLinkClick,
|
|
16
|
+
} from '../tracking/trackers/progressiveProfiling';
|
|
17
|
+
|
|
18
|
+
const ProgressiveProfilingModal = ({
|
|
19
|
+
isOpen, onClose, clearTrigger,
|
|
20
|
+
}) => {
|
|
21
|
+
const { formatMessage } = useIntl();
|
|
22
|
+
const {
|
|
23
|
+
loadState, submitState, error, values, fieldList, onChangeHandler, submit,
|
|
24
|
+
} = useProgressiveProfilingForm();
|
|
25
|
+
|
|
26
|
+
const handleSubmit = async (e) => {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
const success = await submit();
|
|
29
|
+
if (!success) { return; }
|
|
30
|
+
|
|
31
|
+
trackProgressiveProfilingSubmitClick({
|
|
32
|
+
isGenderSelected: !!values.gender,
|
|
33
|
+
isLevelOfEducationSelected: !!values.level_of_education,
|
|
34
|
+
host: window.location.origin,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
clearTrigger();
|
|
38
|
+
onClose();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleSkip = () => {
|
|
42
|
+
trackProgressiveProfilingSkipLinkClick({ host: window.location.origin });
|
|
43
|
+
clearTrigger();
|
|
44
|
+
onClose();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<ModalDialog
|
|
49
|
+
isOpen={isOpen}
|
|
50
|
+
onClose={() => {}}
|
|
51
|
+
hasCloseButton={false}
|
|
52
|
+
size="md"
|
|
53
|
+
title={formatMessage(messages['progressive.profiling.page.heading'])}
|
|
54
|
+
>
|
|
55
|
+
<ModalDialog.Header>
|
|
56
|
+
<ModalDialog.Title>
|
|
57
|
+
{formatMessage(messages['progressive.profiling.page.heading'])}
|
|
58
|
+
</ModalDialog.Title>
|
|
59
|
+
</ModalDialog.Header>
|
|
60
|
+
|
|
61
|
+
<ModalDialog.Body>
|
|
62
|
+
{error && (
|
|
63
|
+
<Alert variant="danger">
|
|
64
|
+
<Alert.Heading>{formatMessage(messages['welcome.page.error.heading'])}</Alert.Heading>
|
|
65
|
+
<p>{formatMessage(messages['welcome.page.error.message'])}</p>
|
|
66
|
+
</Alert>
|
|
67
|
+
)}
|
|
68
|
+
<Form id="profileForm" onSubmit={handleSubmit}>
|
|
69
|
+
{fieldList.map((fieldData) => (
|
|
70
|
+
<FormFieldRenderer
|
|
71
|
+
key={fieldData.name}
|
|
72
|
+
fieldData={fieldData}
|
|
73
|
+
value={values[fieldData.name]}
|
|
74
|
+
onChangeHandler={onChangeHandler}
|
|
75
|
+
/>
|
|
76
|
+
))}
|
|
77
|
+
|
|
78
|
+
{(getConfig().AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && (
|
|
79
|
+
<div className="mt-2">
|
|
80
|
+
<Hyperlink
|
|
81
|
+
destination={getConfig().AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK}
|
|
82
|
+
target="_blank"
|
|
83
|
+
showLaunchIcon={false}
|
|
84
|
+
onClick={() => trackProgressiveProfilingSupportLinkClick({ host: window.location.origin })}
|
|
85
|
+
>
|
|
86
|
+
{formatMessage(messages['optional.fields.information.link'])}
|
|
87
|
+
</Hyperlink>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</Form>
|
|
91
|
+
</ModalDialog.Body>
|
|
92
|
+
<ModalDialog.Footer>
|
|
93
|
+
<Button variant="link" onClick={handleSkip} disabled={submitState === PENDING_STATE}>
|
|
94
|
+
{formatMessage(messages['optional.fields.skip.button'])}
|
|
95
|
+
</Button>
|
|
96
|
+
<Button variant="brand" type="submit" form="profileForm" disabled={loadState !== COMPLETE_STATE || submitState === PENDING_STATE}>
|
|
97
|
+
{formatMessage(messages['optional.fields.submit.button'])}
|
|
98
|
+
</Button>
|
|
99
|
+
</ModalDialog.Footer>
|
|
100
|
+
</ModalDialog>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
ProgressiveProfilingModal.propTypes = {
|
|
105
|
+
isOpen: PropTypes.bool.isRequired,
|
|
106
|
+
onClose: PropTypes.func.isRequired,
|
|
107
|
+
clearTrigger: PropTypes.func.isRequired,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default ProgressiveProfilingModal;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getConfig, snakeCaseObject } from '@edx/frontend-platform';
|
|
2
|
+
import { getAuthenticatedUser, getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
|
3
|
+
|
|
4
|
+
export async function saveProgressiveProfiling(values, extendedProfileFieldNames = []) {
|
|
5
|
+
const payload = { ...values };
|
|
6
|
+
const extendedProfile = [];
|
|
7
|
+
const authenticatedUser = getAuthenticatedUser();
|
|
8
|
+
const client = getAuthenticatedHttpClient();
|
|
9
|
+
|
|
10
|
+
extendedProfileFieldNames.forEach((fieldName) => {
|
|
11
|
+
if (payload[fieldName] !== undefined && payload[fieldName] !== '') {
|
|
12
|
+
extendedProfile.push({
|
|
13
|
+
fieldName,
|
|
14
|
+
fieldValue: payload[fieldName],
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
delete payload[fieldName];
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (extendedProfile.length) {
|
|
22
|
+
payload.extendedProfile = extendedProfile;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
await client.patch(
|
|
26
|
+
`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${authenticatedUser.username}`,
|
|
27
|
+
snakeCaseObject(payload),
|
|
28
|
+
{
|
|
29
|
+
headers: { 'Content-Type': 'application/merge-patch+json' },
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const progressiveProfilingFields = {
|
|
2
|
+
fields: {
|
|
3
|
+
gender: {
|
|
4
|
+
name: 'gender',
|
|
5
|
+
type: 'select',
|
|
6
|
+
label: 'Gender',
|
|
7
|
+
options: [
|
|
8
|
+
['f', 'Female'],
|
|
9
|
+
['m', 'Male'],
|
|
10
|
+
['o', 'Other'],
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
level_of_education: {
|
|
14
|
+
name: 'level_of_education',
|
|
15
|
+
type: 'select',
|
|
16
|
+
label: 'Level of Education',
|
|
17
|
+
options: [
|
|
18
|
+
['p', 'Doctorate'],
|
|
19
|
+
['m', 'Master\'s or professional degree'],
|
|
20
|
+
['b', 'Bachelor\'s Degree'],
|
|
21
|
+
['a', 'Associate Degree'],
|
|
22
|
+
['hs', 'Secondary/High School'],
|
|
23
|
+
['jhs', 'Junior secondary/junior high/middle school'],
|
|
24
|
+
['el', 'Elementary/primary school'],
|
|
25
|
+
['none', 'No formal education'],
|
|
26
|
+
['other', 'Other education'],
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
extendedProfile: [],
|
|
31
|
+
redirectUrl: '',
|
|
32
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Form } from '@openedx/paragon';
|
|
4
|
+
|
|
5
|
+
const FormFieldRenderer = ({
|
|
6
|
+
fieldData, value, onChangeHandler, className,
|
|
7
|
+
}) => {
|
|
8
|
+
switch (fieldData.type) {
|
|
9
|
+
case 'select':
|
|
10
|
+
return (
|
|
11
|
+
<Form.Group controlId={fieldData.name}>
|
|
12
|
+
<Form.Control
|
|
13
|
+
as="select"
|
|
14
|
+
className={className}
|
|
15
|
+
name={fieldData.name}
|
|
16
|
+
value={value ?? ''}
|
|
17
|
+
onChange={onChangeHandler}
|
|
18
|
+
floatingLabel={fieldData.label}
|
|
19
|
+
>
|
|
20
|
+
<option value="">{fieldData.label}</option>
|
|
21
|
+
{fieldData.options.map(option => (
|
|
22
|
+
<option key={option[0]} value={option[0]}>
|
|
23
|
+
{option[1]}
|
|
24
|
+
</option>
|
|
25
|
+
))}
|
|
26
|
+
</Form.Control>
|
|
27
|
+
</Form.Group>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
case 'textarea':
|
|
31
|
+
return (
|
|
32
|
+
<Form.Group controlId={fieldData.name}>
|
|
33
|
+
<Form.Control
|
|
34
|
+
as="textarea"
|
|
35
|
+
className={className}
|
|
36
|
+
name={fieldData.name}
|
|
37
|
+
value={value ?? ''}
|
|
38
|
+
onChange={onChangeHandler}
|
|
39
|
+
floatingLabel={fieldData.label}
|
|
40
|
+
/>
|
|
41
|
+
</Form.Group>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
case 'checkbox':
|
|
45
|
+
return (
|
|
46
|
+
<Form.Group controlId={fieldData.name}>
|
|
47
|
+
<Form.Checkbox
|
|
48
|
+
id={fieldData.name}
|
|
49
|
+
name={fieldData.name}
|
|
50
|
+
checked={!!value}
|
|
51
|
+
onChange={onChangeHandler}
|
|
52
|
+
>
|
|
53
|
+
{fieldData.label}
|
|
54
|
+
</Form.Checkbox>
|
|
55
|
+
</Form.Group>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
default:
|
|
59
|
+
return (
|
|
60
|
+
<Form.Group controlId={fieldData.name}>
|
|
61
|
+
<Form.Control
|
|
62
|
+
className={className}
|
|
63
|
+
name={fieldData.name}
|
|
64
|
+
value={value ?? ''}
|
|
65
|
+
onChange={onChangeHandler}
|
|
66
|
+
floatingLabel={fieldData.label}
|
|
67
|
+
/>
|
|
68
|
+
</Form.Group>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
FormFieldRenderer.propTypes = {
|
|
74
|
+
fieldData: PropTypes.shape({
|
|
75
|
+
name: PropTypes.string.isRequired,
|
|
76
|
+
type: PropTypes.string.isRequired,
|
|
77
|
+
label: PropTypes.string,
|
|
78
|
+
options: PropTypes.arrayOf(
|
|
79
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
80
|
+
),
|
|
81
|
+
}).isRequired,
|
|
82
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
83
|
+
onChangeHandler: PropTypes.func.isRequired,
|
|
84
|
+
className: PropTypes.string,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default FormFieldRenderer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormFieldRenderer } from './FieldRenderer';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { PROGRESSIVE_PROFILING_QUERY_PARAM } from '../utils/constants';
|
|
3
|
+
|
|
4
|
+
export default function useClearProgressiveProfilingQueryParams() {
|
|
5
|
+
return useCallback(() => {
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
|
|
8
|
+
currentUrl.searchParams.delete(PROGRESSIVE_PROFILING_QUERY_PARAM);
|
|
9
|
+
|
|
10
|
+
window.history.replaceState({}, '', currentUrl.toString());
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
COMPLETE_STATE, DEFAULT_STATE, PENDING_STATE,
|
|
4
|
+
} from '../utils/constants';
|
|
5
|
+
import { saveProgressiveProfiling } from '../api/service';
|
|
6
|
+
import { progressiveProfilingFields } from '../data/progressiveProfilingFields';
|
|
7
|
+
|
|
8
|
+
export default function useProgressiveProfilingForm() {
|
|
9
|
+
const [submitState, setSubmitState] = useState(DEFAULT_STATE);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
const [values, setValues] = useState({});
|
|
12
|
+
|
|
13
|
+
const fieldData = progressiveProfilingFields;
|
|
14
|
+
|
|
15
|
+
const fieldList = useMemo(
|
|
16
|
+
() => Object.keys(fieldData.fields).map((key) => fieldData.fields[key]),
|
|
17
|
+
[fieldData],
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const onChangeHandler = (event) => {
|
|
21
|
+
const {
|
|
22
|
+
name, type, value, checked,
|
|
23
|
+
} = event.target;
|
|
24
|
+
setValues((prev) => ({
|
|
25
|
+
...prev,
|
|
26
|
+
[name]: type === 'checkbox' ? checked : value,
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const submit = async () => {
|
|
31
|
+
try {
|
|
32
|
+
setSubmitState(PENDING_STATE);
|
|
33
|
+
setError(null);
|
|
34
|
+
await saveProgressiveProfiling(values, fieldData.extendedProfile || []);
|
|
35
|
+
setSubmitState(COMPLETE_STATE);
|
|
36
|
+
return true;
|
|
37
|
+
} catch (err) {
|
|
38
|
+
setSubmitState(DEFAULT_STATE);
|
|
39
|
+
setError(err);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
loadState: COMPLETE_STATE,
|
|
46
|
+
submitState,
|
|
47
|
+
error,
|
|
48
|
+
values,
|
|
49
|
+
fieldList,
|
|
50
|
+
onChangeHandler,
|
|
51
|
+
submit,
|
|
52
|
+
redirectUrl: fieldData.redirectUrl || '',
|
|
53
|
+
extendedProfileFieldNames: fieldData.extendedProfile || [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PROGRESSIVE_PROFILING_QUERY_PARAM } from '../utils/constants';
|
|
2
|
+
|
|
3
|
+
export default function useProgressiveProfilingTrigger() {
|
|
4
|
+
const params = new URLSearchParams(window.location.search);
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
shouldOpen: params.get(PROGRESSIVE_PROFILING_QUERY_PARAM) === 'true',
|
|
8
|
+
};
|
|
9
|
+
}
|