import { useState } from 'react' import { isIE } from 'react-device-detect' import Carousel from 'nuka-carousel' import CaseSlide from './case-study-slide' import Image from '@hashicorp/react-image' import InlineSvg from '@hashicorp/react-inline-svg' import ActiveControlDot from './img/active-control-dot.svg?include' import InactiveControlDot from './img/inactive-control-dot.svg?include' import LeftArrow from './img/left-arrow-control.svg?include' import RightArrow from './img/right-arrow-control.svg?include' export default function CaseStudyCarousel({ caseStudies, title, logoSection = { grayBackground: false, featuredLogos: [] }, }) { const [slideIndex, setSlideIndex] = useState(0) const { grayBackground, featuredLogos } = logoSection const caseStudySlides = caseStudies.map((caseStudy) => ( )) const logoRows = featuredLogos && Math.ceil(featuredLogos.length / 3) function renderControls() { return (
{caseStudies.map((caseStudy, stableIdx) => { return ( ) })}
) } function sideControls(icon, direction) { return ( ) } return (

{title}

{!isIE ? ( renderControls()} renderCenterLeftControls={({ previousSlide }) => { return sideControls(LeftArrow, previousSlide) }} renderCenterRightControls={({ nextSlide }) => { return sideControls(RightArrow, nextSlide) }} afterSlide={(slideIndex) => setSlideIndex(slideIndex)} > {caseStudySlides} ) : null}
{featuredLogos && featuredLogos.length > 0 && (
{featuredLogos.map((featuredLogo) => ( {featuredLogo.companyName} ))}
)}
) }