@edx/frontend-app-subscription-learner-dashboard 1.80.0 → 1.81.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.
|
@@ -21,17 +21,20 @@ const getProgramCertificateLabel = (programType, formatMessage) => {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
export const ProgramProgressSidebar = ({ inProgress, remaining, completed }) => {
|
|
24
|
-
var _a, _b
|
|
24
|
+
var _a, _b;
|
|
25
25
|
const { formatMessage } = useIntl();
|
|
26
26
|
const { programProgressData, isLoading } = useProgressData();
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const programData = programProgressData === null || programProgressData === void 0 ? void 0 : programProgressData.programData;
|
|
28
|
+
const priceRange = (_b = (_a = programData === null || programData === void 0 ? void 0 : programData.priceRanges) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : undefined;
|
|
29
|
+
const hasPriceRange = Boolean(priceRange && Number.isFinite(Number(priceRange.total)) && priceRange.currency);
|
|
30
|
+
const price = !isLoading && hasPriceRange ? (_jsx(FormattedNumber, { value: priceRange.total, style: "currency", currency: priceRange.currency })) : null;
|
|
31
|
+
const type = (programData === null || programData === void 0 ? void 0 : programData.type) || '';
|
|
29
32
|
const programType = getProgramCertificateLabel(type, formatMessage);
|
|
30
33
|
return (_jsxs("div", { className: "program-certificate-widget", "data-testid": "program-certificate-progress", children: [_jsx(ProgramProgressCircle, { inProgress: inProgress, remaining: remaining, completed: completed }), _jsx("h6", { className: "progress-heading-circle my-5", children: formatMessage(messages.programProgressCertificateLabel) }), type.trim().toLowerCase()
|
|
31
34
|
!== PROGRAM_TYPE_MAP.MICROMASTERS.toLowerCase() && (_jsxs("div", { className: "progress-certificate-content pt-3 px-3", children: [_jsx("p", { className: "text-gray-800", children: formatMessage(messages.programProgressCertificateContentOne, {
|
|
32
35
|
programType: programType,
|
|
33
|
-
}) }), _jsx("p", { className: "text-gray-800", children: formatMessage(messages.programProgressCertificateContentTwo, {
|
|
36
|
+
}) }), price && (_jsx("p", { className: "text-gray-800", children: formatMessage(messages.programProgressCertificateContentTwo, {
|
|
34
37
|
price,
|
|
35
|
-
}) })] }))] }));
|
|
38
|
+
}) }))] }))] }));
|
|
36
39
|
};
|
|
37
40
|
//# sourceMappingURL=index.js.map
|
package/dist/containers/ProgramDashboard/ProgramProgress/ProgramProgressSidebar/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/containers/ProgramDashboard/ProgramProgress/ProgramProgressSidebar/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,0BAA0B,GAAG,CAAC,WAAoB,EAAE,aAAmF,EAAE,EAAE;IAC/I,MAAM,cAAc,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,EAAE,CAAC;IAE3C,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAChG,CAAC;IAED,MAAM,aAAa,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAEnD,QAAQ,aAAa,EAAE,CAAC;QACtB,KAAK,gBAAgB,CAAC,OAAO,CAAC,WAAW,EAAE;YACzC,OAAO,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,sCAAsC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC;QAChH,KAAK,gBAAgB,CAAC,wBAAwB,CAAC,WAAW,EAAE;YAC1D,OAAO,cAAc,CAAC;QACxB;YACE,OAAO,GAAG,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACzH,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAoC,CAAC,EACtE,UAAU,EAAE,SAAS,EAAE,SAAS,EACjC,EAAE,EAAE;;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,EAAE,mBAAmB,EAAE,SAAS,EAAE,GAAG,eAAe,EAAE,CAAC;IAE7D,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/containers/ProgramDashboard/ProgramProgress/ProgramProgressSidebar/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,0BAA0B,GAAG,CAAC,WAAoB,EAAE,aAAmF,EAAE,EAAE;IAC/I,MAAM,cAAc,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,EAAE,CAAC;IAE3C,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAChG,CAAC;IAED,MAAM,aAAa,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAEnD,QAAQ,aAAa,EAAE,CAAC;QAC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A,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,KAAI,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,0BAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAEpE,OAAO,CACL,eACE,SAAS,EAAC,4BAA4B,iBAC1B,8BAA8B,aAE1C,KAAC,qBAAqB,IAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAI,EAC7F,aAAI,SAAS,EAAC,8BAA8B,YACzC,aAAa,CAAC,QAAQ,CAAC,+BAA+B,CAAC,GACrD,EACJ,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;oBACtB,gBAAgB,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CACjD,eAAK,SAAS,EAAC,wCAAwC,aACrD,YAAG,SAAS,EAAC,eAAe,YACzB,aAAa,CAAC,QAAQ,CAAC,oCAAoC,EAAE;4BAC5D,WAAW,EAAE,WAAW;yBACzB,CAAC,GACA,EACH,KAAK,IAAI,CACR,YAAG,SAAS,EAAC,eAAe,YACzB,aAAa,CAAC,QAAQ,CAAC,oCAAoC,EAAE;4BAC5D,KAAK;yBACN,CAAC,GACA,CACL,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { FC } from 'react';\nimport { useIntl, FormattedNumber } from '@openedx/frontend-base';\nimport messages from '../messages';\nimport { ProgramProgressSidebarProps } from '../../data/types';\nimport ProgramProgressCircle from './ProgramProgressCircle';\nimport './index.scss';\nimport { useProgressData } from '@src/hooks';\nimport { PROGRAM_TYPE_MAP } from '../../data/constants';\n\nconst getProgramCertificateLabel = (programType?: string, formatMessage?: (message: typeof messages.programProgressCertificateText) => string) => {\n const normalizedType = programType?.trim();\n\n if (!normalizedType) {\n return formatMessage ? formatMessage(messages.programProgressCertificateText) : 'certificate';\n }\n\n const lowercaseType = normalizedType.toLowerCase();\n\n switch (lowercaseType) {\n case PROGRAM_TYPE_MAP.XSERIES.toLowerCase():\n return formatMessage ? formatMessage(messages.programProgressXSeriesCertificateLabel) : 'XSeries Certificate';\n case PROGRAM_TYPE_MAP.PROFESSIONAL_CERTIFICATE.toLowerCase():\n return normalizedType;\n default:\n return `${normalizedType} ${formatMessage ? formatMessage(messages.programProgressCertificateText) : 'certificate'}`;\n }\n};\n\nexport const ProgramProgressSidebar: FC<ProgramProgressSidebarProps> = ({\n inProgress, remaining, completed\n}) => {\n const { formatMessage } = useIntl();\n const { programProgressData, isLoading } = useProgressData();\n\n const programData = programProgressData?.programData;\n const priceRange = programData?.priceRanges?.[0] ?? undefined;\n const hasPriceRange = Boolean(\n priceRange && Number.isFinite(Number(priceRange.total)) && priceRange.currency,\n );\n const price = !isLoading && hasPriceRange ? (\n <FormattedNumber value={priceRange.total} style=\"currency\" currency={priceRange.currency} />\n ) : null;\n const type = programData?.type || '';\n const programType = getProgramCertificateLabel(type, formatMessage);\n\n return (\n <div\n className=\"program-certificate-widget\"\n data-testid=\"program-certificate-progress\"\n >\n <ProgramProgressCircle inProgress={inProgress} remaining={remaining} completed={completed} />\n <h6 className=\"progress-heading-circle my-5\">\n {formatMessage(messages.programProgressCertificateLabel)}\n </h6>\n {type.trim().toLowerCase()\n !== PROGRAM_TYPE_MAP.MICROMASTERS.toLowerCase() && (\n <div className=\"progress-certificate-content pt-3 px-3\">\n <p className=\"text-gray-800\">\n {formatMessage(messages.programProgressCertificateContentOne, {\n programType: programType,\n })}\n </p>\n {price && (\n <p className=\"text-gray-800\">\n {formatMessage(messages.programProgressCertificateContentTwo, {\n price,\n })}\n </p>\n )}\n </div>\n )}\n </div>\n );\n};\n"]}
|
package/dist/routes.js
CHANGED
|
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { authenticatedLoader, getAuthenticatedHttpClient
|
|
11
|
-
import {
|
|
10
|
+
import { authenticatedLoader, getAuthenticatedHttpClient } from '@openedx/frontend-base';
|
|
11
|
+
import { subscriptionDashboardRole, subscriptionDashboardUrlPath, subscriptionProgramProgressRole } from './constants';
|
|
12
12
|
import { getSubsInitApiUrl } from './data/services/subs/urls';
|
|
13
13
|
import { redirect } from 'react-router-dom';
|
|
14
14
|
import { setCommonTrackingProps, mapSubsInitToTrackingProps } from './tracking';
|
|
@@ -16,7 +16,7 @@ import { setCommonTrackingProps, mapSubsInitToTrackingProps } from './tracking';
|
|
|
16
16
|
const subscriptionAccessLoader = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
18
|
const { data } = yield getAuthenticatedHttpClient().get(getSubsInitApiUrl());
|
|
19
|
-
if (!(data === null || data === void 0 ? void 0 : data.userSubscription) || !data.userSubscription.isSubscriber || !
|
|
19
|
+
if (!(data === null || data === void 0 ? void 0 : data.userSubscription) || !data.userSubscription.isSubscriber || !data.subscriptionEnabled) {
|
|
20
20
|
throw redirect('/learner-dashboard'); //redirect to learner dashboard if user does not have subscription access
|
|
21
21
|
}
|
|
22
22
|
setCommonTrackingProps(mapSubsInitToTrackingProps(data));
|
package/dist/routes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.jsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.jsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AACvH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAA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AO,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;YACvC,CAAC;SAAA;KACF;IACD;QACE,EAAE,EAAE,6DAA6D;QACjE,IAAI,EAAE,sCAAsC;QAC5C,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE;YACN,IAAI,EAAE,+BAA+B;SACtC;QACK,IAAI;;gBACR,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qDAAqD,CAAC,CAAC;gBACnF,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;YACvC,CAAC;SAAA;KACF;CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { authenticatedLoader, getAuthenticatedHttpClient } from '@openedx/frontend-base';\n\nimport { subscriptionDashboardRole, subscriptionDashboardUrlPath, subscriptionProgramProgressRole } from './constants';\nimport { getSubsInitApiUrl } from './data/services/subs/urls';\nimport { redirect } from 'react-router-dom';\nimport { setCommonTrackingProps, mapSubsInitToTrackingProps } from './tracking';\n\n// loader to check if the user has subscription access\nconst subscriptionAccessLoader = async () => {\n try {\n const { data } = await getAuthenticatedHttpClient().get(getSubsInitApiUrl());\n\n if (!data?.userSubscription || !data.userSubscription.isSubscriber || !data.subscriptionEnabled) {\n throw redirect('/learner-dashboard'); //redirect to learner dashboard if user does not have subscription access\n }\n \n setCommonTrackingProps(mapSubsInitToTrackingProps(data));\n return null;\n } catch (error) {\n // Let redirect responses bubble up\n if (error instanceof Response) {\n throw error;\n }\n\n throw redirect('/learner-dashboard'); // redirect to learner dashboard if an error occurs\n }\n};\n\n// composed loader that checks for authentication and subscription access\nconst protectedLoader = async (args) => {\n await authenticatedLoader(args);\n await subscriptionAccessLoader();\n\n return null;\n};\n\nconst routes = [\n {\n id: 'org.edx.frontend.route.subsLearnerDashboard.main',\n path: subscriptionDashboardUrlPath,\n loader: protectedLoader,\n handle: {\n role: subscriptionDashboardRole\n },\n async lazy () {\n const module = await import('./Main');\n return { Component: module.default };\n },\n },\n {\n id: 'org.edx.frontend.route.subsLearnerDashboard.programProgress',\n path: '/subscription-program-progress/:uuid',\n loader: protectedLoader,\n handle: {\n role: subscriptionProgramProgressRole\n },\n async lazy () {\n const module = await import('./containers/ProgramDashboard/ProgramProgress/index');\n return { Component: module.default };\n },\n }\n];\n\nexport default routes;\n"]}
|