import React from "react"; import { Packet, PortNum, PortNumByName } from "../../lib/types"; import { TextMessagePacket } from "./TextMessagePacket"; import { PositionPacket } from "./PositionPacket"; import { NodeInfoPacket } from "./NodeInfoPacket"; import { TelemetryPacket } from "./TelemetryPacket"; import { ErrorPacket } from "./ErrorPacket"; import { WaypointPacket } from "./WaypointPacket"; import { MapReportPacket } from "./MapReportPacket"; import { TraceroutePacket } from "./TraceroutePacket"; import { GenericPacket } from "./GenericPacket"; interface PacketRendererProps { packet: Packet; } export const PacketRenderer: React.FC = ({ packet }) => { const { data } = packet; // If there's a decode error, show the error packet if (data.decodeError) { return ; } // Get the PortNum enum value const portNumValue = typeof data.portNum === 'string' ? PortNumByName[data.portNum] : data.portNum; // Determine which component to use based on portNum switch (portNumValue) { case PortNum.TEXT_MESSAGE_APP: return ; case PortNum.POSITION_APP: return ; case PortNum.NODEINFO_APP: return ; case PortNum.TELEMETRY_APP: return ; case PortNum.WAYPOINT_APP: return ; case PortNum.MAP_REPORT_APP: return ; case PortNum.TRACEROUTE_APP: return ; default: return ; } };