feature: events
This commit is contained in:
parent
a49daabac7
commit
46882e175d
1 changed files with 42 additions and 10 deletions
|
|
@ -1,8 +1,13 @@
|
||||||
|
import { Highlight } from '@/payload-types'
|
||||||
import { fetchEvents } from '@/fetch/events'
|
import { fetchEvents } from '@/fetch/events'
|
||||||
|
import { fetchHighlights } from '@/fetch/highlights'
|
||||||
import { transformEvents } from '@/utils/dto/events'
|
import { transformEvents } from '@/utils/dto/events'
|
||||||
|
import { highlightLink } from '@/utils/dto/highlight'
|
||||||
import { Section } from '@/components/Section/Section'
|
import { Section } from '@/components/Section/Section'
|
||||||
import { Title } from '@/components/Title/Title'
|
import { Title } from '@/components/Title/Title'
|
||||||
|
import { EventRow } from '@/components/EventRow/EventRow'
|
||||||
import { Events } from '@/compositions/Events/Events'
|
import { Events } from '@/compositions/Events/Events'
|
||||||
|
import { ContentWithSlider } from '@/compositions/ContentWithSlider/ContentWithSlider'
|
||||||
|
|
||||||
type EventsBlockProps = {
|
type EventsBlockProps = {
|
||||||
title?: string | null
|
title?: string | null
|
||||||
|
|
@ -14,18 +19,45 @@ export async function EventsBlock({
|
||||||
itemsPerPage = 6,
|
itemsPerPage = 6,
|
||||||
}: EventsBlockProps) {
|
}: EventsBlockProps) {
|
||||||
const events = await fetchEvents()
|
const events = await fetchEvents()
|
||||||
const docs = events?.docs || []
|
const eventDocs = events?.docs || []
|
||||||
|
|
||||||
if (docs.length === 0) return null
|
if (eventDocs.length === 0) return null
|
||||||
|
|
||||||
|
const highlights = await fetchHighlights()
|
||||||
|
const highlightDocs = highlights?.docs || []
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Section>
|
<ContentWithSlider slider={<HighlightsSlider highlights={highlightDocs} />}>
|
||||||
<Title color={'contrast'} title={title || 'Veranstaltungen'} />
|
<Section>
|
||||||
<Events
|
<Title color={'contrast'} title={title || 'Veranstaltungen'} />
|
||||||
events={transformEvents(docs)}
|
<Events
|
||||||
n={itemsPerPage || 6}
|
events={transformEvents(eventDocs)}
|
||||||
schema={'contrast'}
|
n={itemsPerPage || 6}
|
||||||
/>
|
schema={'contrast'}
|
||||||
</Section>
|
/>
|
||||||
|
</Section>
|
||||||
|
</ContentWithSlider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const HighlightsSlider = ({ highlights }: { highlights: Highlight[] }) => (
|
||||||
|
<>
|
||||||
|
<Title
|
||||||
|
title={'Aktuelle Highlights'}
|
||||||
|
size={'md'}
|
||||||
|
fontStyle={'sans-serif'}
|
||||||
|
color={'white'}
|
||||||
|
/>
|
||||||
|
{highlights.map((highlight) => (
|
||||||
|
<EventRow
|
||||||
|
color={'white'}
|
||||||
|
key={highlight.id}
|
||||||
|
date={highlight.date}
|
||||||
|
showDate={false}
|
||||||
|
title={highlight.text}
|
||||||
|
href={highlightLink(highlight)}
|
||||||
|
cancelled={false}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue