Skip to content

Commit e21d653

Browse files
committed
better handling for announcements without CTAs
1 parent 9db8226 commit e21d653

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/features/announcements/components/AnnouncementScreen.js

+21-19
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class AnnouncementScreen extends Component {
229229
__html: marked(announcement.main.text, markedOptions),
230230
}}
231231
/>
232-
{(announcement.main.cta.label || announcement.main.cta.href) && (
232+
{(announcement.main.cta && (announcement.main.cta.label && announcement.main.cta.href)) && (
233233
<div className={classes.mainCtaButton}>
234234
<Button
235235
label={announcement.main.cta.label}
@@ -265,25 +265,27 @@ class AnnouncementScreen extends Component {
265265
__html: marked(announcement.spotlight.text, markedOptions),
266266
}}
267267
/>
268-
<div className={classes.mainCtaButton}>
269-
<Button
270-
label={announcement.spotlight.cta.label}
271-
onClick={() => {
272-
const {
273-
analytics,
274-
href,
275-
label,
276-
} = announcement.spotlight.cta;
277-
if (announcement.spotlight.cta.href.startsWith('http')) {
278-
actions.app.openExternalUrl({ url: href });
279-
} else {
280-
window.location.href = `#${href}`;
281-
}
268+
{announcement.spotlight.cta && (
269+
<div className={classes.mainCtaButton}>
270+
<Button
271+
label={announcement.spotlight.cta.label}
272+
onClick={() => {
273+
const {
274+
analytics,
275+
href,
276+
label,
277+
} = announcement.spotlight.cta;
278+
if (announcement.spotlight.cta.href.startsWith('http')) {
279+
actions.app.openExternalUrl({ url: href });
280+
} else {
281+
window.location.href = `#${href}`;
282+
}
282283

283-
gaEvent(analytics.category, analytics.action, label);
284-
}}
285-
/>
286-
</div>
284+
gaEvent(analytics.category, analytics.action, label);
285+
}}
286+
/>
287+
</div>
288+
)}
287289
</div>
288290
</div>
289291
)}

0 commit comments

Comments
 (0)