---
import HeroBlock from './HeroBlock.astro';
import StoryBlock from './StoryBlock.astro';
import ValuesBlock from './ValuesBlock.astro';
import FleetBlock from './FleetBlock.astro';
import CtaBlock from './CtaBlock.astro';
import SectionWrapper from './SectionWrapper.astro';
import type { AboutPageBlock } from '@/types/globalInterfaces';

interface Props {
    block: AboutPageBlock;
}

const { block } = Astro.props;

// Логика фонов для секций, чтобы сохранить дизайн
const getWrapperClass = (type: string) => {
    switch (type) {
        case 'story': return 'bg-gray-50 py-16 -mx-4'; // Серый фон
        case 'values': return 'bg-white py-16';        // Белый фон
        case 'fleet': return 'bg-gray-50 py-16';       // Серый фон
        default: return 'py-8';
    }
};
---

{block.blockType === 'hero' && (
<HeroBlock title={block.title} subtitle={block.subtitle} />
    )}

{block.blockType === 'cta' && (
<CtaBlock title={block.title} subtitle={block.subtitle} button={block.button} />
    )}

{/* Для Story, Values и Fleet используем обертку SectionWrapper */}
{['story', 'values', 'fleet'].includes(block.blockType) && (
<SectionWrapper className={getWrapperClass(block.blockType)}>
    {block.blockType === 'story' && (
            <StoryBlock
                    title={block.title}
                    content={block.content}
                    image={block.image}
            />
    )}

    {block.blockType === 'values' && (
            <ValuesBlock
                    title={block.title}
                    values={block.values}
            />
    )}

    {block.blockType === 'fleet' && (
            <FleetBlock
                    title={block.title}
                    vehicles={block.vehicles}
            />
    )}
</SectionWrapper>
    )}