import type { AlertConfig, ChartConfig, SessionBoundary, SignalRow, UpsRow } from '@/lib/types';
import type { TimeMode } from '@/lib/types';
import UpsChart from './UpsChart';
import SignalsChart from './SignalsChart';
import TableViz from './TableViz';
import DividerCard from './DividerCard';

export interface ChartCardProps {
  config: ChartConfig;
  rows: SignalRow[];
  upsRows: UpsRow[];
  sessions: SessionBoundary[];
  alerts: AlertConfig[];
  timeMode: TimeMode;
  onEdit: () => void;
  onDelete: () => void;
}

export default function ChartCard(props: ChartCardProps) {
  const { config } = props;
  if (config.chart_type === 'divider')
    return <DividerCard title={config.title} onEdit={props.onEdit} onDelete={props.onDelete} />;
  if (config.chart_type === 'ups') return <UpsChart {...props} />;
  if (config.viz_type === 'table')
    return (
      <TableViz
        config={props.config}
        rows={props.rows}
        onEdit={props.onEdit}
        onDelete={props.onDelete}
      />
    );
  return <SignalsChart {...props} />;
}
