Skip to content

Commit

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

import { getOnlineLocation } from '../utils'
import type { IEvent } from './types'
import type { IHost, Translations, WithUnsubscribeToken } from './utils'
import {
Expand Down Expand Up @@ -73,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.lng}`
const mapsLink = `https://maps.google.com/?q=${event.location.lat},${event.location.long}`

return (
<GeneralEmail
Expand Down Expand Up @@ -151,7 +152,11 @@ const EventEmail = ({
/>
</td>
<td style={{ verticalAlign: 'middle' }}>
<Text style={bodyStyle}>{event.location.value}</Text>
<Text style={bodyStyle}>
{event.location.onlineLink
? getOnlineLocation(event.location.onlineLink)
: event.location.address}
</Text>
</td>
</tr>
</tbody>
Expand Down
5 changes: 3 additions & 2 deletions src/email/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ export interface IEvent {
time: string
location: {
lat: number
lng: number
value: string
long: number
address: string
onlineLink?: string
}
ticketId: string
eventId: string
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './users'
export * from './staking'
export * from './utils/api'
export * from './common'
export * from './utils'
11 changes: 11 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function getDomain(hostname: string) {
const host = hostname.split('.')
host.reverse()
return `${host[1]}.${host[0]}`
}

export function getOnlineLocation(onlineLink: string) {
const subHost = new URL(onlineLink).hostname
const host = getDomain(subHost)
return { 'google.com': 'Google Meet', 'zoom.us': 'Zoom' }[host] ?? 'Online'
}

0 comments on commit 4b64c3a

Please sign in to comment.