@edx/frontend-app-alacarte-checkout 1.32.0 → 1.34.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/assets/after.svg +3 -0
- package/dist/checkoutPage/CheckoutPage.js +2 -1
- package/dist/checkoutPage/CheckoutPage.js.map +1 -1
- package/dist/components/CheckoutGate/CheckoutGate.d.ts +3 -1
- package/dist/components/CheckoutGate/CheckoutGate.js +2 -1
- package/dist/components/CheckoutGate/CheckoutGate.js.map +1 -1
- package/dist/components/OrderHistory/OrderHistoryCard.d.ts +10 -0
- package/dist/components/OrderHistory/OrderHistoryCard.js +6 -0
- package/dist/components/OrderHistory/OrderHistoryCard.js.map +1 -0
- package/dist/components/OrderHistory/OrderHistoryTabDetails/CoursePayments.js +2 -1
- package/dist/components/OrderHistory/OrderHistoryTabDetails/CoursePayments.js.map +1 -1
- package/dist/components/OrderHistory/OrderList.d.ts +2 -0
- package/dist/components/OrderHistory/OrderList.js +44 -0
- package/dist/components/OrderHistory/OrderList.js.map +1 -0
- package/dist/data/hooks/useCheckoutGate.d.ts +17 -5
- package/dist/data/hooks/useCheckoutGate.js +47 -22
- package/dist/data/hooks/useCheckoutGate.js.map +1 -1
- package/dist/data/hooks/useCheckoutQueries.d.ts +6 -0
- package/dist/data/hooks/useCheckoutQueries.js +22 -1
- package/dist/data/hooks/useCheckoutQueries.js.map +1 -1
- package/dist/styles/components/orderHistory.scss +11 -0
- package/dist/utils/alacarteApi.d.ts +11 -0
- package/dist/utils/alacarteApi.js +59 -3
- package/dist/utils/alacarteApi.js.map +1 -1
- package/dist/utils/alacarteQueries.d.ts +3 -0
- package/dist/utils/alacarteQueries.js +11 -0
- package/dist/utils/alacarteQueries.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M15.8333 15.8333H4.16667V4.16667H10V2.5H2.5V17.5H17.5V10H15.8333V15.8333ZM11.6667 2.5V4.16667H14.6583L6.46667 12.3583L7.64167 13.5333L15.8333 5.34167V8.33333H17.5V2.5H11.6667Z" fill="#00262B"/>
|
|
3
|
+
</svg>
|
|
@@ -14,6 +14,7 @@ const CheckoutPage = () => {
|
|
|
14
14
|
const apiUrl = config.VIAX_API_URL;
|
|
15
15
|
const isDevelopment = siteConfig.environment === 'development';
|
|
16
16
|
const disableComplianceCheck = config.DISABLE_COMPLIANCE_CHECK === true;
|
|
17
|
+
const restrictCompliance = config.RESTRICT_COMPLIANCE === true;
|
|
17
18
|
const skipSubscriptionCourseRuns = config.SKIP_SUBSCRIPTION_COURSE_RUNS === true;
|
|
18
19
|
const edxSessionUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/edx-session`;
|
|
19
20
|
const geolocationUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/geolocation/lookup`;
|
|
@@ -23,7 +24,7 @@ const CheckoutPage = () => {
|
|
|
23
24
|
if (!stripePublishableKey || !apiUrl || !edxSessionUrl) {
|
|
24
25
|
return (_jsx(PageWrapper, { children: _jsxs(Alert, { variant: "danger", children: ["We're having trouble loading the checkout. Please refresh the page or try again in a few moments. If the problem persists,", ' ', _jsx("a", { href: "https://courses.edx.org/support/contact_us", children: "contact support" }), "."] }) }));
|
|
25
26
|
}
|
|
26
|
-
return (_jsx(PageWrapper, { children: _jsx(CheckoutGate, { stripePublishableKey: stripePublishableKey, paypalClientId: paypalClientId, apiUrl: apiUrl, edxSessionUrl: edxSessionUrl, geolocationUrl: geolocationUrl, complianceCheckUrl: complianceCheckUrl, disableComplianceCheck: disableComplianceCheck, skipSubscriptionCourseRuns: skipSubscriptionCourseRuns, learnerDashboardUrl: `${LMS_BASE_URL}/dashboard`, homeUrl: LMS_BASE_URL || '/', onComplete: (_subscriptionBiId) => {
|
|
27
|
+
return (_jsx(PageWrapper, { children: _jsx(CheckoutGate, { stripePublishableKey: stripePublishableKey, paypalClientId: paypalClientId, apiUrl: apiUrl, edxSessionUrl: edxSessionUrl, geolocationUrl: geolocationUrl, complianceCheckUrl: complianceCheckUrl, disableComplianceCheck: disableComplianceCheck, restrictCompliance: restrictCompliance, skipSubscriptionCourseRuns: skipSubscriptionCourseRuns, learnerDashboardUrl: `${LMS_BASE_URL}/dashboard`, homeUrl: LMS_BASE_URL || '/', onComplete: (_subscriptionBiId) => {
|
|
27
28
|
console.log(_subscriptionBiId);
|
|
28
29
|
// window.location.href = `/checkout/confirmation?sub=${_subscriptionBiId ?? ''}`;
|
|
29
30
|
// Success screen.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutPage.js","sourceRoot":"","sources":["../../src/checkoutPage/CheckoutPage.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,YAAY,MAAM,yCAAyC,CAAC;AAEnE,MAAM,WAAW,GAA4C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC7E,KAAC,SAAS,cAAE,QAAQ,GAAa,CAClC,CAAC;AAEF,MAAM,YAAY,GAAa,GAAG,EAAE;IAClC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,oBAAoB,GAAG,MAAM,CAAC,iBAA2B,CAAC;IAChE,kEAAkE;IAClE,MAAM,cAAc,GAAI,MAAM,CAAC,gBAAuC,IAAI,SAAS,CAAC;IACpF,MAAM,MAAM,GAA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,CAAC,CAAC;gBAC/B,kFAAkF;gBAClF,kBAAkB;YACpB,CAAC,GACD,GACU,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import React from 'react';\nimport { Alert, Container } from '@openedx/paragon';\nimport { getAppConfig, getSiteConfig } from '@openedx/frontend-base';\nimport { appId } from '@src/constants';\nimport CheckoutGate from '../components/CheckoutGate/CheckoutGate';\n\nconst PageWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <Container>{children}</Container>\n);\n\nconst CheckoutPage: React.FC = () => {\n const config = getAppConfig(appId);\n const siteConfig = getSiteConfig();\n const LMS_BASE_URL = siteConfig.lmsBaseUrl.replace(/\\/$/, '');\n const stripePublishableKey = config.STRIPE_PUBLIC_KEY as string;\n // Optional — the PayPal express button stays disabled without it.\n const paypalClientId = (config.PAYPAL_CLIENT_ID as string | undefined) || undefined;\n const apiUrl = config.VIAX_API_URL as string;\n const isDevelopment = siteConfig.environment === 'development';\n const disableComplianceCheck = config.DISABLE_COMPLIANCE_CHECK === true;\n const skipSubscriptionCourseRuns = config.SKIP_SUBSCRIPTION_COURSE_RUNS === true;\n const edxSessionUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/edx-session`;\n const geolocationUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/geolocation/lookup`;\n const complianceCheckUrl = disableComplianceCheck\n ? undefined\n : `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/compliance-check`;\n\n if (!stripePublishableKey || !apiUrl || !edxSessionUrl) {\n return (\n <PageWrapper>\n <Alert variant=\"danger\">\n We're having trouble loading the checkout. Please refresh the\n page or try again in a few moments. If the problem persists,{' '}\n <a href=\"https://courses.edx.org/support/contact_us\">\n contact support\n </a>\n .\n </Alert>\n </PageWrapper>\n );\n }\n\n return (\n <PageWrapper>\n <CheckoutGate\n stripePublishableKey={stripePublishableKey}\n paypalClientId={paypalClientId}\n apiUrl={apiUrl}\n edxSessionUrl={edxSessionUrl}\n geolocationUrl={geolocationUrl}\n complianceCheckUrl={complianceCheckUrl}\n disableComplianceCheck={disableComplianceCheck}\n skipSubscriptionCourseRuns={skipSubscriptionCourseRuns}\n learnerDashboardUrl={`${LMS_BASE_URL}/dashboard`}\n homeUrl={LMS_BASE_URL || '/'}\n onComplete={(_subscriptionBiId) => {\n console.log(_subscriptionBiId);\n // window.location.href = `/checkout/confirmation?sub=${_subscriptionBiId ?? ''}`;\n // Success screen.\n }}\n />\n </PageWrapper>\n );\n};\n\nexport default CheckoutPage;\n"]}
|
|
1
|
+
{"version":3,"file":"CheckoutPage.js","sourceRoot":"","sources":["../../src/checkoutPage/CheckoutPage.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,YAAY,MAAM,yCAAyC,CAAC;AAEnE,MAAM,WAAW,GAA4C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC7E,KAAC,SAAS,cAAE,QAAQ,GAAa,CAClC,CAAC;AAEF,MAAM,YAAY,GAAa,GAAG,EAAE;IAClC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,oBAAoB,GAAG,MAAM,CAAC,iBAA2B,CAAC;IAChE,kEAAkE;IAClE,MAAM,cAAc,GAAI,MAAM,CAAC,gBAAuC,IAAI,SAAS,CAAC;IACpF,MAAM,MAAM,GAAG,MAAM,CAAC,YAAsB,CAAC;IAC7C,MAAM,aAAa,GAA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EAAE;gBAChC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBAC/B,kFAAkF;gBAClF,kBAAkB;YACpB,CAAC,GACD,GACU,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import React from 'react';\nimport { Alert, Container } from '@openedx/paragon';\nimport { getAppConfig, getSiteConfig } from '@openedx/frontend-base';\nimport { appId } from '@src/constants';\nimport CheckoutGate from '../components/CheckoutGate/CheckoutGate';\n\nconst PageWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <Container>{children}</Container>\n);\n\nconst CheckoutPage: React.FC = () => {\n const config = getAppConfig(appId);\n const siteConfig = getSiteConfig();\n const LMS_BASE_URL = siteConfig.lmsBaseUrl.replace(/\\/$/, '');\n const stripePublishableKey = config.STRIPE_PUBLIC_KEY as string;\n // Optional — the PayPal express button stays disabled without it.\n const paypalClientId = (config.PAYPAL_CLIENT_ID as string | undefined) || undefined;\n const apiUrl = config.VIAX_API_URL as string;\n const isDevelopment = siteConfig.environment === 'development';\n const disableComplianceCheck = config.DISABLE_COMPLIANCE_CHECK === true;\n const restrictCompliance = config.RESTRICT_COMPLIANCE === true;\n const skipSubscriptionCourseRuns = config.SKIP_SUBSCRIPTION_COURSE_RUNS === true;\n const edxSessionUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/edx-session`;\n const geolocationUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/geolocation/lookup`;\n const complianceCheckUrl = disableComplianceCheck\n ? undefined\n : `${isDevelopment ? 'https://courses.stage.edx.org' : LMS_BASE_URL}/api/compliance-check`;\n\n if (!stripePublishableKey || !apiUrl || !edxSessionUrl) {\n return (\n <PageWrapper>\n <Alert variant=\"danger\">\n We're having trouble loading the checkout. Please refresh the\n page or try again in a few moments. If the problem persists,{' '}\n <a href=\"https://courses.edx.org/support/contact_us\">\n contact support\n </a>\n .\n </Alert>\n </PageWrapper>\n );\n }\n\n return (\n <PageWrapper>\n <CheckoutGate\n stripePublishableKey={stripePublishableKey}\n paypalClientId={paypalClientId}\n apiUrl={apiUrl}\n edxSessionUrl={edxSessionUrl}\n geolocationUrl={geolocationUrl}\n complianceCheckUrl={complianceCheckUrl}\n disableComplianceCheck={disableComplianceCheck}\n restrictCompliance={restrictCompliance}\n skipSubscriptionCourseRuns={skipSubscriptionCourseRuns}\n learnerDashboardUrl={`${LMS_BASE_URL}/dashboard`}\n homeUrl={LMS_BASE_URL || '/'}\n onComplete={(_subscriptionBiId) => {\n console.log(_subscriptionBiId);\n // window.location.href = `/checkout/confirmation?sub=${_subscriptionBiId ?? ''}`;\n // Success screen.\n }}\n />\n </PageWrapper>\n );\n};\n\nexport default CheckoutPage;\n"]}
|
|
@@ -8,6 +8,8 @@ export interface CheckoutGateProps extends CheckoutProps {
|
|
|
8
8
|
complianceCheckUrl?: string;
|
|
9
9
|
/** When true, skip the compliance-check request. */
|
|
10
10
|
disableComplianceCheck?: boolean;
|
|
11
|
+
/** When true, skip the compliance-check request and show the blocked modal. */
|
|
12
|
+
restrictCompliance?: boolean;
|
|
11
13
|
}
|
|
12
|
-
declare const CheckoutGate: ({ learnerDashboardUrl, homeUrl, complianceCheckUrl, disableComplianceCheck, ...checkoutProps }: CheckoutGateProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare const CheckoutGate: ({ learnerDashboardUrl, homeUrl, complianceCheckUrl, disableComplianceCheck, restrictCompliance, ...checkoutProps }: CheckoutGateProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
15
|
export default CheckoutGate;
|
|
@@ -18,7 +18,7 @@ import Checkout from '../Checkout/Checkout';
|
|
|
18
18
|
import CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';
|
|
19
19
|
import messages from './Messages';
|
|
20
20
|
const CheckoutGate = (_a) => {
|
|
21
|
-
var { learnerDashboardUrl, homeUrl = '/', complianceCheckUrl, disableComplianceCheck } = _a, checkoutProps = __rest(_a, ["learnerDashboardUrl", "homeUrl", "complianceCheckUrl", "disableComplianceCheck"]);
|
|
21
|
+
var { learnerDashboardUrl, homeUrl = '/', complianceCheckUrl, disableComplianceCheck, restrictCompliance } = _a, checkoutProps = __rest(_a, ["learnerDashboardUrl", "homeUrl", "complianceCheckUrl", "disableComplianceCheck", "restrictCompliance"]);
|
|
22
22
|
const { formatMessage } = useIntl();
|
|
23
23
|
const { gateStatus, userCountry, gateMessage } = useCheckoutGate({
|
|
24
24
|
apiUrl: checkoutProps.apiUrl,
|
|
@@ -26,6 +26,7 @@ const CheckoutGate = (_a) => {
|
|
|
26
26
|
geolocationUrl: checkoutProps.geolocationUrl,
|
|
27
27
|
complianceCheckUrl,
|
|
28
28
|
disableComplianceCheck,
|
|
29
|
+
restrictCompliance,
|
|
29
30
|
learnerDashboardUrl,
|
|
30
31
|
});
|
|
31
32
|
if (gateStatus === 'loading') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutGate.js","sourceRoot":"","sources":["../../../src/components/CheckoutGate/CheckoutGate.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAEzF,OAAO,QAAQ,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"CheckoutGate.js","sourceRoot":"","sources":["../../../src/components/CheckoutGate/CheckoutGate.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OA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tB,YAAG,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAC,YAAY,6CAEhD,CACL,IACK,CACT,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CACL,4BACE,KAAC,uBAAuB,IAAC,MAAM,QAAC,OAAO,EAAE,OAAO,GAAI,GACnD,CACJ,CAAC;IACJ,CAAC;IACD,OAAO,CACL,KAAC,QAAQ,oBACH,aAAa,IACjB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAC,oBAAoB,IACpC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { Alert, Spinner } from '@openedx/paragon';\nimport { Error as ErrorIcon } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { useCheckoutGate } from '../../data/hooks/useCheckoutGate';\nimport Checkout from '../Checkout/Checkout';\nimport CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport type { CheckoutProps } from '../Checkout/Checkout';\nimport messages from './Messages';\n\nexport interface CheckoutGateProps extends CheckoutProps {\n /** URL linked in session-error recovery messaging. */\n learnerDashboardUrl?: string,\n /** Homepage URL for the country-unavailable modal CTA. */\n homeUrl?: string,\n /** ALC-307 compliance-check endpoint — decides whether the learner is embargoed. */\n complianceCheckUrl?: string,\n /** When true, skip the compliance-check request. */\n disableComplianceCheck?: boolean,\n /** When true, skip the compliance-check request and show the blocked modal. */\n restrictCompliance?: boolean,\n}\n\nconst CheckoutGate = ({\n learnerDashboardUrl,\n homeUrl = '/',\n complianceCheckUrl,\n disableComplianceCheck,\n restrictCompliance,\n ...checkoutProps\n}: CheckoutGateProps) => {\n const { formatMessage } = useIntl();\n const { gateStatus, userCountry, gateMessage } = useCheckoutGate({\n apiUrl: checkoutProps.apiUrl,\n edxSessionUrl: checkoutProps.edxSessionUrl,\n geolocationUrl: checkoutProps.geolocationUrl,\n complianceCheckUrl,\n disableComplianceCheck,\n restrictCompliance,\n learnerDashboardUrl,\n });\n\n if (gateStatus === 'loading') {\n return (\n <div className=\"processing-screen\" role=\"status\" aria-live=\"polite\">\n <Spinner animation=\"border\" screenReaderText=\"Checking your account…\" />\n </div>\n );\n }\n\n if (gateStatus === 'error') {\n return (\n <Alert variant=\"danger\" icon={ErrorIcon}>\n {gateMessage\n ?? formatMessage(messages.defaultErrorMessage)}{' '}\n {learnerDashboardUrl && (\n <a href={learnerDashboardUrl} className=\"alert-link\">\n Go to your learner dashboard\n </a>\n )}\n </Alert>\n );\n }\n\n if (gateStatus === 'blocked') {\n return (\n <>\n <CountryUnavailableModal isOpen homeUrl={homeUrl} />\n </>\n );\n }\n return (\n <Checkout\n {...checkoutProps}\n userCountry={userCountry}\n homeUrl={homeUrl}\n orderHistoryUrl=\"/aca-order-history\"\n />\n );\n};\n\nexport default CheckoutGate;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface OrderCardProps {
|
|
2
|
+
title: string;
|
|
3
|
+
purchaseDate: string;
|
|
4
|
+
totalCost: string;
|
|
5
|
+
orderNumber: string;
|
|
6
|
+
onViewReceipt: () => void;
|
|
7
|
+
onViewOrderDetails: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const OrderHistoryCard: ({ title, purchaseDate, totalCost, orderNumber, onViewReceipt, onViewOrderDetails, }: OrderCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default OrderHistoryCard;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, Button } from '@openedx/paragon';
|
|
3
|
+
import after from '../../assets/after.svg';
|
|
4
|
+
const OrderHistoryCard = ({ title, purchaseDate, totalCost, orderNumber, onViewReceipt, onViewOrderDetails, }) => (_jsx(Card, { className: "order-card", children: _jsx(Card.Body, { className: "p-3", children: _jsxs("div", { className: "d-flex justify-content-between align-items-start flex-wrap", children: [_jsxs("div", { children: [_jsx("h6", { className: "mb-2", children: title }), _jsxs("div", { className: "small", children: [_jsxs("div", { className: "d-flex mb-1", children: [_jsx("span", { className: "text-muted orderHistoryCard__details mr-3", children: "Date of purchase:" }), _jsx("span", { children: purchaseDate })] }), _jsxs("div", { className: "d-flex mb-1", children: [_jsx("span", { className: "text-muted mr-3 orderHistoryCard__details", children: "Total cost:" }), _jsx("span", { children: totalCost })] }), _jsxs("div", { className: "d-flex", children: [_jsx("span", { className: "text-muted mr-3 orderHistoryCard__details", children: "Order number:" }), _jsx("span", { children: orderNumber })] })] })] }), _jsxs("div", { className: "d-flex align-items-center gap-3 mt-auto", children: [_jsxs(Button, { variant: "link", size: "sm", onClick: onViewReceipt, className: "d-flex gap-1 p-0 orderHistoryCard__link", children: ["View receipt ", _jsx("img", { src: after, alt: "link" })] }), _jsx(Button, { variant: "link", size: "sm", onClick: onViewOrderDetails, className: "p-0 orderHistoryCard__link", children: "View order details" })] })] }) }) }));
|
|
5
|
+
export default OrderHistoryCard;
|
|
6
|
+
//# sourceMappingURL=OrderHistoryCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderHistoryCard.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderHistoryCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,MAAM,wBAAwB,CAAC;AAW3C,MAAM,gBAAgB,GAAG,CAAC,EACxB,KAAK,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,aAAa,EACb,kBAAkB,GACH,EAAE,EAAE,CAAC,CACpB,KAAC,IAAI,IAAC,SAAS,EAAC,YAAY,YAC1B,KAAC,IAAI,CAAC,IAAI,IAAC,SAAS,EAAC,KAAK,YACxB,eAAK,SAAS,EAAC,4DAA4D,aACzE,0BACE,aAAI,SAAS,EAAC,MAAM,YAAE,KAAK,GAAM,EAEjC,eAAK,SAAS,EAAC,OAAO,aACpB,eAAK,SAAS,EAAC,aAAa,aAC1B,eAAM,SAAS,EAAC,2CAA2C,kCAAyB,EACpF,yBAAO,YAAY,GAAQ,IACvB,EAEN,eAAK,SAAS,EAAC,aAAa,aAC1B,eAAM,SAAS,EAAC,2CAA2C,4BAAmB,EAC9E,yBAAO,SAAS,GAAQ,IACpB,EAEN,eAAK,SAAS,EAAC,QAAQ,aACrB,eAAM,SAAS,EAAC,2CAA2C,8BAAqB,EAChF,yBAAO,WAAW,GAAQ,IACtB,IACF,IACF,EAEN,eAAK,SAAS,EAAC,yCAAyC,aACtD,MAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,aAAa,EACtB,SAAS,EAAC,yCAAyC,8BAEtC,cAAK,GAAG,EAAE,KAAK,EAAE,GAAG,EAAC,MAAM,GAAG,IACpC,EAET,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAC,4BAA4B,mCAG/B,IACL,IACF,GACI,GACP,CACR,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { Card, Button } from '@openedx/paragon';\nimport after from '../../assets/after.svg';\n\ninterface OrderCardProps {\n title: string,\n purchaseDate: string,\n totalCost: string,\n orderNumber: string,\n onViewReceipt: () => void,\n onViewOrderDetails: () => void,\n}\n\nconst OrderHistoryCard = ({\n title,\n purchaseDate,\n totalCost,\n orderNumber,\n onViewReceipt,\n onViewOrderDetails,\n}: OrderCardProps) => (\n <Card className=\"order-card\">\n <Card.Body className=\"p-3\">\n <div className=\"d-flex justify-content-between align-items-start flex-wrap\">\n <div>\n <h6 className=\"mb-2\">{title}</h6>\n\n <div className=\"small\">\n <div className=\"d-flex mb-1\">\n <span className=\"text-muted orderHistoryCard__details mr-3\">Date of purchase:</span>\n <span>{purchaseDate}</span>\n </div>\n\n <div className=\"d-flex mb-1\">\n <span className=\"text-muted mr-3 orderHistoryCard__details\">Total cost:</span>\n <span>{totalCost}</span>\n </div>\n\n <div className=\"d-flex\">\n <span className=\"text-muted mr-3 orderHistoryCard__details\">Order number:</span>\n <span>{orderNumber}</span>\n </div>\n </div>\n </div>\n\n <div className=\"d-flex align-items-center gap-3 mt-auto\">\n <Button\n variant=\"link\"\n size=\"sm\"\n onClick={onViewReceipt}\n className=\"d-flex gap-1 p-0 orderHistoryCard__link\"\n >\n View receipt <img src={after} alt=\"link\" />\n </Button>\n\n <Button\n variant=\"link\"\n size=\"sm\"\n onClick={onViewOrderDetails}\n className=\"p-0 orderHistoryCard__link\"\n >\n View order details\n </Button>\n </div>\n </div>\n </Card.Body>\n </Card>\n);\n\nexport default OrderHistoryCard;\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useIntl } from '@openedx/frontend-base';
|
|
3
3
|
import messages from './messages';
|
|
4
|
+
import OrdersList from '../OrderList';
|
|
4
5
|
const CoursePayments = () => {
|
|
5
6
|
const { formatMessage } = useIntl();
|
|
6
|
-
return (_jsxs("section", { className: "pt-4", "aria-labelledby": "course-payments-empty-heading", children: [_jsx("h2", { id: "course-payments-empty-heading", className: "h5 font-weight-bold text-primary-700 mb-1", children: formatMessage(messages.otherPurchasesTitle) }), _jsx("p", { className: "medium text-gray-700 mb-0", children: formatMessage(messages.coursePurchasesEmptyMessage) })] }));
|
|
7
|
+
return (_jsxs("section", { className: "pt-4", "aria-labelledby": "course-payments-empty-heading", children: [_jsxs("div", { className: "my-2 px-4", children: [_jsx("h2", { id: "course-payments-empty-heading", className: "h5 font-weight-bold text-primary-700 mb-1", children: formatMessage(messages.otherPurchasesTitle) }), _jsx("p", { className: "medium text-gray-700 mb-0", children: formatMessage(messages.coursePurchasesEmptyMessage) })] }), _jsx("div", { className: "mt-2", children: _jsx(OrdersList, {}) })] }));
|
|
7
8
|
};
|
|
8
9
|
export default CoursePayments;
|
|
9
10
|
//# sourceMappingURL=CoursePayments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoursePayments.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabDetails/CoursePayments.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"CoursePayments.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabDetails/CoursePayments.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,MAAM,cAAc,GAAa,GAAG,EAAE;IACpC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IAEpC,OAAO,CACL,mBAAS,SAAS,EAAC,MAAM,qBAAiB,+BAA+B,aACvE,eAAK,SAAS,EAAC,WAAW,aACxB,aAAI,EAAE,EAAC,+BAA+B,EAAC,SAAS,EAAC,2CAA2C,YACzF,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GACzC,EACL,YAAG,SAAS,EAAC,2BAA2B,YACrC,aAAa,CAAC,QAAQ,CAAC,2BAA2B,CAAC,GAClD,IACA,EACN,cAAK,SAAS,EAAC,MAAM,YACnB,KAAC,UAAU,KAAG,GACV,IACE,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import React from 'react';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from './messages';\nimport OrdersList from '../OrderList';\n\nconst CoursePayments: React.FC = () => {\n const { formatMessage } = useIntl();\n\n return (\n <section className=\"pt-4\" aria-labelledby=\"course-payments-empty-heading\">\n <div className=\"my-2 px-4\">\n <h2 id=\"course-payments-empty-heading\" className=\"h5 font-weight-bold text-primary-700 mb-1\">\n {formatMessage(messages.otherPurchasesTitle)}\n </h2>\n <p className=\"medium text-gray-700 mb-0\">\n {formatMessage(messages.coursePurchasesEmptyMessage)}\n </p>\n </div>\n <div className=\"mt-2\">\n <OrdersList />\n </div>\n </section>\n );\n};\n\nexport default CoursePayments;\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import OrderHistoryCard from './OrderHistoryCard';
|
|
3
|
+
const orders = [
|
|
4
|
+
{
|
|
5
|
+
orderId: 'BI0QZ4UAFLTYBCXC',
|
|
6
|
+
orderNumber: '2U-ORD-62638121',
|
|
7
|
+
purchasedAt: '2026-10-26T14:37:56.721Z',
|
|
8
|
+
paymentIntentId: 'pi_3UUp24EUxB2SCTmQ1LBPdo4n',
|
|
9
|
+
name: 'A Verified and Audi course or b2c testing 001',
|
|
10
|
+
total: {
|
|
11
|
+
amount: 90,
|
|
12
|
+
currency: 'USD',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
orderId: 'BI1RX5VBGMUZCDYD',
|
|
17
|
+
orderNumber: '2U-ORD-62638122',
|
|
18
|
+
purchasedAt: '2026-10-24T10:15:30.000Z',
|
|
19
|
+
paymentIntentId: 'pi_3UUp25EUxB2SCTmQ2LBPdo5p',
|
|
20
|
+
name: 'Harvard University CS50 Introduction to Computer Science',
|
|
21
|
+
total: {
|
|
22
|
+
amount: 219,
|
|
23
|
+
currency: 'USD',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
orderId: 'BI2SY6WCHNVAEZE',
|
|
28
|
+
orderNumber: '2U-ORD-62638123',
|
|
29
|
+
purchasedAt: '2026-10-20T08:45:12.000Z',
|
|
30
|
+
paymentIntentId: 'pi_3UUp26EUxB2SCTmQ3LBPdo6q',
|
|
31
|
+
name: 'Introduction to Python Programming',
|
|
32
|
+
total: {
|
|
33
|
+
amount: 49,
|
|
34
|
+
currency: 'USD',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
const OrdersList = () => (_jsx("div", { className: "px-4", children: orders.map((order) => (_jsx("div", { className: "mb-3", children: _jsx(OrderHistoryCard, { title: order.name, purchaseDate: new Date(order.purchasedAt).toLocaleDateString('en-US'), totalCost: `${order.total.currency === 'USD' ? '$' : ''}${order.total.amount.toFixed(2)} ${order.total.currency}`, orderNumber: order.orderNumber, onViewReceipt: () => {
|
|
39
|
+
console.log('View receipt:', order.paymentIntentId);
|
|
40
|
+
}, onViewOrderDetails: () => {
|
|
41
|
+
console.log('View order details:', order.orderId);
|
|
42
|
+
} }) }, order.orderId))) }));
|
|
43
|
+
export default OrdersList;
|
|
44
|
+
//# sourceMappingURL=OrderList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderList.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderList.tsx"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,GAAG;IACb;QACE,OAAO,EAAE,kBAAkB;QAC3B,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,0BAA0B;QACvC,eAAe,EAAE,6BAA6B;QAC9C,IAAI,EAAE,+CAA+C;QACrD,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,KAAK;SAChB;KACF;IACD;QACE,OAAO,EAAE,kBAAkB;QAC3B,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,0BAA0B;QACvC,eAAe,EAAE,6BAA6B;QAC9C,IAAI,EAAE,0DAA0D;QAChE,KAAK,EAAE;YACL,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,KAAK;SAChB;KACF;IACD;QACE,OAAO,EAAE,iBAAiB;QAC1B,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,0BAA0B;QACvC,eAAe,EAAE,6BAA6B;QAC9C,IAAI,EAAE,oCAAoC;QAC1C,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,KAAK;SAChB;KACF;CACF,CAAC;AAEF,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CACvB,cAAK,SAAS,EAAC,MAAM,YAClB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,cAAyB,SAAS,EAAC,MAAM,YACvC,KAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,CAAC,IAAI,EACjB,YAAY,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EACrE,SAAS,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,EACjH,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,aAAa,EAAE,GAAG,EAAE;gBAClB,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;YACtD,CAAC,EACD,kBAAkB,EAAE,GAAG,EAAE;gBACvB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACpD,CAAC,GACD,IAZM,KAAK,CAAC,OAAO,CAajB,CACP,CAAC,GACE,CACP,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import OrderHistoryCard from './OrderHistoryCard';\n\nconst orders = [\n {\n orderId: 'BI0QZ4UAFLTYBCXC',\n orderNumber: '2U-ORD-62638121',\n purchasedAt: '2026-10-26T14:37:56.721Z',\n paymentIntentId: 'pi_3UUp24EUxB2SCTmQ1LBPdo4n',\n name: 'A Verified and Audi course or b2c testing 001',\n total: {\n amount: 90,\n currency: 'USD',\n },\n },\n {\n orderId: 'BI1RX5VBGMUZCDYD',\n orderNumber: '2U-ORD-62638122',\n purchasedAt: '2026-10-24T10:15:30.000Z',\n paymentIntentId: 'pi_3UUp25EUxB2SCTmQ2LBPdo5p',\n name: 'Harvard University CS50 Introduction to Computer Science',\n total: {\n amount: 219,\n currency: 'USD',\n },\n },\n {\n orderId: 'BI2SY6WCHNVAEZE',\n orderNumber: '2U-ORD-62638123',\n purchasedAt: '2026-10-20T08:45:12.000Z',\n paymentIntentId: 'pi_3UUp26EUxB2SCTmQ3LBPdo6q',\n name: 'Introduction to Python Programming',\n total: {\n amount: 49,\n currency: 'USD',\n },\n },\n];\n\nconst OrdersList = () => (\n <div className=\"px-4\">\n {orders.map((order) => (\n <div key={order.orderId} className=\"mb-3\">\n <OrderHistoryCard\n title={order.name}\n purchaseDate={new Date(order.purchasedAt).toLocaleDateString('en-US')}\n totalCost={`${order.total.currency === 'USD' ? '$' : ''}${order.total.amount.toFixed(2)} ${order.total.currency}`}\n orderNumber={order.orderNumber}\n onViewReceipt={() => {\n console.log('View receipt:', order.paymentIntentId);\n }}\n onViewOrderDetails={() => {\n console.log('View order details:', order.orderId);\n }}\n />\n </div>\n ))}\n </div>\n);\n\nexport default OrdersList;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface UseCheckoutGateOptions {
|
|
2
|
-
/**
|
|
2
|
+
/** Viax GraphQL URL. Used to resolve a program's course run keys for compliance-check. */
|
|
3
3
|
apiUrl?: string;
|
|
4
4
|
edxSessionUrl?: string;
|
|
5
5
|
/** Endpoint used to resolve city/etc. for the learner's public IP. */
|
|
@@ -8,6 +8,11 @@ export interface UseCheckoutGateOptions {
|
|
|
8
8
|
complianceCheckUrl?: string;
|
|
9
9
|
/** When true, skip the compliance-check request and do not block on its result. */
|
|
10
10
|
disableComplianceCheck?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Dev-only. When true, skip the compliance-check request and treat the
|
|
13
|
+
* learner as restricted — the same outcome as `{ allowed: false }`.
|
|
14
|
+
*/
|
|
15
|
+
restrictCompliance?: boolean;
|
|
11
16
|
learnerDashboardUrl?: string;
|
|
12
17
|
}
|
|
13
18
|
export type GateStatus = 'loading' | 'blocked' | 'allowed' | 'error';
|
|
@@ -24,12 +29,19 @@ export interface UseCheckoutGateResult {
|
|
|
24
29
|
* Session + embargo compliance gate for à la carte checkout.
|
|
25
30
|
*
|
|
26
31
|
* Calls the ALC-307 compliance-check endpoint with the learner's identity,
|
|
27
|
-
* account-profile country, and public IP/city.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
32
|
+
* account-profile country, and public IP/city. For a course, course_ids is
|
|
33
|
+
* that course's run key. For a program, course_ids is the run key of every
|
|
34
|
+
* course in the program. The compliance-check call fails open
|
|
35
|
+
* (gateStatus = 'allowed') on network/CORS/HTTP errors — only an explicit
|
|
36
|
+
* non-compliant response blocks checkout. Profile/IP/geolocation lookups
|
|
37
|
+
* likewise fail open as request-body inputs. A failed program course-run
|
|
38
|
+
* lookup also fails open and skips the compliance call.
|
|
31
39
|
*
|
|
32
40
|
* When disableComplianceCheck is true, the compliance-check request is not
|
|
33
41
|
* made. Checkout opens once the session and profile have settled.
|
|
42
|
+
*
|
|
43
|
+
* When restrictCompliance is true, the request is also skipped, and the gate
|
|
44
|
+
* blocks once the session and profile have settled — the same screen as
|
|
45
|
+
* `{ allowed: false }`.
|
|
34
46
|
*/
|
|
35
47
|
export declare function useCheckoutGate(options?: UseCheckoutGateOptions): UseCheckoutGateResult;
|
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
import { useProductSelector } from './useAlacarteCheckout';
|
|
2
2
|
import { getCourseRunKeyFromUrl } from '../../utils/url';
|
|
3
|
-
import { useViaxSessionQuery, useUserProfileQuery, usePublicIpQuery, useIpGeolocationQuery, useComplianceCheckQuery, } from './useCheckoutQueries';
|
|
3
|
+
import { useViaxSessionQuery, useUserProfileQuery, usePublicIpQuery, useIpGeolocationQuery, useComplianceCheckQuery, useProgramCourseRunKeysQuery, } from './useCheckoutQueries';
|
|
4
4
|
/**
|
|
5
5
|
* Session + embargo compliance gate for à la carte checkout.
|
|
6
6
|
*
|
|
7
7
|
* Calls the ALC-307 compliance-check endpoint with the learner's identity,
|
|
8
|
-
* account-profile country, and public IP/city.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* account-profile country, and public IP/city. For a course, course_ids is
|
|
9
|
+
* that course's run key. For a program, course_ids is the run key of every
|
|
10
|
+
* course in the program. The compliance-check call fails open
|
|
11
|
+
* (gateStatus = 'allowed') on network/CORS/HTTP errors — only an explicit
|
|
12
|
+
* non-compliant response blocks checkout. Profile/IP/geolocation lookups
|
|
13
|
+
* likewise fail open as request-body inputs. A failed program course-run
|
|
14
|
+
* lookup also fails open and skips the compliance call.
|
|
12
15
|
*
|
|
13
16
|
* When disableComplianceCheck is true, the compliance-check request is not
|
|
14
17
|
* made. Checkout opens once the session and profile have settled.
|
|
18
|
+
*
|
|
19
|
+
* When restrictCompliance is true, the request is also skipped, and the gate
|
|
20
|
+
* blocks once the session and profile have settled — the same screen as
|
|
21
|
+
* `{ allowed: false }`.
|
|
15
22
|
*/
|
|
16
23
|
export function useCheckoutGate(options = {}) {
|
|
17
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
18
|
-
const { edxSessionUrl, geolocationUrl, complianceCheckUrl, disableComplianceCheck = false, learnerDashboardUrl, } = options;
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
25
|
+
const { apiUrl, edxSessionUrl, geolocationUrl, complianceCheckUrl, disableComplianceCheck = false, restrictCompliance = false, learnerDashboardUrl, } = options;
|
|
26
|
+
const runComplianceCheck = !disableComplianceCheck && !restrictCompliance;
|
|
19
27
|
const sessionQuery = useViaxSessionQuery(edxSessionUrl !== null && edxSessionUrl !== void 0 ? edxSessionUrl : null);
|
|
20
28
|
const sessionReady = !!sessionQuery.data;
|
|
21
29
|
const profileQuery = useUserProfileQuery(sessionReady ? (edxSessionUrl !== null && edxSessionUrl !== void 0 ? edxSessionUrl : null) : null, (_b = (_a = sessionQuery.data) === null || _a === void 0 ? void 0 : _a.username) !== null && _b !== void 0 ? _b : null);
|
|
22
30
|
// fetchUserProfile fails open internally (never throws) — "settled" means
|
|
23
31
|
// isLoading is false, regardless of whether data came back null.
|
|
24
32
|
const profileSettled = !profileQuery.isLoading;
|
|
25
|
-
const ipQuery = usePublicIpQuery(sessionReady &&
|
|
26
|
-
const geoQuery = useIpGeolocationQuery(sessionReady &&
|
|
33
|
+
const ipQuery = usePublicIpQuery(sessionReady && runComplianceCheck);
|
|
34
|
+
const geoQuery = useIpGeolocationQuery(sessionReady && runComplianceCheck ? (geolocationUrl !== null && geolocationUrl !== void 0 ? geolocationUrl : null) : null, (_c = ipQuery.data) !== null && _c !== void 0 ? _c : null);
|
|
27
35
|
// IP/geo lookups are best-effort inputs to the request body, not gating
|
|
28
36
|
// signals themselves — treat any terminal state (success OR error) as
|
|
29
37
|
// settled so a flaky ipify/geolocation call never blocks the
|
|
@@ -41,30 +49,47 @@ export function useCheckoutGate(options = {}) {
|
|
|
41
49
|
// the id sent to compliance-check. getCourseRunKeyFromUrl() reads the raw
|
|
42
50
|
// query string and preserves `+` correctly (same util useCheckout uses for
|
|
43
51
|
// the real course lookup).
|
|
52
|
+
// A program has no run key of its own. Compliance-check still wants course
|
|
53
|
+
// run keys, so resolve one for every course in the program before calling.
|
|
44
54
|
const productSelector = useProductSelector();
|
|
45
55
|
const rawCourseRunKey = getCourseRunKeyFromUrl();
|
|
56
|
+
const programUid = productSelector.kind === 'program' ? productSelector.programUid : null;
|
|
57
|
+
const viaxToken = (_e = (_d = sessionQuery.data) === null || _d === void 0 ? void 0 : _d.viaxToken) !== null && _e !== void 0 ? _e : null;
|
|
58
|
+
const programCourseRunsQuery = useProgramCourseRunKeysQuery(runComplianceCheck ? (apiUrl !== null && apiUrl !== void 0 ? apiUrl : null) : null, runComplianceCheck ? viaxToken : null, runComplianceCheck ? programUid : null);
|
|
59
|
+
// Stay on the spinner until the program's course run keys resolve. A failed
|
|
60
|
+
// lookup fails open (compliance is not called) so a catalog error does not
|
|
61
|
+
// block checkout — same as a failed compliance-check call.
|
|
62
|
+
const waitingForProgramRuns = !!programUid
|
|
63
|
+
&& runComplianceCheck
|
|
64
|
+
&& !!apiUrl
|
|
65
|
+
&& !!viaxToken
|
|
66
|
+
&& !programCourseRunsQuery.isSuccess
|
|
67
|
+
&& !programCourseRunsQuery.isError;
|
|
46
68
|
const courseIds = productSelector.kind === 'course'
|
|
47
69
|
? [rawCourseRunKey !== null && rawCourseRunKey !== void 0 ? rawCourseRunKey : productSelector.runKey]
|
|
48
70
|
: productSelector.kind === 'program'
|
|
49
|
-
? [
|
|
71
|
+
? ((_f = programCourseRunsQuery.data) !== null && _f !== void 0 ? _f : [])
|
|
50
72
|
: [];
|
|
51
|
-
const complianceCheckReady =
|
|
73
|
+
const complianceCheckReady = runComplianceCheck
|
|
52
74
|
&& sessionReady
|
|
53
75
|
&& profileSettled
|
|
54
|
-
&& ipGeoSettled
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
&& ipGeoSettled
|
|
77
|
+
&& !waitingForProgramRuns
|
|
78
|
+
&& (!programUid || programCourseRunsQuery.isSuccess);
|
|
79
|
+
const complianceCheckQuery = useComplianceCheckQuery(runComplianceCheck ? (complianceCheckUrl !== null && complianceCheckUrl !== void 0 ? complianceCheckUrl : null) : null, {
|
|
80
|
+
lmsUserId: (_h = (_g = sessionQuery.data) === null || _g === void 0 ? void 0 : _g.edxUserId) !== null && _h !== void 0 ? _h : null,
|
|
81
|
+
fullName: (_k = (_j = profileQuery.data) === null || _j === void 0 ? void 0 : _j.name) !== null && _k !== void 0 ? _k : null,
|
|
82
|
+
country: (_m = (_l = profileQuery.data) === null || _l === void 0 ? void 0 : _l.country) !== null && _m !== void 0 ? _m : null,
|
|
83
|
+
city: (_p = (_o = geoQuery.data) === null || _o === void 0 ? void 0 : _o.city) !== null && _p !== void 0 ? _p : null,
|
|
84
|
+
username: (_r = (_q = sessionQuery.data) === null || _q === void 0 ? void 0 : _q.username) !== null && _r !== void 0 ? _r : null,
|
|
85
|
+
ipAddress: (_s = ipQuery.data) !== null && _s !== void 0 ? _s : null,
|
|
62
86
|
courseIds,
|
|
63
87
|
}, complianceCheckReady);
|
|
64
|
-
const userCountry = (
|
|
88
|
+
const userCountry = (_u = (_t = profileQuery.data) === null || _t === void 0 ? void 0 : _t.country) !== null && _u !== void 0 ? _u : null;
|
|
65
89
|
const loading = (!sessionReady && !sessionQuery.isError)
|
|
66
90
|
|| (sessionReady && !profileSettled)
|
|
67
|
-
|| (
|
|
91
|
+
|| (runComplianceCheck && sessionReady && profileSettled && !ipGeoSettled)
|
|
92
|
+
|| waitingForProgramRuns
|
|
68
93
|
|| (complianceCheckReady && complianceCheckQuery.isLoading);
|
|
69
94
|
let gateStatus;
|
|
70
95
|
if (sessionQuery.isError) {
|
|
@@ -73,7 +98,7 @@ export function useCheckoutGate(options = {}) {
|
|
|
73
98
|
else if (loading) {
|
|
74
99
|
gateStatus = 'loading';
|
|
75
100
|
}
|
|
76
|
-
else if (!disableComplianceCheck && ((
|
|
101
|
+
else if (restrictCompliance || (!disableComplianceCheck && ((_v = complianceCheckQuery.data) === null || _v === void 0 ? void 0 : _v.isBlocked))) {
|
|
77
102
|
gateStatus = 'blocked';
|
|
78
103
|
}
|
|
79
104
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckoutGate.js","sourceRoot":"","sources":["../../../src/data/hooks/useCheckoutGate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO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,OAAO,CAAC,IAAI,mCAAI,IAAI;QAC/B,SAAS;KACV,EACD,oBAAoB,CACrB,CAAC;IAEF,MAAM,WAAW,GAAG,MAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,OAAO,mCAAI,IAAI,CAAC;IAEvD,MAAM,OAAO,GAAG,CAAC,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;WACnD,CAAC,YAAY,IAAI,CAAC,cAAc,CAAC;WACjC,CAAC,CAAC,sBAAsB,IAAI,YAAY,IAAI,cAAc,IAAI,CAAC,YAAY,CAAC;WAC5E,CAAC,oBAAoB,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAE9D,IAAI,UAAsB,CAAC;IAC3B,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;QACzB,UAAU,GAAG,OAAO,CAAC;IACvB,CAAC;SAAM,IAAI,OAAO,EAAE,CAAC;QACnB,UAAU,GAAG,SAAS,CAAC;IACzB,CAAC;SAAM,IAAI,CAAC,sBAAsB,KAAI,MAAA,oBAAoB,CAAC,IAAI,0CAAE,SAAS,CAAA,EAAE,CAAC;QAC3E,UAAU,GAAG,SAAS,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,yEAAyE;QACzE,6EAA6E;QAC7E,UAAU,GAAG,SAAS,CAAC;IACzB,CAAC;IAED,IAAI,WAAW,GAAkB,IAAI,CAAC;IACtC,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC3B,WAAW,GAAG,YAAY,CAAC,KAAK,YAAY,KAAK;YAC/C,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO;YAC5B,CAAC,CAAC,uCAAuC,CAAC;IAC9C,CAAC;IAED,OAAO;QACL,UAAU;QACV,WAAW;QACX,mBAAmB;QACnB,WAAW;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { useProductSelector } from './useAlacarteCheckout';\nimport { getCourseRunKeyFromUrl } from '../../utils/url';\nimport {\n useViaxSessionQuery,\n useUserProfileQuery,\n usePublicIpQuery,\n useIpGeolocationQuery,\n useComplianceCheckQuery,\n} from './useCheckoutQueries';\n\nexport interface UseCheckoutGateOptions {\n /** Kept for call-site compatibility; no longer used (subscriber check removed). */\n apiUrl?: string,\n edxSessionUrl?: string,\n /** Endpoint used to resolve city/etc. for the learner's public IP. */\n geolocationUrl?: string,\n /** ALC-307 compliance-check endpoint — decides whether the learner is embargoed. */\n complianceCheckUrl?: string,\n /** When true, skip the compliance-check request and do not block on its result. */\n disableComplianceCheck?: boolean,\n learnerDashboardUrl?: string,\n}\n\nexport type GateStatus = 'loading' | 'blocked' | 'allowed' | 'error';\n\nexport interface UseCheckoutGateResult {\n /** 'loading' while checks are in flight, 'blocked' if the compliance check rejects the learner, 'allowed' if clear (or compliance check failed), 'error' if session failed. */\n gateStatus: GateStatus,\n /** ISO 3166-1 alpha-2 country code — passed down to Checkout for the UK/CA checkbox. */\n userCountry: string | null,\n learnerDashboardUrl: string | undefined,\n /** Message shown when gateStatus is not 'allowed'. */\n gateMessage: string | null,\n}\n\n/**\n * Session + embargo compliance gate for à la carte checkout.\n *\n * Calls the ALC-307 compliance-check endpoint with the learner's identity,\n * account-profile country, and public IP/city. The compliance-check call\n * fails open (gateStatus = 'allowed') on network/CORS/HTTP errors — only an\n * explicit non-compliant response blocks checkout. Profile/IP/geolocation\n * lookups likewise fail open as request-body inputs.\n *\n * When disableComplianceCheck is true, the compliance-check request is not\n * made. Checkout opens once the session and profile have settled.\n */\nexport function useCheckoutGate(options: UseCheckoutGateOptions = {}): UseCheckoutGateResult {\n const {\n edxSessionUrl,\n geolocationUrl,\n complianceCheckUrl,\n disableComplianceCheck = false,\n learnerDashboardUrl,\n } = options;\n\n const sessionQuery = useViaxSessionQuery(edxSessionUrl ?? null);\n const sessionReady = !!sessionQuery.data;\n\n const profileQuery = useUserProfileQuery(\n sessionReady ? (edxSessionUrl ?? null) : null,\n sessionQuery.data?.username ?? null,\n );\n // fetchUserProfile fails open internally (never throws) — \"settled\" means\n // isLoading is false, regardless of whether data came back null.\n const profileSettled = !profileQuery.isLoading;\n\n const ipQuery = usePublicIpQuery(sessionReady && !disableComplianceCheck);\n const geoQuery = useIpGeolocationQuery(\n sessionReady && !disableComplianceCheck ? (geolocationUrl ?? null) : null,\n ipQuery.data ?? null,\n );\n // IP/geo lookups are best-effort inputs to the request body, not gating\n // signals themselves — treat any terminal state (success OR error) as\n // settled so a flaky ipify/geolocation call never blocks the\n // compliance-check call.\n const ipGeoSettled = (!sessionReady)\n || ipQuery.isError\n || (!!ipQuery.data && !geoQuery.isLoading);\n\n // Both course_uuid + course_run_key (course) or program_uuid (program) are\n // valid product selectors in this app (legacy course_uid / program_uid still\n // work) — use the same selector the rest of checkout uses\n // (useAlacarteCheckout) to know *which* case we're in. But for the actual\n // course_run_key value, don't use productSelector.runKey — nuqs decodes\n // literal `+` as a space (standards-compliant, but course run keys like\n // \"course-v1:edX+DemoX+Demo_Course\" rely on literal `+`), which corrupts\n // the id sent to compliance-check. getCourseRunKeyFromUrl() reads the raw\n // query string and preserves `+` correctly (same util useCheckout uses for\n // the real course lookup).\n const productSelector = useProductSelector();\n const rawCourseRunKey = getCourseRunKeyFromUrl();\n const courseIds = productSelector.kind === 'course'\n ? [rawCourseRunKey ?? productSelector.runKey]\n : productSelector.kind === 'program'\n ? [productSelector.programUid]\n : [];\n\n const complianceCheckReady = !disableComplianceCheck\n && sessionReady\n && profileSettled\n && ipGeoSettled;\n\n const complianceCheckQuery = useComplianceCheckQuery(\n disableComplianceCheck ? null : (complianceCheckUrl ?? null),\n {\n lmsUserId: sessionQuery.data?.edxUserId ?? null,\n fullName: profileQuery.data?.name ?? null,\n country: profileQuery.data?.country ?? null,\n city: geoQuery.data?.city ?? null,\n username: sessionQuery.data?.username ?? null,\n ipAddress: ipQuery.data ?? null,\n courseIds,\n },\n complianceCheckReady,\n );\n\n const userCountry = profileQuery.data?.country ?? null;\n\n const loading = (!sessionReady && !sessionQuery.isError)\n || (sessionReady && !profileSettled)\n || (!disableComplianceCheck && sessionReady && profileSettled && !ipGeoSettled)\n || (complianceCheckReady && complianceCheckQuery.isLoading);\n\n let gateStatus: GateStatus;\n if (sessionQuery.isError) {\n gateStatus = 'error';\n } else if (loading) {\n gateStatus = 'loading';\n } else if (!disableComplianceCheck && complianceCheckQuery.data?.isBlocked) {\n gateStatus = 'blocked';\n } else {\n // Compliant, compliance check skipped/disabled, or compliance API failed\n // (CORS, network, 5xx, etc.) — always fail open so checkout stays available.\n gateStatus = 'allowed';\n }\n\n let gateMessage: string | null = null;\n if (gateStatus === 'error') {\n gateMessage = sessionQuery.error instanceof Error\n ? sessionQuery.error.message\n : 'Failed to establish checkout session.';\n }\n\n return {\n gateStatus,\n userCountry,\n learnerDashboardUrl,\n gateMessage,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useCheckoutGate.js","sourceRoot":"","sources":["../../../src/data/hooks/useCheckoutGate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAgC9B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkC,EAAE;;IAClE,MAAM,EACJ,MAAM,EACN,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GAAG,KAAK,EAC9B,kBAAkB,GAAG,KAAK,EAC1B,mBAAmB,GACpB,GAAG,OAAO,CAAC;IACZ,MAAM,kBAAkB,GAAG,CAAC,sBAAsB,IAAI,CAAC,kBAAkB,CAAC;IAE1E,MAAM,YAAY,GAAG,mBAAmB,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,IAAI,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,CAAC,C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AAkB,IAAI,CAAC;IACtC,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC3B,WAAW,GAAG,YAAY,CAAC,KAAK,YAAY,KAAK;YAC/C,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO;YAC5B,CAAC,CAAC,uCAAuC,CAAC;IAC9C,CAAC;IAED,OAAO;QACL,UAAU;QACV,WAAW;QACX,mBAAmB;QACnB,WAAW;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { useProductSelector } from './useAlacarteCheckout';\nimport { getCourseRunKeyFromUrl } from '../../utils/url';\nimport {\n useViaxSessionQuery,\n useUserProfileQuery,\n usePublicIpQuery,\n useIpGeolocationQuery,\n useComplianceCheckQuery,\n useProgramCourseRunKeysQuery,\n} from './useCheckoutQueries';\n\nexport interface UseCheckoutGateOptions {\n /** Viax GraphQL URL. Used to resolve a program's course run keys for compliance-check. */\n apiUrl?: string,\n edxSessionUrl?: string,\n /** Endpoint used to resolve city/etc. for the learner's public IP. */\n geolocationUrl?: string,\n /** ALC-307 compliance-check endpoint — decides whether the learner is embargoed. */\n complianceCheckUrl?: string,\n /** When true, skip the compliance-check request and do not block on its result. */\n disableComplianceCheck?: boolean,\n /**\n * Dev-only. When true, skip the compliance-check request and treat the\n * learner as restricted — the same outcome as `{ allowed: false }`.\n */\n restrictCompliance?: boolean,\n learnerDashboardUrl?: string,\n}\n\nexport type GateStatus = 'loading' | 'blocked' | 'allowed' | 'error';\n\nexport interface UseCheckoutGateResult {\n /** 'loading' while checks are in flight, 'blocked' if the compliance check rejects the learner, 'allowed' if clear (or compliance check failed), 'error' if session failed. */\n gateStatus: GateStatus,\n /** ISO 3166-1 alpha-2 country code — passed down to Checkout for the UK/CA checkbox. */\n userCountry: string | null,\n learnerDashboardUrl: string | undefined,\n /** Message shown when gateStatus is not 'allowed'. */\n gateMessage: string | null,\n}\n\n/**\n * Session + embargo compliance gate for à la carte checkout.\n *\n * Calls the ALC-307 compliance-check endpoint with the learner's identity,\n * account-profile country, and public IP/city. For a course, course_ids is\n * that course's run key. For a program, course_ids is the run key of every\n * course in the program. The compliance-check call fails open\n * (gateStatus = 'allowed') on network/CORS/HTTP errors — only an explicit\n * non-compliant response blocks checkout. Profile/IP/geolocation lookups\n * likewise fail open as request-body inputs. A failed program course-run\n * lookup also fails open and skips the compliance call.\n *\n * When disableComplianceCheck is true, the compliance-check request is not\n * made. Checkout opens once the session and profile have settled.\n *\n * When restrictCompliance is true, the request is also skipped, and the gate\n * blocks once the session and profile have settled — the same screen as\n * `{ allowed: false }`.\n */\nexport function useCheckoutGate(options: UseCheckoutGateOptions = {}): UseCheckoutGateResult {\n const {\n apiUrl,\n edxSessionUrl,\n geolocationUrl,\n complianceCheckUrl,\n disableComplianceCheck = false,\n restrictCompliance = false,\n learnerDashboardUrl,\n } = options;\n const runComplianceCheck = !disableComplianceCheck && !restrictCompliance;\n\n const sessionQuery = useViaxSessionQuery(edxSessionUrl ?? null);\n const sessionReady = !!sessionQuery.data;\n\n const profileQuery = useUserProfileQuery(\n sessionReady ? (edxSessionUrl ?? null) : null,\n sessionQuery.data?.username ?? null,\n );\n // fetchUserProfile fails open internally (never throws) — \"settled\" means\n // isLoading is false, regardless of whether data came back null.\n const profileSettled = !profileQuery.isLoading;\n\n const ipQuery = usePublicIpQuery(sessionReady && runComplianceCheck);\n const geoQuery = useIpGeolocationQuery(\n sessionReady && runComplianceCheck ? (geolocationUrl ?? null) : null,\n ipQuery.data ?? null,\n );\n // IP/geo lookups are best-effort inputs to the request body, not gating\n // signals themselves — treat any terminal state (success OR error) as\n // settled so a flaky ipify/geolocation call never blocks the\n // compliance-check call.\n const ipGeoSettled = (!sessionReady)\n || ipQuery.isError\n || (!!ipQuery.data && !geoQuery.isLoading);\n\n // Both course_uuid + course_run_key (course) or program_uuid (program) are\n // valid product selectors in this app (legacy course_uid / program_uid still\n // work) — use the same selector the rest of checkout uses\n // (useAlacarteCheckout) to know *which* case we're in. But for the actual\n // course_run_key value, don't use productSelector.runKey — nuqs decodes\n // literal `+` as a space (standards-compliant, but course run keys like\n // \"course-v1:edX+DemoX+Demo_Course\" rely on literal `+`), which corrupts\n // the id sent to compliance-check. getCourseRunKeyFromUrl() reads the raw\n // query string and preserves `+` correctly (same util useCheckout uses for\n // the real course lookup).\n // A program has no run key of its own. Compliance-check still wants course\n // run keys, so resolve one for every course in the program before calling.\n const productSelector = useProductSelector();\n const rawCourseRunKey = getCourseRunKeyFromUrl();\n const programUid = productSelector.kind === 'program' ? productSelector.programUid : null;\n const viaxToken = sessionQuery.data?.viaxToken ?? null;\n const programCourseRunsQuery = useProgramCourseRunKeysQuery(\n runComplianceCheck ? (apiUrl ?? null) : null,\n runComplianceCheck ? viaxToken : null,\n runComplianceCheck ? programUid : null,\n );\n // Stay on the spinner until the program's course run keys resolve. A failed\n // lookup fails open (compliance is not called) so a catalog error does not\n // block checkout — same as a failed compliance-check call.\n const waitingForProgramRuns = !!programUid\n && runComplianceCheck\n && !!apiUrl\n && !!viaxToken\n && !programCourseRunsQuery.isSuccess\n && !programCourseRunsQuery.isError;\n\n const courseIds = productSelector.kind === 'course'\n ? [rawCourseRunKey ?? productSelector.runKey]\n : productSelector.kind === 'program'\n ? (programCourseRunsQuery.data ?? [])\n : [];\n\n const complianceCheckReady = runComplianceCheck\n && sessionReady\n && profileSettled\n && ipGeoSettled\n && !waitingForProgramRuns\n && (!programUid || programCourseRunsQuery.isSuccess);\n\n const complianceCheckQuery = useComplianceCheckQuery(\n runComplianceCheck ? (complianceCheckUrl ?? null) : null,\n {\n lmsUserId: sessionQuery.data?.edxUserId ?? null,\n fullName: profileQuery.data?.name ?? null,\n country: profileQuery.data?.country ?? null,\n city: geoQuery.data?.city ?? null,\n username: sessionQuery.data?.username ?? null,\n ipAddress: ipQuery.data ?? null,\n courseIds,\n },\n complianceCheckReady,\n );\n\n const userCountry = profileQuery.data?.country ?? null;\n\n const loading = (!sessionReady && !sessionQuery.isError)\n || (sessionReady && !profileSettled)\n || (runComplianceCheck && sessionReady && profileSettled && !ipGeoSettled)\n || waitingForProgramRuns\n || (complianceCheckReady && complianceCheckQuery.isLoading);\n\n let gateStatus: GateStatus;\n if (sessionQuery.isError) {\n gateStatus = 'error';\n } else if (loading) {\n gateStatus = 'loading';\n } else if (restrictCompliance || (!disableComplianceCheck && complianceCheckQuery.data?.isBlocked)) {\n gateStatus = 'blocked';\n } else {\n // Compliant, compliance check skipped/disabled, or compliance API failed\n // (CORS, network, 5xx, etc.) — always fail open so checkout stays available.\n gateStatus = 'allowed';\n }\n\n let gateMessage: string | null = null;\n if (gateStatus === 'error') {\n gateMessage = sessionQuery.error instanceof Error\n ? sessionQuery.error.message\n : 'Failed to establish checkout session.';\n }\n\n return {\n gateStatus,\n userCountry,\n learnerDashboardUrl,\n gateMessage,\n };\n}\n"]}
|
|
@@ -31,6 +31,12 @@ export interface ComplianceCheckInputs {
|
|
|
31
31
|
export declare function useComplianceCheckQuery(complianceCheckUrl: string | null, inputs: ComplianceCheckInputs, ready: boolean): import("@tanstack/react-query").UseQueryResult<import("../../utils/provision").ComplianceCheckResult, Error>;
|
|
32
32
|
/** Polls the cart state machine every second; stops on terminal states. */
|
|
33
33
|
export declare function useCartStatusQuery(client: CheckoutClient | null, cartBiId: string | null): import("@tanstack/react-query").UseQueryResult<CartStatusResult, Error>;
|
|
34
|
+
/**
|
|
35
|
+
* Course run keys for every course in a program, for the compliance-check
|
|
36
|
+
* `course_ids` list. Disabled unless apiUrl, the viax token, and a program
|
|
37
|
+
* uid are all present.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useProgramCourseRunKeysQuery(apiUrl: string | null, viaxToken: string | null, programUid: string | null): import("@tanstack/react-query").UseQueryResult<string[], Error>;
|
|
34
40
|
/** Looks up the created subscription biId after success. */
|
|
35
41
|
export declare function useSubscriptionIdQuery(client: CheckoutClient | null, cartBiId: string | null, enabled: boolean): import("@tanstack/react-query").UseQueryResult<import("../../types").SubscriptionDetails | null, Error>;
|
|
36
42
|
/**
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import { useQuery } from '@tanstack/react-query';
|
|
8
8
|
import { isTerminalStatus } from '../../constants';
|
|
9
9
|
import { checkoutKeys } from './keys';
|
|
10
|
+
import { getProgramCourseRunKeys } from '../../utils/alacarteApi';
|
|
11
|
+
import { createGqlClient } from '../../utils/graphqlClient';
|
|
10
12
|
import { fetchEdxSession, fetchUserProfile, fetchPublicIp, fetchIpGeolocation, fetchComplianceCheck, fetchSubscriptionCourseKey } from '../../utils/provision';
|
|
11
13
|
/** Exchange edX session cookies for a viax token on page load. */
|
|
12
14
|
export function useViaxSessionQuery(sessionUrl) {
|
|
@@ -81,7 +83,7 @@ export function useIpGeolocationQuery(geolocationUrl, ipAddress) {
|
|
|
81
83
|
export function useComplianceCheckQuery(complianceCheckUrl, inputs, ready) {
|
|
82
84
|
const { lmsUserId, fullName, country, city, username, ipAddress, courseIds, } = inputs;
|
|
83
85
|
return useQuery({
|
|
84
|
-
queryKey: ['checkout', 'complianceCheck', username !== null && username !== void 0 ? username : 'none', ipAddress !== null && ipAddress !== void 0 ? ipAddress : 'none'],
|
|
86
|
+
queryKey: ['checkout', 'complianceCheck', username !== null && username !== void 0 ? username : 'none', ipAddress !== null && ipAddress !== void 0 ? ipAddress : 'none', courseIds],
|
|
85
87
|
enabled: !!complianceCheckUrl && ready && !!lmsUserId && !!username,
|
|
86
88
|
queryFn: () => {
|
|
87
89
|
const requestBody = {
|
|
@@ -111,6 +113,25 @@ export function useCartStatusQuery(client, cartBiId) {
|
|
|
111
113
|
gcTime: 0,
|
|
112
114
|
});
|
|
113
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Course run keys for every course in a program, for the compliance-check
|
|
118
|
+
* `course_ids` list. Disabled unless apiUrl, the viax token, and a program
|
|
119
|
+
* uid are all present.
|
|
120
|
+
*/
|
|
121
|
+
export function useProgramCourseRunKeysQuery(apiUrl, viaxToken, programUid) {
|
|
122
|
+
return useQuery({
|
|
123
|
+
queryKey: ['checkout', 'programCourseRunKeys', programUid !== null && programUid !== void 0 ? programUid : 'none'],
|
|
124
|
+
enabled: !!apiUrl && !!viaxToken && !!programUid,
|
|
125
|
+
queryFn: () => {
|
|
126
|
+
const { gql, setToken } = createGqlClient({ apiUrl: apiUrl });
|
|
127
|
+
setToken(viaxToken);
|
|
128
|
+
return getProgramCourseRunKeys(gql, programUid);
|
|
129
|
+
},
|
|
130
|
+
staleTime: Infinity,
|
|
131
|
+
refetchOnWindowFocus: false,
|
|
132
|
+
retry: 1,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
114
135
|
/** Looks up the created subscription biId after success. */
|
|
115
136
|
export function useSubscriptionIdQuery(client, cartBiId, enabled) {
|
|
116
137
|
return useQuery({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckoutQueries.js","sourceRoot":"","sources":["../../../src/data/hooks/useCheckoutQueries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAM/B,kEAAkE;AAClE,MAAM,UAAU,mBAAmB,CAAC,UAAyB;IAC3D,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,YAAY,CAAC,WAAW,EAAE;QACpC,OAAO,EAAE,CAAC,CAAC,UAAU;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,UAAW,CAAC;QAC3C,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;QACxB,qEAAqE;QACrE,kEAAkE;QAClE,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;AACL,CAAC;AAED,mF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;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAC3C,UAAyB,EACzB,YAA2B;IAE3B,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,YAAY,CAAC,qBAAqB,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,MAAM,CAAC;QACpE,OAAO,EAAE,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,YAAY;QACvC,OAAO,EAAE,GAAG,EAAE,CAAC,0BAA0B,CAAC,UAAW,EAAE,YAAa,CAAC;QACrE,SAAS,EAAE,QAAQ;QACnB,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA6B,EAC7B,YAAqB,EACrB,YAA2B;IAE3B,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,MAAM,CAAC;QAC3D,OAAO,EAAE,CAAC,CAAC,MAAM,IAAI,YAAY,IAAI,CAAC,CAAC,YAAY;QACnD,OAAO,EAAE,GAAiC,EAAE,CAAC,MAAO,CAAC,eAAe,CAAC,YAAa,CAAC;QACnF,SAAS,EAAE,QAAQ;QACnB,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * query/useCheckoutQueries.ts — read-side TanStack Query hooks.\n *\n * useViaxSessionQuery runs on mount to exchange the edX session for a viax\n * token.\n */\nimport { useQuery } from '@tanstack/react-query';\nimport { isTerminalStatus } from '../../constants';\nimport { checkoutKeys } from './keys';\nimport {\n fetchEdxSession,\n fetchUserProfile,\n fetchPublicIp,\n fetchIpGeolocation,\n fetchComplianceCheck,\n fetchSubscriptionCourseKey\n} from '../../utils/provision';\nimport type { ComplianceCheckRequest } from '../../utils/provision';\nimport type {\n CheckoutClient, CartStatusResult, CourseDetail,\n} from '../../types';\n\n/** Exchange edX session cookies for a viax token on page load. */\nexport function useViaxSessionQuery(sessionUrl: string | null) {\n return useQuery({\n queryKey: checkoutKeys.viaxSession(),\n enabled: !!sessionUrl,\n queryFn: () => fetchEdxSession(sessionUrl!),\n staleTime: 5 * 60 * 1000,\n // Avoid tearing down CheckoutGate (and remounting Checkout) when the\n // learner alt-tabs away and back after the session becomes stale.\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Checks whether the authenticated learner already has an active subscription. */\nexport function useCurrentUserSubscriberQuery(client: CheckoutClient | null, sessionReady: boolean) {\n return useQuery({\n queryKey: ['checkout', 'currentUserSubscriber'],\n enabled: !!client && sessionReady,\n queryFn: () => client!.isCurrentUserSubscriber(),\n staleTime: 5 * 60 * 1000,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/**\n * Fetches the user's country and full name from their edX account profile.\n * Derives the LMS base URL from the session URL (same origin).\n * Returns nulls if the fetch fails or a field is absent — checkout stays open in that case.\n */\nexport function useUserProfileQuery(sessionUrl: string | null, username: string | null) {\n return useQuery({\n queryKey: ['checkout', 'userProfile', username],\n enabled: !!sessionUrl && !!username,\n queryFn: () => {\n const lmsBaseUrl = new URL(sessionUrl!).origin;\n return fetchUserProfile(lmsBaseUrl, username!);\n },\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Fetches the learner's current public IP once the viax session is ready. */\nexport function usePublicIpQuery(sessionReady: boolean) {\n return useQuery({\n queryKey: ['checkout', 'publicIp'],\n enabled: sessionReady,\n queryFn: () => fetchPublicIp(),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Resolves city/etc. for the public IP via the LMS geolocation endpoint. */\nexport function useIpGeolocationQuery(geolocationUrl: string | null, ipAddress: string | null) {\n return useQuery({\n queryKey: ['checkout', 'ipGeolocation', ipAddress ?? 'none'],\n enabled: !!geolocationUrl && !!ipAddress,\n queryFn: () => fetchIpGeolocation(geolocationUrl!, ipAddress!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\nexport interface ComplianceCheckInputs {\n lmsUserId: string | null,\n fullName: string | null,\n country: string | null,\n city: string | null,\n username: string | null,\n ipAddress: string | null,\n courseIds: string[],\n}\n\n/**\n * Calls the ALC-307 compliance-check endpoint once identity, country, and\n * IP/city are resolved. Errors surface via isError; useCheckoutGate treats\n * those as fail-open (gateStatus = 'allowed') so CORS/network failures do\n * not block checkout — only an explicit isBlocked result does.\n */\nexport function useComplianceCheckQuery(\n complianceCheckUrl: string | null,\n inputs: ComplianceCheckInputs,\n ready: boolean,\n) {\n const {\n lmsUserId, fullName, country, city, username, ipAddress, courseIds,\n } = inputs;\n\n return useQuery({\n queryKey: ['checkout', 'complianceCheck', username ?? 'none', ipAddress ?? 'none'],\n enabled: !!complianceCheckUrl && ready && !!lmsUserId && !!username,\n queryFn: () => {\n const requestBody: ComplianceCheckRequest = {\n lms_user_id: lmsUserId!,\n full_name: fullName ?? '',\n country: country ?? '',\n city: city ?? '',\n user: username!,\n ip_address: ipAddress ?? '',\n course_ids: courseIds,\n };\n return fetchComplianceCheck(complianceCheckUrl!, requestBody);\n },\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Polls the cart state machine every second; stops on terminal states. */\nexport function useCartStatusQuery(client: CheckoutClient | null, cartBiId: string | null) {\n return useQuery({\n queryKey: checkoutKeys.status(cartBiId ?? 'none'),\n enabled: !!client && !!cartBiId,\n queryFn: (): Promise<CartStatusResult> => client!.getCartStatus(cartBiId!),\n refetchInterval: (query) =>\n isTerminalStatus(query.state.data?.status ?? null) ? false : 1000,\n refetchOnWindowFocus: false,\n gcTime: 0,\n });\n}\n\n/** Looks up the created subscription biId after success. */\nexport function useSubscriptionIdQuery(\n client: CheckoutClient | null,\n cartBiId: string | null,\n enabled: boolean,\n) {\n return useQuery({\n queryKey: checkoutKeys.subscriptionId(cartBiId ?? 'none'),\n enabled: enabled && !!client && !!cartBiId,\n queryFn: () => client!.findSubscriptionBiId(cartBiId!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n });\n}\n\n/**\n * Resolves the Viax course key for a course run via\n * GET /api/subscription/course_runs/?key=<course run key>.\n * Used when the URL has both course_uuid (or legacy course_uid) and course_run_key.\n * Pass null for lmsBaseUrl or courseRunKey to disable (e.g. when\n * SKIP_SUBSCRIPTION_COURSE_RUNS derives the key locally instead).\n */\nexport function useSubscriptionCourseKeyQuery(\n lmsBaseUrl: string | null,\n courseRunKey: string | null,\n) {\n return useQuery({\n queryKey: checkoutKeys.subscriptionCourseKey(courseRunKey ?? 'none'),\n enabled: !!lmsBaseUrl && !!courseRunKey,\n queryFn: () => fetchSubscriptionCourseKey(lmsBaseUrl!, courseRunKey!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/**\n * Fetches Viax course details by the `course` value returned from\n * GET /api/subscription/course_runs/ (not the course-run `key` or the raw URL param).\n * Skipped entirely when that value is absent.\n */\nexport function useCourseDetailQuery(\n client: CheckoutClient | null,\n sessionReady: boolean,\n courseRunKey: string | null,\n) {\n return useQuery({\n queryKey: checkoutKeys.courseDetail(courseRunKey ?? 'none'),\n enabled: !!client && sessionReady && !!courseRunKey,\n queryFn: (): Promise<CourseDetail | null> => client!.getCourseDetail(courseRunKey!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useCheckoutQueries.js","sourceRoot":"","sources":["../../../src/data/hooks/useCheckoutQueries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;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6BAA6B,CAC3C,UAAyB,EACzB,YAA2B;IAE3B,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,YAAY,CAAC,qBAAqB,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,MAAM,CAAC;QACpE,OAAO,EAAE,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,YAAY;QACvC,OAAO,EAAE,GAAG,EAAE,CAAC,0BAA0B,CAAC,UAAW,EAAE,YAAa,CAAC;QACrE,SAAS,EAAE,QAAQ;QACnB,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA6B,EAC7B,YAAqB,EACrB,YAA2B;IAE3B,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,MAAM,CAAC;QAC3D,OAAO,EAAE,CAAC,CAAC,MAAM,IAAI,YAAY,IAAI,CAAC,CAAC,YAAY;QACnD,OAAO,EAAE,GAAiC,EAAE,CAAC,MAAO,CAAC,eAAe,CAAC,YAAa,CAAC;QACnF,SAAS,EAAE,QAAQ;QACnB,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * query/useCheckoutQueries.ts — read-side TanStack Query hooks.\n *\n * useViaxSessionQuery runs on mount to exchange the edX session for a viax\n * token.\n */\nimport { useQuery } from '@tanstack/react-query';\nimport { isTerminalStatus } from '../../constants';\nimport { checkoutKeys } from './keys';\nimport { getProgramCourseRunKeys } from '../../utils/alacarteApi';\nimport { createGqlClient } from '../../utils/graphqlClient';\nimport {\n fetchEdxSession,\n fetchUserProfile,\n fetchPublicIp,\n fetchIpGeolocation,\n fetchComplianceCheck,\n fetchSubscriptionCourseKey\n} from '../../utils/provision';\nimport type { ComplianceCheckRequest } from '../../utils/provision';\nimport type {\n CheckoutClient, CartStatusResult, CourseDetail,\n} from '../../types';\n\n/** Exchange edX session cookies for a viax token on page load. */\nexport function useViaxSessionQuery(sessionUrl: string | null) {\n return useQuery({\n queryKey: checkoutKeys.viaxSession(),\n enabled: !!sessionUrl,\n queryFn: () => fetchEdxSession(sessionUrl!),\n staleTime: 5 * 60 * 1000,\n // Avoid tearing down CheckoutGate (and remounting Checkout) when the\n // learner alt-tabs away and back after the session becomes stale.\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Checks whether the authenticated learner already has an active subscription. */\nexport function useCurrentUserSubscriberQuery(client: CheckoutClient | null, sessionReady: boolean) {\n return useQuery({\n queryKey: ['checkout', 'currentUserSubscriber'],\n enabled: !!client && sessionReady,\n queryFn: () => client!.isCurrentUserSubscriber(),\n staleTime: 5 * 60 * 1000,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/**\n * Fetches the user's country and full name from their edX account profile.\n * Derives the LMS base URL from the session URL (same origin).\n * Returns nulls if the fetch fails or a field is absent — checkout stays open in that case.\n */\nexport function useUserProfileQuery(sessionUrl: string | null, username: string | null) {\n return useQuery({\n queryKey: ['checkout', 'userProfile', username],\n enabled: !!sessionUrl && !!username,\n queryFn: () => {\n const lmsBaseUrl = new URL(sessionUrl!).origin;\n return fetchUserProfile(lmsBaseUrl, username!);\n },\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Fetches the learner's current public IP once the viax session is ready. */\nexport function usePublicIpQuery(sessionReady: boolean) {\n return useQuery({\n queryKey: ['checkout', 'publicIp'],\n enabled: sessionReady,\n queryFn: () => fetchPublicIp(),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Resolves city/etc. for the public IP via the LMS geolocation endpoint. */\nexport function useIpGeolocationQuery(geolocationUrl: string | null, ipAddress: string | null) {\n return useQuery({\n queryKey: ['checkout', 'ipGeolocation', ipAddress ?? 'none'],\n enabled: !!geolocationUrl && !!ipAddress,\n queryFn: () => fetchIpGeolocation(geolocationUrl!, ipAddress!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\nexport interface ComplianceCheckInputs {\n lmsUserId: string | null,\n fullName: string | null,\n country: string | null,\n city: string | null,\n username: string | null,\n ipAddress: string | null,\n courseIds: string[],\n}\n\n/**\n * Calls the ALC-307 compliance-check endpoint once identity, country, and\n * IP/city are resolved. Errors surface via isError; useCheckoutGate treats\n * those as fail-open (gateStatus = 'allowed') so CORS/network failures do\n * not block checkout — only an explicit isBlocked result does.\n */\nexport function useComplianceCheckQuery(\n complianceCheckUrl: string | null,\n inputs: ComplianceCheckInputs,\n ready: boolean,\n) {\n const {\n lmsUserId, fullName, country, city, username, ipAddress, courseIds,\n } = inputs;\n\n return useQuery({\n queryKey: ['checkout', 'complianceCheck', username ?? 'none', ipAddress ?? 'none', courseIds],\n enabled: !!complianceCheckUrl && ready && !!lmsUserId && !!username,\n queryFn: () => {\n const requestBody: ComplianceCheckRequest = {\n lms_user_id: lmsUserId!,\n full_name: fullName ?? '',\n country: country ?? '',\n city: city ?? '',\n user: username!,\n ip_address: ipAddress ?? '',\n course_ids: courseIds,\n };\n return fetchComplianceCheck(complianceCheckUrl!, requestBody);\n },\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Polls the cart state machine every second; stops on terminal states. */\nexport function useCartStatusQuery(client: CheckoutClient | null, cartBiId: string | null) {\n return useQuery({\n queryKey: checkoutKeys.status(cartBiId ?? 'none'),\n enabled: !!client && !!cartBiId,\n queryFn: (): Promise<CartStatusResult> => client!.getCartStatus(cartBiId!),\n refetchInterval: (query) =>\n isTerminalStatus(query.state.data?.status ?? null) ? false : 1000,\n refetchOnWindowFocus: false,\n gcTime: 0,\n });\n}\n\n/**\n * Course run keys for every course in a program, for the compliance-check\n * `course_ids` list. Disabled unless apiUrl, the viax token, and a program\n * uid are all present.\n */\nexport function useProgramCourseRunKeysQuery(\n apiUrl: string | null,\n viaxToken: string | null,\n programUid: string | null,\n) {\n return useQuery({\n queryKey: ['checkout', 'programCourseRunKeys', programUid ?? 'none'],\n enabled: !!apiUrl && !!viaxToken && !!programUid,\n queryFn: () => {\n const { gql, setToken } = createGqlClient({ apiUrl: apiUrl! });\n setToken(viaxToken!);\n return getProgramCourseRunKeys(gql, programUid!);\n },\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/** Looks up the created subscription biId after success. */\nexport function useSubscriptionIdQuery(\n client: CheckoutClient | null,\n cartBiId: string | null,\n enabled: boolean,\n) {\n return useQuery({\n queryKey: checkoutKeys.subscriptionId(cartBiId ?? 'none'),\n enabled: enabled && !!client && !!cartBiId,\n queryFn: () => client!.findSubscriptionBiId(cartBiId!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n });\n}\n\n/**\n * Resolves the Viax course key for a course run via\n * GET /api/subscription/course_runs/?key=<course run key>.\n * Used when the URL has both course_uuid (or legacy course_uid) and course_run_key.\n * Pass null for lmsBaseUrl or courseRunKey to disable (e.g. when\n * SKIP_SUBSCRIPTION_COURSE_RUNS derives the key locally instead).\n */\nexport function useSubscriptionCourseKeyQuery(\n lmsBaseUrl: string | null,\n courseRunKey: string | null,\n) {\n return useQuery({\n queryKey: checkoutKeys.subscriptionCourseKey(courseRunKey ?? 'none'),\n enabled: !!lmsBaseUrl && !!courseRunKey,\n queryFn: () => fetchSubscriptionCourseKey(lmsBaseUrl!, courseRunKey!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n\n/**\n * Fetches Viax course details by the `course` value returned from\n * GET /api/subscription/course_runs/ (not the course-run `key` or the raw URL param).\n * Skipped entirely when that value is absent.\n */\nexport function useCourseDetailQuery(\n client: CheckoutClient | null,\n sessionReady: boolean,\n courseRunKey: string | null,\n) {\n return useQuery({\n queryKey: checkoutKeys.courseDetail(courseRunKey ?? 'none'),\n enabled: !!client && sessionReady && !!courseRunKey,\n queryFn: (): Promise<CourseDetail | null> => client!.getCourseDetail(courseRunKey!),\n staleTime: Infinity,\n refetchOnWindowFocus: false,\n retry: 1,\n });\n}\n"]}
|
|
@@ -26,6 +26,17 @@ export declare function capturePaypalOrder(gql: GqlRunner, biId: string, paypalO
|
|
|
26
26
|
export declare function cancelPaypalOrder(gql: GqlRunner, biId: string, paypalOrderId: string): Promise<AlacartePaypalOrderResult>;
|
|
27
27
|
export declare function getOwnedProduct(gql: GqlRunner, productId: string): Promise<OwnedProductResult>;
|
|
28
28
|
export declare function getAllOwnedProducts(gql: GqlRunner): Promise<AllOwnedProductsResult>;
|
|
29
|
+
/** `tCourseRuns` returns every run it knows. Compliance needs the run the
|
|
30
|
+
* learner would actually buy: published runs when any exist, otherwise
|
|
31
|
+
* whatever keys came back so a course is not dropped. */
|
|
32
|
+
export declare function courseRunKeysFromRuns(runs: unknown): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Course run keys for every course in a program.
|
|
35
|
+
* Compliance-check takes course run keys (`course-v1:...`), and a program
|
|
36
|
+
* has no single run key of its own — look the program's courses up, then
|
|
37
|
+
* each course's runs via `tCourseRuns(courseUuid: <maId>)`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getProgramCourseRunKeys(gql: GqlRunner, programUid: string): Promise<string[]>;
|
|
29
40
|
/** Fetch a program's catalog/marketing details by tProgramUuid. */
|
|
30
41
|
export declare function getProgramDetail(gql: GqlRunner, programUid: string): Promise<ProgramDetail | null>;
|
|
31
42
|
/** Fetch a course's full catalog/marketing details by Viax tCourseKey for the PDP banner. */
|
|
@@ -17,7 +17,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
* itself and propagate unchanged, exactly as with every other function in
|
|
18
18
|
* bootstrapApi.ts/cartApi.ts.
|
|
19
19
|
*/
|
|
20
|
-
import { GET_ALACARTE_CHECKOUT, SELECT_ALACARTE_PRODUCT, UPDATE_ALACARTE_CHECKOUT, GET_OWNED_PRODUCT, GET_ALL_OWNED_PRODUCTS, GET_PROGRAM_DETAIL, GET_PLACED_ORDER, GET_ORDER_DATES, PLACE_ALACARTE_ORDER, GET_BANNER_COURSE_DETAIL, GET_BANNER_PROGRAM_DETAIL, CAPTURE_PAYPAL_ORDER, CANCEL_PAYPAL_ORDER, } from './alacarteQueries';
|
|
20
|
+
import { GET_ALACARTE_CHECKOUT, SELECT_ALACARTE_PRODUCT, UPDATE_ALACARTE_CHECKOUT, GET_OWNED_PRODUCT, GET_ALL_OWNED_PRODUCTS, GET_PROGRAM_DETAIL, GET_PROGRAM_COURSE_IDS, GET_PLACED_ORDER, GET_ORDER_DATES, PLACE_ALACARTE_ORDER, GET_BANNER_COURSE_DETAIL, GET_BANNER_PROGRAM_DETAIL, CAPTURE_PAYPAL_ORDER, CANCEL_PAYPAL_ORDER, } from './alacarteQueries';
|
|
21
21
|
function normalizeCheckoutResult(payload) {
|
|
22
22
|
var _a;
|
|
23
23
|
return {
|
|
@@ -177,6 +177,63 @@ export function getAllOwnedProducts(gql) {
|
|
|
177
177
|
};
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
+
function programUuidFilter(programUid) {
|
|
181
|
+
return `tProgramUuid='${programUid.trim().replace(/'/g, "''")}'`;
|
|
182
|
+
}
|
|
183
|
+
/** `tCourseRuns` returns every run it knows. Compliance needs the run the
|
|
184
|
+
* learner would actually buy: published runs when any exist, otherwise
|
|
185
|
+
* whatever keys came back so a course is not dropped. */
|
|
186
|
+
export function courseRunKeysFromRuns(runs) {
|
|
187
|
+
if (!Array.isArray(runs))
|
|
188
|
+
return [];
|
|
189
|
+
const withKeys = runs.flatMap((run) => {
|
|
190
|
+
if (!run || typeof run !== 'object')
|
|
191
|
+
return [];
|
|
192
|
+
const record = run;
|
|
193
|
+
const key = typeof record.courserun_key === 'string' ? record.courserun_key.trim() : '';
|
|
194
|
+
if (!key)
|
|
195
|
+
return [];
|
|
196
|
+
return [{ key, published: record.courserun_status === 'published' || record.courserun_status == null }];
|
|
197
|
+
});
|
|
198
|
+
const published = withKeys.filter((run) => run.published);
|
|
199
|
+
const chosen = published.length > 0 ? published : withKeys;
|
|
200
|
+
return chosen.map((run) => run.key);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Course run keys for every course in a program.
|
|
204
|
+
* Compliance-check takes course run keys (`course-v1:...`), and a program
|
|
205
|
+
* has no single run key of its own — look the program's courses up, then
|
|
206
|
+
* each course's runs via `tCourseRuns(courseUuid: <maId>)`.
|
|
207
|
+
*/
|
|
208
|
+
export function getProgramCourseRunKeys(gql, programUid) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
var _a, _b, _c, _d, _e;
|
|
211
|
+
const tProgramUuid = programUid.trim();
|
|
212
|
+
if (!tProgramUuid)
|
|
213
|
+
return [];
|
|
214
|
+
const data = yield gql(GET_PROGRAM_COURSE_IDS, { filter: programUuidFilter(tProgramUuid) });
|
|
215
|
+
const courses = (_e = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.filterTwouProgram) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.tCourses) !== null && _e !== void 0 ? _e : [];
|
|
216
|
+
const courseIds = [];
|
|
217
|
+
for (const course of courses) {
|
|
218
|
+
const maId = typeof (course === null || course === void 0 ? void 0 : course.maId) === 'string' ? course.maId.trim() : '';
|
|
219
|
+
if (maId && !courseIds.includes(maId))
|
|
220
|
+
courseIds.push(maId);
|
|
221
|
+
}
|
|
222
|
+
if (courseIds.length === 0)
|
|
223
|
+
return [];
|
|
224
|
+
const fields = courseIds.map((id, index) => (`c${index}: tCourseRuns(courseUuid: ${JSON.stringify(id)})`)).join('\n');
|
|
225
|
+
const runsData = yield gql(`query ProgramCourseRuns {\n${fields}\n}`);
|
|
226
|
+
const keys = [];
|
|
227
|
+
courseIds.forEach((_, index) => {
|
|
228
|
+
var _a;
|
|
229
|
+
for (const key of courseRunKeysFromRuns((_a = runsData === null || runsData === void 0 ? void 0 : runsData[`c${index}`]) === null || _a === void 0 ? void 0 : _a.runs)) {
|
|
230
|
+
if (!keys.includes(key))
|
|
231
|
+
keys.push(key);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return keys;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
180
237
|
/** Fetch a program's catalog/marketing details by tProgramUuid. */
|
|
181
238
|
export function getProgramDetail(gql, programUid) {
|
|
182
239
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -184,8 +241,7 @@ export function getProgramDetail(gql, programUid) {
|
|
|
184
241
|
const tProgramUuid = programUid.trim();
|
|
185
242
|
if (!tProgramUuid)
|
|
186
243
|
return null;
|
|
187
|
-
const
|
|
188
|
-
const data = yield gql(GET_PROGRAM_DETAIL, { filter });
|
|
244
|
+
const data = yield gql(GET_PROGRAM_DETAIL, { filter: programUuidFilter(tProgramUuid) });
|
|
189
245
|
const node = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.filterTwouProgram) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.node;
|
|
190
246
|
if (!(node === null || node === void 0 ? void 0 : node.uid))
|
|
191
247
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alacarteApi.js","sourceRoot":"","sources":["../../src/utils/alacarteApi.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,qBAAqB,EAAE,uBAAuB,EAAE,wBAAwB,EACxE,iBAAiB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,gBAAgB,EAC/E,eAAe,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,yBAAyB,EAC1F,oBAAoB,EAAE,mBAAmB,GAC1C,MAAM,mBAAmB,CAAC;AAQ3B,SAAS,uBAAuB,CAAC,OAAY;;IAC3C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IAAI;gBAChC,QAAQ,EAAE,MAAA,CAAC,CAAC,QAAQ,mCAAI,IAAI;gBAC5B,UAAU,EAAE,MAAA,CAAC,CAAC,UAAU,mCAAI,IAAI;gBAChC,cAAc,EAAE,MAAA,CAAC,CAAC,cAAc,mCAAI,IAAI;gBACxC,OAAO,EAAE,CAAA,MAAA,CAAC,CAAC,OAAO,0CAAE,IAAI,EAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;aAC3D,CAAC,CAAA;SAAA,CAAC,CAAC;QAEJ,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,IAAI;YACnC,gBAAgB,EAAE,MAAA,IAAI,CAAC,gBAAgB,mCAAI,IAAI;YAC/C,cAAc,EAAE,MAAA,IAAI,CAAC,cAAc,mCAAI,IAAI;YAC3C,oBAAoB,EAAE,MAAA,IAAI,CAAC,oBAAoB,mCAAI,IAAI;YACvD,OAAO,EAAE,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAI;YAC7B,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,mCAAI,IAAI;YACvB,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,IAAI;YACnC,QAAQ,EAAE,MAAA,IAAI,CAAC,QAAQ,mCAAI,IAAI;YAC/B,eAAe,EAAE,MAAA,IAAI,CAAC,eAAe,mCAAI,IAAI;YAC7C,QAAQ;SACT,CAAC;IACJ,CAAC;CAAA","sourcesContent":["/**\n * utils/alacarteApi.ts — à la carte checkout + owned-products operations.\n *\n * Convention: every function here returns the `{ ok, ... }` envelope as-is.\n * `ok: false` is a normal domain outcome (see alacarte-*-api.md `error` table)\n * and must be branched on by the caller — it is NOT thrown here. Transport\n * errors (missing token, HTTP 401, GraphQL errors[]) are thrown by gql()\n * itself and propagate unchanged, exactly as with every other function in\n * bootstrapApi.ts/cartApi.ts.\n */\nimport {\n GET_ALACARTE_CHECKOUT, SELECT_ALACARTE_PRODUCT, UPDATE_ALACARTE_CHECKOUT,\n GET_OWNED_PRODUCT, GET_ALL_OWNED_PRODUCTS, GET_PROGRAM_DETAIL, GET_PLACED_ORDER,\n GET_ORDER_DATES, PLACE_ALACARTE_ORDER, GET_BANNER_COURSE_DETAIL, GET_BANNER_PROGRAM_DETAIL,\n CAPTURE_PAYPAL_ORDER, CANCEL_PAYPAL_ORDER,\n} from './alacarteQueries';\nimport type {\n GqlRunner, AlacarteCheckoutResult, OwnedProductResult, AllOwnedProductsResult,\n ProgramDetail, ProgramCourseRef, PlacedOrderResult, OrderDatesResult,\n AlacarteBillingAddress, AlacartePlaceOrderApiResult, AlacartePaymentMethod, AlacartePaypalOrderResult,\n BannerCourseDetail, BannerCourseInstructor, BannerProgramDetail, BannerProgramCourse,\n} from '../types/alacarte';\n\nfunction normalizeCheckoutResult(payload: any): AlacarteCheckoutResult {\n return {\n ok: payload?.ok === true,\n checkout: payload?.checkout ?? null,\n replaced: payload?.replaced,\n priceChanged: payload?.priceChanged,\n blocked: payload?.blocked,\n couponRecheck: payload?.couponRecheck,\n error: payload?.error,\n };\n}\n\nexport async function getCheckout(gql: GqlRunner): Promise<AlacarteCheckoutResult> {\n const data = await gql(GET_ALACARTE_CHECKOUT);\n return normalizeCheckoutResult(data?.tCheckout);\n}\n\nexport async function selectCourse(\n gql: GqlRunner, courseUid: string, runKey: string, viewedPrice?: number,\n): Promise<AlacarteCheckoutResult> {\n const data = await gql(SELECT_ALACARTE_PRODUCT, { courseUid, runKey, viewedPrice });\n return normalizeCheckoutResult(data?.tCheckoutSelect);\n}\n\nexport async function selectProgram(\n gql: GqlRunner, programUid: string, viewedPrice?: number,\n): Promise<AlacarteCheckoutResult> {\n const data = await gql(SELECT_ALACARTE_PRODUCT, { programUid, viewedPrice });\n return normalizeCheckoutResult(data?.tCheckoutSelect);\n}\n\nexport async function updateCheckout(\n gql: GqlRunner,\n args: { biId?: string, couponCode?: string, termsAccepted?: boolean, acceptPrice?: boolean },\n): Promise<AlacarteCheckoutResult> {\n const data = await gql(UPDATE_ALACARTE_CHECKOUT, args);\n return normalizeCheckoutResult(data?.tCheckoutUpdate);\n}\n\n/** Reads the placed order for the confirmation page — never re-priced. */\nexport async function getPlacedOrder(gql: GqlRunner, biId: string): Promise<PlacedOrderResult> {\n const data = await gql(GET_PLACED_ORDER, { biId });\n const payload = data?.tPlacedOrder;\n return {\n ok: payload?.ok === true,\n order: payload?.order ?? null,\n error: payload?.error,\n };\n}\n\n/** Reads the order's placement/creation timestamps for the confirmation page. */\nexport async function getOrderDates(gql: GqlRunner, biId: string): Promise<OrderDatesResult> {\n const data = await gql(GET_ORDER_DATES, { biId });\n const payload = data?.getTwouOrder;\n return {\n ok: !!payload,\n dates: payload\n ? { tPlacedAt: payload.tPlacedAt ?? null, biCreatedAt: payload.biCreatedAt ?? null }\n : null,\n };\n}\n\n/**\n * One-call place order (section 5a). Runs sanctions + payment start and\n * returns the Stripe client secret.\n *\n * Only `country` (two-letter ISO) is required. Other address fields are\n * optional — the checkout UI also collects country-specific fields (ALC-177).\n */\nexport async function placeCheckoutOrder(\n gql: GqlRunner,\n biId: string,\n billing?: AlacarteBillingAddress,\n paymentMethod?: AlacartePaymentMethod,\n): Promise<AlacartePlaceOrderApiResult> {\n const optional = (value?: string): string | undefined => {\n const trimmed = value?.trim();\n return trimmed ? trimmed : undefined;\n };\n\n const data = await gql(PLACE_ALACARTE_ORDER, {\n biId,\n paymentMethod,\n country: billing?.country?.trim().toUpperCase() || undefined,\n firstName: optional(billing?.firstName),\n lastName: optional(billing?.lastName),\n line1: optional(billing?.line1),\n line2: optional(billing?.line2),\n city: optional(billing?.city),\n state: optional(billing?.state),\n postcode: optional(billing?.postcode),\n });\n const payload = data?.tCheckoutPlaceOrder;\n const payment = payload?.payment;\n return {\n ok: payload?.ok === true,\n payment: payment?.clientSecret\n ? {\n clientSecret: payment.clientSecret,\n paymentIntentId: payment.paymentIntentId ?? '',\n amount: payment.amount ?? 0,\n currency: payment.currency ?? 'usd',\n }\n : null,\n paypal: payment?.paypalOrderId\n ? {\n paypalOrderId: payment.paypalOrderId,\n amount: payment.amount ?? 0,\n currency: payment.currency ?? 'usd',\n }\n : null,\n checkout: payload?.checkout ?? null,\n error: payload?.error,\n };\n}\n\nfunction normalizePaypalOrderResult(payload: any): AlacartePaypalOrderResult {\n return {\n ok: payload?.ok === true,\n status: payload?.status,\n orderNumber: payload?.orderNumber,\n error: payload?.error,\n };\n}\n\n/** Captures the PayPal order the learner approved — places the order on COMPLETED. */\nexport async function capturePaypalOrder(\n gql: GqlRunner, biId: string, paypalOrderId: string,\n): Promise<AlacartePaypalOrderResult> {\n const data = await gql(CAPTURE_PAYPAL_ORDER, { biId, paypalOrderId });\n return normalizePaypalOrderResult(data?.tCheckoutCapturePaypalOrder);\n}\n\n/** Abandons an unapproved PayPal order so the checkout can be paid again. */\nexport async function cancelPaypalOrder(\n gql: GqlRunner, biId: string, paypalOrderId: string,\n): Promise<AlacartePaypalOrderResult> {\n const data = await gql(CANCEL_PAYPAL_ORDER, { biId, paypalOrderId });\n return normalizePaypalOrderResult(data?.tCheckoutCancelPaypalOrder);\n}\n\nexport async function getOwnedProduct(gql: GqlRunner, productId: string): Promise<OwnedProductResult> {\n const data = await gql(GET_OWNED_PRODUCT, { productId });\n const payload = data?.tOwnedProducts;\n return {\n ok: payload?.ok === true,\n product: payload?.product ?? null,\n error: payload?.error,\n };\n}\n\nexport async function getAllOwnedProducts(gql: GqlRunner): Promise<AllOwnedProductsResult> {\n const data = await gql(GET_ALL_OWNED_PRODUCTS);\n const payload = data?.tOwnedProducts;\n return {\n ok: payload?.ok === true,\n owned: payload?.owned ?? null,\n error: payload?.error,\n };\n}\n\n/** Fetch a program's catalog/marketing details by tProgramUuid. */\nexport async function getProgramDetail(gql: GqlRunner, programUid: string): Promise<ProgramDetail | null> {\n const tProgramUuid = programUid.trim();\n if (!tProgramUuid) return null;\n\n const filter = `tProgramUuid='${tProgramUuid.replace(/'/g, \"''\")}'`;\n const data = await gql(GET_PROGRAM_DETAIL, { filter });\n const node = data?.filterTwouProgram?.edges?.[0]?.node;\n if (!node?.uid) return null;\n\n const tCourses: ProgramCourseRef[] = (node.tCourses ?? []).map((c: any) => ({\n id: c.id,\n uid: c.uid ?? null,\n maName: c.maName ?? null,\n maDescription: c.maDescription ?? null,\n tShortDescription: c.tShortDescription ?? null,\n imageUrl: c.imageUrl ?? null,\n tBrandText: c.tBrandText ?? null,\n tOrgLogoUrl: c.tOrgLogoUrl ?? null,\n tUrlCourse: c.tUrlCourse ?? null,\n tMarketingSlug: c.tMarketingSlug ?? null,\n tStatus: c.tStatus?.code ? { code: c.tStatus.code } : null,\n }));\n\n return {\n uid: node.uid,\n tEffortLow: node.tEffortLow ?? null,\n tEnrollmentCount: node.tEnrollmentCount ?? null,\n tMarketingSlug: node.tMarketingSlug ?? null,\n tSkills: node.tSkills ?? null,\n tFaq: node.tFaq ?? null,\n tLevelType: node.tLevelType ?? null,\n tCourses,\n };\n}\n\n// ─── Banner details (PDP banner before checkout) ─────────────────────────────\n\n/** Fetch a course's full catalog/marketing details by Viax tCourseKey for the PDP banner. */\nexport async function getBannerCourseDetail(gql: GqlRunner, courseKey: string): Promise<BannerCourseDetail | null> {\n const key = courseKey.trim();\n if (!key) return null;\n\n const filter = `tCourseKey = '${key.replace(/'/g, \"''\")}' and tAlacartePurchasable='true'`;\n const data = await gql(GET_BANNER_COURSE_DETAIL, { filter });\n const node = data?.filterTwouCourse?.edges?.[0]?.node;\n if (!node?.uid) return null;\n\n const instructors: BannerCourseInstructor[] = (node.tInstructors ?? []).map((i: any) => ({\n tGivenName: i.tGivenName ?? null,\n tFamilyName: i.tFamilyName ?? null,\n tOrganization: i.tOrganization ?? null,\n tInstructorUuid: i.tInstructorUuid ?? null,\n tSortValue: i.tSortValue ?? null,\n }));\n\n return {\n uid: node.uid,\n id: node.id ?? null,\n maName: node.maName ?? '',\n tEnrollmentCount: node.tEnrollmentCount ?? null,\n tAlacartePurchasable: node.tAlacartePurchasable ?? null,\n tCourseKey: node.tCourseKey ?? null,\n tShortDescription: node.tShortDescription ?? null,\n maDescription: node.maDescription ?? null,\n tBrandText: node.tBrandText ?? null,\n tOrgLogoUrl: node.tOrgLogoUrl ?? null,\n imageUrl: node.imageUrl ?? null,\n tUrlCourse: node.tUrlCourse ?? null,\n tMarketingSlug: node.tMarketingSlug ?? null,\n tLevelType: node.tLevelType ?? null,\n tPacingType: node.tPacingType?.code ?? null,\n tDurationLow: node.tDurationLow ?? null,\n tDurationHigh: node.tDurationHigh ?? null,\n tDurationUnit: node.tDurationUnit?.code ?? null,\n tEffortLow: node.tEffortLow ?? null,\n tEffortHigh: node.tEffortHigh ?? null,\n tEffortUnit: node.tEffortUnit?.code ?? null,\n tLanguage: node.tLanguage ?? null,\n tExpectedLearningItems: node.tExpectedLearningItems ?? null,\n tSkills: node.tSkills ?? null,\n tPrerequisites: node.tPrerequisites ?? null,\n tSyllabus: node.tSyllabus ?? null,\n tFaq: node.tFaq ?? null,\n tTestimonials: node.tTestimonials ?? null,\n tTranscriptLanguages: node.tTranscriptLanguages ?? null,\n tInstructors: instructors,\n };\n}\n\n/** Fetch a program's full catalog/marketing details by tProgramUuid for the PDP banner. */\nexport async function getBannerProgramDetail(gql: GqlRunner, programUid: string): Promise<BannerProgramDetail | null> {\n const tProgramUuid = programUid.trim();\n if (!tProgramUuid) return null;\n\n const filter = `tProgramUuid='${tProgramUuid.replace(/'/g, \"''\")}' AND tAlacartePurchasable=true`;\n const data = await gql(GET_BANNER_PROGRAM_DETAIL, { filter });\n const node = data?.filterTwouProgram?.edges?.[0]?.node;\n if (!node?.uid) return null;\n\n const tCourses: BannerProgramCourse[] = (node.tCourses ?? []).map((c: any) => ({\n id: c.id,\n uid: c.uid ?? null,\n maName: c.maName ?? null,\n maDescription: c.maDescription ?? null,\n tShortDescription: c.tShortDescription ?? null,\n tBrandText: c.tBrandText ?? null,\n tOrgLogoUrl: c.tOrgLogoUrl ?? null,\n tCourseKey: c.tCourseKey ?? null,\n imageUrl: c.imageUrl ?? null,\n tUrlCourse: c.tUrlCourse ?? null,\n tMarketingSlug: c.tMarketingSlug ?? null,\n tStatus: c.tStatus?.code ? { code: c.tStatus.code } : null,\n }));\n\n return {\n uid: node.uid,\n tEffortLow: node.tEffortLow ?? null,\n tEnrollmentCount: node.tEnrollmentCount ?? null,\n tMarketingSlug: node.tMarketingSlug ?? null,\n tAlacartePurchasable: node.tAlacartePurchasable ?? null,\n tSkills: node.tSkills ?? null,\n tFaq: node.tFaq ?? null,\n tLevelType: node.tLevelType ?? null,\n imageUrl: node.imageUrl ?? null,\n tBannerImageUrl: node.tBannerImageUrl ?? null,\n tCourses,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"alacarteApi.js","sourceRoot":"","sources":["../../src/utils/alacarteApi.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,qBAAqB,EAAE,uBAAuB,EAAE,wBAAwB,EACxE,iBAAiB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,sBAAsB,EACrF,gBAAgB,EAChB,eAAe,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,yBAAyB,EAC1F,oBAAoB,EAAE,mBAAmB,GAC1C,MAAM,mBAAmB,CAAC;AAQ3B,SAAS,uBAAuB,CAAC,OAAY;;IAC3C,OAAO;QACL,EAAE,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,EAAE,MAAK,IAAI;QACxB,QAAQ,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,IAAI;QACnC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ;QAC3B,YAAY,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY;QACnC,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,C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CAAI,IAAI;gBAC5B,UAAU,EAAE,MAAA,CAAC,CAAC,UAAU,mCAAI,IAAI;gBAChC,cAAc,EAAE,MAAA,CAAC,CAAC,cAAc,mCAAI,IAAI;gBACxC,OAAO,EAAE,CAAA,MAAA,CAAC,CAAC,OAAO,0CAAE,IAAI,EAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;aAC3D,CAAC,CAAA;SAAA,CAAC,CAAC;QAEJ,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,IAAI;YACnC,gBAAgB,EAAE,MAAA,IAAI,CAAC,gBAAgB,mCAAI,IAAI;YAC/C,cAAc,EAAE,MAAA,IAAI,CAAC,cAAc,mCAAI,IAAI;YAC3C,oBAAoB,EAAE,MAAA,IAAI,CAAC,oBAAoB,mCAAI,IAAI;YACvD,OAAO,EAAE,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAI;YAC7B,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,mCAAI,IAAI;YACvB,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,IAAI;YACnC,QAAQ,EAAE,MAAA,IAAI,CAAC,QAAQ,mCAAI,IAAI;YAC/B,eAAe,EAAE,MAAA,IAAI,CAAC,eAAe,mCAAI,IAAI;YAC7C,QAAQ;SACT,CAAC;IACJ,CAAC;CAAA","sourcesContent":["/**\n * utils/alacarteApi.ts — à la carte checkout + owned-products operations.\n *\n * Convention: every function here returns the `{ ok, ... }` envelope as-is.\n * `ok: false` is a normal domain outcome (see alacarte-*-api.md `error` table)\n * and must be branched on by the caller — it is NOT thrown here. Transport\n * errors (missing token, HTTP 401, GraphQL errors[]) are thrown by gql()\n * itself and propagate unchanged, exactly as with every other function in\n * bootstrapApi.ts/cartApi.ts.\n */\nimport {\n GET_ALACARTE_CHECKOUT, SELECT_ALACARTE_PRODUCT, UPDATE_ALACARTE_CHECKOUT,\n GET_OWNED_PRODUCT, GET_ALL_OWNED_PRODUCTS, GET_PROGRAM_DETAIL, GET_PROGRAM_COURSE_IDS,\n GET_PLACED_ORDER,\n GET_ORDER_DATES, PLACE_ALACARTE_ORDER, GET_BANNER_COURSE_DETAIL, GET_BANNER_PROGRAM_DETAIL,\n CAPTURE_PAYPAL_ORDER, CANCEL_PAYPAL_ORDER,\n} from './alacarteQueries';\nimport type {\n GqlRunner, AlacarteCheckoutResult, OwnedProductResult, AllOwnedProductsResult,\n ProgramDetail, ProgramCourseRef, PlacedOrderResult, OrderDatesResult,\n AlacarteBillingAddress, AlacartePlaceOrderApiResult, AlacartePaymentMethod, AlacartePaypalOrderResult,\n BannerCourseDetail, BannerCourseInstructor, BannerProgramDetail, BannerProgramCourse,\n} from '../types/alacarte';\n\nfunction normalizeCheckoutResult(payload: any): AlacarteCheckoutResult {\n return {\n ok: payload?.ok === true,\n checkout: payload?.checkout ?? null,\n replaced: payload?.replaced,\n priceChanged: payload?.priceChanged,\n blocked: payload?.blocked,\n couponRecheck: payload?.couponRecheck,\n error: payload?.error,\n };\n}\n\nexport async function getCheckout(gql: GqlRunner): Promise<AlacarteCheckoutResult> {\n const data = await gql(GET_ALACARTE_CHECKOUT);\n return normalizeCheckoutResult(data?.tCheckout);\n}\n\nexport async function selectCourse(\n gql: GqlRunner, courseUid: string, runKey: string, viewedPrice?: number,\n): Promise<AlacarteCheckoutResult> {\n const data = await gql(SELECT_ALACARTE_PRODUCT, { courseUid, runKey, viewedPrice });\n return normalizeCheckoutResult(data?.tCheckoutSelect);\n}\n\nexport async function selectProgram(\n gql: GqlRunner, programUid: string, viewedPrice?: number,\n): Promise<AlacarteCheckoutResult> {\n const data = await gql(SELECT_ALACARTE_PRODUCT, { programUid, viewedPrice });\n return normalizeCheckoutResult(data?.tCheckoutSelect);\n}\n\nexport async function updateCheckout(\n gql: GqlRunner,\n args: { biId?: string, couponCode?: string, termsAccepted?: boolean, acceptPrice?: boolean },\n): Promise<AlacarteCheckoutResult> {\n const data = await gql(UPDATE_ALACARTE_CHECKOUT, args);\n return normalizeCheckoutResult(data?.tCheckoutUpdate);\n}\n\n/** Reads the placed order for the confirmation page — never re-priced. */\nexport async function getPlacedOrder(gql: GqlRunner, biId: string): Promise<PlacedOrderResult> {\n const data = await gql(GET_PLACED_ORDER, { biId });\n const payload = data?.tPlacedOrder;\n return {\n ok: payload?.ok === true,\n order: payload?.order ?? null,\n error: payload?.error,\n };\n}\n\n/** Reads the order's placement/creation timestamps for the confirmation page. */\nexport async function getOrderDates(gql: GqlRunner, biId: string): Promise<OrderDatesResult> {\n const data = await gql(GET_ORDER_DATES, { biId });\n const payload = data?.getTwouOrder;\n return {\n ok: !!payload,\n dates: payload\n ? { tPlacedAt: payload.tPlacedAt ?? null, biCreatedAt: payload.biCreatedAt ?? null }\n : null,\n };\n}\n\n/**\n * One-call place order (section 5a). Runs sanctions + payment start and\n * returns the Stripe client secret.\n *\n * Only `country` (two-letter ISO) is required. Other address fields are\n * optional — the checkout UI also collects country-specific fields (ALC-177).\n */\nexport async function placeCheckoutOrder(\n gql: GqlRunner,\n biId: string,\n billing?: AlacarteBillingAddress,\n paymentMethod?: AlacartePaymentMethod,\n): Promise<AlacartePlaceOrderApiResult> {\n const optional = (value?: string): string | undefined => {\n const trimmed = value?.trim();\n return trimmed ? trimmed : undefined;\n };\n\n const data = await gql(PLACE_ALACARTE_ORDER, {\n biId,\n paymentMethod,\n country: billing?.country?.trim().toUpperCase() || undefined,\n firstName: optional(billing?.firstName),\n lastName: optional(billing?.lastName),\n line1: optional(billing?.line1),\n line2: optional(billing?.line2),\n city: optional(billing?.city),\n state: optional(billing?.state),\n postcode: optional(billing?.postcode),\n });\n const payload = data?.tCheckoutPlaceOrder;\n const payment = payload?.payment;\n return {\n ok: payload?.ok === true,\n payment: payment?.clientSecret\n ? {\n clientSecret: payment.clientSecret,\n paymentIntentId: payment.paymentIntentId ?? '',\n amount: payment.amount ?? 0,\n currency: payment.currency ?? 'usd',\n }\n : null,\n paypal: payment?.paypalOrderId\n ? {\n paypalOrderId: payment.paypalOrderId,\n amount: payment.amount ?? 0,\n currency: payment.currency ?? 'usd',\n }\n : null,\n checkout: payload?.checkout ?? null,\n error: payload?.error,\n };\n}\n\nfunction normalizePaypalOrderResult(payload: any): AlacartePaypalOrderResult {\n return {\n ok: payload?.ok === true,\n status: payload?.status,\n orderNumber: payload?.orderNumber,\n error: payload?.error,\n };\n}\n\n/** Captures the PayPal order the learner approved — places the order on COMPLETED. */\nexport async function capturePaypalOrder(\n gql: GqlRunner, biId: string, paypalOrderId: string,\n): Promise<AlacartePaypalOrderResult> {\n const data = await gql(CAPTURE_PAYPAL_ORDER, { biId, paypalOrderId });\n return normalizePaypalOrderResult(data?.tCheckoutCapturePaypalOrder);\n}\n\n/** Abandons an unapproved PayPal order so the checkout can be paid again. */\nexport async function cancelPaypalOrder(\n gql: GqlRunner, biId: string, paypalOrderId: string,\n): Promise<AlacartePaypalOrderResult> {\n const data = await gql(CANCEL_PAYPAL_ORDER, { biId, paypalOrderId });\n return normalizePaypalOrderResult(data?.tCheckoutCancelPaypalOrder);\n}\n\nexport async function getOwnedProduct(gql: GqlRunner, productId: string): Promise<OwnedProductResult> {\n const data = await gql(GET_OWNED_PRODUCT, { productId });\n const payload = data?.tOwnedProducts;\n return {\n ok: payload?.ok === true,\n product: payload?.product ?? null,\n error: payload?.error,\n };\n}\n\nexport async function getAllOwnedProducts(gql: GqlRunner): Promise<AllOwnedProductsResult> {\n const data = await gql(GET_ALL_OWNED_PRODUCTS);\n const payload = data?.tOwnedProducts;\n return {\n ok: payload?.ok === true,\n owned: payload?.owned ?? null,\n error: payload?.error,\n };\n}\n\nfunction programUuidFilter(programUid: string): string {\n return `tProgramUuid='${programUid.trim().replace(/'/g, \"''\")}'`;\n}\n\n/** `tCourseRuns` returns every run it knows. Compliance needs the run the\n * learner would actually buy: published runs when any exist, otherwise\n * whatever keys came back so a course is not dropped. */\nexport function courseRunKeysFromRuns(runs: unknown): string[] {\n if (!Array.isArray(runs)) return [];\n const withKeys = runs.flatMap((run) => {\n if (!run || typeof run !== 'object') return [];\n const record = run as { courserun_key?: unknown, courserun_status?: unknown };\n const key = typeof record.courserun_key === 'string' ? record.courserun_key.trim() : '';\n if (!key) return [];\n return [{ key, published: record.courserun_status === 'published' || record.courserun_status == null }];\n });\n const published = withKeys.filter((run) => run.published);\n const chosen = published.length > 0 ? published : withKeys;\n return chosen.map((run) => run.key);\n}\n\n/**\n * Course run keys for every course in a program.\n * Compliance-check takes course run keys (`course-v1:...`), and a program\n * has no single run key of its own — look the program's courses up, then\n * each course's runs via `tCourseRuns(courseUuid: <maId>)`.\n */\nexport async function getProgramCourseRunKeys(gql: GqlRunner, programUid: string): Promise<string[]> {\n const tProgramUuid = programUid.trim();\n if (!tProgramUuid) return [];\n\n const data = await gql(GET_PROGRAM_COURSE_IDS, { filter: programUuidFilter(tProgramUuid) });\n const courses = data?.filterTwouProgram?.edges?.[0]?.node?.tCourses ?? [];\n const courseIds: string[] = [];\n for (const course of courses) {\n const maId = typeof course?.maId === 'string' ? course.maId.trim() : '';\n if (maId && !courseIds.includes(maId)) courseIds.push(maId);\n }\n if (courseIds.length === 0) return [];\n\n const fields = courseIds.map((id, index) => (\n `c${index}: tCourseRuns(courseUuid: ${JSON.stringify(id)})`\n )).join('\\n');\n const runsData = await gql(`query ProgramCourseRuns {\\n${fields}\\n}`);\n\n const keys: string[] = [];\n courseIds.forEach((_, index) => {\n for (const key of courseRunKeysFromRuns(runsData?.[`c${index}`]?.runs)) {\n if (!keys.includes(key)) keys.push(key);\n }\n });\n return keys;\n}\n\n/** Fetch a program's catalog/marketing details by tProgramUuid. */\nexport async function getProgramDetail(gql: GqlRunner, programUid: string): Promise<ProgramDetail | null> {\n const tProgramUuid = programUid.trim();\n if (!tProgramUuid) return null;\n\n const data = await gql(GET_PROGRAM_DETAIL, { filter: programUuidFilter(tProgramUuid) });\n const node = data?.filterTwouProgram?.edges?.[0]?.node;\n if (!node?.uid) return null;\n\n const tCourses: ProgramCourseRef[] = (node.tCourses ?? []).map((c: any) => ({\n id: c.id,\n uid: c.uid ?? null,\n maName: c.maName ?? null,\n maDescription: c.maDescription ?? null,\n tShortDescription: c.tShortDescription ?? null,\n imageUrl: c.imageUrl ?? null,\n tBrandText: c.tBrandText ?? null,\n tOrgLogoUrl: c.tOrgLogoUrl ?? null,\n tUrlCourse: c.tUrlCourse ?? null,\n tMarketingSlug: c.tMarketingSlug ?? null,\n tStatus: c.tStatus?.code ? { code: c.tStatus.code } : null,\n }));\n\n return {\n uid: node.uid,\n tEffortLow: node.tEffortLow ?? null,\n tEnrollmentCount: node.tEnrollmentCount ?? null,\n tMarketingSlug: node.tMarketingSlug ?? null,\n tSkills: node.tSkills ?? null,\n tFaq: node.tFaq ?? null,\n tLevelType: node.tLevelType ?? null,\n tCourses,\n };\n}\n\n// ─── Banner details (PDP banner before checkout) ─────────────────────────────\n\n/** Fetch a course's full catalog/marketing details by Viax tCourseKey for the PDP banner. */\nexport async function getBannerCourseDetail(gql: GqlRunner, courseKey: string): Promise<BannerCourseDetail | null> {\n const key = courseKey.trim();\n if (!key) return null;\n\n const filter = `tCourseKey = '${key.replace(/'/g, \"''\")}' and tAlacartePurchasable='true'`;\n const data = await gql(GET_BANNER_COURSE_DETAIL, { filter });\n const node = data?.filterTwouCourse?.edges?.[0]?.node;\n if (!node?.uid) return null;\n\n const instructors: BannerCourseInstructor[] = (node.tInstructors ?? []).map((i: any) => ({\n tGivenName: i.tGivenName ?? null,\n tFamilyName: i.tFamilyName ?? null,\n tOrganization: i.tOrganization ?? null,\n tInstructorUuid: i.tInstructorUuid ?? null,\n tSortValue: i.tSortValue ?? null,\n }));\n\n return {\n uid: node.uid,\n id: node.id ?? null,\n maName: node.maName ?? '',\n tEnrollmentCount: node.tEnrollmentCount ?? null,\n tAlacartePurchasable: node.tAlacartePurchasable ?? null,\n tCourseKey: node.tCourseKey ?? null,\n tShortDescription: node.tShortDescription ?? null,\n maDescription: node.maDescription ?? null,\n tBrandText: node.tBrandText ?? null,\n tOrgLogoUrl: node.tOrgLogoUrl ?? null,\n imageUrl: node.imageUrl ?? null,\n tUrlCourse: node.tUrlCourse ?? null,\n tMarketingSlug: node.tMarketingSlug ?? null,\n tLevelType: node.tLevelType ?? null,\n tPacingType: node.tPacingType?.code ?? null,\n tDurationLow: node.tDurationLow ?? null,\n tDurationHigh: node.tDurationHigh ?? null,\n tDurationUnit: node.tDurationUnit?.code ?? null,\n tEffortLow: node.tEffortLow ?? null,\n tEffortHigh: node.tEffortHigh ?? null,\n tEffortUnit: node.tEffortUnit?.code ?? null,\n tLanguage: node.tLanguage ?? null,\n tExpectedLearningItems: node.tExpectedLearningItems ?? null,\n tSkills: node.tSkills ?? null,\n tPrerequisites: node.tPrerequisites ?? null,\n tSyllabus: node.tSyllabus ?? null,\n tFaq: node.tFaq ?? null,\n tTestimonials: node.tTestimonials ?? null,\n tTranscriptLanguages: node.tTranscriptLanguages ?? null,\n tInstructors: instructors,\n };\n}\n\n/** Fetch a program's full catalog/marketing details by tProgramUuid for the PDP banner. */\nexport async function getBannerProgramDetail(gql: GqlRunner, programUid: string): Promise<BannerProgramDetail | null> {\n const tProgramUuid = programUid.trim();\n if (!tProgramUuid) return null;\n\n const filter = `tProgramUuid='${tProgramUuid.replace(/'/g, \"''\")}' AND tAlacartePurchasable=true`;\n const data = await gql(GET_BANNER_PROGRAM_DETAIL, { filter });\n const node = data?.filterTwouProgram?.edges?.[0]?.node;\n if (!node?.uid) return null;\n\n const tCourses: BannerProgramCourse[] = (node.tCourses ?? []).map((c: any) => ({\n id: c.id,\n uid: c.uid ?? null,\n maName: c.maName ?? null,\n maDescription: c.maDescription ?? null,\n tShortDescription: c.tShortDescription ?? null,\n tBrandText: c.tBrandText ?? null,\n tOrgLogoUrl: c.tOrgLogoUrl ?? null,\n tCourseKey: c.tCourseKey ?? null,\n imageUrl: c.imageUrl ?? null,\n tUrlCourse: c.tUrlCourse ?? null,\n tMarketingSlug: c.tMarketingSlug ?? null,\n tStatus: c.tStatus?.code ? { code: c.tStatus.code } : null,\n }));\n\n return {\n uid: node.uid,\n tEffortLow: node.tEffortLow ?? null,\n tEnrollmentCount: node.tEnrollmentCount ?? null,\n tMarketingSlug: node.tMarketingSlug ?? null,\n tAlacartePurchasable: node.tAlacartePurchasable ?? null,\n tSkills: node.tSkills ?? null,\n tFaq: node.tFaq ?? null,\n tLevelType: node.tLevelType ?? null,\n imageUrl: node.imageUrl ?? null,\n tBannerImageUrl: node.tBannerImageUrl ?? null,\n tCourses,\n };\n}\n"]}
|
|
@@ -39,6 +39,9 @@ export declare const CAPTURE_PAYPAL_ORDER = "mutation CapturePaypalOrder($biId:
|
|
|
39
39
|
/** The learner closed the PayPal window without approving — settles the
|
|
40
40
|
* attempt as a failed payment so the checkout can be retried. */
|
|
41
41
|
export declare const CANCEL_PAYPAL_ORDER = "mutation CancelPaypalOrder($biId: String!, $paypalOrderId: String!) {\n tCheckoutCancelPaypalOrder(biId: $biId, paypalOrderId: $paypalOrderId)\n}";
|
|
42
|
+
/** Catalog ids (`maId`) of the courses in a program. `tCourseRuns` looks up
|
|
43
|
+
* course run keys by this id, not by the Viax uid or `tCourseKey`. */
|
|
44
|
+
export declare const GET_PROGRAM_COURSE_IDS = "query GetProgramCourseIds($filter: String!) {\n filterTwouProgram(_first: 1, _filter: $filter) {\n edges {\n node {\n tCourses { maId }\n }\n }\n }\n}";
|
|
42
45
|
/** Fetch a program's catalog/marketing details by tProgramUuid (program analog of
|
|
43
46
|
* GET_COURSE_DETAIL, which filters courses by tCourseKey). */
|
|
44
47
|
export declare const GET_PROGRAM_DETAIL = "query GetProgramDetail($filter: String!) {\n filterTwouProgram(_first: 1, _filter: $filter) {\n edges {\n node {\n uid\n tProgramUuid\n tEffortLow\n tEnrollmentCount\n tMarketingSlug\n tSkills\n tFaq\n tLevelType\n tCourses {\n id\n maName\n uid\n tCourseKey\n tShortDescription\n maDescription\n tBrandText\n tOrgLogoUrl\n imageUrl\n tUrlCourse\n tMarketingSlug\n tStatus { code }\n }\n }\n }\n }\n}";
|
|
@@ -88,6 +88,17 @@ export const CANCEL_PAYPAL_ORDER = `mutation CancelPaypalOrder($biId: String!, $
|
|
|
88
88
|
tCheckoutCancelPaypalOrder(biId: $biId, paypalOrderId: $paypalOrderId)
|
|
89
89
|
}`;
|
|
90
90
|
// ─── Program details ──────────────────────────────────────────────────────────
|
|
91
|
+
/** Catalog ids (`maId`) of the courses in a program. `tCourseRuns` looks up
|
|
92
|
+
* course run keys by this id, not by the Viax uid or `tCourseKey`. */
|
|
93
|
+
export const GET_PROGRAM_COURSE_IDS = `query GetProgramCourseIds($filter: String!) {
|
|
94
|
+
filterTwouProgram(_first: 1, _filter: $filter) {
|
|
95
|
+
edges {
|
|
96
|
+
node {
|
|
97
|
+
tCourses { maId }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}`;
|
|
91
102
|
/** Fetch a program's catalog/marketing details by tProgramUuid (program analog of
|
|
92
103
|
* GET_COURSE_DETAIL, which filters courses by tCourseKey). */
|
|
93
104
|
export const GET_PROGRAM_DETAIL = `query GetProgramDetail($filter: String!) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alacarteQueries.js","sourceRoot":"","sources":["../../src/utils/alacarteQueries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iFAAiF;AAEjF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;EAEnC,CAAC;AAEH;;;;;+DAK+D;AAC/D,MAAM,CAAC,MAAM,uBAAuB,GAAG;;EAErC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;EAEtC,CAAC;AAEH,iFAAiF;AAEjF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;EAE/B,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;EAEpC,CAAC;AAEH,gFAAgF;AAEhF;gFACgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAG;;EAE9B,CAAC;AAEH;;6CAE6C;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;EAK7B,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;EAwBlC,CAAC;AAEH;oEACoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG;;EAElC,CAAC;AAEH;kEACkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG;;EAEjC,CAAC;AAEH,iFAAiF;AAEjF;+DAC+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BhC,CAAC;AAEH,gFAAgF;AAEhF,wFAAwF;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CtC,CAAC;AAEH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCvC,CAAC","sourcesContent":["/**\n * utils/alacarteQueries.ts — GraphQL documents for the à la carte checkout flow.\n * tCheckout / tCheckoutSelect / tCheckoutUpdate / tOwnedProducts / tPlacedOrder\n * are JSON-scalar fields — no field selection sets allowed; the whole response\n * object comes back as-is (same style as GET_IS_CURRENT_USER_SUBSCRIBER in\n * queries.ts). GET_PROGRAM_DETAIL is the one exception — filterTwouProgram is\n * a normal typed field with an explicit selection set, mirroring GET_COURSE_DETAIL.\n * See alacarte-checkout-api.md and alacarte-owned-products-api.md at the repo\n * root for the full contract.\n */\n\n// ─── Checkout ─────────────────────────────────────────────────────────────────\n\nexport const GET_ALACARTE_CHECKOUT = `query GetAlacarteCheckout {\n tCheckout\n}`;\n\n/** Selects a course or a program into the learner's open checkout. Pass only\n * the relevant variables — courseUid+runKey for a course, programUid alone\n * for a program; GraphQL omits unset optional variables cleanly.\n * viewedPrice is the amount (USD, before any coupon) the learner saw before\n * checkout — for a program, the price after already-owned courses are taken\n * off. Omit it to accept whatever price checkout resolves. */\nexport const SELECT_ALACARTE_PRODUCT = `mutation SelectAlacarteProduct($courseUid: String, $runKey: String, $programUid: String, $viewedPrice: Float) {\n tCheckoutSelect(courseUid: $courseUid, runKey: $runKey, programUid: $programUid, viewedPrice: $viewedPrice)\n}`;\n\nexport const UPDATE_ALACARTE_CHECKOUT = `mutation UpdateAlacarteCheckout($biId: String, $couponCode: String, $termsAccepted: Boolean, $acceptPrice: Boolean) {\n tCheckoutUpdate(biId: $biId, couponCode: $couponCode, termsAccepted: $termsAccepted, acceptPrice: $acceptPrice)\n}`;\n\n// ─── Owned products ───────────────────────────────────────────────────────────\n\nexport const GET_OWNED_PRODUCT = `query GetOwnedProduct($productId: String!) {\n tOwnedProducts(productId: $productId)\n}`;\n\nexport const GET_ALL_OWNED_PRODUCTS = `query GetAllOwnedProducts {\n tOwnedProducts\n}`;\n\n// ─── Placed order (confirmation page) ────────────────────────────────────────\n\n/** Reads the order as recorded at placement — the same biId the checkout had.\n * Never re-priced, so a later catalog change doesn't alter what this shows. */\nexport const GET_PLACED_ORDER = `query GetPlacedOrder($biId: String!) {\n tPlacedOrder(biId: $biId)\n}`;\n\n/** Order placement/creation timestamps — used for purchase date and the\n * refund-window deadline on the confirmation page. Use tPlacedAt; fall back\n * to biCreatedAt when tPlacedAt is null. */\nexport const GET_ORDER_DATES = `query GetSingleOrder($biId: String!) {\n getTwouOrder(biId: $biId) {\n tPlacedAt\n biCreatedAt\n }\n}`;\n\n/**\n * One-call \"Place your order\" — sanctions, payment start, and Stripe client\n * secret. Only `country` (two-letter ISO) is required; other address fields\n * are optional when the UI collects country alone.\n * See alacarte-checkout-api.md section 5a.\n */\nexport const PLACE_ALACARTE_ORDER = `mutation PlaceAlacarteOrder(\n $biId: String,\n $paymentMethod: String,\n $firstName: String,\n $lastName: String,\n $line1: String,\n $line2: String,\n $city: String,\n $state: String,\n $postcode: String,\n $country: String\n) {\n tCheckoutPlaceOrder(\n biId: $biId,\n paymentMethod: $paymentMethod,\n firstName: $firstName,\n lastName: $lastName,\n line1: $line1,\n line2: $line2,\n city: $city,\n state: $state,\n postcode: $postcode,\n country: $country\n )\n}`;\n\n/** Captures the PayPal order the learner approved in the PayPal buttons\n * (tCheckoutPlaceOrder with paymentMethod \"PAYPAL\" created it). */\nexport const CAPTURE_PAYPAL_ORDER = `mutation CapturePaypalOrder($biId: String!, $paypalOrderId: String!) {\n tCheckoutCapturePaypalOrder(biId: $biId, paypalOrderId: $paypalOrderId)\n}`;\n\n/** The learner closed the PayPal window without approving — settles the\n * attempt as a failed payment so the checkout can be retried. */\nexport const CANCEL_PAYPAL_ORDER = `mutation CancelPaypalOrder($biId: String!, $paypalOrderId: String!) {\n tCheckoutCancelPaypalOrder(biId: $biId, paypalOrderId: $paypalOrderId)\n}`;\n\n// ─── Program details ──────────────────────────────────────────────────────────\n\n/** Fetch a program's catalog/marketing details by tProgramUuid (program analog of\n * GET_COURSE_DETAIL, which filters courses by tCourseKey). */\nexport const GET_PROGRAM_DETAIL = `query GetProgramDetail($filter: String!) {\n filterTwouProgram(_first: 1, _filter: $filter) {\n edges {\n node {\n uid\n tProgramUuid\n tEffortLow\n tEnrollmentCount\n tMarketingSlug\n tSkills\n tFaq\n tLevelType\n tCourses {\n id\n maName\n uid\n tCourseKey\n tShortDescription\n maDescription\n tBrandText\n tOrgLogoUrl\n imageUrl\n tUrlCourse\n tMarketingSlug\n tStatus { code }\n }\n }\n }\n }\n}`;\n\n// ─── Banner details (PDP banner before checkout) ─────────────────────────────\n\n/** Fetch a course's full catalog/marketing details by tCourseKey for the PDP banner. */\nexport const GET_BANNER_COURSE_DETAIL = `query GetBannerCourseDetail($filter: String!) {\n filterTwouCourse(_first: 1, _filter: $filter) {\n edges {\n node {\n maName\n tEnrollmentCount\n tAlacartePurchasable\n uid\n id\n tCourseKey\n tShortDescription\n maDescription\n tBrandText\n tOrgLogoUrl\n imageUrl\n tUrlCourse\n tMarketingSlug\n tLevelType\n tPacingType { code }\n tDurationLow\n tDurationHigh\n tDurationUnit { code }\n tEffortLow\n tEffortHigh\n tEffortUnit { code }\n tLanguage\n tExpectedLearningItems\n tSkills\n tPrerequisites\n tSyllabus\n tFaq\n tTestimonials\n tTranscriptLanguages\n tInstructors {\n tGivenName\n tFamilyName\n tOrganization\n tInstructorUuid\n tSortValue\n }\n }\n }\n }\n}`;\n\n/** Fetch a program's full catalog/marketing details by tProgramUuid for the PDP banner. */\nexport const GET_BANNER_PROGRAM_DETAIL = `query GetBannerProgramDetail($filter: String!) {\n filterTwouProgram(_first: 1, _filter: $filter) {\n edges {\n node {\n uid\n tProgramUuid\n tEffortLow\n tEnrollmentCount\n tMarketingSlug\n tAlacartePurchasable\n tSkills\n tFaq\n tLevelType\n imageUrl\n tBannerImageUrl\n tCourses {\n id\n maName\n uid\n tCourseKey\n tShortDescription\n maDescription\n tBrandText\n tOrgLogoUrl\n tCourseKey\n imageUrl\n tUrlCourse\n tMarketingSlug\n tStatus { code }\n }\n }\n }\n }\n}`;\n"]}
|
|
1
|
+
{"version":3,"file":"alacarteQueries.js","sourceRoot":"","sources":["../../src/utils/alacarteQueries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iFAAiF;AAEjF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;EAEnC,CAAC;AAEH;;;;;+DAK+D;AAC/D,MAAM,CAAC,MAAM,uBAAuB,GAAG;;EAErC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;EAEtC,CAAC;AAEH,iFAAiF;AAEjF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;EAE/B,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;EAEpC,CAAC;AAEH,gFAAgF;AAEhF;gFACgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAG;;EAE9B,CAAC;AAEH;;6CAE6C;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;EAK7B,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;EAwBlC,CAAC;AAEH;oEACoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG;;EAElC,CAAC;AAEH;kEACkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG;;EAEjC,CAAC;AAEH,iFAAiF;AAEjF;uEACuE;AACvE,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;EAQpC,CAAC;AAEH;+DAC+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BhC,CAAC;AAEH,gFAAgF;AAEhF,wFAAwF;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CtC,CAAC;AAEH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCvC,CAAC","sourcesContent":["/**\n * utils/alacarteQueries.ts — GraphQL documents for the à la carte checkout flow.\n * tCheckout / tCheckoutSelect / tCheckoutUpdate / tOwnedProducts / tPlacedOrder\n * are JSON-scalar fields — no field selection sets allowed; the whole response\n * object comes back as-is (same style as GET_IS_CURRENT_USER_SUBSCRIBER in\n * queries.ts). GET_PROGRAM_DETAIL is the one exception — filterTwouProgram is\n * a normal typed field with an explicit selection set, mirroring GET_COURSE_DETAIL.\n * See alacarte-checkout-api.md and alacarte-owned-products-api.md at the repo\n * root for the full contract.\n */\n\n// ─── Checkout ─────────────────────────────────────────────────────────────────\n\nexport const GET_ALACARTE_CHECKOUT = `query GetAlacarteCheckout {\n tCheckout\n}`;\n\n/** Selects a course or a program into the learner's open checkout. Pass only\n * the relevant variables — courseUid+runKey for a course, programUid alone\n * for a program; GraphQL omits unset optional variables cleanly.\n * viewedPrice is the amount (USD, before any coupon) the learner saw before\n * checkout — for a program, the price after already-owned courses are taken\n * off. Omit it to accept whatever price checkout resolves. */\nexport const SELECT_ALACARTE_PRODUCT = `mutation SelectAlacarteProduct($courseUid: String, $runKey: String, $programUid: String, $viewedPrice: Float) {\n tCheckoutSelect(courseUid: $courseUid, runKey: $runKey, programUid: $programUid, viewedPrice: $viewedPrice)\n}`;\n\nexport const UPDATE_ALACARTE_CHECKOUT = `mutation UpdateAlacarteCheckout($biId: String, $couponCode: String, $termsAccepted: Boolean, $acceptPrice: Boolean) {\n tCheckoutUpdate(biId: $biId, couponCode: $couponCode, termsAccepted: $termsAccepted, acceptPrice: $acceptPrice)\n}`;\n\n// ─── Owned products ───────────────────────────────────────────────────────────\n\nexport const GET_OWNED_PRODUCT = `query GetOwnedProduct($productId: String!) {\n tOwnedProducts(productId: $productId)\n}`;\n\nexport const GET_ALL_OWNED_PRODUCTS = `query GetAllOwnedProducts {\n tOwnedProducts\n}`;\n\n// ─── Placed order (confirmation page) ────────────────────────────────────────\n\n/** Reads the order as recorded at placement — the same biId the checkout had.\n * Never re-priced, so a later catalog change doesn't alter what this shows. */\nexport const GET_PLACED_ORDER = `query GetPlacedOrder($biId: String!) {\n tPlacedOrder(biId: $biId)\n}`;\n\n/** Order placement/creation timestamps — used for purchase date and the\n * refund-window deadline on the confirmation page. Use tPlacedAt; fall back\n * to biCreatedAt when tPlacedAt is null. */\nexport const GET_ORDER_DATES = `query GetSingleOrder($biId: String!) {\n getTwouOrder(biId: $biId) {\n tPlacedAt\n biCreatedAt\n }\n}`;\n\n/**\n * One-call \"Place your order\" — sanctions, payment start, and Stripe client\n * secret. Only `country` (two-letter ISO) is required; other address fields\n * are optional when the UI collects country alone.\n * See alacarte-checkout-api.md section 5a.\n */\nexport const PLACE_ALACARTE_ORDER = `mutation PlaceAlacarteOrder(\n $biId: String,\n $paymentMethod: String,\n $firstName: String,\n $lastName: String,\n $line1: String,\n $line2: String,\n $city: String,\n $state: String,\n $postcode: String,\n $country: String\n) {\n tCheckoutPlaceOrder(\n biId: $biId,\n paymentMethod: $paymentMethod,\n firstName: $firstName,\n lastName: $lastName,\n line1: $line1,\n line2: $line2,\n city: $city,\n state: $state,\n postcode: $postcode,\n country: $country\n )\n}`;\n\n/** Captures the PayPal order the learner approved in the PayPal buttons\n * (tCheckoutPlaceOrder with paymentMethod \"PAYPAL\" created it). */\nexport const CAPTURE_PAYPAL_ORDER = `mutation CapturePaypalOrder($biId: String!, $paypalOrderId: String!) {\n tCheckoutCapturePaypalOrder(biId: $biId, paypalOrderId: $paypalOrderId)\n}`;\n\n/** The learner closed the PayPal window without approving — settles the\n * attempt as a failed payment so the checkout can be retried. */\nexport const CANCEL_PAYPAL_ORDER = `mutation CancelPaypalOrder($biId: String!, $paypalOrderId: String!) {\n tCheckoutCancelPaypalOrder(biId: $biId, paypalOrderId: $paypalOrderId)\n}`;\n\n// ─── Program details ──────────────────────────────────────────────────────────\n\n/** Catalog ids (`maId`) of the courses in a program. `tCourseRuns` looks up\n * course run keys by this id, not by the Viax uid or `tCourseKey`. */\nexport const GET_PROGRAM_COURSE_IDS = `query GetProgramCourseIds($filter: String!) {\n filterTwouProgram(_first: 1, _filter: $filter) {\n edges {\n node {\n tCourses { maId }\n }\n }\n }\n}`;\n\n/** Fetch a program's catalog/marketing details by tProgramUuid (program analog of\n * GET_COURSE_DETAIL, which filters courses by tCourseKey). */\nexport const GET_PROGRAM_DETAIL = `query GetProgramDetail($filter: String!) {\n filterTwouProgram(_first: 1, _filter: $filter) {\n edges {\n node {\n uid\n tProgramUuid\n tEffortLow\n tEnrollmentCount\n tMarketingSlug\n tSkills\n tFaq\n tLevelType\n tCourses {\n id\n maName\n uid\n tCourseKey\n tShortDescription\n maDescription\n tBrandText\n tOrgLogoUrl\n imageUrl\n tUrlCourse\n tMarketingSlug\n tStatus { code }\n }\n }\n }\n }\n}`;\n\n// ─── Banner details (PDP banner before checkout) ─────────────────────────────\n\n/** Fetch a course's full catalog/marketing details by tCourseKey for the PDP banner. */\nexport const GET_BANNER_COURSE_DETAIL = `query GetBannerCourseDetail($filter: String!) {\n filterTwouCourse(_first: 1, _filter: $filter) {\n edges {\n node {\n maName\n tEnrollmentCount\n tAlacartePurchasable\n uid\n id\n tCourseKey\n tShortDescription\n maDescription\n tBrandText\n tOrgLogoUrl\n imageUrl\n tUrlCourse\n tMarketingSlug\n tLevelType\n tPacingType { code }\n tDurationLow\n tDurationHigh\n tDurationUnit { code }\n tEffortLow\n tEffortHigh\n tEffortUnit { code }\n tLanguage\n tExpectedLearningItems\n tSkills\n tPrerequisites\n tSyllabus\n tFaq\n tTestimonials\n tTranscriptLanguages\n tInstructors {\n tGivenName\n tFamilyName\n tOrganization\n tInstructorUuid\n tSortValue\n }\n }\n }\n }\n}`;\n\n/** Fetch a program's full catalog/marketing details by tProgramUuid for the PDP banner. */\nexport const GET_BANNER_PROGRAM_DETAIL = `query GetBannerProgramDetail($filter: String!) {\n filterTwouProgram(_first: 1, _filter: $filter) {\n edges {\n node {\n uid\n tProgramUuid\n tEffortLow\n tEnrollmentCount\n tMarketingSlug\n tAlacartePurchasable\n tSkills\n tFaq\n tLevelType\n imageUrl\n tBannerImageUrl\n tCourses {\n id\n maName\n uid\n tCourseKey\n tShortDescription\n maDescription\n tBrandText\n tOrgLogoUrl\n tCourseKey\n imageUrl\n tUrlCourse\n tMarketingSlug\n tStatus { code }\n }\n }\n }\n }\n}`;\n"]}
|