import React from 'react';
import { Text } from '@/ui/Text';
import { StatusDot } from '@/ui/StatusDot';
import { Table, TableHead, TableBody, TableRow, TableHeader, TableCell } from '@/ui/Table';

export interface ActivityItem {
  id: string;
  type: string;
  description: string;
  timestamp: string;
  status?: 'success' | 'warning' | 'critical' | 'info';
}

interface RecentActivityTableProps {
  items: ActivityItem[];
}

/**
 * RecentActivityTable
 * 
 * A high-density table for displaying recent events and telemetry logs.
 * Uses UI primitives to comply with architectural constraints.
 */
export function RecentActivityTable({ items }: RecentActivityTableProps) {
  const getStatusColor = (status?: string) => {
    switch (status) {
      case 'success': return 'var(--color-success)';
      case 'warning': return 'var(--color-warning)';
      case 'critical': return 'var(--color-critical)';
      default: return 'var(--color-primary)';
    }
  };

  return (
    <Table>
      <TableHead>
        <TableRow>
          <TableHeader>
            <Text size="xs" weight="medium" uppercase letterSpacing="wider" color="var(--color-text-low)">Type</Text>
          </TableHeader>
          <TableHeader>
            <Text size="xs" weight="medium" uppercase letterSpacing="wider" color="var(--color-text-low)">Description</Text>
          </TableHeader>
          <TableHeader>
            <Text size="xs" weight="medium" uppercase letterSpacing="wider" color="var(--color-text-low)">Time</Text>
          </TableHeader>
          <TableHeader>
            <Text size="xs" weight="medium" uppercase letterSpacing="wider" color="var(--color-text-low)">Status</Text>
          </TableHeader>
        </TableRow>
      </TableHead>
      <TableBody>
        {items.map((item) => (
          <TableRow key={item.id}>
            <TableCell>
              <Text font="mono" color="var(--color-telemetry)" size="xs">{item.type}</Text>
            </TableCell>
            <TableCell>
              <Text color="var(--color-text-med)" size="xs">{item.description}</Text>
            </TableCell>
            <TableCell>
              <Text color="var(--color-text-low)" size="xs">{item.timestamp}</Text>
            </TableCell>
            <TableCell>
              <StatusDot color={getStatusColor(item.status)} size={1.5} />
            </TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
