import { useDevice } from "../../core/stores/deviceStore.ts"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "../UI/Dialog.tsx"; import type { Protobuf, Types } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { useTranslation } from "react-i18next"; export interface LocationResponseDialogProps { location: Types.PacketMetadata | undefined; open: boolean; onOpenChange: () => void; } export const LocationResponseDialog = ({ location, open, onOpenChange, }: LocationResponseDialogProps) => { const { t } = useTranslation(); const { getNode } = useDevice(); const from = getNode(location?.from ?? 0); const longName = from?.user?.longName ?? (from ? `!${numberToHexUnpadded(from?.num)}` : t("common_unknown")); const shortName = from?.user?.shortName ?? (from ? `${numberToHexUnpadded(from?.num).substring(0, 4)}` : t("common_unknown")); return ( {t("dialog_locationResponse_titlePrefix")} {longName} ({shortName})

{t("dialog_locationResponse_label_coordinates")} {location?.data.latitudeI / 1e7},{" "} {location?.data.longitudeI / 1e7}

{t("dialog_locationResponse_label_altitude")} {location?.data.altitude} {t("dialog_locationResponse_unit_meter")}

); };