"use client"; import { Button } from "@/components/ui/button"; import { voiceSampleUrl } from "@/lib/data"; import { ArrowRight, PauseIcon, PlayIcon } from "lucide-react"; import Image from "next/image"; import { useState } from "react"; interface ToyPickerProps { imageSize: number; buttonText: string; showHelpText: boolean; } interface IDoctorPersonality { key: string; name: string; } const getDoctorImageSrc = (key: string) => { return "/personality/" + key + ".jpeg"; }; const DoctorPersonalities: IDoctorPersonality[] = [ { key: "aggie_blood_test_pal", name: "Aggie Blood Test Pal", }, { key: "santa_claus", name: "Santa Claus", }, { key: "luna_epilepsy_pal", name: "Luna Epilepsy Pal", }, ]; const ToyPicker: React.FC = ({ imageSize, buttonText }) => { const [selectedPersonality, setSelectedPersonality] = useState(DoctorPersonalities[0]); const [playing, setPlaying] = useState(null); const [audioElement, setAudioElement] = useState( null ); const playAudio = (personality: IDoctorPersonality) => { 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); }; const onClickSelectedPersonality = (personality: IDoctorPersonality) => { setSelectedPersonality(personality); }; return (
{DoctorPersonalities.map((personality) => { const chosen = selectedPersonality?.key === personality.key; return (
onClickSelectedPersonality(personality) } > {personality.name}
{personality.name}
{chosen && ( <> )}
); })}
{/* {showHelpText && (

(pick your favorite AI character to get started!)

)} */}
); }; export default ToyPicker;