Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check to event-details page #188

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading