@edx/frontend-app-alacarte-checkout 1.31.0 → 1.32.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.
@@ -85,9 +85,9 @@ const AlacarteConfirmation = ({ order, awaiting, error, onContinue, productDetai
85
85
  amount: discount.toFixed(2),
86
86
  currency,
87
87
  }) })] })), _jsxs("div", { className: "alacarte-confirmation__price-row alacarte-confirmation__price-row--paid", children: [_jsx("span", { children: formatMessage(messages.amountPaid) }), _jsx("span", { children: money(paid) })] })] }));
88
- return (_jsx("div", { className: "alacarte-confirmation", "data-testid": "alacarte-confirmation", children: _jsxs(Row, { className: "alacarte-confirmation__row", children: [_jsxs(Col, { xs: 12, lg: 7, className: "alacarte-confirmation__main", children: [_jsx("h1", { className: "alacarte-confirmation__headline font-weight-bold mb-4", children: formatMessage(messages.headline) }), _jsx("p", { className: "alacarte-confirmation__subheadline mb-4", children: formatMessage(programOrder ? messages.subheadlineProgram : messages.subheadlineCourse, { productLabel }) }), _jsxs("div", { className: "alacarte-confirmation__ctas d-flex align-items-center flex-wrap mb-4.5", children: [_jsx(Button, { variant: "brand", className: "alacarte-confirmation__cta-primary", onClick: onContinue, children: formatMessage(programOrder ? messages.startProgram : messages.startCourse) }), orderHistoryUrl && (_jsx("a", { href: orderHistoryUrl, className: "alacarte-confirmation__order-history", children: formatMessage(messages.viewOrderHistory) }))] }), _jsx("div", { className: "alacarte-confirmation__summary-mobile d-lg-none", children: summaryCard }), programOrder && (purchasedCourseNames.length > 0 || previouslyPurchased.length > 0) && (_jsxs("div", { className: "alacarte-confirmation__about-program mb-5", children: [_jsx("h2", { className: "alacarte-confirmation__about-title", children: formatMessage(messages.aboutProgram) }), purchasedCourseNames.length > 0 && (_jsxs(_Fragment, { children: [_jsx("p", { className: "alacarte-confirmation__courses-included", children: formatMessage(messages.coursesIncluded, { count: programCourseTotal }) }), _jsx("ul", { className: "alacarte-confirmation__course-list mb-0", children: purchasedCourseNames.map((name) => (_jsx("li", { children: name }, name))) })] })), previouslyPurchased.length > 0 && (_jsxs("div", { className: "alacarte-confirmation__previously-purchased", "data-testid": "confirmation-previously-purchased", children: [_jsx("p", { className: "alacarte-confirmation__previously-purchased-heading", children: formatMessage(messages.previouslyPurchased, {
88
+ return (_jsx("div", { className: "alacarte-confirmation", "data-testid": "alacarte-confirmation", children: _jsxs(Row, { className: "alacarte-confirmation__row", children: [_jsxs(Col, { xs: 12, lg: 7, className: "alacarte-confirmation__main", children: [_jsx("h1", { className: "alacarte-confirmation__headline font-weight-bold mb-4", children: formatMessage(messages.headline) }), _jsx("p", { className: "alacarte-confirmation__subheadline mb-4", children: formatMessage(programOrder ? messages.subheadlineProgram : messages.subheadlineCourse, { productLabel }) }), _jsxs("div", { className: "alacarte-confirmation__ctas d-flex align-items-center flex-wrap mb-4.5", children: [_jsx(Button, { variant: "brand", className: "alacarte-confirmation__cta-primary", onClick: onContinue, children: formatMessage(programOrder ? messages.startProgram : messages.startCourse) }), orderHistoryUrl && (_jsx("a", { href: orderHistoryUrl, className: "alacarte-confirmation__order-history", children: formatMessage(messages.viewOrderHistory) }))] }), _jsx("div", { className: "alacarte-confirmation__summary-mobile d-lg-none", children: summaryCard }), programOrder && (purchasedCourseNames.length > 0 || previouslyPurchased.length > 0) && (_jsxs("div", { className: "alacarte-confirmation__about-program mb-5", children: [_jsx("h2", { className: "alacarte-confirmation__about-title", children: formatMessage(messages.aboutProgram) }), purchasedCourseNames.length > 0 && (_jsxs(_Fragment, { children: [_jsx("h3", { className: "alacarte-confirmation__courses-included", children: formatMessage(messages.coursesIncluded, { count: programCourseTotal }) }), _jsx("ul", { className: "alacarte-confirmation__course-list mb-0", children: purchasedCourseNames.map((name) => (_jsx("li", { children: name }, name))) })] })), previouslyPurchased.length > 0 && (_jsxs("div", { className: "alacarte-confirmation__previously-purchased", "data-testid": "confirmation-previously-purchased", children: [_jsx("h3", { className: "alacarte-confirmation__previously-purchased-heading", children: formatMessage(messages.previouslyPurchased, {
89
89
  count: previouslyPurchased.length,
90
- }) }), _jsx("ul", { className: "alacarte-confirmation__course-list mb-0", children: previouslyPurchased.map((name) => (_jsx("li", { children: name }, name))) })] }))] })), _jsxs(Row, { children: [_jsxs(Col, { xs: 12, md: 7, className: "mb-4", children: [_jsx("h2", { className: "h5 font-weight-bold mb-3", children: formatMessage(messages.whatsIncluded) }), _jsxs("ul", { className: "alacarte-confirmation__benefits", children: [_jsx("li", { children: formatMessage(messages.benefit1) }), _jsx("li", { children: formatMessage(messages.benefit2) }), _jsx("li", { children: formatMessage(messages.benefit3) })] })] }), _jsxs(Col, { xs: 12, md: 5, className: "mb-4", children: [_jsxs("div", { className: "mb-3", children: [_jsx("p", { className: "font-weight-bold mb-0", children: formatMessage(messages.orderNumber) }), _jsx("p", { className: "text-muted mb-0", children: order.orderNumber })] }), _jsxs("div", { children: [_jsx("p", { className: "font-weight-bold mb-0", children: formatMessage(messages.purchaseDate) }), _jsx("p", { className: "text-muted mb-0", children: purchaseDate !== null && purchaseDate !== void 0 ? purchaseDate : '' })] })] })] }), refundWindowOpen && refundBy && (_jsxs(_Fragment, { children: [_jsx("hr", { className: "alacarte-confirmation__divider" }), _jsx("p", { className: "alacarte-confirmation__refund text-muted small mb-0", children: formatMessage(messages.refundNotice, { date: refundBy }) })] }))] }), _jsx(Col, { xs: 12, lg: 5, className: "alacarte-confirmation__summary-col d-none d-lg-block", children: summaryCard })] }) }));
90
+ }) }), _jsx("ul", { className: "alacarte-confirmation__course-list mb-0", children: previouslyPurchased.map((name) => (_jsx("li", { children: name }, name))) })] }))] })), _jsxs(Row, { children: [_jsxs(Col, { xs: 12, md: 7, className: "mb-4", children: [_jsx("h2", { className: "h5 font-weight-bold mb-3", children: formatMessage(messages.whatsIncluded) }), _jsxs("ul", { className: "alacarte-confirmation__benefits", children: [_jsx("li", { children: formatMessage(messages.benefit1) }), _jsx("li", { children: formatMessage(messages.benefit2) }), _jsx("li", { children: formatMessage(messages.benefit3) })] })] }), _jsxs(Col, { xs: 12, md: 5, className: "mb-4", children: [_jsxs("div", { className: "mb-3", children: [_jsx("h2", { className: "alacarte-confirmation__detail-heading font-weight-bold mb-0", children: formatMessage(messages.orderNumber) }), _jsx("p", { className: "text-muted mb-0", children: order.orderNumber })] }), _jsxs("div", { children: [_jsx("h2", { className: "alacarte-confirmation__detail-heading font-weight-bold mb-0", children: formatMessage(messages.purchaseDate) }), _jsx("p", { className: "text-muted mb-0", children: purchaseDate !== null && purchaseDate !== void 0 ? purchaseDate : '' })] })] })] }), refundWindowOpen && refundBy && (_jsxs(_Fragment, { children: [_jsx("hr", { className: "alacarte-confirmation__divider" }), _jsx("p", { className: "alacarte-confirmation__refund text-muted small mb-0", children: formatMessage(messages.refundNotice, { date: refundBy }) })] }))] }), _jsx(Col, { xs: 12, lg: 5, className: "alacarte-confirmation__summary-col d-none d-lg-block", children: summaryCard })] }) }));
91
91
  };
92
92
  export default AlacarteConfirmation;
