Skip to content

Commit fc7d381

Browse files
make contract card titles link to org page (#2648)
1 parent bda7ebe commit fc7d381

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/OrganizationCards.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ describe("OrganizationCards", () => {
5555
return renderWithProviders(<OrganizationCards />)
5656
}
5757

58-
afterEach(() => {
59-
jest.clearAllMocks()
60-
})
61-
6258
it("renders nothing when user has no B2B organizations", () => {
6359
setup({ organizations: [] })
6460

@@ -133,8 +129,12 @@ describe("OrganizationCards", () => {
133129

134130
// Should show all contracts for the organization
135131
// Each contract appears twice (mobile + desktop)
136-
expect(await screen.findAllByText("Contract 1")).toHaveLength(2)
137-
expect(screen.getAllByText("Contract 2")).toHaveLength(2)
132+
expect(
133+
await screen.findAllByRole("link", { name: "Contract 1" }),
134+
).toHaveLength(2)
135+
expect(screen.getAllByRole("link", { name: "Contract 2" })).toHaveLength(
136+
2,
137+
)
138138
})
139139

140140
it("renders Continue buttons with correct organization URLs", async () => {

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/OrganizationCards.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import Image from "next/image"
33
import graduateLogo from "@/public/images/dashboard/graduate.png"
4-
import { Stack, Typography, styled, theme } from "ol-components"
4+
import { Stack, Typography, styled, theme, Link } from "ol-components"
55
import { useQuery } from "@tanstack/react-query"
66
import { DashboardCardRoot } from "./DashboardCard"
77
import { mitxUserQueries } from "api/mitxonline-hooks/user"
@@ -55,12 +55,17 @@ const CardRootStyled = styled(DashboardCardRoot)({
5555
},
5656
})
5757

58+
const TitleLink = styled(Link)({
59+
width: "100%",
60+
})
61+
5862
const CardContent = styled(Stack)({
5963
display: "flex",
6064
justifyContent: "space-between",
6165
alignItems: "center",
6266
padding: "16px",
6367
width: "100%",
68+
gap: "16px",
6469
"&:not(:last-child)": {
6570
borderBottom: `1px solid ${theme.custom.colors.lightGray2}`,
6671
},
@@ -90,19 +95,20 @@ interface OrganizationContractsProps {
9095
const OrganizationContracts: React.FC<OrganizationContractsProps> = ({
9196
org,
9297
}) => {
93-
const contractContent = org.contracts?.length
94-
? org.contracts?.map((contract) => (
98+
const contractContent =
99+
org.contracts?.map((contract) => {
100+
const href = organizationView(org.slug.replace("org-", ""))
101+
return (
95102
<CardContent key={contract.id} direction="row">
96-
<Typography variant="subtitle2">{contract.name}</Typography>
97-
<ButtonLink
98-
size="small"
99-
href={organizationView(org.slug.replace("org-", ""))}
100-
>
103+
<TitleLink size="medium" color="black" href={href}>
104+
{contract.name}
105+
</TitleLink>
106+
<ButtonLink size="small" href={href}>
101107
Continue
102108
</ButtonLink>
103109
</CardContent>
104-
))
105-
: null
110+
)
111+
}) ?? null
106112
return (
107113
<ContractCard>
108114
<Title key={org.id}>

0 commit comments

Comments
 (0)