fix(SW-978): Small fixes
This commit is contained in:
@@ -5,6 +5,25 @@ import { getUrlWithSignature } from "@/utils/map"
|
||||
|
||||
import { StaticMapProps } from "@/types/components/maps/staticMap"
|
||||
|
||||
function getCenter({
|
||||
coordinates,
|
||||
city,
|
||||
country,
|
||||
}: {
|
||||
coordinates?: { lat: number; lng: number }
|
||||
city?: string
|
||||
country?: string
|
||||
}): string | undefined {
|
||||
switch (true) {
|
||||
case !!coordinates:
|
||||
return `${coordinates.lat},${coordinates.lng}`
|
||||
case !!country:
|
||||
return `${city}, ${country}`
|
||||
default:
|
||||
return city
|
||||
}
|
||||
}
|
||||
|
||||
export default function StaticMap({
|
||||
city,
|
||||
country,
|
||||
@@ -19,9 +38,7 @@ export default function StaticMap({
|
||||
const key = env.GOOGLE_STATIC_MAP_KEY
|
||||
const secret = env.GOOGLE_STATIC_MAP_SIGNATURE_SECRET
|
||||
const baseUrl = "https://maps.googleapis.com/maps/api/staticmap"
|
||||
const center = coordinates
|
||||
? `${coordinates.lat},${coordinates.lng}`
|
||||
: `${city}, ${country}`
|
||||
const center = getCenter({ coordinates, city, country })
|
||||
|
||||
if (!center) {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user