diff --git a/frontends/api/src/mitxonline/hooks/programs/queries.ts b/frontends/api/src/mitxonline/hooks/programs/queries.ts index 60556bee7a..0363a5b33f 100644 --- a/frontends/api/src/mitxonline/hooks/programs/queries.ts +++ b/frontends/api/src/mitxonline/hooks/programs/queries.ts @@ -5,7 +5,7 @@ import type { ProgramCollectionsApiProgramCollectionsListRequest, ProgramsApiProgramsListV2Request, ProgramsApiProgramsRetrieveV2Request, - V2Program, + V2ProgramDetail, } from "@mitodl/mitxonline-api-axios/v2" import { programCollectionsApi, programsApi } from "../../clients" @@ -30,7 +30,7 @@ const programsQueries = { programDetail: (opts: ProgramsApiProgramsRetrieveV2Request) => queryOptions({ queryKey: programsKeys.programDetail(opts), - queryFn: async (): Promise => { + queryFn: async (): Promise => { return programsApi.programsRetrieveV2(opts).then((res) => res.data) }, }), diff --git a/frontends/main/src/app-pages/ProductPages/CourseEnrollmentButton.tsx b/frontends/main/src/app-pages/ProductPages/CourseEnrollmentButton.tsx index ecfb8d48fb..677e7173f6 100644 --- a/frontends/main/src/app-pages/ProductPages/CourseEnrollmentButton.tsx +++ b/frontends/main/src/app-pages/ProductPages/CourseEnrollmentButton.tsx @@ -106,7 +106,7 @@ const CourseEnrollmentButton: React.FC = ({ return ( <> - + + + {enrollment ? ( + + Enrolled + + ) : ( + + )} {isError && ( There was a problem processing your enrollment. Please try again. diff --git a/frontends/main/src/app-pages/ProductPages/ProgramPage.test.tsx b/frontends/main/src/app-pages/ProductPages/ProgramPage.test.tsx index c5f6e7b183..807b30e25c 100644 --- a/frontends/main/src/app-pages/ProductPages/ProgramPage.test.tsx +++ b/frontends/main/src/app-pages/ProductPages/ProgramPage.test.tsx @@ -16,7 +16,6 @@ import type { } from "@mitodl/mitxonline-api-axios/v2" import { renderWithProviders, waitFor, screen, within } from "@/test-utils" import ProgramPage from "./ProgramPage" -import { HeadingIds } from "./util" import { assertHeadings } from "ol-test-utilities" import { notFound } from "next/navigation" @@ -228,7 +227,7 @@ describe("ProgramPage", () => { assertHeadings( [ { level: 1, name: page.title }, - { level: 2, name: "Program summary" }, + { level: 2, name: "Program Information" }, { level: 2, name: "About this Program" }, { level: 2, name: "Courses" }, { level: 3, name: "Core Dog Courses" }, @@ -247,34 +246,6 @@ describe("ProgramPage", () => { ) }) - test("Page Navigation", async () => { - const program = makeProgram({ ...makeReqs() }) - const page = makePage({ program_details: program }) - setupApis({ program, page }) - renderWithProviders() - - const nav = await screen.findByRole("navigation", { - name: "Program 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 program = makeProgram({ ...makeReqs() }) @@ -453,10 +424,10 @@ describe("ProgramPage", () => { setupApis({ program, page }) renderWithProviders() - const buttons = await screen.findAllByRole("button", { + const button = await screen.findByRole("button", { name: /enroll/i, }) - expect(buttons.length).toBeGreaterThanOrEqual(1) + expect(button).toBeInTheDocument() }) test("Shows a YouTube video in the sidebar when video_url is a YouTube URL", async () => { @@ -506,15 +477,15 @@ describe("ProgramPage", () => { }) test.each([ - { courses: [], pages: [makePage()] }, + { programs: [], pages: [makePage()] }, { - courses: [makeProgram({ ...makeReqs() })], + programs: [makeProgram({ ...makeReqs() })], pages: [], }, - ])("Returns 404 if no program found", async ({ courses, pages }) => { + ])("Returns 404 if no program found", async ({ programs, pages }) => { setMockResponse.get( urls.programs.programsList({ readable_id: "readable_id" }), - { results: courses }, + { results: programs }, ) setMockResponse.get(urls.pages.programPages("readable_id"), { items: pages, diff --git a/frontends/main/src/app-pages/ProductPages/ProgramPage.tsx b/frontends/main/src/app-pages/ProductPages/ProgramPage.tsx index 0716e707a9..0d0080f5a8 100644 --- a/frontends/main/src/app-pages/ProductPages/ProgramPage.tsx +++ b/frontends/main/src/app-pages/ProductPages/ProgramPage.tsx @@ -16,15 +16,13 @@ import RawHTML from "./RawHTML" import UnstyledRawHTML from "@/components/UnstyledRawHTML/UnstyledRawHTML" 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 { ProgramPageItem, V2Program } from "@mitodl/mitxonline-api-axios/v2" -import { ProgramSummary } from "./ProductSummary" +import type { V2ProgramDetail } from "@mitodl/mitxonline-api-axios/v2" import { DEFAULT_RESOURCE_IMG, pluralize } from "ol-utilities" import { useFeatureFlagsLoaded } from "@/common/useFeatureFlagsLoaded" -import ProgramEnrollmentButton from "./ProgramEnrollmentButton" +import ProgramInfoBox from "./InfoBoxProgram" import { coursesQueries } from "api/mitxonline-hooks/courses" import MitxOnlineCourseCard from "./MitxOnlineCourseCard" @@ -38,42 +36,6 @@ const PrerequisitesSection = styled.section({ gap: "16px", }) -const getNavLinks = (page: ProgramPageItem): 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, - }, - ] as const - return all.filter((item) => item.content) -} - const DescriptionHTML = styled(UnstyledRawHTML)({ p: { margin: 0 }, }) @@ -100,7 +62,7 @@ const ReqTitleNote = styled("span")(({ theme }) => ({ })) type RequirementsSectionProps = { - program: V2Program + program: V2ProgramDetail } const getCompletionText = (parsedReqs: RequirementData[]) => { @@ -223,8 +185,6 @@ const ProgramPage: React.FC = ({ readableId }) => { return null } - 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 = @@ -245,12 +205,9 @@ const ProgramPage: React.FC = ({ readableId }) => { } imageSrc={imageSrc} videoUrl={page.video_url} - summaryTitle="Program summary" - sidebarSummary={ - + infoBox={ + } - enrollButton={} - navbar={} > {page.about ? (