Skip to content

WIP receipt page - #3717

Open
gumaerc wants to merge 2 commits into
mainfrom
cg/receipt-page
Open

WIP receipt page#3717
gumaerc wants to merge 2 commits into
mainfrom
cg/receipt-page

Conversation

@gumaerc

@gumaerc gumaerc commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Description (What does it do?)

Screenshots (if appropriate):

  • Desktop screenshots
  • Mobile width screenshots

How can this be tested?

Additional Context

Copilot AI review requested due to automatic review settings August 3, 2026 23:35
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

OpenAPI Changes

No changes detected

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new MITx Online receipt experience to the Next.js frontend, including dedicated receipt routes and dashboard “Receipt” links that resolve an order ID from order history before navigating to the receipt.

Changes:

  • Introduces /receipt/[orderId] and resolver routes (/receipt/by-run/[runId], /receipt/by-program/[programId]) plus URL helpers.
  • Adds receipt UI components/utilities (detail list, order summary, formatting) and redirect logic to resolve an order ID via orders/history.
  • Updates dashboard enrollment cards and test utilities to use resolved internal receipt links instead of opening MITx Online legacy URLs, with extensive test coverage and API test factory support.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontends/main/src/common/urls.ts Adds receipt route constants and path helpers.
frontends/main/src/common/mitxonline/useOrderIdForResource.ts New hook to resolve latest fulfilled order ID for a run/program from order history.
frontends/main/src/app/(site)/receipt/[orderId]/page.tsx New receipt route entrypoint (validates param, renders receipt page).
frontends/main/src/app/(site)/receipt/by-run/[runId]/page.tsx New resolver route: run → order → receipt redirect.
frontends/main/src/app/(site)/receipt/by-program/[programId]/page.tsx New resolver route: program → order → receipt redirect.
frontends/main/src/app-pages/ReceiptPage/receiptUtils.ts Receipt formatting utilities (money, dates, address, payment method, discount code).
frontends/main/src/app-pages/ReceiptPage/ReceiptRedirect.tsx Client redirect component that replaces history entry with resolved receipt route.
frontends/main/src/app-pages/ReceiptPage/ReceiptRedirect.test.tsx Tests for resolver redirect behavior and matching logic.
frontends/main/src/app-pages/ReceiptPage/ReceiptPage.tsx Client receipt page fetching order + user, rendering receipt sections and error/404 states.
frontends/main/src/app-pages/ReceiptPage/ReceiptPage.test.tsx Tests for receipt rendering, formatting, conditional sections, and error handling.
frontends/main/src/app-pages/ReceiptPage/ReceiptOrderSummary.tsx Order summary sidebar (discount/quantity totals, total paid).
frontends/main/src/app-pages/ReceiptPage/ReceiptDetailList.tsx Shared receipt detail list rendering + filtering helper.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/test-utils.ts Adds setupOrderHistory helper for tests rendering verified enrollment cards.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/receiptMenuItem.ts Switches receipt menu item to internal href using resolved order ID.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/receiptMenuItem.test.ts Updates receipt menu item tests for new behavior.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/ProgramEnrollmentDisplay.test.tsx Ensures order-history calls are mocked for verified cards.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/ProgramEnrollmentCard.tsx Resolves program receipt order ID client-side and conditionally shows receipt menu item.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/ProgramEnrollmentCard.test.tsx Updates tests to assert internal receipt link and hidden state when no order resolves.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/HomeEnrollmentsDisplay.test.tsx Ensures order-history calls are mocked for verified cards.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrolledCourseCard.tsx Resolves run receipt order ID client-side and conditionally shows receipt menu item.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrolledCourseCard.test.tsx Updates tests to assert internal receipt link and hidden state when no order resolves.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/DashboardDialogs.test.tsx Ensures order-history calls are mocked for verified cards.
frontends/main/src/app-pages/DashboardPage/ContractContent.test.tsx Ensures order-history calls are mocked for verified cards.
frontends/main/next.config.js Adds a Turbopack memory limit configuration.
frontends/api/src/mitxonline/test-utils/urls.ts Adds test util URL builder for orders/history.
frontends/api/src/mitxonline/test-utils/factories/orders.ts Expands order-related factories to support order history and receipt needs.
frontends/api/src/mitxonline/hooks/orders/queries.ts Adds react-query historyList query for MITx Online orders history.

Comment on lines +51 to +57
const formatPaymentMethod = (order: Order): string | null => {
const transaction = order.transactions
if (!transaction) return null
if (transaction.payment_method === "paypal") return "Paypal"
const parts = [transaction.card_type, transaction.card_number].filter(Boolean)
return parts.length > 0 ? parts.join(" | ") : null
}
Comment on lines +38 to +44
historyList: (opts: OrdersApiOrdersHistoryListRequest = {}) =>
queryOptions({
queryKey: orderKeys.historyList(opts),
queryFn: async (): Promise<PaginatedOrderHistoryList> => {
return ordersApi.ordersHistoryList(opts).then((res) => res.data)
},
}),
<MainColumn>
<Typography variant="body1">
We could not load this receipt.{" "}
<SupportLink href={`mailto:${SUPPORT_EMAIL}`}>
@gumaerc

gumaerc commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Some upstream changes we should make in MITx Online before continuing work on the frontend:

  1. Order.purchaser: drop many=True and add a name field. It's annotated as a list but returns an object, so the generated type is wrong; and ExtendedLegalAddress is only country/state/email. Learn ignores the field entirely and calls users/me just to get a name. Fix both and the receipt renders from one response.

  2. Normalize money field precision. One receipt payload returns total_price_paid: "149.00000", total_paid: "149.00", price: "149.00", discount: "0.0", and refunds[].amount as a number. Four formats and two types for currency in a single object. Consistent 2-decimal strings (or consistent numbers) removes per-field parsing.

  3. Make transactions and street_address consistently null-or-populated. They currently come back as None, or as an object with every field null, depending on whether a transaction row exists — so consumers handle three shapes for one field.

  4. Always paginate orders/history. With no PAGE_SIZE configured, omitting limit bypasses pagination and returns a bare array instead of the {count, results} envelope the schema declares. A generated client that omits limit breaks.

  5. Populate CEUs or remove it. Declared in the schema and hardcoded to None in TransactionLineSerializer, so it's permanently blank.

  6. Add a discriminator to Product.purchasable_object. Untagged union whose three variants all expose a bare id from different tables; Learn currently identifies them by which optional fields are present.

@gumaerc
gumaerc force-pushed the cg/receipt-page branch 2 times, most recently from 2e3fcdd to 68df7a2 Compare August 4, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants