Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
293394c
feat: move enrollment button below course summary content
ChristopherChudzicki Mar 5, 2026
c3890ef
feat: add program bundle upsell to course summary sidebar
ChristopherChudzicki Mar 5, 2026
b337fec
refactor: single-structure info box with CSS grid, fix bundle upsell …
ChristopherChudzicki Mar 6, 2026
9560cdf
feat: remove product page navbar/navigation links
ChristopherChudzicki Mar 6, 2026
807f11a
refactor: split SummaryCard/SummaryContent, delete ProductNavbar, add…
ChristopherChudzicki Mar 6, 2026
2071c13
refactor: simplify sidebar layout, tablet 2-col metadata, row-style u…
ChristopherChudzicki Mar 6, 2026
a6e49db
refactor: move sticky to SummaryCol, use HEADER_HEIGHT, add column-rule
ChristopherChudzicki Mar 6, 2026
0f250d3
feat: refine bundle upsell copy, pricing, and AskTIM layout
ChristopherChudzicki Mar 7, 2026
07332bd
feat: restore enrollment button at all breakpoints, update upsell tests
ChristopherChudzicki Mar 7, 2026
7c50d0a
fix: hide empty upsell, parameterize AskTIM, require enrollButton
ChristopherChudzicki Mar 7, 2026
6488ee4
fix some minor spacing issues
ChristopherChudzicki Mar 8, 2026
af9f081
fix: replace hardcoded dates in ProductSummary tests with relative dates
ChristopherChudzicki Mar 8, 2026
e61dd43
test: add error-state test for ProgramBundleUpsell, use deferred prom…
ChristopherChudzicki Mar 8, 2026
ba561d2
refactor: extract hardcoded bundle discount to named constant
ChristopherChudzicki Mar 8, 2026
8d195d2
feat: add loading skeleton to ProgramBundleUpsell, improve tests
ChristopherChudzicki Mar 8, 2026
3b0588c
feat: create CourseInfoBox wrapper component
ChristopherChudzicki Mar 8, 2026
c09eec9
feat: create ProgramInfoBox wrapper component
ChristopherChudzicki Mar 8, 2026
6ac1270
test: assert summary mocks are rendered in InfoBox tests
ChristopherChudzicki Mar 8, 2026
ff080ad
refactor: simplify ProductPageTemplate to single infoBox prop
ChristopherChudzicki Mar 8, 2026
c32ffd4
fix: log warning when program bundle upsell queries fail
ChristopherChudzicki Mar 8, 2026
17321ce
refactor: rename and reorganize InfoBox components
ChristopherChudzicki Mar 8, 2026
c84e283
refactor: extract ProgramBundleUpsell to its own module
ChristopherChudzicki Mar 8, 2026
c79c37f
test: assert summary mocks are rendered in InfoBox tests
ChristopherChudzicki Mar 9, 2026
179af08
remove asktim
ChristopherChudzicki Mar 9, 2026
8d329ca
refactor: clean up review feedback and batch program queries
ChristopherChudzicki Mar 9, 2026
ee92f44
simplify a test call
ChristopherChudzicki Mar 9, 2026
6cc91c1
align enrollment button to right column on tablet
ChristopherChudzicki Mar 9, 2026
22721e8
refactor program bundle upsell layout and remove best value header
ChristopherChudzicki Mar 9, 2026
8796b26
restore disabled link behavior
ChristopherChudzicki Mar 11, 2026
105bf6e
fix wrapping
ChristopherChudzicki Mar 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontends/api/src/mitxonline/hooks/programs/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
ProgramCollectionsApiProgramCollectionsListRequest,
ProgramsApiProgramsListV2Request,
ProgramsApiProgramsRetrieveV2Request,
V2Program,
V2ProgramDetail,
} from "@mitodl/mitxonline-api-axios/v2"
import { programCollectionsApi, programsApi } from "../../clients"

