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

export default function FrequencyTable({ frequencies }: { frequencies: Frequency[] }) {
  const rows = frequencies.map((frequency) => (
    <Table.Tr key={frequency.id}>
      <Table.Td>{frequency.id}</Table.Td>
      <Table.Td>{frequency.name}</Table.Td>
      <Table.Td>{frequency.frequency_mhz}</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.Tr>
      </Table.Thead>
      <Table.Tbody>{rows}</Table.Tbody>
    </Table>
  );
}