"use client"; import Image from "next/image"; import { Button } from "@/components/ui/button"; import { Pause, Play } from "lucide-react"; import { Card, CardContent } from "@/components/ui/card"; import { getPersonalityImageSrc } from "@/lib/utils"; import { useEffect, useRef, useState } from "react"; import { voiceSampleUrl } from "@/lib/data"; interface LandingPagePersonality { key: string; name: string; description: string; } const ChosenPersonalities: LandingPagePersonality[] = [ { key: "geo_guide", name: "Travel guide", description: "A travel guide who can help you plan your next trip.", }, { key: "ironman", name: "Ironman", description: "A superhero who can help you with your problems.", }, { key: "math_wiz", name: "Your math tutor", description: "A math tutor who can help you with your math problems.", }, { key: "master_chef", name: "Master chef", description: "A master chef who can help you with your cooking.", }, { key: "art_guru", name: "Art teacher", description: "An art guru who can help you with your art.", }, { key: "female_lover", name: "Romance healer", description: "A muse of connection who can help you with your love life.", }, { key: "male_lover", name: "Poet of love", description: "A poet of love who can help you with your love life.", }, { key: "sherlock", name: "SherlockGPT", description: "A detective who can help you with your problems.", }, { key: "aggie_blood_test_pal", name: "Medical buddy", description: "A medical companion helping kids feel less anxious during procedures.", }, ]; interface CharacterCarouselCardProps { personality: LandingPagePersonality; } const CharacterCarouselCard = ({ personality }: CharacterCarouselCardProps) => { const [playing, setPlaying] = useState(null); const [audioElement, setAudioElement] = useState( null ); const playAudio = (personality: LandingPagePersonality) => { if (playing === personality.key && audioElement) { // Pause current audio audioElement.pause(); setPlaying(null); setAudioElement(null); return; } // Stop any currently playing audio if (audioElement) { audioElement.pause(); } const audio = new Audio(`${voiceSampleUrl}${personality.key}.wav`); audio.onended = () => { setPlaying(null); setAudioElement(null); }; audio.play(); setPlaying(personality.key); setAudioElement(audio); }; return ( {/* Circular Avatar */}
{personality.key}
{/* Text and Play Button */}

{personality.name}

{personality.description}

); }; const CharacterCarousel = () => { const scrollRef = useRef(null); const [showLeftShadow, setShowLeftShadow] = useState(false); const [showRightShadow, setShowRightShadow] = useState(true); const handleScroll = () => { if (scrollRef.current) { const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current; setShowLeftShadow(scrollLeft > 0); setShowRightShadow(scrollLeft < scrollWidth - clientWidth - 1); } }; useEffect(() => { const scrollElement = scrollRef.current; if (scrollElement) { scrollElement.addEventListener("scroll", handleScroll); handleScroll(); // Initial check return () => scrollElement.removeEventListener("scroll", handleScroll); } }, []); return (
{ChosenPersonalities.map((personality, index) => ( ))}
//
//
//
// {ChosenPersonalities.map((personality, index) => ( // // ))} //
//
//
); }; export default CharacterCarousel;