import { formatDateEST } from "@/lib/timezoneUtils";

export default function CallLogsSection({ data }: { data: any[] }) {
  return (
    <div className="space-y-4">
      <h2 className="text-xl font-bold text-foreground border-b pb-2">Call Logs</h2>
      <div className="space-y-3">
        {data.map((item) => (
          <div key={item.id} className="p-4 bg-muted/30 rounded-lg border">
            <div className="flex items-start justify-between">
              <div>
                <p className="font-semibold text-foreground">{item.caller_name}</p>
                <p className="text-xs text-muted-foreground mt-1">
                  {item.created_at ? formatDateEST(item.created_at) : "-"}
                  {item.call_type && ` · ${item.call_type}`}
                  {item.subject && ` · ${item.subject}`}
                </p>
              </div>
            </div>
            {item.notes && (
              <p className="text-sm text-muted-foreground mt-2 whitespace-pre-wrap">
                {item.notes?.replace(/<[^>]*>/g, "")}
              </p>
            )}
          </div>
        ))}
      </div>
    </div>
  );
}
