diff --git a/src/compositions/Blocks/EventsBlock.tsx b/src/compositions/Blocks/EventsBlock.tsx index db757dc..1b3a629 100644 --- a/src/compositions/Blocks/EventsBlock.tsx +++ b/src/compositions/Blocks/EventsBlock.tsx @@ -1,8 +1,13 @@ +import { Highlight } from '@/payload-types' import { fetchEvents } from '@/fetch/events' +import { fetchHighlights } from '@/fetch/highlights' import { transformEvents } from '@/utils/dto/events' +import { highlightLink } from '@/utils/dto/highlight' import { Section } from '@/components/Section/Section' import { Title } from '@/components/Title/Title' +import { EventRow } from '@/components/EventRow/EventRow' import { Events } from '@/compositions/Events/Events' +import { ContentWithSlider } from '@/compositions/ContentWithSlider/ContentWithSlider' type EventsBlockProps = { title?: string | null @@ -14,18 +19,45 @@ export async function EventsBlock({ itemsPerPage = 6, }: EventsBlockProps) { 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 ( -
- - <Events - events={transformEvents(docs)} - n={itemsPerPage || 6} - schema={'contrast'} - /> - </Section> + <ContentWithSlider slider={<HighlightsSlider highlights={highlightDocs} />}> + <Section> + <Title color={'contrast'} title={title || 'Veranstaltungen'} /> + <Events + events={transformEvents(eventDocs)} + n={itemsPerPage || 6} + schema={'contrast'} + /> + </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} + /> + ))} + </> +)