2022-06-07 14:49:39 +00:00
import type { TFunction } from "next-i18next" ;
2022-08-26 00:48:50 +00:00
import { guessEventLocationType } from "@calcom/app-store/locations" ;
2023-04-13 19:03:08 +00:00
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser" ;
2022-08-26 00:48:50 +00:00
import logger from "@calcom/lib/logger" ;
2022-06-06 17:49:56 +00:00
import type { CalendarEvent } from "@calcom/types/Calendar" ;
2023-03-12 17:39:46 +00:00
import { CallToActionIcon } from "./CallToActionIcon" ;
2022-06-06 17:49:56 +00:00
import { Info } from "./Info" ;
2022-06-07 14:49:39 +00:00
export function LocationInfo ( props : { calEvent : CalendarEvent ; t : TFunction } ) {
const { t } = props ;
2022-06-06 17:49:56 +00:00
2022-08-26 00:48:50 +00:00
// We would not be able to determine provider name for DefaultEventLocationTypes
const providerName = guessEventLocationType ( props . calEvent . location ) ? . label ;
logger . debug ( ` LocationInfo: ${ JSON . stringify ( props . calEvent ) } ${ providerName } ` ) ;
2022-06-06 17:49:56 +00:00
2022-08-26 00:48:50 +00:00
const location = props . calEvent . location ;
let meetingUrl = location ? . search ( /^https?:/ ) !== - 1 ? location : undefined ;
if ( props . calEvent ) {
2023-04-13 19:03:08 +00:00
meetingUrl = getVideoCallUrlFromCalEvent ( props . calEvent ) || meetingUrl ;
2022-08-26 00:48:50 +00:00
}
const isPhone = location ? . startsWith ( "+" ) ;
// Because of location being a value here, we can determine the app that generated the location only for Dynamic Link based apps where the value is integrations:*
// For static link based location apps, the value is that URL itself. So, it is not straightforward to determine the app that generated the location.
// If we know the App we can always provide the name of the app like we do it for Google Hangout/Google Meet
if ( meetingUrl ) {
2022-06-06 17:49:56 +00:00
return (
< Info
label = { t ( "where" ) }
withSpacer
description = {
2022-08-26 00:48:50 +00:00
< a
href = { meetingUrl }
target = "_blank"
title = { t ( "meeting_url" ) }
2023-01-17 21:14:16 +00:00
style = { { color : "#101010" } }
2022-08-26 00:48:50 +00:00
rel = "noreferrer" >
2023-03-12 17:39:46 +00:00
{ providerName || "Link" } < CallToActionIcon iconName = "linkIcon" / >
2022-08-26 00:48:50 +00:00
< / a >
2022-06-06 17:49:56 +00:00
}
extraInfo = {
2022-08-26 00:48:50 +00:00
meetingUrl && (
< div style = { { color : "#494949" , fontWeight : 400 , lineHeight : "24px" } } >
< >
{ t ( "meeting_url" ) } : { " " }
< a href = { meetingUrl } title = { t ( "meeting_url" ) } style = { { color : "#3E3E3E" } } >
{ meetingUrl }
< / a >
< / >
< / div >
)
2022-06-06 17:49:56 +00:00
}
/ >
) ;
}
2022-08-26 00:48:50 +00:00
if ( isPhone ) {
2022-06-06 17:49:56 +00:00
return (
< Info
label = { t ( "where" ) }
withSpacer
description = {
2022-08-26 00:48:50 +00:00
< a href = { "tel:" + location } title = "Phone" style = { { color : "#3E3E3E" } } >
{ location }
2022-06-17 18:34:41 +00:00
< / a >
2022-06-06 17:49:56 +00:00
}
/ >
) ;
}
2022-08-26 00:48:50 +00:00
2022-06-06 17:49:56 +00:00
return (
< Info
label = { t ( "where" ) }
withSpacer
2022-08-26 00:48:50 +00:00
description = { providerName || location }
2022-06-06 17:49:56 +00:00
extraInfo = {
2022-06-17 09:02:29 +00:00
( providerName === "Zoom" || providerName === "Google" ) && props . calEvent . requiresConfirmation ? (
2022-06-06 17:49:56 +00:00
< p style = { { color : "#494949" , fontWeight : 400 , lineHeight : "24px" } } >
< > { t ( "meeting_url_provided_after_confirmed" ) } < / >
< / p >
) : null
}
/ >
) ;
}