import React from "react"; import { Box, Paper, Typography, Button, IconButton, Skeleton, Tooltip } from "@mui/material"; import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline"; import VisibilityIcon from "@mui/icons-material/Visibility"; import CachedIcon from "@mui/icons-material/Cached"; import { ListCellRenderer } from "../../react-openapi"; import type { ReportFieldConfigs } from "./types"; interface ReportListProps { reports: any[]; loading: boolean; fields: ReportFieldConfigs | null; selectedId: string | null; onView: (id: string) => void; onRegenerate: (report: any) => void; onDelete: (id: string) => void; } export function ReportList({ reports, loading, fields, selectedId, onView, onRegenerate, onDelete }: ReportListProps) { if (loading && reports.length === 0) { return ( {[0, 1, 2].map((i) => ( ))} ); } return ( {reports.map((report) => { const q = report.query ?? {}; const range = q.start_date || q.end_date ? `range ${q.start_date || "…"} → ${q.end_date || "…"}` : null; const dims = Array.isArray(q.group_dims) ? q.group_dims.join(", ") : ""; const granularities = Array.isArray(q.granularities) ? q.granularities.join(", ") : ""; const accounts = Array.isArray(q.accounts) ? `${q.accounts.length} account${q.accounts.length === 1 ? "" : "s"}` : "all accounts"; const amounts = q.min_amount != null || q.max_amount != null ? `amount ${q.min_amount ?? "0"} → ${q.max_amount ?? "∞"}` : null; return ( {report.name || report.id} {granularities} / {dims} {range && ( {range} )} {accounts} {amounts && ( {amounts} )} {fields && ( )} onDelete(report.id)}> ); })} ); }