Skip to content

Commit 3895b4e

Browse files
fix price separator display (#2348)
1 parent c22abe4 commit 3895b4e

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

frontends/ol-components/src/components/LearningResourceCard/LearningResourceCard.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,18 @@ const Info = ({
6666
size: Size
6767
}) => {
6868
const prices = getLearningResourcePrices(resource)
69-
const certificatePrice =
70-
size === "small" && prices.certificate.display?.includes("–")
71-
? ""
72-
: prices.certificate.display
73-
? prices.certificate.display
74-
: ""
75-
const separator = size === "small" ? "" : ": "
69+
const getCertPriceAndLabel = () => {
70+
if (size === "small") {
71+
const label = ""
72+
const hasRange = prices.course.display?.includes("–")
73+
const certificatePrice = hasRange ? "" : prices.certificate.display
74+
return { certificatePrice, label }
75+
}
76+
const certificatePrice = prices.certificate.display
77+
const label = certificatePrice ? "Certificate:" : "Certificate"
78+
return { certificatePrice, label }
79+
}
80+
const { certificatePrice, label } = getCertPriceAndLabel()
7681
return (
7782
<>
7883
<span>{getReadableResourceType(resource.resource_type)}</span>
@@ -84,14 +89,14 @@ const Info = ({
8489
<RiAwardFill />
8590
</Tooltip>
8691
) : (
87-
<RiAwardFill />
92+
<>
93+
<RiAwardFill />
94+
{label}
95+
{certificatePrice ? (
96+
<CertificatePrice>{certificatePrice}</CertificatePrice>
97+
) : null}
98+
</>
8899
)}
89-
{size === "small" ? "" : "Certificate"}
90-
{certificatePrice ? (
91-
<CertificatePrice>
92-
{`${separator}${certificatePrice}`}
93-
</CertificatePrice>
94-
) : null}
95100
</Certificate>
96101
)}
97102
<Price>{prices.course.display}</Price>

0 commit comments

Comments
 (0)