'use client';

import { ActionItem } from '@/lib/page-queries/ActionsPageQuery';
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/ui/Table';
import { Text } from '@/ui/Text';
import { ActionStatusBadge } from './ActionStatusBadge';

interface ActionListProps {
  actions: ActionItem[];
}

export function ActionList({ actions }: ActionListProps) {
  return (
    <Table>
      <TableHead>
        <TableRow>
          <TableHeader>Timestamp</TableHeader>
          <TableHeader>Type</TableHeader>
          <TableHeader>Initiator</TableHeader>
          <TableHeader>Status</TableHeader>
          <TableHeader>Details</TableHeader>
        </TableRow>
      </TableHead>
      <TableBody>
        {actions.map((action) => (
          <TableRow 
            key={action.id} 
            clickable
          >
            <TableCell>
              <Text font="mono" size="xs" variant="low">{action.timestamp}</Text>
            </TableCell>
            <TableCell>
              <Text size="xs" weight="medium" variant="med">{action.type}</Text>
            </TableCell>
            <TableCell>
              <Text size="xs" variant="low">{action.initiator}</Text>
            </TableCell>
            <TableCell>
              <ActionStatusBadge status={action.status} />
            </TableCell>
            <TableCell>
              <Text size="xs" variant="low">
                {action.details}
              </Text>
            </TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
