// Block `winter_objection` — réutilise le composant d'origine WinterObjectionSection
// (card sombre photo + texte traitant l'objection « et l'hiver ? »). Les champs WP
// non remplis retombent sur les défauts du composant (parité pixel préservée).

import WinterObjectionSection from "@/components/WinterObjectionSection";
import { mapImage } from "@/lib/wp/mappers";
import type { WpImageField } from "@/lib/wp/types";

export interface WinterObjectionBlock {
  __typename: string;
  origine?: string | null;
  titre?: string | null;
  intro?: string | null;
  paragraphe1?: string | null;
  paragraphe2?: string | null;
  image?: WpImageField | null;
}

const WinterObjection = (props: WinterObjectionBlock & { position?: number }) => {
  const image = mapImage(props.image);

  return (
    <WinterObjectionSection
      {...(props.titre ? { titre: props.titre } : {})}
      {...(props.intro ? { intro: props.intro } : {})}
      {...(props.paragraphe1 ? { paragraphe1: props.paragraphe1 } : {})}
      {...(props.paragraphe2 ? { paragraphe2: props.paragraphe2 } : {})}
      {...(image ? { imageSrc: image.sourceUrl } : {})}
      {...(image?.altText ? { imageAlt: image.altText } : {})}
    />
  );
};

export default WinterObjection;
