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

const ThreeOptionsWithTitle = (props: any) => {
  const options = [];

  for (let i = 0; i < props.option; i++) {
    let o = {
      title: props[`option_${i}_title`],
      background: props[`option_${i}_background`] === "1",
      content: props[`option_${i}_content`],
    };

    options.push(o);
  }

  if (options.length < 1) return <></>;

  return (
    <Container id={props.anchor}>
      <Section gridArea="thin">
        <h3 className="h1">{props.title}</h3>
        <div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-xs xl:gap-x-sm">
          {options.map((option) => (
            <div
              key={option.title}
              className={`rounded-lg p-sm flex flex-col ${
                option.background ? "bg-yellow" : ""
              }`}
            >
              <h3 className="h1">{option.title}</h3>
              <Wsywig content={option.content} />
            </div>
          ))}
        </div>
      </Section>
    </Container>
  );
};

export default ThreeOptionsWithTitle;
