import type { LandingPageBlock } from './content';
import { CTA } from './cta';
import { FAQ } from './faq';
import { Features } from './features';
import { Hero } from './hero';
import { LogoCloud } from './logo-cloud';
import { Pricing } from './pricing';
import { Stats } from './stats';
import { TechStack } from './tech-stack';
import { Testimonials } from './testimonials';

interface LandingPageBuilderProps {
  blocks: LandingPageBlock[];
}

export const LandingPageBuilder = ({ blocks }: LandingPageBuilderProps) => {
  return blocks.map((block, index) => {
    const key = block.id ?? `${block.blockType}-${index}`;

    switch (block.blockType) {
      case 'hero': {
        return <Hero key={key} content={block} />;
      }
      case 'features': {
        return <Features key={key} content={block} />;
      }
      case 'techStack': {
        return <TechStack key={key} content={block} />;
      }
      case 'testimonials': {
        return <Testimonials key={key} content={block} />;
      }
      case 'logoCloud': {
        return <LogoCloud key={key} content={block} />;
      }
      case 'stats': {
        return <Stats key={key} content={block} />;
      }
      case 'pricing': {
        return <Pricing key={key} content={block} />;
      }
      case 'faq': {
        return <FAQ key={key} content={block} />;
      }
      case 'cta': {
        return <CTA key={key} content={block} />;
      }
      default: {
        return null;
      }
    }
  });
};
