import { useEffect, useState } from "react"; import { cn } from "../lib/utils"; import { conversationService } from "../api/conversationService"; type QuestionBubbleProps = { text: string; image_key?: string | null; }; export const QuestionBubble = ({ text, image_key }: QuestionBubbleProps) => { const [imageUrl, setImageUrl] = useState(null); const [imageError, setImageError] = useState(false); useEffect(() => { if (!image_key) return; conversationService .getPresignedImageUrl(image_key) .then(setImageUrl) .catch((err) => { console.error("Failed to load image:", err); setImageError(true); }); }, [image_key]); return (
{imageError && (
🖼️ Image failed to load
)} {imageUrl && ( Uploaded image )} {text}
); };