import { formatLocationAddressPreview } from "@/domain/locations/mappers/location-mapper"; import type { Location } from "@/domain/locations/types/location"; type SiteAddress = Pick; /** Google Maps search link for a site address; opens in a new tab. */ export function buildSiteMapsUrl(location: SiteAddress): string { const query = formatLocationAddressPreview(location); return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`; } /** True once Street, City and State are all filled, so a map preview can render. */ export function hasCompleteSiteAddress(location: SiteAddress): boolean { return [location.address, location.city, location.state].every( (part) => (part?.trim() ?? "") !== "", ); } /** Key-less Google Maps embed URL for the read-only preview. */ export function buildSiteMapEmbedUrl(location: SiteAddress): string { const query = formatLocationAddressPreview(location); return `https://www.google.com/maps?q=${encodeURIComponent(query)}&output=embed`; }