import Container from "@/components/Container/Container";
import Section from "@/components/Section/Section";
import Thumbnail from "@/components/Thumbnail/Thumbnail";
import { getCachedMedia } from "@/services/wp";
import Wsywig from "@/components/Wsywig/Wsywig";

const TwoColumnWithImage = async (props: { [rest: string]: any }) => {
  if (!props.image_desktop) return <></>;

  const media = await getCachedMedia(props.image_desktop);


  if (!media) return <></>;

  return (
    <Container id={props.anchor}>
      <Section gridArea="thin">
        <div className="grid grid-cols-1 md:grid-cols-2 gap-md">
          <Thumbnail
            width={600}
            height={600}
            imageUrl={media.source_url}
            alt={media.alt}
          />
          <div>
            <h4 className="h1">{props.title}</h4>
            {props.supporting_title && <h5>{props.supporting_title}</h5>}
            {props.content && <Wsywig content={props.content} />}
          </div>
        </div>
      </Section>
    </Container>
  );
};

export default TwoColumnWithImage;
