fix: apply feedback

This commit is contained in:
abdou6666 2025-02-07 10:12:29 +01:00
parent bc9e35977e
commit 2fde4e3439

View File

@ -8,14 +8,10 @@
import { useRef } from "react"; import { useRef } from "react";
import { StdIncomingLocationMessage } from "@/types/message.types";
export interface GeolocationMessageProps { export interface GeolocationMessageProps {
message: { message: StdIncomingLocationMessage;
type: "location";
coordinates: {
lat: number;
lon: number;
};
};
} }
const GeolocationMessage: React.FC<GeolocationMessageProps> = ({ message }) => { const GeolocationMessage: React.FC<GeolocationMessageProps> = ({ message }) => {
@ -25,15 +21,10 @@ const GeolocationMessage: React.FC<GeolocationMessageProps> = ({ message }) => {
throw new Error("Unable to find coordinates"); throw new Error("Unable to find coordinates");
} }
const coordinates = { const { lat, lon } = message?.coordinates || { lat: 0.0, lng: 0.0 };
lat: message?.coordinates?.lat || 0.0,
lng: message?.coordinates?.lon || 0.0,
};
const openStreetMapUrl = `https://www.openstreetmap.org/export/embed.html?bbox=${ const openStreetMapUrl = `https://www.openstreetmap.org/export/embed.html?bbox=${
coordinates.lng - 0.1 lon - 0.1
},${coordinates.lat - 0.1},${coordinates.lng + 0.1},${ },${lat - 0.1},${lon + 0.1},${lat + 0.1}&layer=mapnik&marker=${lat},${lon}`;
coordinates.lat + 0.1
}&layer=mapnik&marker=${coordinates.lat},${coordinates.lng}`;
return ( return (
<div <div