2023-03-07 22:37:56 +00:00
|
|
|
import { z } from "zod";
|
|
|
|
|
2022-08-26 00:48:50 +00:00
|
|
|
import { getEventLocationType, locationKeyToString } from "@calcom/app-store/locations";
|
2022-08-29 16:01:45 +00:00
|
|
|
import { classNames } from "@calcom/lib";
|
2023-01-04 15:31:50 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { Tooltip } from "@calcom/ui";
|
|
|
|
import { FiLink } from "@calcom/ui/components/icon";
|
2022-08-26 00:48:50 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { Props } from "./pages/AvailabilityPage";
|
2022-08-26 00:48:50 +00:00
|
|
|
|
|
|
|
export function AvailableEventLocations({ locations }: { locations: Props["eventType"]["locations"] }) {
|
2023-01-04 15:31:50 +00:00
|
|
|
const { t } = useLocale();
|
|
|
|
|
2022-08-29 16:01:45 +00:00
|
|
|
return locations.length ? (
|
2023-02-08 12:14:52 +00:00
|
|
|
<div className="dark:text-darkgray-600 mr-6 flex w-full flex-col space-y-4 break-words text-sm text-gray-600">
|
2023-02-03 10:20:45 +00:00
|
|
|
{locations.map((location, index) => {
|
2022-10-18 23:31:41 +00:00
|
|
|
const eventLocationType = getEventLocationType(location.type);
|
|
|
|
if (!eventLocationType) {
|
|
|
|
// It's possible that the location app got uninstalled
|
|
|
|
return null;
|
|
|
|
}
|
2023-03-07 22:37:56 +00:00
|
|
|
|
|
|
|
const translateAbleKeys = [
|
|
|
|
"attendee_in_person",
|
|
|
|
"in_person",
|
|
|
|
"attendee_phone_number",
|
|
|
|
"link_meeting",
|
|
|
|
"organizer_phone_number",
|
|
|
|
];
|
|
|
|
|
|
|
|
const locationKey = z.string().default("").parse(locationKeyToString(location));
|
|
|
|
|
|
|
|
const translatedLocation = location.type.startsWith("integrations:")
|
|
|
|
? eventLocationType.label
|
|
|
|
: translateAbleKeys.includes(locationKey)
|
|
|
|
? t(locationKey)
|
|
|
|
: locationKey;
|
|
|
|
|
2022-10-18 23:31:41 +00:00
|
|
|
return (
|
2023-02-03 10:20:45 +00:00
|
|
|
<div key={`${location.type}-${index}`} className="flex flex-row items-center text-sm font-medium">
|
2022-11-22 12:04:06 +00:00
|
|
|
{eventLocationType.iconUrl === "/link.svg" ? (
|
2023-03-08 21:59:15 +00:00
|
|
|
<FiLink className="dark:text-darkgray-600 min-h-4 min-w-4 ml-[2px] opacity-70 ltr:mr-[10px] rtl:ml-[10px] dark:opacity-100 " />
|
2022-11-22 12:04:06 +00:00
|
|
|
) : (
|
|
|
|
<img
|
|
|
|
src={eventLocationType.iconUrl}
|
|
|
|
className={classNames(
|
2023-01-04 07:38:45 +00:00
|
|
|
"ml-[2px] h-4 w-4 opacity-70 ltr:mr-[10px] rtl:ml-[10px] dark:opacity-100 ",
|
2023-02-08 12:14:52 +00:00
|
|
|
!eventLocationType.iconUrl?.includes("api") ? "dark:invert-[.65]" : ""
|
2022-11-22 12:04:06 +00:00
|
|
|
)}
|
|
|
|
alt={`${eventLocationType.label} icon`}
|
|
|
|
/>
|
|
|
|
)}
|
2023-03-07 22:37:56 +00:00
|
|
|
<Tooltip content={translatedLocation}>
|
|
|
|
<p className="line-clamp-1">{translatedLocation}</p>
|
2022-10-19 18:00:48 +00:00
|
|
|
</Tooltip>
|
2022-10-18 23:31:41 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
2022-08-26 00:48:50 +00:00
|
|
|
</div>
|
2023-03-07 22:37:56 +00:00
|
|
|
) : null;
|
2022-08-26 00:48:50 +00:00
|
|
|
}
|