import Container from "@/components/Container/Container";
import Section from "@/components/Section/Section";
import InfoBlock from "@/components/InfoBlock/InfoBlock";

const ThreeInfoBlocks = (props: any) => {
  const blocks = [];

  for (let i = 0; i < props.block; i++) {
    if (props[`block_${i}_statistic`]) {
      blocks.push({
        statistic: props[`block_${i}_statistic`],
        content: props[`block_${i}_content`],
        colour: props[`block_${i}_colour`] || null,
      });
    }
  }

  return (
    <Container id={props.anchor}>
      <Section
        gridArea="thin"
        className="flex justify-center flex-wrap lg:flex-nowrap -mx-xs"
      >
        {blocks.map((block, index) => (
          <div key={index} className="w-full lg:w-1/3 px-xs mb-xs lg:mb-none">
            <InfoBlock
              stat={block.statistic}
              content={block.content}
              colour={block.colour}
            />
          </div>
        ))}
      </Section>
    </Container>
  );
};

export default ThreeInfoBlocks;
