Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
borispoehland committed Aug 26, 2024
1 parent c85ca75 commit 7cc1be3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions src/email/event-email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@react-email/components'
import { createTranslator } from 'use-intl'

import { getOnlineLocation } from '../utils'
import { getMapsLink, getOnlineLocation } from '../utils'
import type { IEvent } from './types'
import type { IHost, Translations, WithUnsubscribeToken } from './utils'
import {
Expand Down Expand Up @@ -74,7 +74,7 @@ const EventEmail = ({

const href = `${HOST}/event/${event.eventId}?guest=${event.ticketId}`

const mapsLink = `https://maps.google.com/?q=${event.location.lat},${event.location.long}`
const mapsLink = getMapsLink(event.location)

return (
<GeneralEmail
Expand Down Expand Up @@ -161,9 +161,11 @@ const EventEmail = ({
</tr>
</tbody>
</table>
<Link href={mapsLink} style={linkStyle}>
{t('maps')}
</Link>
{event.location.address && event.location.placeId && (
<Link href={mapsLink} style={linkStyle}>
{t('maps')}
</Link>
)}
</Center>
</Section>
<Section className="px-5 py-8 text-center">
Expand Down
9 changes: 2 additions & 7 deletions src/email/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NftActivityType } from '../types'
import { IEventDoc, NftActivityType } from '../types'

export const offerTradeTypes = [
NftActivityType.OFFER_TRADE,
Expand Down Expand Up @@ -92,12 +92,7 @@ export interface IEvent {
backgroundImage: string
ticketImage: string
time: string
location: {
lat: number
long: number
address: string
onlineLink?: string
}
location: IEventDoc['location']
ticketId: string
eventId: string
}
1 change: 1 addition & 0 deletions src/types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IEventDoc {
startTime: number
endTime: number
location: {
placeId?: string
address?: string
lat?: number
long?: number
Expand Down
6 changes: 6 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { IEventDoc } from './types'

export function getDomain(hostname: string) {
const host = hostname.split('.')
host.reverse()
Expand All @@ -9,3 +11,7 @@ export function getOnlineLocation(onlineLink: string) {
const host = getDomain(subHost)
return { 'google.com': 'Google Meet', 'zoom.us': 'Zoom' }[host] ?? 'Online'
}

export function getMapsLink(location: IEventDoc['location']) {
return `https://maps.google.com/?query=${location.address}&query_place_id=${location.placeId}`
}

0 comments on commit 7cc1be3

Please sign in to comment.