Skip to content

Commit

Permalink
better handling for announcements without CTAs
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Apr 4, 2022
1 parent 9db8226 commit e21d653
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/features/announcements/components/AnnouncementScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class AnnouncementScreen extends Component {
__html: marked(announcement.main.text, markedOptions),
}}
/>
{(announcement.main.cta.label || announcement.main.cta.href) && (
{(announcement.main.cta && (announcement.main.cta.label && announcement.main.cta.href)) && (
<div className={classes.mainCtaButton}>
<Button
label={announcement.main.cta.label}
Expand Down Expand Up @@ -265,25 +265,27 @@ class AnnouncementScreen extends Component {
__html: marked(announcement.spotlight.text, markedOptions),
}}
/>
<div className={classes.mainCtaButton}>
<Button
label={announcement.spotlight.cta.label}
onClick={() => {
const {
analytics,
href,
label,
} = announcement.spotlight.cta;
if (announcement.spotlight.cta.href.startsWith('http')) {
actions.app.openExternalUrl({ url: href });
} else {
window.location.href = `#${href}`;
}
{announcement.spotlight.cta && (
<div className={classes.mainCtaButton}>
<Button
label={announcement.spotlight.cta.label}
onClick={() => {
const {
analytics,
href,
label,
} = announcement.spotlight.cta;
if (announcement.spotlight.cta.href.startsWith('http')) {
actions.app.openExternalUrl({ url: href });
} else {
window.location.href = `#${href}`;
}

gaEvent(analytics.category, analytics.action, label);
}}
/>
</div>
gaEvent(analytics.category, analytics.action, label);
}}
/>
</div>
)}
</div>
</div>
)}
Expand Down

0 comments on commit e21d653

Please sign in to comment.