Expand All @@ -30,7 +30,7 @@ const programsQueries = {
programDetail: (opts: ProgramsApiProgramsRetrieveV2Request) =>
queryOptions({
queryKey: programsKeys.programDetail(opts),
queryFn: async (): Promise<V2Program> => {
queryFn: async (): Promise<V2ProgramDetail> => {
return programsApi.programsRetrieveV2(opts).then((res) => res.data)
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const CourseEnrollmentButton: React.FC<CourseEnrollmentButtonProps> = ({

return (
<>
<Stack width="100%" gap="12px">
<Stack gap="12px">
<Button
disabled={
!nextRun ||
Expand Down
55 changes: 23 additions & 32 deletions frontends/main/src/app-pages/ProductPages/CoursePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "api/test-utils"
import { renderWithProviders, waitFor, screen, within } from "@/test-utils"
import CoursePage from "./CoursePage"
import { HeadingIds } from "./util"
import { assertHeadings } from "ol-test-utilities"
import { notFound } from "next/navigation"

Expand Down Expand Up @@ -97,7 +96,7 @@ describe("CoursePage", () => {
await waitFor(() => {
assertHeadings([
{ level: 1, name: page.title },
{ level: 2, name: "Course summary" },
{ level: 2, name: "Course Information" },
{ level: 2, name: "About this Course" },
{ level: 2, name: "What you'll learn" },
{ level: 2, name: "How you'll learn" },
Expand All @@ -109,34 +108,6 @@ describe("CoursePage", () => {
})
})

test("Page Navigation", async () => {
const course = makeCourse()
const page = makePage({ course_details: course })
setupApis({ course, page })
renderWithProviders(<CoursePage readableId={course.readable_id} />)

const nav = await screen.findByRole("navigation", {
name: "Course Details",
})
const links = within(nav).getAllByRole("link")

expect(links[0]).toHaveTextContent("About")
expect(links[0]).toHaveAttribute("href", `#${HeadingIds.About}`)
expect(document.getElementById(HeadingIds.About)).toBeVisible()
expect(links[1]).toHaveTextContent("What you'll learn")
expect(links[1]).toHaveAttribute("href", `#${HeadingIds.What}`)
expect(document.getElementById(HeadingIds.What)).toBeVisible()
expect(links[2]).toHaveTextContent("How you'll learn")
expect(links[2]).toHaveAttribute("href", `#${HeadingIds.How}`)
expect(document.getElementById(HeadingIds.How)).toBeVisible()
expect(links[3]).toHaveTextContent("Prerequisites")
expect(links[3]).toHaveAttribute("href", `#${HeadingIds.Prereqs}`)
expect(document.getElementById(HeadingIds.Prereqs)).toBeVisible()
expect(links[4]).toHaveTextContent("Instructors")
expect(links[4]).toHaveAttribute("href", `#${HeadingIds.Instructors}`)
expect(document.getElementById(HeadingIds.Instructors)).toBeVisible()
})

// Collasping sections tested in AboutSection.test.tsx
test("About section has expected content", async () => {
const course = makeCourse()
Expand Down Expand Up @@ -192,14 +163,34 @@ describe("CoursePage", () => {
expectRawContent(section, page.prerequisites)
})

test("Renders program bundle upsell when course belongs to a program (content tested in ProgramBundleUpsell.test)", async () => {
const baseProgram = factories.programs.baseProgram()
const programDetail = factories.programs.program({
id: baseProgram.id,
readable_id: baseProgram.readable_id,
products: [factories.courses.product({ price: "500" })],
})
const course = makeCourse({ programs: [baseProgram] })
const page = makePage({ course_details: course })
setupApis({ course, page })
setMockResponse.get(urls.programs.programsList({ id: [baseProgram.id] }), {
results: [programDetail],
})
renderWithProviders(<CoursePage readableId={course.readable_id} />)

expect(
await screen.findByTestId("program-bundle-upsell"),
).toBeInTheDocument()
})

test("Renders an enrollment button", async () => {
const course = makeCourse()
const page = makePage({ course_details: course })
setupApis({ course, page })
renderWithProviders(<CoursePage readableId={course.readable_id} />)

const buttons = await screen.findAllByTestId("course-enrollment-button")
expect(buttons.length).toBeGreaterThanOrEqual(1)
const button = await screen.findByTestId("course-enrollment-button")
expect(button).toBeInTheDocument()
})

test("Shows a YouTube video in the sidebar when video_url is a YouTube URL", async () => {
Expand Down
48 changes: 2 additions & 46 deletions frontends/main/src/app-pages/ProductPages/CoursePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { pagesQueries } from "api/mitxonline-hooks/pages"
import { useQuery } from "@tanstack/react-query"
import { styled } from "@mitodl/smoot-design"
import { coursesQueries } from "api/mitxonline-hooks/courses"
import { CourseSummary } from "./ProductSummary"
import { useFeatureFlagEnabled } from "posthog-js/react"
import { FeatureFlags } from "@/common/feature_flags"
import { notFound } from "next/navigation"
Expand All @@ -16,14 +15,12 @@ import InstructorsSection from "./InstructorsSection"
import RawHTML from "./RawHTML"
import AboutSection from "./AboutSection"
import ProductPageTemplate from "./ProductPageTemplate"
import ProductNavbar, { HeadingData } from "./ProductNavbar"
import WhoCanTakeSection from "./WhoCanTakeSection"
import WhatYoullLearnSection from "./WhatYoullLearnSection"
import HowYoullLearnSection, { DEFAULT_HOW_DATA } from "./HowYoullLearnSection"
import { CoursePageItem } from "@mitodl/mitxonline-api-axios/v2"
import { DEFAULT_RESOURCE_IMG } from "ol-utilities"
import { useFeatureFlagsLoaded } from "@/common/useFeatureFlagsLoaded"
import CourseEnrollmentButton from "./CourseEnrollmentButton"
import CourseInfoBox from "./InfoBoxCourse"

type CoursePageProps = {
readableId: string
Expand All @@ -35,42 +32,6 @@ const PrerequisitesSection = styled.section({
gap: "16px",
})

const getNavLinks = (page: CoursePageItem): HeadingData[] => {
const all = [
{
id: HeadingIds.About,
label: "About",
variant: "primary",
content: page.about,
},
{
id: HeadingIds.What,
label: "What you'll learn",
variant: "secondary",
content: page.what_you_learn,
},
{
id: HeadingIds.How,
label: "How you'll learn",
variant: "secondary",
content: true,
},
{
id: HeadingIds.Prereqs,
label: "Prerequisites",
variant: "secondary",
content: page.prerequisites,
},
{
id: HeadingIds.Instructors,
label: "Instructors",
variant: "secondary",
content: page.faculty.length ? "x" : undefined,
},
] as const
return all.filter((item) => item.content)
}

const CoursePage: React.FC<CoursePageProps> = ({ readableId }) => {
const pages = useQuery(pagesQueries.coursePages(readableId))
const courses = useQuery(
Expand All @@ -95,8 +56,6 @@ const CoursePage: React.FC<CoursePageProps> = ({ readableId }) => {
}
}

const navLinks = getNavLinks(page)

// feature_image_src will be nullable in a future MITx Online API update
// (null means no image set). Fall back to our own default image.
const imageSrc =
Expand All @@ -110,10 +69,7 @@ const CoursePage: React.FC<CoursePageProps> = ({ readableId }) => {
shortDescription={page.course_details.page.description}
imageSrc={imageSrc}
videoUrl={page.video_url}
summaryTitle="Course summary"
sidebarSummary={<CourseSummary course={course} />}
enrollButton={<CourseEnrollmentButton course={course} />}
navbar={<ProductNavbar navLinks={navLinks} productNoun="Course" />}
infoBox={<CourseInfoBox course={course} />}
>
{page.about ? (
<AboutSection productNoun="Course" aboutHtml={page.about} />
Expand Down
33 changes: 33 additions & 0 deletions frontends/main/src/app-pages/ProductPages/InfoBoxCourse.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react"
import { VisuallyHidden } from "@mitodl/smoot-design"
import type { CourseWithCourseRunsSerializerV2 } from "@mitodl/mitxonline-api-axios/v2"
import { HeadingIds } from "./util"
import { CourseSummary } from "./ProductSummary"
import ProgramBundleUpsell from "./ProgramBundleUpsell"
import CourseEnrollmentButton from "./CourseEnrollmentButton"
import { InfoBoxCard, InfoBoxContent, InfoBoxEnrollArea } from "./InfoBoxParts"

type CourseInfoBoxProps = {
course: CourseWithCourseRunsSerializerV2
}

const CourseInfoBox: React.FC<CourseInfoBoxProps> = ({ course }) => {
return (
<InfoBoxCard as="section" aria-labelledby={HeadingIds.Summary}>
<VisuallyHidden>
<h2 id={HeadingIds.Summary}>Course Information</h2>
</VisuallyHidden>
<InfoBoxContent>
<CourseSummary course={course} />
</InfoBoxContent>
<InfoBoxEnrollArea>
<CourseEnrollmentButton course={course} />
</InfoBoxEnrollArea>
{course.programs?.length ? (
<ProgramBundleUpsell programs={course.programs} />
) : null}
</InfoBoxCard>
)
}

export default CourseInfoBox
39 changes: 39 additions & 0 deletions frontends/main/src/app-pages/ProductPages/InfoBoxParts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { styled } from "@mitodl/smoot-design"

/**
* Outer card wrapper: border, shadow, radius. No padding — children control
* their own insets so that elements like the bundle upsell can span edge-to-edge.
*/
export const InfoBoxCard = styled.div(({ theme }) => ({
border: `1px solid ${theme.custom.colors.lightGray2}`,
backgroundColor: theme.custom.colors.white,
borderRadius: "4px",
boxShadow: "0 8px 20px 0 rgba(120, 147, 172, 0.10)",
overflow: "hidden",
}))

/** Padded content area inside the summary card. */
export const InfoBoxContent = styled.div(({ theme }) => ({
padding: "24px",
[theme.breakpoints.up("md")]: {
padding: "24px 32px",
},
[theme.breakpoints.down("sm")]: {
padding: "16px",
},
}))

export const InfoBoxEnrollArea = styled.div(({ theme }) => ({
padding: "8px 24px 24px",
[theme.breakpoints.up("md")]: {
padding: "8px 32px 24px",
},
[theme.breakpoints.between("sm", "md")]: {
display: "flex",
justifyContent: "flex-end",
"> *": { flex: "0 1 50%" },
Copy link
Contributor

@gumaerc gumaerc Mar 10, 2026

Choose a reason for hiding this comment

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

I don't think we need to change this here but I'm a bit confused as to the scope of the changes here. This PR is supposed to be about the program upsell but seems to be doing a lot of change to the layout, but doesn't completely align it with the current Figma.

Image

The tablet view is rendering the enrollment button inside the info box here, but it seems it's supposed to be in the image area. I imagine that work is being saved for a future PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The scope of this PR is "Program Bundle Upsell" / "Unified HTML structure" / " InfoBox refactor".

The banner updates are handled in

Let me confirm the enrollment button removal with Steve/Bilal tomorrow. I suspect that's finalized now, and since the banner PR is pretty much ready, we can remove it now. (Figma still shows it for Mobile, but that may be a mistake; we will keep it in the infobox on desktop.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wrapping issue resolved, btw

Screenshot 2026-03-11 at 12 51 50 PM

},
[theme.breakpoints.down("sm")]: {
padding: "8px 16px 16px",
},
}))
36 changes: 36 additions & 0 deletions frontends/main/src/app-pages/ProductPages/InfoBoxProgram.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from "react"
import { VisuallyHidden } from "@mitodl/smoot-design"
import type {
V2ProgramDetail,
CourseWithCourseRunsSerializerV2,
} from "@mitodl/mitxonline-api-axios/v2"
import { HeadingIds } from "./util"
import { ProgramSummary } from "./ProductSummary"
import ProgramEnrollmentButton from "./ProgramEnrollmentButton"
import { InfoBoxCard, InfoBoxContent, InfoBoxEnrollArea } from "./InfoBoxParts"

type ProgramInfoBoxProps = {
program: V2ProgramDetail
courses?: CourseWithCourseRunsSerializerV2[]
}

const ProgramInfoBox: React.FC<ProgramInfoBoxProps> = ({
program,
courses,
}) => {
return (
<InfoBoxCard as="section" aria-labelledby={HeadingIds.Summary}>
<VisuallyHidden>
<h2 id={HeadingIds.Summary}>Program Information</h2>
</VisuallyHidden>
<InfoBoxContent>
<ProgramSummary program={program} courses={courses} />
</InfoBoxContent>
<InfoBoxEnrollArea>
<ProgramEnrollmentButton program={program} />
</InfoBoxEnrollArea>
</InfoBoxCard>
)
}

export default ProgramInfoBox
69 changes: 0 additions & 69 deletions frontends/main/src/app-pages/ProductPages/ProductNavbar.tsx

This file was deleted.

Loading
Loading