import { useDevice } from "@core/stores/deviceStore.ts"; import type { Protobuf } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { useTranslation } from "react-i18next"; export interface TraceRouteProps { from?: Protobuf.Mesh.NodeInfo; to?: Protobuf.Mesh.NodeInfo; route: Array; routeBack?: Array; snrTowards?: Array; snrBack?: Array; } interface RoutePathProps { title: string; startNode?: Protobuf.Mesh.NodeInfo; endNode?: Protobuf.Mesh.NodeInfo; path: number[]; snr?: number[]; } const RoutePath = ( { title, startNode, endNode, path, snr }: RoutePathProps, ) => { const { getNode } = useDevice(); const { t } = useTranslation(); return (

{title}

{startNode?.user?.longName}

↓ {snr?.[0] ?? t("traceRoute_snrUnknown")} {t("common.dbUnit")}

{path.map((hop, i) => (

{getNode(hop)?.user?.longName ?? `${t("traceRoute_nodeUnknownPrefix")}${numberToHexUnpadded(hop)}`}

↓ {snr?.[i + 1] ?? t("traceRoute_snrUnknown")} {t("common.dbUnit")}

))}

{endNode?.user?.longName}

); }; export const TraceRoute = ({ from, to, route, routeBack, snrTowards, snrBack, }: TraceRouteProps) => { const { t } = useTranslation(); return (
{routeBack && routeBack.length > 0 && ( )}
); };