import { Parish } from '@/payload-types' import { Container } from '@/components/Container/Container' import { HTMLText } from '@/components/Text/HTMLText' import { Section } from '@/components/Section/Section' import { Button } from '@/components/Button/Button' import { DonationForm } from '@/components/DonationForm/DonationForm' import { YoutubePlayer } from '@/components/YoutubePlayer/YoutubePlayer' import { DonationAppeal } from '@/components/DonationAppeal/DonationAppeal' import { ImageCardsBlock } from '@/compositions/Blocks/ImageCardsBlock' import { Title } from '@/components/Title/Title' import { Collapsible } from '@/components/Collapsible/Collapsible' import { NextPrevButtons } from '@/components/NextPrevButtons/NextPrevButtons' type BlocksProps = { content: Parish['content'] } export function ParishBlocks({ content }: BlocksProps) { if (!content) return null; // determine if some margin at the bottom should be added const length = content.length; const shouldAddMargin = content[length - 1].blockType === "text" return ( <>
{content.map(item => { if (item.blockType === "text") { return ( ); } if (item.blockType === "document" && typeof item.file === "object") { return (
) } if (item.blockType === "donation") { return
} if (item.blockType === "youtube") { return
} if (item.blockType === "imageCards") { return } if (item.blockType === "title") { return ( </Container> ) } if (item.blockType === "collapsibles") { return ( <Section key={item.id} padding={"small"}> <Container> {item.items.map(entry => ( <Collapsible key={entry.id} title={entry.title}> <HTMLText width={"3/4"} data={entry.content} /> </Collapsible> ))} </Container> </Section> ) } if (item.blockType === "donationAppeal") { return <Section key={item.id} padding={"small"}> <Container> <DonationAppeal /> </Container> </Section> } if (item.blockType === 'nextPrevButtons') { const prev = item.prev?.href && item.prev?.text ? { href: item.prev.href, text: item.prev.text } : undefined const next = item.next?.href && item.next?.text ? { href: item.next.href, text: item.next.text } : undefined return ( <Section key={item.id} padding={'medium'} paddingBottom={'small'}> <NextPrevButtons prev={prev} next={next} /> </Section> ) } })} </div> { shouldAddMargin && <Section></Section> } </> ) }