Show organizers on events

This commit is contained in:
ponas committed 2019-07-25 22:21:15 +02:00
1 parent d072bdfe18
commit 5435677853
3 files changed
+49 -1

No files matched your search

+4
View File
@@ -171,6 +171,10 @@ export const pageQuery = graphql`
slug
path
description
association {
title
path
}
}
}
fragment EventListFields on wordpress__wp_events {
+23 -1
View File
@@ -34,6 +34,7 @@ export const EventTemplate = ({
priceStudent,
priceRegular,
eventTypes,
organizers,
}) => {
const hasFeaturedMedia = featuredMedia && !!featuredMedia.localFile
return (
@@ -117,6 +118,18 @@ export const EventTemplate = ({
</a>
)}
</div>
{organizers && (
<div className="event-organizers">
<div className="event-organizers-title">
{organizers.length === 1 ? 'Arrangør' : 'Arrangører'}
</div>
{organizers.map(organizer => (
<div className="event-organizer">
<Link to={organizer.path}>{organizer.name}</Link>
</div>
))}
</div>
)}
<div
className="event-content wp-content"
dangerouslySetInnerHTML={{ __html: content }}
@@ -131,13 +144,21 @@ EventTemplate.propTypes = {
featuredMedia: PropTypes.shape({}),
startTime: PropTypes.string.isRequired,
endTime: PropTypes.string,
venue: PropTypes.shape({}),
venue: PropTypes.shape({
title: PropTypes.string,
path: PropTypes.string,
preposition: PropTypes.string,
}),
venueCustom: PropTypes.string,
facebookUrl: PropTypes.string,
ticketUrl: PropTypes.string,
priceStudent: PropTypes.string,
priceRegular: PropTypes.string,
eventTypes: PropTypes.arrayOf(PropTypes.string),
organizers: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string,
path: PropTypes.string,
})),
}
const Event = ({ data }) => {
@@ -159,6 +180,7 @@ const Event = ({ data }) => {
priceStudent={event.price_member}
priceRegular={event.price_regular}
eventTypes={event.event_types}
organizers={event.event_organizers}
/>
</Layout>
)
+22
View File
@@ -61,6 +61,27 @@ const mapEventsToEventOrganizers = entities => {
})
}
const mapEventOrganizersToAssociations = entities => {
const associations = entities.filter(
e => e.__type === 'wordpress__wp_associations'
)
return entities.map(e => {
if (e.__type !== 'wordpress__wp_event_organizers') {
return e
}
// Replace venue IDs with links to their nodes.
const associationId = e.association_id
if (associationId !== null) {
e.association___NODE = associations.find(
obj => associationId === obj.wordpress_id
).id
}
delete e.association_id
return e
})
}
const mapEventsToVenues = entities => {
const venues = entities.filter(e => e.__type === 'wordpress__wp_venues')
@@ -87,6 +108,7 @@ const neufNormalizer = ({ entities }) => {
entities = decodeTitles(entities)
entities = mapEventsToEventTypes(entities)
entities = mapEventsToEventOrganizers(entities)
entities = mapEventOrganizersToAssociations(entities)
entities = mapEventsToVenues(entities)
return entities
}