93
93
  //# sourceMappingURL=AlacarteConfirmation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AlacarteConfirmation.js","sourceRoot":"","sources":["../../../src/components/AlacarteConfirmation/AlacarteConfirmation.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAqBlC,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;A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C,uBAAK,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAM,EAC3C,uBAAK,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAM,IACxC,IACD,EACN,MAAC,GAAG,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,EAAC,MAAM,aAClC,eAAK,SAAS,EAAC,MAAM,aACnB,YAAG,SAAS,EAAC,uBAAuB,YACjC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,GAClC,EACJ,YAAG,SAAS,EAAC,iBAAiB,YAAE,KAAK,CAAC,WAAW,GAAK,IAClD,EACN,0BACE,YAAG,SAAS,EAAC,uBAAuB,YACjC,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,GACnC,EACJ,YAAG,SAAS,EAAC,iBAAiB,YAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,GAAK,IACnD,IACF,IACF,EAEL,gBAAgB,IAAI,QAAQ,IAAI,CAC/B,8BACE,aAAI,SAAS,EAAC,gCAAgC,GAAG,EACjD,YAAG,SAAS,EAAC,qDAAqD,YAC/D,aAAa,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,GACvD,IACH,CACJ,IACG,EAEN,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,EAAC,sDAAsD,YACjF,WAAW,GACR,IACF,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import React, { useMemo } from 'react';\nimport { Alert, Button, Col, Icon, Row } from '@openedx/paragon';\nimport { Error as ErrorIcon, Monitor } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { ProcessingScreen } from '../StatusScreens/StatusScreens';\nimport type { CourseDetail } from '../../types';\nimport type {\n AlacarteProgramOwnedCourse, PlacedOrder, ProductDetail, ProgramDetail,\n} from '../../types/alacarte';\nimport messages from './Messages';\n\nexport interface AlacarteConfirmationProps {\n order: PlacedOrder | null,\n awaiting: boolean,\n error: string | null,\n onContinue?: () => void,\n /** Optional catalog detail from checkout — logo / brand. */\n productDetail?: ProductDetail | null,\n /** Display title from the checkout line (course or program name). */\n productTitle?: string | null,\n /** Program member courses already owned before this order. */\n ownedCourses?: AlacarteProgramOwnedCourse[] | null,\n /** Learner order-history / dashboard URL for the secondary CTA. */\n orderHistoryUrl?: string | null,\n /** ISO timestamp the order was placed (tPlacedAt, falling back to\n * biCreatedAt). Drives both the purchase date and the refund deadline\n * (placedAt + 14 days); the refund line is hidden once that date passes. */\n placedAt?: string | null,\n}\n\nfunction normalizeName(name: string): string {\n return name.trim().toLowerCase().replace(/\\s+/g, ' ');\n}\n\nfunction isProgramOrder(order: PlacedOrder): boolean {\n return order.lines.some((line) => line.kind === 'program' || !!line.programId);\n}\n\nfunction formatPurchaseDate(locale: string, date: Date): string {\n return new Intl.DateTimeFormat(locale, {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n }).format(date);\n}\n\nfunction addDays(from: Date, days: number): Date {\n const result = new Date(from);\n result.setDate(result.getDate() + days);\n return result;\n}\n\nconst AlacarteConfirmation = ({\n order,\n awaiting,\n error,\n onContinue,\n productDetail = null,\n productTitle = null,\n ownedCourses = null,\n orderHistoryUrl = null,\n placedAt = null,\n}: AlacarteConfirmationProps) => {\n const { formatMessage, locale = 'en-US' } = useIntl();\n\n const placedAtDate = useMemo(() => {\n const parsed = placedAt ? new Date(placedAt) : null;\n return parsed && !Number.isNaN(parsed.getTime()) ? parsed : null;\n }, [placedAt]);\n\n const purchaseDate = useMemo(\n () => (placedAtDate ? formatPurchaseDate(locale, placedAtDate) : null),\n [locale, placedAtDate],\n );\n const refundDeadlineDate = useMemo(\n () => (placedAtDate ? addDays(placedAtDate, 14) : null),\n [placedAtDate],\n );\n const refundBy = useMemo(\n () => (refundDeadlineDate ? formatPurchaseDate(locale, refundDeadlineDate) : null),\n [locale, refundDeadlineDate],\n );\n const refundWindowOpen = !!refundDeadlineDate && refundDeadlineDate.getTime() >= Date.now();\n\n if (awaiting && !order) {\n return <ProcessingScreen />;\n }\n\n if (error && !order) {\n return (\n <Alert variant=\"danger\" icon={ErrorIcon}>\n {formatMessage(messages.orderLoadError, { error })}\n </Alert>\n );\n }\n\n if (!order) {\n return null;\n }\n\n const programOrder = isProgramOrder(order);\n const courseDetail = productDetail && 'maId' in productDetail\n ? (productDetail as CourseDetail)\n : null;\n const programDetail = productDetail && 'tCourses' in productDetail\n ? (productDetail as ProgramDetail)\n : null;\n\n const firstLine = order.lines[0];\n const brand = courseDetail?.tBrandText?.trim()\n || programDetail?.tCourses?.[0]?.tBrandText?.trim()\n || '';\n const baseName = productTitle\n || firstLine?.name\n || (programOrder ? 'your program' : 'your course');\n\n const productLabel = !programOrder && brand && !productTitle?.includes(brand)\n ? `${brand}: ${baseName}`\n : baseName;\n\n const orgLogo = courseDetail?.imageUrl\n || programDetail?.tCourses?.[0]?.tOrgLogoUrl\n || programDetail?.tCourses?.[0]?.imageUrl\n || null;\n\n const currency = order.totals?.currency ?? 'USD';\n // Subtotal is price less owned-course deduction (before coupon/offer discount).\n const subtotal = Math.max(\n 0,\n (order.totals?.price ?? 0) - (order.totals?.deduction ?? 0),\n );\n const discount = order.totals?.discount ?? 0;\n const paid = order.totals?.paid ?? 0;\n\n const money = (amount: number) => formatMessage(messages.moneyAmount, {\n amount: amount.toFixed(2),\n currency,\n });\n\n const purchasedCourseNames = programOrder\n ? order.lines.map((line) => line.name?.trim()).filter((name): name is string => !!name)\n : [];\n const purchasedNameSet = new Set(purchasedCourseNames.map(normalizeName));\n\n const previouslyPurchased = (ownedCourses ?? [])\n .map((c) => c.name?.trim())\n .filter((name): name is string => !!name && !purchasedNameSet.has(normalizeName(name)));\n\n const programCourseTotal = programDetail?.tCourses?.length\n ?? (purchasedCourseNames.length + previouslyPurchased.length);\n\n const summaryCard = (\n <aside\n className=\"alacarte-confirmation__summary\"\n aria-label={formatMessage(messages.purchaseSummary)}\n >\n <h2 className=\"alacarte-confirmation__summary-title font-weight-bold mb-0\">\n {formatMessage(messages.purchaseSummary)}\n </h2>\n <hr className=\"alacarte-confirmation__summary-divider\" />\n\n <div className=\"alacarte-confirmation__product d-flex align-items-start\">\n {orgLogo ? (\n <img\n src={orgLogo}\n alt=\"\"\n className=\"alacarte-confirmation__org-logo\"\n />\n ) : (\n <div\n className=\"alacarte-confirmation__org-logo alacarte-confirmation__org-logo--placeholder\"\n aria-hidden\n />\n )}\n <div>\n <span className=\"alacarte-confirmation__badge\">\n <Icon src={Monitor} className=\"alacarte-confirmation__badge-icon\" />\n {formatMessage(messages.verifiedCertificate)}\n </span>\n <p className=\"alacarte-confirmation__product-name font-weight-bold mb-0\">\n {productLabel}\n </p>\n </div>\n </div>\n\n <hr className=\"alacarte-confirmation__summary-divider\" />\n\n <div className=\"alacarte-confirmation__price-row\">\n <span>{formatMessage(messages.subtotal)}</span>\n <span>{money(subtotal)}</span>\n </div>\n {discount > 0 && (\n <div className=\"alacarte-confirmation__price-row alacarte-confirmation__price-row--discount\">\n <span>{formatMessage(messages.discountsApplied)}</span>\n <span>\n {formatMessage(messages.discountAmount, {\n amount: discount.toFixed(2),\n currency,\n })}\n </span>\n </div>\n )}\n <div className=\"alacarte-confirmation__price-row alacarte-confirmation__price-row--paid\">\n <span>{formatMessage(messages.amountPaid)}</span>\n <span>{money(paid)}</span>\n </div>\n </aside>\n );\n\n return (\n <div className=\"alacarte-confirmation\" data-testid=\"alacarte-confirmation\">\n <Row className=\"alacarte-confirmation__row\">\n <Col xs={12} lg={7} className=\"alacarte-confirmation__main\">\n <h1 className=\"alacarte-confirmation__headline font-weight-bold mb-4\">\n {formatMessage(messages.headline)}\n </h1>\n <p className=\"alacarte-confirmation__subheadline mb-4\">\n {formatMessage(\n programOrder ? messages.subheadlineProgram : messages.subheadlineCourse,\n { productLabel },\n )}\n </p>\n\n <div className=\"alacarte-confirmation__ctas d-flex align-items-center flex-wrap mb-4.5\">\n <Button\n variant=\"brand\"\n className=\"alacarte-confirmation__cta-primary\"\n onClick={onContinue}\n >\n {formatMessage(programOrder ? messages.startProgram : messages.startCourse)}\n </Button>\n {orderHistoryUrl && (\n <a href={orderHistoryUrl} className=\"alacarte-confirmation__order-history\">\n {formatMessage(messages.viewOrderHistory)}\n </a>\n )}\n </div>\n\n <div className=\"alacarte-confirmation__summary-mobile d-lg-none\">\n {summaryCard}\n </div>\n\n {programOrder && (purchasedCourseNames.length > 0 || previouslyPurchased.length > 0) && (\n <div className=\"alacarte-confirmation__about-program mb-5\">\n <h2 className=\"alacarte-confirmation__about-title\">\n {formatMessage(messages.aboutProgram)}\n </h2>\n {purchasedCourseNames.length > 0 && (\n <>\n <p className=\"alacarte-confirmation__courses-included\">\n {formatMessage(messages.coursesIncluded, { count: programCourseTotal })}\n </p>\n <ul className=\"alacarte-confirmation__course-list mb-0\">\n {purchasedCourseNames.map((name) => (\n <li key={name}>{name}</li>\n ))}\n </ul>\n </>\n )}\n {previouslyPurchased.length > 0 && (\n <div\n className=\"alacarte-confirmation__previously-purchased\"\n data-testid=\"confirmation-previously-purchased\"\n >\n <p className=\"alacarte-confirmation__previously-purchased-heading\">\n {formatMessage(messages.previouslyPurchased, {\n count: previouslyPurchased.length,\n })}\n </p>\n <ul className=\"alacarte-confirmation__course-list mb-0\">\n {previouslyPurchased.map((name) => (\n <li key={name}>{name}</li>\n ))}\n </ul>\n </div>\n )}\n </div>\n )}\n\n <Row>\n <Col xs={12} md={7} className=\"mb-4\">\n <h2 className=\"h5 font-weight-bold mb-3\">\n {formatMessage(messages.whatsIncluded)}\n </h2>\n <ul className=\"alacarte-confirmation__benefits\">\n <li>{formatMessage(messages.benefit1)}</li>\n <li>{formatMessage(messages.benefit2)}</li>\n <li>{formatMessage(messages.benefit3)}</li>\n </ul>\n </Col>\n <Col xs={12} md={5} className=\"mb-4\">\n <div className=\"mb-3\">\n <p className=\"font-weight-bold mb-0\">\n {formatMessage(messages.orderNumber)}\n </p>\n <p className=\"text-muted mb-0\">{order.orderNumber}</p>\n </div>\n <div>\n <p className=\"font-weight-bold mb-0\">\n {formatMessage(messages.purchaseDate)}\n </p>\n <p className=\"text-muted mb-0\">{purchaseDate ?? ''}</p>\n </div>\n </Col>\n </Row>\n\n {refundWindowOpen && refundBy && (\n <>\n <hr className=\"alacarte-confirmation__divider\" />\n <p className=\"alacarte-confirmation__refund text-muted small mb-0\">\n {formatMessage(messages.refundNotice, { date: refundBy })}\n </p>\n </>\n )}\n </Col>\n\n <Col xs={12} lg={5} className=\"alacarte-confirmation__summary-col d-none d-lg-block\">\n {summaryCard}\n </Col>\n </Row>\n </div>\n );\n};\n\nexport default AlacarteConfirmation;\n"]}
1
+ {"version":3,"file":"AlacarteConfirmation.js","sourceRoot":"","sources":["../../../src/components/AlacarteConfirmation/AlacarteConfirmation.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAqBlC,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,cAAc,CAAC,KAAkB;IACxC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC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,EAAE,EAAE,CAAC,EAAE,SAAS,EAAC,MAAM,aAClC,eAAK,SAAS,EAAC,MAAM,aACnB,aAAI,SAAS,EAAC,6DAA6D,YACxE,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,GACjC,EACL,YAAG,SAAS,EAAC,iBAAiB,YAAE,KAAK,CAAC,WAAW,GAAK,IAClD,EACN,0BACE,aAAI,SAAS,EAAC,6DAA6D,YACxE,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,GAClC,EACL,YAAG,SAAS,EAAC,iBAAiB,YAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,GAAK,IACnD,IACF,IACF,EAEL,gBAAgB,IAAI,QAAQ,IAAI,CAC/B,8BACE,aAAI,SAAS,EAAC,gCAAgC,GAAG,EACjD,YAAG,SAAS,EAAC,qDAAqD,YAC/D,aAAa,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,GACvD,IACH,CACJ,IACG,EAEN,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,EAAC,sDAAsD,YACjF,WAAW,GACR,IACF,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import React, { useMemo } from 'react';\nimport { Alert, Button, Col, Icon, Row } from '@openedx/paragon';\nimport { Error as ErrorIcon, Monitor } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { ProcessingScreen } from '../StatusScreens/StatusScreens';\nimport type { CourseDetail } from '../../types';\nimport type {\n AlacarteProgramOwnedCourse, PlacedOrder, ProductDetail, ProgramDetail,\n} from '../../types/alacarte';\nimport messages from './Messages';\n\nexport interface AlacarteConfirmationProps {\n order: PlacedOrder | null,\n awaiting: boolean,\n error: string | null,\n onContinue?: () => void,\n /** Optional catalog detail from checkout — logo / brand. */\n productDetail?: ProductDetail | null,\n /** Display title from the checkout line (course or program name). */\n productTitle?: string | null,\n /** Program member courses already owned before this order. */\n ownedCourses?: AlacarteProgramOwnedCourse[] | null,\n /** Learner order-history / dashboard URL for the secondary CTA. */\n orderHistoryUrl?: string | null,\n /** ISO timestamp the order was placed (tPlacedAt, falling back to\n * biCreatedAt). Drives both the purchase date and the refund deadline\n * (placedAt + 14 days); the refund line is hidden once that date passes. */\n placedAt?: string | null,\n}\n\nfunction normalizeName(name: string): string {\n return name.trim().toLowerCase().replace(/\\s+/g, ' ');\n}\n\nfunction isProgramOrder(order: PlacedOrder): boolean {\n return order.lines.some((line) => line.kind === 'program' || !!line.programId);\n}\n\nfunction formatPurchaseDate(locale: string, date: Date): string {\n return new Intl.DateTimeFormat(locale, {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n }).format(date);\n}\n\nfunction addDays(from: Date, days: number): Date {\n const result = new Date(from);\n result.setDate(result.getDate() + days);\n return result;\n}\n\nconst AlacarteConfirmation = ({\n order,\n awaiting,\n error,\n onContinue,\n productDetail = null,\n productTitle = null,\n ownedCourses = null,\n orderHistoryUrl = null,\n placedAt = null,\n}: AlacarteConfirmationProps) => {\n const { formatMessage, locale = 'en-US' } = useIntl();\n\n const placedAtDate = useMemo(() => {\n const parsed = placedAt ? new Date(placedAt) : null;\n return parsed && !Number.isNaN(parsed.getTime()) ? parsed : null;\n }, [placedAt]);\n\n const purchaseDate = useMemo(\n () => (placedAtDate ? formatPurchaseDate(locale, placedAtDate) : null),\n [locale, placedAtDate],\n );\n const refundDeadlineDate = useMemo(\n () => (placedAtDate ? addDays(placedAtDate, 14) : null),\n [placedAtDate],\n );\n const refundBy = useMemo(\n () => (refundDeadlineDate ? formatPurchaseDate(locale, refundDeadlineDate) : null),\n [locale, refundDeadlineDate],\n );\n const refundWindowOpen = !!refundDeadlineDate && refundDeadlineDate.getTime() >= Date.now();\n\n if (awaiting && !order) {\n return <ProcessingScreen />;\n }\n\n if (error && !order) {\n return (\n <Alert variant=\"danger\" icon={ErrorIcon}>\n {formatMessage(messages.orderLoadError, { error })}\n </Alert>\n );\n }\n\n if (!order) {\n return null;\n }\n\n const programOrder = isProgramOrder(order);\n const courseDetail = productDetail && 'maId' in productDetail\n ? (productDetail as CourseDetail)\n : null;\n const programDetail = productDetail && 'tCourses' in productDetail\n ? (productDetail as ProgramDetail)\n : null;\n\n const firstLine = order.lines[0];\n const brand = courseDetail?.tBrandText?.trim()\n || programDetail?.tCourses?.[0]?.tBrandText?.trim()\n || '';\n const baseName = productTitle\n || firstLine?.name\n || (programOrder ? 'your program' : 'your course');\n\n const productLabel = !programOrder && brand && !productTitle?.includes(brand)\n ? `${brand}: ${baseName}`\n : baseName;\n\n const orgLogo = courseDetail?.imageUrl\n || programDetail?.tCourses?.[0]?.tOrgLogoUrl\n || programDetail?.tCourses?.[0]?.imageUrl\n || null;\n\n const currency = order.totals?.currency ?? 'USD';\n // Subtotal is price less owned-course deduction (before coupon/offer discount).\n const subtotal = Math.max(\n 0,\n (order.totals?.price ?? 0) - (order.totals?.deduction ?? 0),\n );\n const discount = order.totals?.discount ?? 0;\n const paid = order.totals?.paid ?? 0;\n\n const money = (amount: number) => formatMessage(messages.moneyAmount, {\n amount: amount.toFixed(2),\n currency,\n });\n\n const purchasedCourseNames = programOrder\n ? order.lines.map((line) => line.name?.trim()).filter((name): name is string => !!name)\n : [];\n const purchasedNameSet = new Set(purchasedCourseNames.map(normalizeName));\n\n const previouslyPurchased = (ownedCourses ?? [])\n .map((c) => c.name?.trim())\n .filter((name): name is string => !!name && !purchasedNameSet.has(normalizeName(name)));\n\n const programCourseTotal = programDetail?.tCourses?.length\n ?? (purchasedCourseNames.length + previouslyPurchased.length);\n\n const summaryCard = (\n <aside\n className=\"alacarte-confirmation__summary\"\n aria-label={formatMessage(messages.purchaseSummary)}\n >\n <h2 className=\"alacarte-confirmation__summary-title font-weight-bold mb-0\">\n {formatMessage(messages.purchaseSummary)}\n </h2>\n <hr className=\"alacarte-confirmation__summary-divider\" />\n\n <div className=\"alacarte-confirmation__product d-flex align-items-start\">\n {orgLogo ? (\n <img\n src={orgLogo}\n alt=\"\"\n className=\"alacarte-confirmation__org-logo\"\n />\n ) : (\n <div\n className=\"alacarte-confirmation__org-logo alacarte-confirmation__org-logo--placeholder\"\n aria-hidden\n />\n )}\n <div>\n <span className=\"alacarte-confirmation__badge\">\n <Icon src={Monitor} className=\"alacarte-confirmation__badge-icon\" />\n {formatMessage(messages.verifiedCertificate)}\n </span>\n <p className=\"alacarte-confirmation__product-name font-weight-bold mb-0\">\n {productLabel}\n </p>\n </div>\n </div>\n\n <hr className=\"alacarte-confirmation__summary-divider\" />\n\n <div className=\"alacarte-confirmation__price-row\">\n <span>{formatMessage(messages.subtotal)}</span>\n <span>{money(subtotal)}</span>\n </div>\n {discount > 0 && (\n <div className=\"alacarte-confirmation__price-row alacarte-confirmation__price-row--discount\">\n <span>{formatMessage(messages.discountsApplied)}</span>\n <span>\n {formatMessage(messages.discountAmount, {\n amount: discount.toFixed(2),\n currency,\n })}\n </span>\n </div>\n )}\n <div className=\"alacarte-confirmation__price-row alacarte-confirmation__price-row--paid\">\n <span>{formatMessage(messages.amountPaid)}</span>\n <span>{money(paid)}</span>\n </div>\n </aside>\n );\n\n return (\n <div className=\"alacarte-confirmation\" data-testid=\"alacarte-confirmation\">\n <Row className=\"alacarte-confirmation__row\">\n <Col xs={12} lg={7} className=\"alacarte-confirmation__main\">\n <h1 className=\"alacarte-confirmation__headline font-weight-bold mb-4\">\n {formatMessage(messages.headline)}\n </h1>\n <p className=\"alacarte-confirmation__subheadline mb-4\">\n {formatMessage(\n programOrder ? messages.subheadlineProgram : messages.subheadlineCourse,\n { productLabel },\n )}\n </p>\n\n <div className=\"alacarte-confirmation__ctas d-flex align-items-center flex-wrap mb-4.5\">\n <Button\n variant=\"brand\"\n className=\"alacarte-confirmation__cta-primary\"\n onClick={onContinue}\n >\n {formatMessage(programOrder ? messages.startProgram : messages.startCourse)}\n </Button>\n {orderHistoryUrl && (\n <a href={orderHistoryUrl} className=\"alacarte-confirmation__order-history\">\n {formatMessage(messages.viewOrderHistory)}\n </a>\n )}\n </div>\n\n <div className=\"alacarte-confirmation__summary-mobile d-lg-none\">\n {summaryCard}\n </div>\n\n {programOrder && (purchasedCourseNames.length > 0 || previouslyPurchased.length > 0) && (\n <div className=\"alacarte-confirmation__about-program mb-5\">\n <h2 className=\"alacarte-confirmation__about-title\">\n {formatMessage(messages.aboutProgram)}\n </h2>\n {purchasedCourseNames.length > 0 && (\n <>\n <h3 className=\"alacarte-confirmation__courses-included\">\n {formatMessage(messages.coursesIncluded, { count: programCourseTotal })}\n </h3>\n <ul className=\"alacarte-confirmation__course-list mb-0\">\n {purchasedCourseNames.map((name) => (\n <li key={name}>{name}</li>\n ))}\n </ul>\n </>\n )}\n {previouslyPurchased.length > 0 && (\n <div\n className=\"alacarte-confirmation__previously-purchased\"\n data-testid=\"confirmation-previously-purchased\"\n >\n <h3 className=\"alacarte-confirmation__previously-purchased-heading\">\n {formatMessage(messages.previouslyPurchased, {\n count: previouslyPurchased.length,\n })}\n </h3>\n <ul className=\"alacarte-confirmation__course-list mb-0\">\n {previouslyPurchased.map((name) => (\n <li key={name}>{name}</li>\n ))}\n </ul>\n </div>\n )}\n </div>\n )}\n\n <Row>\n <Col xs={12} md={7} className=\"mb-4\">\n <h2 className=\"h5 font-weight-bold mb-3\">\n {formatMessage(messages.whatsIncluded)}\n </h2>\n <ul className=\"alacarte-confirmation__benefits\">\n <li>{formatMessage(messages.benefit1)}</li>\n <li>{formatMessage(messages.benefit2)}</li>\n <li>{formatMessage(messages.benefit3)}</li>\n </ul>\n </Col>\n <Col xs={12} md={5} className=\"mb-4\">\n <div className=\"mb-3\">\n <h2 className=\"alacarte-confirmation__detail-heading font-weight-bold mb-0\">\n {formatMessage(messages.orderNumber)}\n </h2>\n <p className=\"text-muted mb-0\">{order.orderNumber}</p>\n </div>\n <div>\n <h2 className=\"alacarte-confirmation__detail-heading font-weight-bold mb-0\">\n {formatMessage(messages.purchaseDate)}\n </h2>\n <p className=\"text-muted mb-0\">{purchaseDate ?? ''}</p>\n </div>\n </Col>\n </Row>\n\n {refundWindowOpen && refundBy && (\n <>\n <hr className=\"alacarte-confirmation__divider\" />\n <p className=\"alacarte-confirmation__refund text-muted small mb-0\">\n {formatMessage(messages.refundNotice, { date: refundBy })}\n </p>\n </>\n )}\n </Col>\n\n <Col xs={12} lg={5} className=\"alacarte-confirmation__summary-col d-none d-lg-block\">\n {summaryCard}\n </Col>\n </Row>\n </div>\n );\n};\n\nexport default AlacarteConfirmation;\n"]}
@@ -48,7 +48,7 @@ const CartSummary = ({ productTitle, productBlurb, learnerCount: learnerCountPro
48
48
  .filter(Boolean)
49
49
  .join(', ');
50
50
  const discount = (_g = alacarteLine === null || alacarteLine === void 0 ? void 0 : alacarteLine.discount) !== null && _g !== void 0 ? _g : null;
51
- return (_jsxs("div", { className: "cart-summary ", children: [_jsxs(Card, { className: "cart-summary__card p-3", children: [_jsxs(Card.Section, { className: "d-flex justify-content-between align-items-center p-0 pb-3", children: [_jsx("span", { className: "font-weight-bold text-gray-900", children: formatMessage(messages.summaryHeading) }), _jsxs(Badge, { variant: "light", className: "d-flex align-items-center px-2 py-1", children: [_jsx(Icon, { src: Group, className: "mr-1", style: { width: '1rem', height: '1rem' } }), subscriberCount == null ? (_jsx("span", { className: "cart-summary__count-skeleton", "aria-busy": "true", "aria-label": formatMessage(messages.loadingSubscribers), "data-testid": "subscriber-count-skeleton", children: _jsx(Skeleton, { width: 96, height: 12 }) })) : (formatMessage(messages.learnersSubscribed, {
51
+ return (_jsxs("div", { className: "cart-summary ", children: [_jsxs(Card, { className: "cart-summary__card p-3", children: [_jsxs(Card.Section, { className: "d-flex justify-content-between align-items-center p-0 pb-3", children: [_jsx("h2", { className: "cart-summary__heading font-weight-bold text-gray-900 mb-0", children: formatMessage(messages.summaryHeading) }), _jsxs(Badge, { variant: "light", className: "d-flex align-items-center px-2 py-1", children: [_jsx(Icon, { src: Group, className: "mr-1", style: { width: '1rem', height: '1rem' } }), subscriberCount == null ? (_jsx("span", { className: "cart-summary__count-skeleton", "aria-busy": "true", "aria-label": formatMessage(messages.loadingSubscribers), "data-testid": "subscriber-count-skeleton", children: _jsx(Skeleton, { width: 96, height: 12 }) })) : (formatMessage(messages.learnersSubscribed, {
52
52
  count: subscriberCount.toLocaleString(),
53
53
  }))] })] }), _jsx(Card.Divider, {}), _jsxs(Card.Section, { className: "p-0 py-3", children: [course ? (_jsx(CourseEnrollmentCard, { course: course, variant: "summary" })) : programDetail ? (_jsx(ProgramEnrollmentCard, { program: programDetail, programName: lineName !== null && lineName !== void 0 ? lineName : '', ownedCourses: ownedCourses })) : lineName ? (_jsx("p", { className: "font-weight-bold mb-0 text-primary-500", children: lineName })) : (_jsxs("div", { className: "d-flex align-items-start", children: [_jsx(EdxUnlimitedLogo, { ariaLabel: "edX Plus" }), _jsxs("div", { children: [_jsx("p", { className: "font-weight-bold mb-0 text-primary-500", children: title }), _jsx("p", { className: "small mb-0 text-gray-900", children: blurb })] })] })), !programDetail && ownedCourseNames && (_jsx("p", { className: "cart-summary__already-yours small text-gray-700 mb-0 mt-2", "data-testid": "already-yours", children: formatMessage(messages.alreadyYours, { names: ownedCourseNames }) }))] }), _jsx(Card.Divider, {}), _jsxs(Card.Section, { className: "cart-summary__subtotal-row d-flex justify-content-between align-items-center p-0 pt-3", children: [_jsx("span", { className: "cart-summary__subtotal text-gray-900", children: formatMessage(messages.subtotal) }), _jsx("span", { className: "cart-summary__subtotal text-gray-900", children: subtotalText })] }), discount && (_jsxs(Card.Section, { className: "d-flex justify-content-between align-items-center p-0", "data-testid": "discount-row", children: [_jsx("span", { className: "text-success font-weight-bold", children: formatMessage(messages.discountApplied) }), _jsx("span", { className: "text-success font-weight-bold", children: formatMessage(messages.discountAmount, {
54
54
  amount: discount.amount.toFixed(2),
@@ -1 +1 @@
1
- {"version":3,"file":"CartSummary.js","sourceRoot":"","sources":["../../../src/components/CartSummary/CartSummary.tsx"],"names":[],"mappings":";A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Q,CAAC,iBAAiB,CAAC,GACxC,EACJ,YAAG,SAAS,EAAC,6CAA6C,YACvD,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GACxC,IACA,IACF,IACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import React from 'react';\nimport { Badge, Card, Icon, Skeleton } from '@openedx/paragon';\nimport { Group } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { EdxUnlimitedLogo } from '../BrandMarks/BrandMarks';\nimport CourseEnrollmentCard from '../CourseEnrollmentCard/CourseEnrollmentCard';\nimport ProgramEnrollmentCard from '../ProgramEnrollmentCard/ProgramEnrollmentCard';\nimport PromoCode from '../PromoCode/PromoCode';\nimport type { PromoCodeProps } from '../PromoCode/PromoCode';\nimport type { CourseDetail } from '../../types';\nimport type { AlacarteLine, ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\nimport learnersIcon from './world-icon.svg';\nimport institutionsIcon from './student-icon.svg';\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport interface CartSummaryProps {\n productTitle?: string,\n productBlurb?: string,\n /** Promotional monthly price amount e.g. \"39\" */\n monthlyAmount?: string,\n /** Regular monthly price after the promo period e.g. \"59\" */\n monthlyRegularAmount?: string,\n /** Length of the promotional period in months */\n promoMonths?: number,\n /** Annual price amount e.g. \"299\" */\n annualAmount?: string,\n currency?: string,\n defaultCycle?: BillingCycle,\n monthlyRenewalLabel?: string,\n annualRenewalLabel?: string,\n /** Called when the learner switches monthly ↔ annual. */\n onCycleChange?: (cycle: BillingCycle) => void,\n learnerCount?: number,\n /** When set, shows the course enrollment preview card below the summary card. */\n course?: CourseDetail | null,\n /** À la carte checkout line — when present, drives the subtotal/total and\n * the product name shown, in place of the generic edX Plus placeholder. */\n alacarteLine?: AlacarteLine | null,\n /** Program catalog detail (filterTwouProgram) — when present, drives the\n * \"Courses included in this program\" list. */\n programDetail?: ProgramDetail | null,\n /** Fallback program name — used when there is no alacarteLine to provide it\n * (e.g. already-owned overlay). */\n programName?: string | null,\n /** Coupon input — when set, wires PromoCode to tCheckoutUpdate. */\n promoCode?: PromoCodeProps | null,\n}\n\nconst CartSummary = ({\n productTitle,\n productBlurb,\n learnerCount: learnerCountProp,\n course = null,\n alacarteLine = null,\n programDetail = null,\n programName: programNameProp = null,\n promoCode = null,\n}: CartSummaryProps) => {\n const { formatMessage } = useIntl();\n const title = productTitle ?? formatMessage(messages.productTitle);\n const blurb = productBlurb ?? formatMessage(messages.productBlurb);\n\n // Prefer the product's own enrollment count (course or program catalog field).\n const isProgramLine = alacarteLine?.kind === 'program';\n const subscriberCount = course?.tEnrollmentCount\n ?? programDetail?.tEnrollmentCount\n ?? learnerCountProp\n ?? null;\n\n // No fallback amount — an unresolved à la carte line means we don't know\n // the price yet, so the row is left blank rather than showing a made-up\n // number that could be mistaken for the real one.\n // Program subtotal is price less owned-course deduction (before coupon/discount).\n const deductionAmount = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.deduction?.amount ?? 0)\n : 0;\n const subtotalAmount = alacarteLine?.price\n ? Math.max(0, alacarteLine.price.amount - deductionAmount)\n : null;\n const subtotalText = subtotalAmount != null && alacarteLine?.price\n ? formatMessage(messages.subtotalAmount, {\n amount: subtotalAmount.toFixed(2), currency: alacarteLine.price.currency,\n })\n : '';\n const totalText = alacarteLine?.amountDue\n ? formatMessage(messages.todaysTotalValue, {\n amount: alacarteLine.amountDue.amount.toFixed(2), currency: alacarteLine.amountDue.currency,\n })\n : '';\n\n const lineName = alacarteLine\n ? (alacarteLine.kind === 'course' ? alacarteLine.courseName : alacarteLine.programName)\n : programNameProp;\n\n const ownedCourses = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.ownedCourses ?? [])\n : [];\n const ownedCourseNames = ownedCourses\n .map((c) => c.name)\n .filter(Boolean)\n .join(', ');\n const discount = alacarteLine?.discount ?? null;\n\n return (\n <div className=\"cart-summary \">\n <Card className=\"cart-summary__card p-3\">\n <Card.Section className=\"d-flex justify-content-between align-items-center p-0 pb-3\">\n <span className=\"font-weight-bold text-gray-900\">\n {formatMessage(messages.summaryHeading)}\n </span>\n <Badge\n variant=\"light\"\n className=\"d-flex align-items-center px-2 py-1\"\n >\n <Icon\n src={Group}\n className=\"mr-1\"\n style={{ width: '1rem', height: '1rem' }}\n />\n {subscriberCount == null ? (\n <span\n className=\"cart-summary__count-skeleton\"\n aria-busy=\"true\"\n aria-label={formatMessage(messages.loadingSubscribers)}\n data-testid=\"subscriber-count-skeleton\"\n >\n <Skeleton width={96} height={12} />\n </span>\n ) : (\n formatMessage(messages.learnersSubscribed, {\n count: subscriberCount.toLocaleString(),\n })\n )}\n </Badge>\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"p-0 py-3\">\n {course ? (\n <CourseEnrollmentCard course={course} variant=\"summary\" />\n ) : programDetail ? (\n <ProgramEnrollmentCard\n program={programDetail}\n programName={lineName ?? ''}\n ownedCourses={ownedCourses}\n />\n ) : lineName ? (\n <p className=\"font-weight-bold mb-0 text-primary-500\">{lineName}</p>\n ) : (\n <div className=\"d-flex align-items-start\">\n <EdxUnlimitedLogo ariaLabel=\"edX Plus\" />\n <div>\n <p className=\"font-weight-bold mb-0 text-primary-500\">{title}</p>\n <p className=\"small mb-0 text-gray-900\">{blurb}</p>\n </div>\n </div>\n )}\n {/* Fallback when catalog detail hasn't loaded yet — once it has,\n owned courses are listed under \"Previously purchased\" in the card. */}\n {!programDetail && ownedCourseNames && (\n <p\n className=\"cart-summary__already-yours small text-gray-700 mb-0 mt-2\"\n data-testid=\"already-yours\"\n >\n {formatMessage(messages.alreadyYours, { names: ownedCourseNames })}\n </p>\n )}\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"cart-summary__subtotal-row d-flex justify-content-between align-items-center p-0 pt-3\">\n <span className=\"cart-summary__subtotal text-gray-900\">\n {formatMessage(messages.subtotal)}\n </span>\n <span className=\"cart-summary__subtotal text-gray-900\">\n {subtotalText}\n </span>\n </Card.Section>\n\n {discount && (\n <Card.Section\n className=\"d-flex justify-content-between align-items-center p-0\"\n data-testid=\"discount-row\"\n >\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountApplied)}\n </span>\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </Card.Section>\n )}\n\n <Card.Section className=\"d-flex justify-content-between align-items-center p-0\">\n <span className=\"cart-summary__total-label text-gray-900\">\n {formatMessage(messages.todaysTotal)}\n </span>\n <span className=\"cart-summary__total-value mb-0 text-gray-900\">\n {totalText}\n </span>\n </Card.Section>\n </Card>\n\n {promoCode ? <PromoCode {...promoCode} /> : null}\n\n {/* Stats row */}\n <div className=\"cart-summary__stats d-none d-lg-flex\">\n <div className=\"cart-summary__stat d-flex align-items-center mr-4\">\n <img src={learnersIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-500 mb-0\">\n {formatMessage(messages.learnersCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-500 mb-0\">\n {formatMessage(messages.learnersLabel)}\n </p>\n </div>\n </div>\n <div className=\"cart-summary__stat d-flex align-items-center\">\n <img src={institutionsIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-500 mb-0\">\n {formatMessage(messages.institutionsCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-500 mb-0\">\n {formatMessage(messages.institutionsLabel)}\n </p>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default CartSummary;\n"]}
1
+ {"version":3,"file":"CartSummary.js","sourceRoot":"","sources":["../../../src/components/CartSummary/CartSummary.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO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iB,CAAC,GACxC,IACA,IACF,IACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import React from 'react';\nimport { Badge, Card, Icon, Skeleton } from '@openedx/paragon';\nimport { Group } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { EdxUnlimitedLogo } from '../BrandMarks/BrandMarks';\nimport CourseEnrollmentCard from '../CourseEnrollmentCard/CourseEnrollmentCard';\nimport ProgramEnrollmentCard from '../ProgramEnrollmentCard/ProgramEnrollmentCard';\nimport PromoCode from '../PromoCode/PromoCode';\nimport type { PromoCodeProps } from '../PromoCode/PromoCode';\nimport type { CourseDetail } from '../../types';\nimport type { AlacarteLine, ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\nimport learnersIcon from './world-icon.svg';\nimport institutionsIcon from './student-icon.svg';\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport interface CartSummaryProps {\n productTitle?: string,\n productBlurb?: string,\n /** Promotional monthly price amount e.g. \"39\" */\n monthlyAmount?: string,\n /** Regular monthly price after the promo period e.g. \"59\" */\n monthlyRegularAmount?: string,\n /** Length of the promotional period in months */\n promoMonths?: number,\n /** Annual price amount e.g. \"299\" */\n annualAmount?: string,\n currency?: string,\n defaultCycle?: BillingCycle,\n monthlyRenewalLabel?: string,\n annualRenewalLabel?: string,\n /** Called when the learner switches monthly ↔ annual. */\n onCycleChange?: (cycle: BillingCycle) => void,\n learnerCount?: number,\n /** When set, shows the course enrollment preview card below the summary card. */\n course?: CourseDetail | null,\n /** À la carte checkout line — when present, drives the subtotal/total and\n * the product name shown, in place of the generic edX Plus placeholder. */\n alacarteLine?: AlacarteLine | null,\n /** Program catalog detail (filterTwouProgram) — when present, drives the\n * \"Courses included in this program\" list. */\n programDetail?: ProgramDetail | null,\n /** Fallback program name — used when there is no alacarteLine to provide it\n * (e.g. already-owned overlay). */\n programName?: string | null,\n /** Coupon input — when set, wires PromoCode to tCheckoutUpdate. */\n promoCode?: PromoCodeProps | null,\n}\n\nconst CartSummary = ({\n productTitle,\n productBlurb,\n learnerCount: learnerCountProp,\n course = null,\n alacarteLine = null,\n programDetail = null,\n programName: programNameProp = null,\n promoCode = null,\n}: CartSummaryProps) => {\n const { formatMessage } = useIntl();\n const title = productTitle ?? formatMessage(messages.productTitle);\n const blurb = productBlurb ?? formatMessage(messages.productBlurb);\n\n // Prefer the product's own enrollment count (course or program catalog field).\n const isProgramLine = alacarteLine?.kind === 'program';\n const subscriberCount = course?.tEnrollmentCount\n ?? programDetail?.tEnrollmentCount\n ?? learnerCountProp\n ?? null;\n\n // No fallback amount — an unresolved à la carte line means we don't know\n // the price yet, so the row is left blank rather than showing a made-up\n // number that could be mistaken for the real one.\n // Program subtotal is price less owned-course deduction (before coupon/discount).\n const deductionAmount = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.deduction?.amount ?? 0)\n : 0;\n const subtotalAmount = alacarteLine?.price\n ? Math.max(0, alacarteLine.price.amount - deductionAmount)\n : null;\n const subtotalText = subtotalAmount != null && alacarteLine?.price\n ? formatMessage(messages.subtotalAmount, {\n amount: subtotalAmount.toFixed(2), currency: alacarteLine.price.currency,\n })\n : '';\n const totalText = alacarteLine?.amountDue\n ? formatMessage(messages.todaysTotalValue, {\n amount: alacarteLine.amountDue.amount.toFixed(2), currency: alacarteLine.amountDue.currency,\n })\n : '';\n\n const lineName = alacarteLine\n ? (alacarteLine.kind === 'course' ? alacarteLine.courseName : alacarteLine.programName)\n : programNameProp;\n\n const ownedCourses = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.ownedCourses ?? [])\n : [];\n const ownedCourseNames = ownedCourses\n .map((c) => c.name)\n .filter(Boolean)\n .join(', ');\n const discount = alacarteLine?.discount ?? null;\n\n return (\n <div className=\"cart-summary \">\n <Card className=\"cart-summary__card p-3\">\n <Card.Section className=\"d-flex justify-content-between align-items-center p-0 pb-3\">\n <h2 className=\"cart-summary__heading font-weight-bold text-gray-900 mb-0\">\n {formatMessage(messages.summaryHeading)}\n </h2>\n <Badge\n variant=\"light\"\n className=\"d-flex align-items-center px-2 py-1\"\n >\n <Icon\n src={Group}\n className=\"mr-1\"\n style={{ width: '1rem', height: '1rem' }}\n />\n {subscriberCount == null ? (\n <span\n className=\"cart-summary__count-skeleton\"\n aria-busy=\"true\"\n aria-label={formatMessage(messages.loadingSubscribers)}\n data-testid=\"subscriber-count-skeleton\"\n >\n <Skeleton width={96} height={12} />\n </span>\n ) : (\n formatMessage(messages.learnersSubscribed, {\n count: subscriberCount.toLocaleString(),\n })\n )}\n </Badge>\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"p-0 py-3\">\n {course ? (\n <CourseEnrollmentCard course={course} variant=\"summary\" />\n ) : programDetail ? (\n <ProgramEnrollmentCard\n program={programDetail}\n programName={lineName ?? ''}\n ownedCourses={ownedCourses}\n />\n ) : lineName ? (\n <p className=\"font-weight-bold mb-0 text-primary-500\">{lineName}</p>\n ) : (\n <div className=\"d-flex align-items-start\">\n <EdxUnlimitedLogo ariaLabel=\"edX Plus\" />\n <div>\n <p className=\"font-weight-bold mb-0 text-primary-500\">{title}</p>\n <p className=\"small mb-0 text-gray-900\">{blurb}</p>\n </div>\n </div>\n )}\n {/* Fallback when catalog detail hasn't loaded yet — once it has,\n owned courses are listed under \"Previously purchased\" in the card. */}\n {!programDetail && ownedCourseNames && (\n <p\n className=\"cart-summary__already-yours small text-gray-700 mb-0 mt-2\"\n data-testid=\"already-yours\"\n >\n {formatMessage(messages.alreadyYours, { names: ownedCourseNames })}\n </p>\n )}\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"cart-summary__subtotal-row d-flex justify-content-between align-items-center p-0 pt-3\">\n <span className=\"cart-summary__subtotal text-gray-900\">\n {formatMessage(messages.subtotal)}\n </span>\n <span className=\"cart-summary__subtotal text-gray-900\">\n {subtotalText}\n </span>\n </Card.Section>\n\n {discount && (\n <Card.Section\n className=\"d-flex justify-content-between align-items-center p-0\"\n data-testid=\"discount-row\"\n >\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountApplied)}\n </span>\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </Card.Section>\n )}\n\n <Card.Section className=\"d-flex justify-content-between align-items-center p-0\">\n <span className=\"cart-summary__total-label text-gray-900\">\n {formatMessage(messages.todaysTotal)}\n </span>\n <span className=\"cart-summary__total-value mb-0 text-gray-900\">\n {totalText}\n </span>\n </Card.Section>\n </Card>\n\n {promoCode ? <PromoCode {...promoCode} /> : null}\n\n {/* Stats row */}\n <div className=\"cart-summary__stats d-none d-lg-flex\">\n <div className=\"cart-summary__stat d-flex align-items-center mr-4\">\n <img src={learnersIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-500 mb-0\">\n {formatMessage(messages.learnersCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-500 mb-0\">\n {formatMessage(messages.learnersLabel)}\n </p>\n </div>\n </div>\n <div className=\"cart-summary__stat d-flex align-items-center\">\n <img src={institutionsIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-500 mb-0\">\n {formatMessage(messages.institutionsCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-500 mb-0\">\n {formatMessage(messages.institutionsLabel)}\n </p>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default CartSummary;\n"]}
@@ -52,7 +52,7 @@ const ProgramEnrollmentCard = ({ program, programName, ownedCourses = null, }) =
52
52
  ? includedCourses
53
53
  : includedCourses.slice(0, INITIAL_VISIBLE_COURSES);
54
54
  const hasMoreIncluded = includedCourses.length > INITIAL_VISIBLE_COURSES;
55
- return (_jsxs("div", { className: "program-enrollment-card", children: [_jsxs("div", { className: "program-enrollment-card__header d-flex align-items-start", children: [brandLogoUrl && (_jsx("div", { className: "program-enrollment-card__logo-wrap flex-shrink-0", children: _jsx("img", { src: brandLogoUrl, alt: formatMessage(messages.logoAlt, { brand: brandText }), className: "program-enrollment-card__logo" }) })), _jsxs("div", { className: "program-enrollment-card__content flex-grow-1", children: [_jsxs("span", { className: "program-enrollment-card__certificate-badge", children: [_jsx(Icon, { src: Monitor, className: "program-enrollment-card__certificate-icon" }), formatMessage(messages.verifiedCertificate)] }), _jsx("p", { className: "program-enrollment-card__title font-weight-bold mb-0", children: programName })] })] }), includedCourses.length > 0 && (_jsxs("div", { className: "program-enrollment-card__courses", children: [_jsx("p", { className: "program-enrollment-card__courses-heading font-weight-bold mb-2 text-gray-900", children: formatMessage(messages.coursesIncluded, { count: program.tCourses.length }) }), _jsx("ul", { className: "program-enrollment-card__course-list mb-2", children: visibleIncluded.map((c) => (_jsx("li", { children: courseLabel(c) }, c.id))) }), hasMoreIncluded && (_jsx(Button, { variant: "tertiary", size: "sm", className: "program-enrollment-card__toggle px-0", onClick: () => setExpanded((value) => !value), iconAfter: expanded ? ExpandLess : ExpandMore, children: formatMessage(expanded ? messages.showLess : messages.showAll) }))] })), previouslyPurchased.length > 0 && (_jsxs("div", { className: "program-enrollment-card__purchased", "data-testid": "previously-purchased", children: [_jsx("p", { className: "program-enrollment-card__purchased-heading font-weight-bold font-italic mb-2 text-gray-900", children: formatMessage(messages.previouslyPurchased, { count: previouslyPurchased.length }) }), _jsx("ul", { className: "program-enrollment-card__course-list mb-0", children: previouslyPurchased.map((name) => (_jsx("li", { children: name }, name))) })] }))] }));
55
+ return (_jsxs("div", { className: "program-enrollment-card", children: [_jsxs("div", { className: "program-enrollment-card__header d-flex align-items-start", children: [brandLogoUrl && (_jsx("div", { className: "program-enrollment-card__logo-wrap flex-shrink-0", children: _jsx("img", { src: brandLogoUrl, alt: formatMessage(messages.logoAlt, { brand: brandText }), className: "program-enrollment-card__logo" }) })), _jsxs("div", { className: "program-enrollment-card__content flex-grow-1", children: [_jsxs("span", { className: "program-enrollment-card__certificate-badge", children: [_jsx(Icon, { src: Monitor, className: "program-enrollment-card__certificate-icon" }), formatMessage(messages.verifiedCertificate)] }), _jsx("p", { className: "program-enrollment-card__title font-weight-bold mb-0", children: programName })] })] }), includedCourses.length > 0 && (_jsxs("div", { className: "program-enrollment-card__courses", children: [_jsx("h3", { className: "program-enrollment-card__courses-heading font-weight-bold mb-2 text-gray-900", children: formatMessage(messages.coursesIncluded, { count: program.tCourses.length }) }), _jsx("ul", { className: "program-enrollment-card__course-list mb-2", children: visibleIncluded.map((c) => (_jsx("li", { children: courseLabel(c) }, c.id))) }), hasMoreIncluded && (_jsx(Button, { variant: "tertiary", size: "sm", className: "program-enrollment-card__toggle px-0", onClick: () => setExpanded((value) => !value), iconAfter: expanded ? ExpandLess : ExpandMore, children: formatMessage(expanded ? messages.showLess : messages.showAll) }))] })), previouslyPurchased.length > 0 && (_jsxs("div", { className: "program-enrollment-card__purchased", "data-testid": "previously-purchased", children: [_jsx("h3", { className: "program-enrollment-card__purchased-heading font-weight-bold font-italic mb-2 text-gray-900", children: formatMessage(messages.previouslyPurchased, { count: previouslyPurchased.length }) }), _jsx("ul", { className: "program-enrollment-card__course-list mb-0", children: previouslyPurchased.map((name) => (_jsx("li", { children: name }, name))) })] }))] }));
56
56
  };
57
57
  export default ProgramEnrollmentCard;
58
58
  //# sourceMappingURL=ProgramEnrollmentCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProgramEnrollmentCard.js","sourceRoot":"","sources":["../../../src/components/ProgramEnrollmentCard/ProgramEnrollmentCard.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;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'@openedx/paragon';\nimport { Monitor, ExpandMore, ExpandLess } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport type { AlacarteProgramOwnedCourse, ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\n\nexport interface ProgramEnrollmentCardProps {\n program: ProgramDetail,\n /** The line's own programName — filterTwouProgram has no name field of its own. */\n programName: string,\n /** Member courses the learner already owns — shown under \"Previously purchased\". */\n ownedCourses?: AlacarteProgramOwnedCourse[] | null,\n}\n\nconst INITIAL_VISIBLE_COURSES = 2;\n\nfunction courseLabel(course: { id: string, maName: string | null, tMarketingSlug: string | null }): string {\n return course.maName ?? course.tMarketingSlug ?? course.id;\n}\n\n/** Catalog ids sometimes arrive as `TwouCourse:<uuid>` while owned courseId is bare UUID. */\nfunction normalizeId(id: string): string {\n const trimmed = id.trim().toLowerCase();\n const parts = trimmed.split(':');\n return parts[parts.length - 1] || trimmed;\n}\n\nfunction normalizeName(name: string): string {\n return name.trim().toLowerCase().replace(/\\s+/g, ' ');\n}\n\nfunction isOwnedCatalogCourse(\n course: ProgramDetail['tCourses'][number],\n ownedIds: Set<string>,\n ownedNames: Set<string>,\n): boolean {\n if (ownedIds.has(normalizeId(course.id))) return true;\n if (course.uid && ownedIds.has(normalizeId(course.uid))) return true;\n const label = courseLabel(course);\n return !!label && ownedNames.has(normalizeName(label));\n}\n\nconst ProgramEnrollmentCard = ({\n program,\n programName,\n ownedCourses = null,\n}: ProgramEnrollmentCardProps) => {\n const { formatMessage } = useIntl();\n const [expanded, setExpanded] = useState(false);\n\n const ownedList = useMemo(() => ownedCourses ?? [], [ownedCourses]);\n const ownedIds = useMemo(\n () => new Set(\n ownedList\n .map((c) => c.courseId)\n .filter(Boolean)\n .map(normalizeId),\n ),\n [ownedList],\n );\n const ownedNames = useMemo(\n () => new Set(\n ownedList\n .map((c) => c.name?.trim())\n .filter((name): name is string => !!name)\n .map(normalizeName),\n ),\n [ownedList],\n );\n\n const includedCourses = useMemo(\n () => program.tCourses.filter((c) => !isOwnedCatalogCourse(c, ownedIds, ownedNames)),\n [program.tCourses, ownedIds, ownedNames],\n );\n\n const previouslyPurchased = useMemo(\n () => ownedList\n .map((c) => c.name?.trim())\n .filter((name): name is string => !!name),\n [ownedList],\n );\n\n // The program itself has no brand/logo field in filterTwouProgram — approximate\n // it from its first member course, which does carry tOrgLogoUrl/tBrandText.\n const primaryCourse = program.tCourses[0];\n const brandLogoUrl = primaryCourse?.tOrgLogoUrl ?? null;\n const brandText = primaryCourse?.tBrandText ?? '';\n\n const visibleIncluded = expanded\n ? includedCourses\n : includedCourses.slice(0, INITIAL_VISIBLE_COURSES);\n const hasMoreIncluded = includedCourses.length > INITIAL_VISIBLE_COURSES;\n\n return (\n <div className=\"program-enrollment-card\">\n <div className=\"program-enrollment-card__header d-flex align-items-start\">\n {brandLogoUrl && (\n <div className=\"program-enrollment-card__logo-wrap flex-shrink-0\">\n <img\n src={brandLogoUrl}\n alt={formatMessage(messages.logoAlt, { brand: brandText })}\n className=\"program-enrollment-card__logo\"\n />\n </div>\n )}\n <div className=\"program-enrollment-card__content flex-grow-1\">\n <span className=\"program-enrollment-card__certificate-badge\">\n <Icon src={Monitor} className=\"program-enrollment-card__certificate-icon\" />\n {formatMessage(messages.verifiedCertificate)}\n </span>\n <p className=\"program-enrollment-card__title font-weight-bold mb-0\">\n {programName}\n </p>\n </div>\n </div>\n\n {includedCourses.length > 0 && (\n <div className=\"program-enrollment-card__courses\">\n <p className=\"program-enrollment-card__courses-heading font-weight-bold mb-2 text-gray-900\">\n {formatMessage(messages.coursesIncluded, { count: program.tCourses.length })}\n </p>\n <ul className=\"program-enrollment-card__course-list mb-2\">\n {visibleIncluded.map((c) => (\n <li key={c.id}>{courseLabel(c)}</li>\n ))}\n </ul>\n {hasMoreIncluded && (\n <Button\n variant=\"tertiary\"\n size=\"sm\"\n className=\"program-enrollment-card__toggle px-0\"\n onClick={() => setExpanded((value) => !value)}\n iconAfter={expanded ? ExpandLess : ExpandMore}\n >\n {formatMessage(expanded ? messages.showLess : messages.showAll)}\n </Button>\n )}\n </div>\n )}\n\n {previouslyPurchased.length > 0 && (\n <div\n className=\"program-enrollment-card__purchased\"\n data-testid=\"previously-purchased\"\n >\n <p className=\"program-enrollment-card__purchased-heading font-weight-bold font-italic mb-2 text-gray-900\">\n {formatMessage(messages.previouslyPurchased, { count: previouslyPurchased.length })}\n </p>\n <ul className=\"program-enrollment-card__course-list mb-0\">\n {previouslyPurchased.map((name) => (\n <li key={name}>{name}</li>\n ))}\n </ul>\n </div>\n )}\n </div>\n );\n};\n\nexport default ProgramEnrollmentCard;\n"]}
1
+ {"version":3,"file":"ProgramEnrollmentCard.js","sourceRoot":"","sources":["../../../src/components/ProgramEnrollmentCard/ProgramEnrollmentCard.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAUlC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAElC,SAAS,WAAW,CAAC,MAA4E;;IAC/F,OAAO,MAAA,MAAA,MAAM,CAAC,MAAM,mCAAI,MAAM,CAAC,cAAc,mCAAI,MAAM,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED,6FAA6F;AAC7F,SAAS,WAAW,CAAC,EAAU;IAC7B,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC;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AAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAC7C,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,YAE5C,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GACxD,CACV,IACG,CACP,EAEA,mBAAmB,CAAC,MAAM,GAAG,CAAC,IAAI,CACjC,eACE,SAAS,EAAC,oCAAoC,iBAClC,sBAAsB,aAElC,aAAI,SAAS,EAAC,4FAA4F,YACvG,aAAa,CAAC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,GAChF,EACL,aAAI,SAAS,EAAC,2CAA2C,YACtD,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACjC,uBAAgB,IAAI,IAAX,IAAI,CAAa,CAC3B,CAAC,GACC,IACD,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["import React, { useMemo, useState } from 'react';\nimport { Button, Icon } from '@openedx/paragon';\nimport { Monitor, ExpandMore, ExpandLess } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport type { AlacarteProgramOwnedCourse, ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\n\nexport interface ProgramEnrollmentCardProps {\n program: ProgramDetail,\n /** The line's own programName — filterTwouProgram has no name field of its own. */\n programName: string,\n /** Member courses the learner already owns — shown under \"Previously purchased\". */\n ownedCourses?: AlacarteProgramOwnedCourse[] | null,\n}\n\nconst INITIAL_VISIBLE_COURSES = 2;\n\nfunction courseLabel(course: { id: string, maName: string | null, tMarketingSlug: string | null }): string {\n return course.maName ?? course.tMarketingSlug ?? course.id;\n}\n\n/** Catalog ids sometimes arrive as `TwouCourse:<uuid>` while owned courseId is bare UUID. */\nfunction normalizeId(id: string): string {\n const trimmed = id.trim().toLowerCase();\n const parts = trimmed.split(':');\n return parts[parts.length - 1] || trimmed;\n}\n\nfunction normalizeName(name: string): string {\n return name.trim().toLowerCase().replace(/\\s+/g, ' ');\n}\n\nfunction isOwnedCatalogCourse(\n course: ProgramDetail['tCourses'][number],\n ownedIds: Set<string>,\n ownedNames: Set<string>,\n): boolean {\n if (ownedIds.has(normalizeId(course.id))) return true;\n if (course.uid && ownedIds.has(normalizeId(course.uid))) return true;\n const label = courseLabel(course);\n return !!label && ownedNames.has(normalizeName(label));\n}\n\nconst ProgramEnrollmentCard = ({\n program,\n programName,\n ownedCourses = null,\n}: ProgramEnrollmentCardProps) => {\n const { formatMessage } = useIntl();\n const [expanded, setExpanded] = useState(false);\n\n const ownedList = useMemo(() => ownedCourses ?? [], [ownedCourses]);\n const ownedIds = useMemo(\n () => new Set(\n ownedList\n .map((c) => c.courseId)\n .filter(Boolean)\n .map(normalizeId),\n ),\n [ownedList],\n );\n const ownedNames = useMemo(\n () => new Set(\n ownedList\n .map((c) => c.name?.trim())\n .filter((name): name is string => !!name)\n .map(normalizeName),\n ),\n [ownedList],\n );\n\n const includedCourses = useMemo(\n () => program.tCourses.filter((c) => !isOwnedCatalogCourse(c, ownedIds, ownedNames)),\n [program.tCourses, ownedIds, ownedNames],\n );\n\n const previouslyPurchased = useMemo(\n () => ownedList\n .map((c) => c.name?.trim())\n .filter((name): name is string => !!name),\n [ownedList],\n );\n\n // The program itself has no brand/logo field in filterTwouProgram — approximate\n // it from its first member course, which does carry tOrgLogoUrl/tBrandText.\n const primaryCourse = program.tCourses[0];\n const brandLogoUrl = primaryCourse?.tOrgLogoUrl ?? null;\n const brandText = primaryCourse?.tBrandText ?? '';\n\n const visibleIncluded = expanded\n ? includedCourses\n : includedCourses.slice(0, INITIAL_VISIBLE_COURSES);\n const hasMoreIncluded = includedCourses.length > INITIAL_VISIBLE_COURSES;\n\n return (\n <div className=\"program-enrollment-card\">\n <div className=\"program-enrollment-card__header d-flex align-items-start\">\n {brandLogoUrl && (\n <div className=\"program-enrollment-card__logo-wrap flex-shrink-0\">\n <img\n src={brandLogoUrl}\n alt={formatMessage(messages.logoAlt, { brand: brandText })}\n className=\"program-enrollment-card__logo\"\n />\n </div>\n )}\n <div className=\"program-enrollment-card__content flex-grow-1\">\n <span className=\"program-enrollment-card__certificate-badge\">\n <Icon src={Monitor} className=\"program-enrollment-card__certificate-icon\" />\n {formatMessage(messages.verifiedCertificate)}\n </span>\n <p className=\"program-enrollment-card__title font-weight-bold mb-0\">\n {programName}\n </p>\n </div>\n </div>\n\n {includedCourses.length > 0 && (\n <div className=\"program-enrollment-card__courses\">\n <h3 className=\"program-enrollment-card__courses-heading font-weight-bold mb-2 text-gray-900\">\n {formatMessage(messages.coursesIncluded, { count: program.tCourses.length })}\n </h3>\n <ul className=\"program-enrollment-card__course-list mb-2\">\n {visibleIncluded.map((c) => (\n <li key={c.id}>{courseLabel(c)}</li>\n ))}\n </ul>\n {hasMoreIncluded && (\n <Button\n variant=\"tertiary\"\n size=\"sm\"\n className=\"program-enrollment-card__toggle px-0\"\n onClick={() => setExpanded((value) => !value)}\n iconAfter={expanded ? ExpandLess : ExpandMore}\n >\n {formatMessage(expanded ? messages.showLess : messages.showAll)}\n </Button>\n )}\n </div>\n )}\n\n {previouslyPurchased.length > 0 && (\n <div\n className=\"program-enrollment-card__purchased\"\n data-testid=\"previously-purchased\"\n >\n <h3 className=\"program-enrollment-card__purchased-heading font-weight-bold font-italic mb-2 text-gray-900\">\n {formatMessage(messages.previouslyPurchased, { count: previouslyPurchased.length })}\n </h3>\n <ul className=\"program-enrollment-card__course-list mb-0\">\n {previouslyPurchased.map((name) => (\n <li key={name}>{name}</li>\n ))}\n </ul>\n </div>\n )}\n </div>\n );\n};\n\nexport default ProgramEnrollmentCard;\n"]}
@@ -6,7 +6,7 @@ import { useIntl } from '@openedx/frontend-base';
6
6
  import messages from './Messages';
7
7
  const PromoBanner = ({ testId, children, }) => {
8
8
  const { formatMessage } = useIntl();
9
- return (_jsxs("div", { className: "promo-code__banner", "data-testid": testId, children: [_jsx("span", { className: "promo-code__banner-text", children: children }), _jsx(Icon, { src: InfoOutline, className: "promo-code__banner-icon", screenReaderText: formatMessage(messages.bannerInfo) })] }));
9
+ return (_jsxs("div", { className: "promo-code__banner", "data-testid": testId, children: [_jsx("h3", { className: "promo-code__banner-text", children: children }), _jsx(Icon, { src: InfoOutline, className: "promo-code__banner-icon", screenReaderText: formatMessage(messages.bannerInfo) })] }));
10
10
  };
11
11
  const PromoCode = ({ value, onChange, onApply, onRemove, appliedCode = null, discount = null, offer = null, error = null, isApplying = false, disabled = false, }) => {
12
12
  const { formatMessage } = useIntl();
@@ -1 +1 @@
1
- {"version":3,"file":"PromoCode.js","sourceRoot":"","sources":["../../../src/components/PromoCode/PromoCode.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AA+BlC,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,QAAQ,GAIT,EAAE,EAAE;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,OAAO,CACL,eAAK,SAAS,EAAC,oBAAoB,iBAAc,MAAM,aACrD,eAAM,SAAS,EAAC,yBAAyB,YAAE,QAAQ,GAAQ,EAC3D,KAAC,IAAI,IACH,GAAG,EAAE,WAAW,EAChB,SAAS,EAAC,yBAAyB,EACnC,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,GACpD,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,EACjB,KAA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AAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,QAAQ,EACnB,SAAS,EAAC,mBAAmB,YAE5B,UAAU;4BACT,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;4BAClC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,GAC1B,IACJ,CACR,EACA,KAAK,IAAI,CACR,eAAK,EAAE,EAAC,iBAAiB,EAAC,SAAS,EAAC,mBAAmB,EAAC,IAAI,EAAC,OAAO,aAClE,eAAM,SAAS,EAAC,wBAAwB,iBAAa,MAAM,GAAG,EAC7D,KAAK,IACF,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import React, { useState } from 'react';\nimport { Icon } from '@openedx/paragon';\nimport { Check, InfoOutline } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from './Messages';\n\nexport interface PromoDiscount {\n /** Whole-number percent off, e.g. 15. */\n percent: number,\n amount: number,\n currency: string,\n}\n\n/** A known offer advertised before the learner applies it. */\nexport interface PromoOffer {\n code: string,\n percent: number,\n}\n\nexport interface PromoCodeProps {\n value: string,\n onChange: (value: string) => void,\n onApply: () => void,\n /** Clears an applied coupon (sends empty string to the API). */\n onRemove?: () => void,\n appliedCode?: string | null,\n /** Applied coupon's discount. Drives the applied banner and amount row. */\n discount?: PromoDiscount | null,\n /** Shown on the empty field when we already know a code and its percent. */\n offer?: PromoOffer | null,\n error?: string | null,\n isApplying?: boolean,\n disabled?: boolean,\n}\n\nconst PromoBanner = ({\n testId,\n children,\n}: {\n testId: string,\n children: React.ReactNode,\n}) => {\n const { formatMessage } = useIntl();\n return (\n <div className=\"promo-code__banner\" data-testid={testId}>\n <span className=\"promo-code__banner-text\">{children}</span>\n <Icon\n src={InfoOutline}\n className=\"promo-code__banner-icon\"\n screenReaderText={formatMessage(messages.bannerInfo)}\n />\n </div>\n );\n};\n\nconst PromoCode = ({\n value,\n onChange,\n onApply,\n onRemove,\n appliedCode = null,\n discount = null,\n offer = null,\n error = null,\n isApplying = false,\n disabled = false,\n}: PromoCodeProps) => {\n const { formatMessage } = useIntl();\n const [focused, setFocused] = useState(false);\n const trimmed = value.trim();\n const canApply = !disabled && !isApplying && trimmed.length > 0;\n const offerMatchesField = !trimmed\n || (!!offer && trimmed.toLowerCase() === offer.code.toLowerCase());\n // A discount on the line without a coupon code means the backend omitted the\n // code string but the coupon is still active — show the applied state.\n const hasAppliedState = !!appliedCode || !!discount;\n const showOffer = !hasAppliedState && !!offer && offerMatchesField;\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault();\n if (canApply) onApply();\n };\n\n return (\n <div className=\"promo-code\">\n {hasAppliedState && discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.discountAppliedBanner)}\n </PromoBanner>\n ) : null}\n {appliedCode && !discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </PromoBanner>\n ) : null}\n {showOffer && offer ? (\n <PromoBanner testId=\"promo-offer-banner\">\n {formatMessage(messages.saveWithCode, { percent: offer.percent, code: offer.code })}\n </PromoBanner>\n ) : null}\n\n {hasAppliedState ? (\n <div className=\"promo-code__applied\">\n {appliedCode && discount ? (\n <p className=\"promo-code__celebration\">\n <span aria-hidden=\"true\">🎉</span>\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </p>\n ) : null}\n {discount ? (\n <>\n <hr className=\"promo-code__divider\" />\n <div className=\"promo-code__discount-row\" data-testid=\"promo-discount-row\">\n <span className=\"promo-code__discount-label\">\n {formatMessage(messages.discountApplied)}\n <Icon src={Check} className=\"promo-code__check\" aria-hidden />\n </span>\n {onRemove ? (\n <button\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={onRemove}\n disabled={disabled || isApplying}\n >\n {formatMessage(messages.remove)}\n </button>\n ) : null}\n <span className=\"promo-code__amount\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </div>\n </>\n ) : onRemove && (\n <button\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={onRemove}\n disabled={disabled || isApplying}\n >\n {formatMessage(messages.remove)}\n </button>\n )}\n </div>\n ) : (\n <form className=\"promo-code__form\" onSubmit={handleSubmit}>\n <div className={`promo-code__field${focused || value ? ' promo-code__field--active' : ''}${error ? ' promo-code__field--error' : ''}`}>\n <label htmlFor=\"promoCode\" className=\"promo-code__label\">\n {formatMessage(messages.placeholder)}\n </label>\n <input\n id=\"promoCode\"\n type=\"text\"\n className=\"promo-code__input\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n disabled={disabled || isApplying}\n aria-invalid={!!error}\n aria-describedby={error ? 'promoCode-error' : undefined}\n />\n </div>\n <button\n type=\"submit\"\n disabled={!canApply}\n className=\"promo-code__apply\"\n >\n {isApplying\n ? formatMessage(messages.applying)\n : formatMessage(messages.apply)}\n </button>\n </form>\n )}\n {error && (\n <div id=\"promoCode-error\" className=\"promo-code__error\" role=\"alert\">\n <span className=\"promo-code__error-icon\" aria-hidden=\"true\" />\n {error}\n </div>\n )}\n </div>\n );\n};\n\nexport default PromoCode;\n"]}
1
+ {"version":3,"file":"PromoCode.js","sourceRoot":"","sources":["../../../src/components/PromoCode/PromoCode.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AA+BlC,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,QAAQ,GAIT,EAAE,EAAE;IACH,MAAM,EAAE,aAA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CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAC/B,QAAQ,EAAE,QAAQ,IAAI,UAAU,kBAClB,CAAC,CAAC,KAAK,sBACH,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,GACvD,IACE,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,QAAQ,EACnB,SAAS,EAAC,mBAAmB,YAE5B,UAAU;4BACT,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;4BAClC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,GAC1B,IACJ,CACR,EACA,KAAK,IAAI,CACR,eAAK,EAAE,EAAC,iBAAiB,EAAC,SAAS,EAAC,mBAAmB,EAAC,IAAI,EAAC,OAAO,aAClE,eAAM,SAAS,EAAC,wBAAwB,iBAAa,MAAM,GAAG,EAC7D,KAAK,IACF,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import React, { useState } from 'react';\nimport { Icon } from '@openedx/paragon';\nimport { Check, InfoOutline } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from './Messages';\n\nexport interface PromoDiscount {\n /** Whole-number percent off, e.g. 15. */\n percent: number,\n amount: number,\n currency: string,\n}\n\n/** A known offer advertised before the learner applies it. */\nexport interface PromoOffer {\n code: string,\n percent: number,\n}\n\nexport interface PromoCodeProps {\n value: string,\n onChange: (value: string) => void,\n onApply: () => void,\n /** Clears an applied coupon (sends empty string to the API). */\n onRemove?: () => void,\n appliedCode?: string | null,\n /** Applied coupon's discount. Drives the applied banner and amount row. */\n discount?: PromoDiscount | null,\n /** Shown on the empty field when we already know a code and its percent. */\n offer?: PromoOffer | null,\n error?: string | null,\n isApplying?: boolean,\n disabled?: boolean,\n}\n\nconst PromoBanner = ({\n testId,\n children,\n}: {\n testId: string,\n children: React.ReactNode,\n}) => {\n const { formatMessage } = useIntl();\n return (\n <div className=\"promo-code__banner\" data-testid={testId}>\n <h3 className=\"promo-code__banner-text\">{children}</h3>\n <Icon\n src={InfoOutline}\n className=\"promo-code__banner-icon\"\n screenReaderText={formatMessage(messages.bannerInfo)}\n />\n </div>\n );\n};\n\nconst PromoCode = ({\n value,\n onChange,\n onApply,\n onRemove,\n appliedCode = null,\n discount = null,\n offer = null,\n error = null,\n isApplying = false,\n disabled = false,\n}: PromoCodeProps) => {\n const { formatMessage } = useIntl();\n const [focused, setFocused] = useState(false);\n const trimmed = value.trim();\n const canApply = !disabled && !isApplying && trimmed.length > 0;\n const offerMatchesField = !trimmed\n || (!!offer && trimmed.toLowerCase() === offer.code.toLowerCase());\n // A discount on the line without a coupon code means the backend omitted the\n // code string but the coupon is still active — show the applied state.\n const hasAppliedState = !!appliedCode || !!discount;\n const showOffer = !hasAppliedState && !!offer && offerMatchesField;\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault();\n if (canApply) onApply();\n };\n\n return (\n <div className=\"promo-code\">\n {hasAppliedState && discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.discountAppliedBanner)}\n </PromoBanner>\n ) : null}\n {appliedCode && !discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </PromoBanner>\n ) : null}\n {showOffer && offer ? (\n <PromoBanner testId=\"promo-offer-banner\">\n {formatMessage(messages.saveWithCode, { percent: offer.percent, code: offer.code })}\n </PromoBanner>\n ) : null}\n\n {hasAppliedState ? (\n <div className=\"promo-code__applied\">\n {appliedCode && discount ? (\n <p className=\"promo-code__celebration\">\n <span aria-hidden=\"true\">🎉</span>\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </p>\n ) : null}\n {discount ? (\n <>\n <hr className=\"promo-code__divider\" />\n <div className=\"promo-code__discount-row\" data-testid=\"promo-discount-row\">\n <span className=\"promo-code__discount-label\">\n {formatMessage(messages.discountApplied)}\n <Icon src={Check} className=\"promo-code__check\" aria-hidden />\n </span>\n {onRemove ? (\n <button\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={onRemove}\n disabled={disabled || isApplying}\n >\n {formatMessage(messages.remove)}\n </button>\n ) : null}\n <span className=\"promo-code__amount\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </div>\n </>\n ) : onRemove && (\n <button\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={onRemove}\n disabled={disabled || isApplying}\n >\n {formatMessage(messages.remove)}\n </button>\n )}\n </div>\n ) : (\n <form className=\"promo-code__form\" onSubmit={handleSubmit}>\n <div className={`promo-code__field${focused || value ? ' promo-code__field--active' : ''}${error ? ' promo-code__field--error' : ''}`}>\n <label htmlFor=\"promoCode\" className=\"promo-code__label\">\n {formatMessage(messages.placeholder)}\n </label>\n <input\n id=\"promoCode\"\n type=\"text\"\n className=\"promo-code__input\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n disabled={disabled || isApplying}\n aria-invalid={!!error}\n aria-describedby={error ? 'promoCode-error' : undefined}\n />\n </div>\n <button\n type=\"submit\"\n disabled={!canApply}\n className=\"promo-code__apply\"\n >\n {isApplying\n ? formatMessage(messages.applying)\n : formatMessage(messages.apply)}\n </button>\n </form>\n )}\n {error && (\n <div id=\"promoCode-error\" className=\"promo-code__error\" role=\"alert\">\n <span className=\"promo-code__error-icon\" aria-hidden=\"true\" />\n {error}\n </div>\n )}\n </div>\n );\n};\n\nexport default PromoCode;\n"]}
@@ -72,6 +72,14 @@
72
72
  padding: 1rem;
73
73
  }
74
74
 
75
+ // Order number / Purchase date — semantic <h2>s styled as bold body text.
76
+ &__detail-heading {
77
+ font-family: inherit;
78
+ font-size: inherit;
79
+ line-height: inherit;
80
+ color: inherit;
81
+ }
82
+
75
83
  &__about-title {
76
84
  font-size: 1.125rem;
77
85
  font-weight: 700;
@@ -80,6 +88,8 @@
80
88
  }
81
89
 
82
90
  &__courses-included {
91
+ font-family: inherit;
92
+ line-height: inherit;
83
93
  font-size: 1rem;
84
94
  font-weight: 600;
85
95
  color: #000000;
@@ -91,6 +101,8 @@
91
101
  }
92
102
 
93
103
  &__previously-purchased-heading {
104
+ font-family: inherit;
105
+ line-height: inherit;
94
106
  font-size: 1rem;
95
107
  font-weight: 700;
96
108
  font-style: italic;
@@ -9,6 +9,13 @@
9
9
  margin-top: 32px;
10
10
  }
11
11
 
12
+ // Semantic <h2> styled as the surrounding body text, not Paragon's h2 scale.
13
+ &__heading {
14
+ font-family: inherit;
15
+ font-size: inherit;
16
+ line-height: inherit;
17
+ }
18
+
12
19
  &__stats {
13
20
  display: flex;
14
21
  gap: 1.5rem;
@@ -53,7 +53,9 @@
53
53
 
54
54
  &__courses-heading,
55
55
  &__purchased-heading {
56
+ font-family: inherit;
56
57
  font-size: 0.95rem;
58
+ line-height: inherit;
57
59
  }
58
60
 
59
61
  &__course-list {
@@ -27,8 +27,12 @@
27
27
  flex-shrink: 0;
28
28
  }
29
29
 
30
+ // Semantic <h3> — takes its typography from the banner, not Paragon's h3 scale.
30
31
  &__banner-text {
31
32
  min-width: 0;
33
+ margin: 0;
34
+ font: inherit;
35
+ color: inherit;
32
36
  }
33
37
 
34
38
  &__form {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-app-alacarte-checkout",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "alacarte Checkout Frontend application",
5
5
  "repository": {
6
6
  "type": "git",