Skip to content

Commit

Permalink
Merge pull request #188 from nih-sparc/fix-event-details-page-crash
Browse files Browse the repository at this point in the history
Added check to event-details page
  • Loading branch information
egauzens authored Aug 21, 2024
2 parents ddf6a76 + 398014b commit 4a11a28
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pages/news-and-events/events/[eventId]/event-details/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ heroSummary }}
</div>
</page-hero>
<div class="container pt-32">
<div v-if="eventDetailsItem" class="container pt-32">
<div class="subpage">
<div class="header mb-32">
<h2>Event Details</h2>
Expand Down Expand Up @@ -62,12 +62,11 @@ export default {
async setup() {
const route = useRoute()
const router = useRouter()
try {
const page = await getEventPage(route.params.eventId)
const eventDetailsItem = pathOr(null, ['fields','eventDetails'], page)
if (isEmpty(eventDetailsItem)) {
router.push(`/news-and-events/events/${route.params.eventId}`)
const eventDetailsItem = pathOr(null, ['fields', 'eventDetails'], page)
if (isEmpty(eventDetailsItem) || eventDetailsItem == null) {
navigateTo(`/news-and-events/events/${route.params.eventId}`, { redirectCode: 301 })
}
return {
page,
Expand Down Expand Up @@ -115,8 +114,8 @@ export default {
* Compute and convert the date the article was created
* @returns {String}
*/
updatedDate: function() {
return format(parseISO(this.eventDetailsItem.sys.updatedAt), 'MM/dd/yyyy')
updatedDate: function () {
return this.eventDetailsItem ? format(parseISO(this.eventDetailsItem?.sys.updatedAt), 'MM/dd/yyyy') : undefined
},
breadcrumb: function() {
return [
Expand Down

0 comments on commit 4a11a28

Please sign in to comment.