"use client"; import Link from "next/link"; import Image from "next/image"; import { useQuery } from "@tanstack/react-query"; import { Copy, Play, Twitter } from "lucide-react"; import PostgrestError from "@/lib/config"; import { createClient } from "@/utils/supabase/client"; import { Tables } from "@/utils/supabase/database.types"; import { toast } from "sonner"; import { Separator } from "@/components/ui/separator"; import { Button, buttonVariants } from "@/components/ui/button"; import Spinner from "@/components/spinner"; type ResponseAgentCardProps = { agentResponseId: string; }; export default function ResponseAgentCard({ agentResponseId, }: ResponseAgentCardProps) { const { data: responseData, isLoading, error, } = useQuery({ retry: 0, queryKey: ["agent-responses", agentResponseId], queryFn: async ({ signal }) => { const supabase = createClient(); const response = await supabase .from("agent_responses") .select( ` *, agents ( agent_id:id, name, image_url ) ` ) .eq("id", agentResponseId) .limit(1) .single(); if (response.error) throw new PostgrestError(response.error); return response; }, }); if (error) return

{error.message}

; if (isLoading || !responseData || !responseData.data) return ; return ; } const CardContent = ({ agentResponse, }: { agentResponse: Tables<"agent_responses"> & { agents: { agent_id: number; name: string; image_url: string; }; }; }) => { const { id, agent_id, question, response, agents } = agentResponse; return ( <>
test

{agents.name}

{id}

Question:

{question}

Response:

{response}

Share on Twitter Ask Another
); };