import type { DefaultEventLocationType, EventLocationTypeFromApp, LocationObject, } from "@calcom/app-store/locations"; import { getEventLocationType, getTranslatedLocation } from "@calcom/app-store/locations"; import { classNames } from "@calcom/lib"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Tooltip } from "@calcom/ui"; import { Link } from "@calcom/ui/components/icon"; const excludeNullValues = (value: unknown) => !!value; function RenderIcon({ eventLocationType, isTooltip, }: { eventLocationType: DefaultEventLocationType | EventLocationTypeFromApp; isTooltip: boolean; }) { return ( {`${eventLocationType.label} ); } function RenderLocationTooltip({ locations }: { locations: LocationObject[] }) { const { t } = useLocale(); return (

{t("select_on_next_step")}

{locations.map( ( location: Pick, "link" | "address"> & Omit, index: number ) => { const eventLocationType = getEventLocationType(location.type); if (!eventLocationType) { return null; } const translatedLocation = getTranslatedLocation(location, eventLocationType, t); return (

{translatedLocation}

); } )}
); } export function AvailableEventLocations({ locations }: { locations: LocationObject[] }) { const { t } = useLocale(); const renderLocations = locations.map( ( location: Pick, "link" | "address"> & Omit, index: number ) => { const eventLocationType = getEventLocationType(location.type); if (!eventLocationType) { // It's possible that the location app got uninstalled return null; } if (eventLocationType.variable === "hostDefault") { return null; } const translatedLocation = getTranslatedLocation(location, eventLocationType, t); return (
{eventLocationType.iconUrl === "/link.svg" ? ( ) : ( )}

{translatedLocation}

); } ); const filteredLocations = renderLocations.filter(excludeNullValues) as JSX.Element[]; return filteredLocations.length > 1 ? (
map-pin }>

{t("location_options", { locationCount: filteredLocations.length, })}

) : filteredLocations.length === 1 ? (
{filteredLocations}
) : null; }