Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
28 lines
970 B
TypeScript
28 lines
970 B
TypeScript
import type { MapCoordinates } from '@/lib/neshanNavigation'
|
|
|
|
function coordinatePair({ lat, lng }: MapCoordinates) {
|
|
return `${lat},${lng}`
|
|
}
|
|
|
|
/** Opens the event pin in Google Maps when the visitor's location is unavailable. */
|
|
export function getGoogleMapsPlaceUrl(destination: MapCoordinates) {
|
|
const url = new URL('https://www.google.com/maps/search/')
|
|
|
|
url.searchParams.set('api', '1')
|
|
url.searchParams.set('query', coordinatePair(destination))
|
|
|
|
return url.toString()
|
|
}
|
|
|
|
/** Opens driving directions in Google Maps from a known origin to an event destination. */
|
|
export function getGoogleMapsDirectionsUrl(origin: MapCoordinates, destination: MapCoordinates) {
|
|
const url = new URL('https://www.google.com/maps/dir/')
|
|
|
|
url.searchParams.set('api', '1')
|
|
url.searchParams.set('origin', coordinatePair(origin))
|
|
url.searchParams.set('destination', coordinatePair(destination))
|
|
url.searchParams.set('travelmode', 'driving')
|
|
|
|
return url.toString()
|
|
}
|