import { Table } from '@mantine/core';
import { Communication } from '@lib/airport.types.ts';

export function CommunicationTable({ communications }: { communications: Communication[] }) {
  const rows = communications.map((communication) => (
    <Table.Tr key={communication.id}>
      <Table.Td>{communication.id}</Table.Td>
      <Table.Td>{communication.name}</Table.Td>
      <Table.Td>{communication.frequencies_mhz}</Table.Td>
      <Table.Td>{communication.phone}</Table.Td>
    </Table.Tr>
  ));

  return (
    <Table>
      <Table.Thead>
        <Table.Tr>
          <Table.Th>ID</Table.Th>
          <Table.Th>Name</Table.Th>
          <Table.Th>MHz</Table.Th>
          <Table.Th>Phone</Table.Th>
        </Table.Tr>
      </Table.Thead>
      <Table.Tbody>{rows}</Table.Tbody>
    </Table>
  );
}
