import React, { useEffect, useRef, useState } from "react"; import VideoButton from "../buttons/VideoButton.jsx"; import Link from "next/link"; function Section({ videoUrl, videoUrlWeb, text, headingLevel = 1, buttonVideoURL, buttonOneText, buttonTwoText, buttonLink, posterPath, }) { const videoRef = useRef(null); const [isPlaying, setIsPlaying] = useState(false); useEffect(() => { const playPromise = videoRef.current?.play(); if (playPromise) { playPromise .then(() => { setIsPlaying(true); }) .catch((error) => { console.error("Play error:", error); }); } return () => { if (videoRef.current) { videoRef.current.pause(); } }; }, []); if (headingLevel <= 0 || headingLevel >= 7) { throw new Error("Invalid heading level"); } const Heading = `h${headingLevel}`; return (
{text}
{buttonTwoText}
); } export default Section;