@edx/frontend-app-subscription-learner-dashboard 1.70.2 → 1.72.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/constants.js
CHANGED
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,2CAA2C,CAAC;AAEjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,yFAAyF;AACzF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAC5C,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAgB,SAAS,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAgB,QAAQ,CAAC;AAEzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,sCAAsC,CAAC;AAEhF,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E,MAAM,CAAC,MAAM,+BAA+B,GAAG,4CAA4C,CAAC;AAE5F,MAAM,CAAC,MAAM,4BAA4B,GAAG,iCAAiC,CAAC;AAE9E,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,gBAAgB;IAChB,WAAW;IACX,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,WAAW;IACX,OAAO;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,2CAA2C,CAAC;AAEjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,yFAAyF;AACzF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAC5C,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAgB,SAAS,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAgB,QAAQ,CAAC;AAEzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,sCAAsC,CAAC;AAEhF,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E,MAAM,CAAC,MAAM,+BAA+B,GAAG,4CAA4C,CAAC;AAE5F,MAAM,CAAC,MAAM,4BAA4B,GAAG,iCAAiC,CAAC;AAE9E,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,gBAAgB;IAChB,WAAW;IACX,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,WAAW;IACX,OAAO;IACP,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC","sourcesContent":["import { ProductType } from './types/types';\n\nexport const appId = 'org.openedx.frontend.app.learnerDashboard';\n\nexport const HITS_PER_PAGE_PROGRAMS = 4;\nexport const HITS_PER_PAGE_COURSES = 4;\n\n/** Facet attribute names in ALGOLIA_PRODUCT_INDEX_NAME — update if your index differs */\nexport const FACET_PRODUCT_TYPE = 'product';\nexport const FACET_SUBJECTS = 'subjects';\n\nexport const PRODUCT_TYPE_PROGRAM: ProductType = 'program';\nexport const PRODUCT_TYPE_COURSE: ProductType = 'course';\n\nexport const subscriptionDashboardRole = 'org.edx.frontend.subs.role.dashboard';\n\nexport const subscriptionSignoutRole = 'org.openedx.frontend.role.signOut';\n\nexport const subscriptionAccountRole = 'org.openedx.frontend.role.account';\n\nexport const subscriptionProfileRole = 'org.openedx.frontend.role.profile';\n\nexport const subscriptionProgramProgressRole = 'org.edx.frontend.subs.role.programProgress';\n\nexport const subscriptionDashboardUrlPath = '/subscription-learner-dashboard';\n\nexport const SUBSCRIPTION_ROUTE_PREFIXES = [\n '/subscription-',\n '/checkout',\n '/order-history',\n];\n\nexport const NON_SUBSCRIPTION_ROUTE_PREFIXES = [\n '/learner-',\n '/aca-',\n '/order-history'\n];\n\nexport const learnerDashboardUrlPath = '/learner-dashboard';\n"]}
|
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useEffect, useState, useCallback } from 'react';
|
|
3
3
|
import { Hyperlink, Image } from '@openedx/paragon';
|
|
4
|
-
import { getSiteConfig, useSiteEvent } from '@openedx/frontend-base';
|
|
4
|
+
import { getAuthenticatedHttpClient, getSiteConfig, useSiteEvent } from '@openedx/frontend-base';
|
|
5
5
|
import { useLocation } from 'react-router-dom';
|
|
6
6
|
import { NON_SUBSCRIPTION_ROUTE_PREFIXES } from '../../constants';
|
|
7
|
+
import { getSubsInitApiUrl } from '../../data/services/subs/urls';
|
|
7
8
|
import edxPlus from '../../assets/edxPlus.svg';
|
|
8
9
|
import { createEventTracker } from '../../data/services/segment/utils';
|
|
9
10
|
import eventNames, { categories } from '../../tracking/constants';
|
|
10
|
-
import { getCommonTrackingProps } from '../../tracking';
|
|
11
|
+
import { getCommonTrackingProps, mapSubsInitToTrackingProps, setCommonTrackingProps } from '../../tracking';
|
|
11
12
|
import edXLogo from '../../assets/edXLogo.png';
|
|
12
13
|
const CHECKOUT_PAYMENT_STATE_CHANGED = 'org.openedx.frontend.event.subscriptionCheckout.paymentStateChanged.v1';
|
|
13
14
|
const SiteLogo = () => {
|
|
14
15
|
const siteConfig = getSiteConfig();
|
|
15
16
|
const { pathname } = useLocation();
|
|
16
17
|
const [isPaid, setIsPaid] = useState(false);
|
|
18
|
+
const [isSubscriber, setIsSubscriber] = useState(getCommonTrackingProps().isSubscriber);
|
|
19
|
+
// Loaders only populate tracking props on subscription routes, so the shared header fetches them.
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (isSubscriber !== undefined) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
let active = true;
|
|
25
|
+
getAuthenticatedHttpClient().get(getSubsInitApiUrl())
|
|
26
|
+
.then(({ data }) => {
|
|
27
|
+
var _a;
|
|
28
|
+
if (!active)
|
|
29
|
+
return;
|
|
30
|
+
setCommonTrackingProps(mapSubsInitToTrackingProps(data));
|
|
31
|
+
setIsSubscriber(((_a = data === null || data === void 0 ? void 0 : data.userSubscription) === null || _a === void 0 ? void 0 : _a.isSubscriber) === true);
|
|
32
|
+
})
|
|
33
|
+
.catch(() => {
|
|
34
|
+
if (active)
|
|
35
|
+
setIsSubscriber(false);
|
|
36
|
+
});
|
|
37
|
+
return () => {
|
|
38
|
+
active = false;
|
|
39
|
+
};
|
|
40
|
+
}, [isSubscriber]);
|
|
17
41
|
const handlePaymentStateChanged = useCallback((_topic, data) => {
|
|
18
42
|
setIsPaid((data === null || data === void 0 ? void 0 : data.isPaid) === true);
|
|
19
43
|
}, []);
|
|
20
44
|
useSiteEvent(CHECKOUT_PAYMENT_STATE_CHANGED, handlePaymentStateChanged);
|
|
21
|
-
const { isSubscriber } = getCommonTrackingProps();
|
|
22
45
|
const dest = isSubscriber ? `${siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.baseUrl}/subscription-learner-dashboard` : `${siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.baseUrl}/learner-dashboard`;
|
|
23
46
|
const handleLogoClick = () => {
|
|
24
47
|
createEventTracker(eventNames.headerLogoClicked, { category: categories.header, label: dest })();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SiteLogo.js","sourceRoot":"","sources":["../../../src/widgets/LearnerDashboardHeader/SiteLogo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SiteLogo.js","sourceRoot":"","sources":["../../../src/widgets/LearnerDashboardHeader/SiteLogo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,UAAU,EAAE,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC3G,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAE/C,MAAM,8BAA8B,GAAG,wEAAwE,CAAC;AAEhH,MAAM,QAAQ,GAAO,GAAG,EAAE;IACxB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;IACnC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,YAAY,EAAE,e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oBAAoB,CAAC;IAEjI,MAAM,eAAe,GAAG,GAAG,EAAE;QAC3B,kBAAkB,CAChB,UAAU,CAAC,iBAAiB,EAC5B,EAAE,QAAQ,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAC7C,EAAE,CAAC;IACN,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,sBAAsB,GAAG,+BAA+B,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3G,MAAM,WAAW,GACb,CAAC,YAAY;WACV,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC;WACvB,CAAC,UAAU,IAAI,sBAAsB,CAAC,CAAC;IAE9C,OAAO,CACL,KAAC,SAAS,IAAC,WAAW,EAAE,IAAI,EAAE,SAAS,EAAC,KAAK,EAAC,OAAO,EAAE,eAAe,YACpE,mBAAS,SAAS,EAAC,WAAW,aAE5B,iBAAQ,KAAK,EAAC,qBAAqB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAI,EAC/E,iBAAQ,KAAK,EAAC,oBAAoB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAI,EAE9E,KAAC,KAAK,IAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAI,IACrE,GACA,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FC, useEffect, useState, useCallback } from 'react';\nimport { Hyperlink, Image } from '@openedx/paragon';\nimport { getAuthenticatedHttpClient, getSiteConfig, useSiteEvent } from '@openedx/frontend-base';\nimport { useLocation } from 'react-router-dom';\nimport { NON_SUBSCRIPTION_ROUTE_PREFIXES } from '@src/constants';\nimport { getSubsInitApiUrl } from '@src/data/services/subs/urls';\n\nimport edxPlus from '../../assets/edxPlus.svg';\nimport { createEventTracker } from '@src/data/services/segment/utils';\nimport eventNames, { categories } from '@src/tracking/constants';\nimport { getCommonTrackingProps, mapSubsInitToTrackingProps, setCommonTrackingProps } from '@src/tracking';\nimport edXLogo from '../../assets/edXLogo.png';\n\nconst CHECKOUT_PAYMENT_STATE_CHANGED = 'org.openedx.frontend.event.subscriptionCheckout.paymentStateChanged.v1';\n\nconst SiteLogo: FC = () => {\n const siteConfig = getSiteConfig();\n\n const { pathname } = useLocation();\n const [isPaid, setIsPaid] = useState(false);\n const [isSubscriber, setIsSubscriber] = useState<boolean | undefined>(getCommonTrackingProps().isSubscriber);\n\n // Loaders only populate tracking props on subscription routes, so the shared header fetches them.\n useEffect(() => {\n if (isSubscriber !== undefined) {\n return undefined;\n }\n let active = true;\n getAuthenticatedHttpClient().get(getSubsInitApiUrl())\n .then(({ data }) => {\n if (!active) return;\n setCommonTrackingProps(mapSubsInitToTrackingProps(data));\n setIsSubscriber(data?.userSubscription?.isSubscriber === true);\n })\n .catch(() => {\n if (active) setIsSubscriber(false);\n });\n return () => {\n active = false;\n };\n }, [isSubscriber]);\n\n const handlePaymentStateChanged = useCallback(\n (_topic: string, data?: { isPaid: boolean }) => {\n setIsPaid(data?.isPaid === true);\n }, []);\n\n useSiteEvent(CHECKOUT_PAYMENT_STATE_CHANGED, handlePaymentStateChanged);\n\n const dest = isSubscriber ? `${siteConfig?.baseUrl}/subscription-learner-dashboard` : `${siteConfig?.baseUrl}/learner-dashboard`;\n\n const handleLogoClick = () => {\n createEventTracker(\n eventNames.headerLogoClicked,\n { category: categories.header, label: dest }\n )();\n };\n\n const isCheckout = pathname.startsWith('/checkout');\n const isNonSubscriptionRoute = NON_SUBSCRIPTION_ROUTE_PREFIXES.some(prefix => pathname.startsWith(prefix));\n const showEdxLogo\n = !isSubscriber\n && !(isCheckout && isPaid)\n && (isCheckout || isNonSubscriptionRoute);\n\n return (\n <Hyperlink destination={dest} className=\"p-0\" onClick={handleLogoClick}>\n <picture className=\"site-logo\">\n {/* Desktop: adjust min-width values to your breakpoints */}\n <source media=\"(min-width: 1024px)\" srcSet={showEdxLogo ? edXLogo : edxPlus} />\n <source media=\"(min-width: 768px)\" srcSet={showEdxLogo ? edXLogo : edxPlus} />\n {/* fallback/mobile */}\n <Image src={showEdxLogo ? edXLogo : edxPlus} style={{ maxHeight: '2rem' }} />\n </picture>\n </Hyperlink>\n );\n};\n\nexport default SiteLogo;\n"]}
|