Skip to content

Commit 290d840

Browse files
authored
chore: update mitxonline api with null default image changes (#3044)
* upgrade api package * remove some redundant comments * set default instructor icon * remove another redundant comment * add a test for the default icon
1 parent f9e9314 commit 290d840

9 files changed

Lines changed: 38 additions & 22 deletions

File tree

frontends/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"ol-test-utilities": "0.0.0"
3030
},
3131
"dependencies": {
32-
"@mitodl/mitxonline-api-axios": "^2026.3.5",
32+
"@mitodl/mitxonline-api-axios": "^2026.3.12",
3333
"@tanstack/react-query": "^5.66.0",
3434
"axios": "^1.12.2",
3535
"tiny-invariant": "^1.3.3"

frontends/main/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@emotion/styled": "^11.11.0",
1515
"@floating-ui/react": "^0.27.16",
1616
"@mitodl/course-search-utils": "^3.5.2",
17-
"@mitodl/mitxonline-api-axios": "^2026.3.5",
17+
"@mitodl/mitxonline-api-axios": "^2026.3.12",
1818
"@mitodl/smoot-design": "^6.24.0",
1919
"@mui/material": "^6.4.5",
2020
"@mui/material-nextjs": "^6.4.3",

frontends/main/src/app-pages/ProductPages/CoursePage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ const CoursePage: React.FC<CoursePageProps> = ({ readableId }) => {
6363
}
6464
}
6565

66-
// feature_image_src will be nullable in a future MITx Online API update
67-
// (null means no image set). Fall back to our own default image.
6866
const imageSrc =
6967
page.course_details.page.feature_image_src || DEFAULT_RESOURCE_IMG
7068

frontends/main/src/app-pages/ProductPages/InstructorsSection.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,18 @@ test("Changes active instructor content on portrait click", async () => {
5959

6060
expect(screen.queryByRole("dialog")).not.toBeInTheDocument()
6161
})
62+
63+
test("Shows default icon when instructor has no image", async () => {
64+
const instructors = [makeFaculty({ feature_image_src: null })]
65+
renderWithProviders(<InstructorsSection instructors={instructors} />)
66+
67+
const section = await screen.findByRole("region", {
68+
name: "Meet your instructors",
69+
})
70+
const button = within(section).getByRole("button", {
71+
name: instructors[0].instructor_name,
72+
})
73+
74+
expect(button.querySelector("img")).not.toBeInTheDocument()
75+
expect(button.querySelector("svg")).toBeInTheDocument()
76+
})

frontends/main/src/app-pages/ProductPages/InstructorsSection.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CarouselV2 } from "ol-components/CarouselV2"
99
import type { Faculty } from "@mitodl/mitxonline-api-axios/v2"
1010
import { HeadingIds } from "./util"
1111
import RawHTML from "./RawHTML"
12+
import { RiAccountCircleFill } from "@remixicon/react"
1213

1314
const InstructorsSectionRoot = styled.section(({ theme }) => ({
1415
display: "flex",
@@ -56,6 +57,7 @@ const InstructorButton = styled.button(({ theme }) => ({
5657
flexDirection: "column",
5758
gap: "8px",
5859
alignItems: "center",
60+
overflow: "hidden",
5961
width: "100%",
6062
border: 0,
6163
padding: 0,
@@ -87,6 +89,9 @@ const InstructorAvatar = styled.div(({ theme }) => ({
8789
boxShadow: `inset 0 0 0 2px ${theme.custom.colors.red}`,
8890
},
8991
}))
92+
const DefaultInstructorImage = styled(RiAccountCircleFill)(({ theme }) => ({
93+
color: theme.custom.colors.silverGrayDark,
94+
}))
9095
const InstructorImage = styled(Image)({
9196
height: "84px",
9297
width: "84px",
@@ -182,12 +187,16 @@ const InstructorsSection: React.FC<{ instructors: Faculty[] }> = ({
182187
onClick={() => setActiveInstructorId(instructor.id)}
183188
>
184189
<InstructorAvatar>
185-
<InstructorImage
186-
width={84}
187-
height={84}
188-
src={instructor.feature_image_src || ""}
189-
alt=""
190-
/>
190+
{instructor.feature_image_src ? (
191+
<InstructorImage
192+
width={84}
193+
height={84}
194+
src={instructor.feature_image_src}
195+
alt=""
196+
/>
197+
) : (
198+
<DefaultInstructorImage size={84} aria-hidden="true" />
199+
)}
191200
</InstructorAvatar>
192201
<InstructorName>{instructor.instructor_name}</InstructorName>
193202
</InstructorButton>

frontends/main/src/app-pages/ProductPages/ProgramPage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ const ProgramPage: React.FC<ProgramPageProps> = ({ readableId }) => {
192192
return null
193193
}
194194

195-
// feature_image_src will be nullable in a future MITx Online API update
196-
// (null means no image set). Fall back to our own default image.
197195
const imageSrc =
198196
page.program_details.page.feature_image_src || DEFAULT_RESOURCE_IMG
199197

frontends/main/src/app/(products)/courses/[readable_id]/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export const generateMetadata = async (
2626
}
2727
const [course] = coursePages.items
2828

29-
// feature_image_src will be nullable in a future MITx Online API update
30-
// (null means no image set). Fall back to our own default image.
3129
const image =
3230
course.course_details.page.feature_image_src || DEFAULT_RESOURCE_IMG
3331

frontends/main/src/app/(products)/programs/[readable_id]/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export const generateMetadata = async (
2626
}
2727
const [program] = programPages.items
2828

29-
// feature_image_src will be nullable in a future MITx Online API update
30-
// (null means no image set). Fall back to our own default image.
3129
const image =
3230
program.program_details.page.feature_image_src || DEFAULT_RESOURCE_IMG
3331

yarn.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)