"use client"; import React, { useEffect, useState } from "react"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { format } from "date-fns"; interface ChatHistoryEntry { session_id: string; human: string; ai: string; timestamp: string; } export default function Page() { const [chatHistory, setChatHistory] = useState([]); useEffect(() => { const fetchData = async () => { try { const response = await fetch("/api/v1/admin/chat_history"); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); setChatHistory(data); } catch (error) { console.error("Fetching error: ", error); } }; fetchData(); }, []); return (