import { ArrowLeft } from "lucide-react"; import { useCallback, useEffect, useState } from "react"; import { getHandoffConversation } from "../api"; function HandoffMessageBody({ message }) { const [showQuoted, setShowQuoted] = useState(false); const displayText = message.new_reply_content || message.body_text || message.snippet; return ( <>
{displayText}
{message.has_quoted_text && message.raw_body && ( )} {showQuoted && message.raw_body && (
{message.raw_body}
)} ); } function formatTime(dateValue) { if (!dateValue) return ""; return new Date(dateValue).toLocaleString(undefined, { hour: "numeric", minute: "2-digit", }); } export default function HandoffConversation({ handoffId, onBack }) { const token = sessionStorage.getItem("agmail_access_token"); const [conversation, setConversation] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(""); const load = useCallback(async () => { setLoading(true); setError(""); try { const data = await getHandoffConversation(handoffId, token); setConversation(data); } catch (err) { setError(err.message); } finally { setLoading(false); } }, [handoffId, token]); useEffect(() => { load(); }, [load]); if (loading) { return

Loading conversation…

; } if (error) { return

{error}

; } if (!conversation) return null; return (

{conversation.external_subject || "(No subject)"}

Linked conversation: {conversation.linked_external.sender} “{conversation.linked_external.subject}”
{conversation.messages.map((message) => (
{message.role === "human" ? "HUMAN OWNER" : "AGENT"}
))}
); }