import { useQuery } from "@tanstack/react-query"; import { CalendarPlus, Check, ChevronDown, CornerDownRight, Send } from "lucide-react"; import { useId, useState } from "react"; import { Button } from "#/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "#/components/ui/dialog"; import { NativeSelect, NativeSelectOption } from "#/components/ui/native-select"; import { Textarea } from "#/components/ui/textarea"; import type { Conversation } from "./mock-conversations"; import { reviewReply } from "./server-functions"; export function ConversationDetail({ conversation, onResolve, }: { conversation: Conversation; onResolve: (result: "sent" | "waiting" | "later" | "dismissed", note?: string) => void; }) { const instanceId = useId(); const [draft, setDraft] = useState(conversation.drafts[0]?.text ?? ""); const [tone, setTone] = useState(conversation.drafts[0]?.label ?? ""); const [review, setReview] = useState<"send" | "schedule" | null>(null); const [slot, setSlot] = useState(""); const [scheduled, setScheduled] = useState(""); const evaluation = useQuery({ queryKey: ["reply-review", conversation.id, draft], queryFn: ({ signal }) => reviewReply({ data: { conversationId: conversation.id, draft }, signal }), enabled: review === "send" && !!draft.trim(), retry: false, staleTime: Infinity, gcTime: 0, }); return (
{conversation.messages.map((message) => (

{message.direction === "in" ? conversation.name.split(" ")[0] : "You"} {message.channel} · {message.time}

{message.text}
))}
To {conversation.name.split(" ")[0]}
Reply suggestions
{conversation.drafts.map((option) => ( ))}