| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | // Get router variables
 | 
					
						
							| 
									
										
										
										
											2022-03-07 15:48:51 +00:00
										 |  |  | import { | 
					
						
							|  |  |  |   ArrowLeftIcon, | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |   CalendarIcon, | 
					
						
							| 
									
										
										
										
											2022-03-07 15:48:51 +00:00
										 |  |  |   ChevronDownIcon, | 
					
						
							|  |  |  |   ChevronUpIcon, | 
					
						
							|  |  |  |   ClockIcon, | 
					
						
							|  |  |  |   CreditCardIcon, | 
					
						
							|  |  |  |   GlobeIcon, | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |   InformationCircleIcon, | 
					
						
							| 
									
										
										
										
											2022-03-07 15:48:51 +00:00
										 |  |  | } from "@heroicons/react/solid"; | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import * as Collapsible from "@radix-ui/react-collapsible"; | 
					
						
							| 
									
										
										
										
											2022-02-03 23:23:20 +00:00
										 |  |  | import { useContracts } from "contexts/contractsContext"; | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | import dayjs, { Dayjs } from "dayjs"; | 
					
						
							|  |  |  | import customParseFormat from "dayjs/plugin/customParseFormat"; | 
					
						
							|  |  |  | import utc from "dayjs/plugin/utc"; | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import { useRouter } from "next/router"; | 
					
						
							| 
									
										
										
										
											2021-09-23 14:08:44 +00:00
										 |  |  | import { useEffect, useMemo, useState } from "react"; | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import { FormattedNumber, IntlProvider } from "react-intl"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 02:47:34 +00:00
										 |  |  | import { useEmbedStyles, useIsEmbed, useIsBackgroundTransparent, sdkActionManager } from "@calcom/embed-core"; | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  | import classNames from "@calcom/lib/classNames"; | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  | import { useLocale } from "@calcom/lib/hooks/useLocale"; | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import { asStringOrNull } from "@lib/asStringOrNull"; | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | import { timeZone } from "@lib/clock"; | 
					
						
							| 
									
										
										
										
											2022-03-07 15:48:51 +00:00
										 |  |  | import { BASE_URL } from "@lib/config/constants"; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:44:04 +00:00
										 |  |  | import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally"; | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import useTheme from "@lib/hooks/useTheme"; | 
					
						
							|  |  |  | import { isBrandingHidden } from "@lib/isBrandingHidden"; | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  | import { parseDate } from "@lib/parseDate"; | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; | 
					
						
							| 
									
										
										
										
											2022-02-23 12:37:15 +00:00
										 |  |  | import { detectBrowserTimeFormat } from "@lib/timeFormat"; | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-16 08:51:46 +00:00
										 |  |  | import CustomBranding from "@components/CustomBranding"; | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | import AvailableTimes from "@components/booking/AvailableTimes"; | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import DatePicker from "@components/booking/DatePicker"; | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | import TimeOptions from "@components/booking/TimeOptions"; | 
					
						
							|  |  |  | import { HeadSeo } from "@components/seo/head-seo"; | 
					
						
							|  |  |  | import AvatarGroup from "@components/ui/AvatarGroup"; | 
					
						
							| 
									
										
										
										
											2021-09-26 14:04:01 +00:00
										 |  |  | import PoweredByCal from "@components/ui/PoweredByCal"; | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-23 14:08:44 +00:00
										 |  |  | import { AvailabilityPageProps } from "../../../pages/[user]/[type]"; | 
					
						
							| 
									
										
										
										
											2021-09-29 21:33:18 +00:00
										 |  |  | import { AvailabilityTeamPageProps } from "../../../pages/team/[slug]/[type]"; | 
					
						
							| 
									
										
										
										
											2021-09-23 14:08:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | dayjs.extend(utc); | 
					
						
							|  |  |  | dayjs.extend(customParseFormat); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-29 21:33:18 +00:00
										 |  |  | type Props = AvailabilityTeamPageProps | AvailabilityPageProps; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  | const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPage, booking }: Props) => { | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |   const router = useRouter(); | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  |   const isEmbed = useIsEmbed(); | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |   const { rescheduleUid } = router.query; | 
					
						
							| 
									
										
										
										
											2022-02-10 11:07:14 +00:00
										 |  |  |   const { isReady, Theme } = useTheme(profile.theme); | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |   const { t, i18n } = useLocale(); | 
					
						
							| 
									
										
										
										
											2022-02-03 23:23:20 +00:00
										 |  |  |   const { contracts } = useContracts(); | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  |   const availabilityDatePickerEmbedStyles = useEmbedStyles("availabilityDatePicker"); | 
					
						
							|  |  |  |   let isBackgroundTransparent = useIsBackgroundTransparent(); | 
					
						
							| 
									
										
										
										
											2022-04-04 15:44:04 +00:00
										 |  |  |   useExposePlanGlobally(plan); | 
					
						
							| 
									
										
										
										
											2022-02-03 23:23:20 +00:00
										 |  |  |   useEffect(() => { | 
					
						
							|  |  |  |     if (eventType.metadata.smartContractAddress) { | 
					
						
							|  |  |  |       const eventOwner = eventType.users[0]; | 
					
						
							|  |  |  |       if (!contracts[(eventType.metadata.smartContractAddress || null) as number]) | 
					
						
							|  |  |  |         router.replace(`/${eventOwner.username}`); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, [contracts, eventType.metadata.smartContractAddress, router]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |   const selectedDate = useMemo(() => { | 
					
						
							|  |  |  |     const dateString = asStringOrNull(router.query.date); | 
					
						
							|  |  |  |     if (dateString) { | 
					
						
							| 
									
										
										
										
											2022-03-28 18:50:31 +00:00
										 |  |  |       const offsetString = dateString.substr(11, 14); // hhmm
 | 
					
						
							|  |  |  |       const offsetSign = dateString.substr(10, 1); // + or -
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const offsetHour = offsetString.slice(0, -2); | 
					
						
							|  |  |  |       const offsetMinute = offsetString.slice(-2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const utcOffsetInMinutes = | 
					
						
							|  |  |  |         (offsetSign === "-" ? -1 : 1) * | 
					
						
							|  |  |  |         (60 * (offsetHour !== "" ? parseInt(offsetHour) : 0) + | 
					
						
							|  |  |  |           (offsetMinute !== "" ? parseInt(offsetMinute) : 0)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const date = dayjs(dateString.substr(0, 10)).utcOffset(utcOffsetInMinutes, true); | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |       return date.isValid() ? date : null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return null; | 
					
						
							|  |  |  |   }, [router.query.date]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 02:47:34 +00:00
										 |  |  |   if (selectedDate) { | 
					
						
							|  |  |  |     // Let iframe take the width available due to increase in max-width
 | 
					
						
							|  |  |  |     sdkActionManager?.fire("__refreshWidth", {}); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |   const [isTimeOptionsOpen, setIsTimeOptionsOpen] = useState(false); | 
					
						
							| 
									
										
										
										
											2022-02-23 12:37:15 +00:00
										 |  |  |   const [timeFormat, setTimeFormat] = useState(detectBrowserTimeFormat); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |   const telemetry = useTelemetry(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   useEffect(() => { | 
					
						
							|  |  |  |     handleToggle24hClock(localStorage.getItem("timeOption.is24hClock") === "true"); | 
					
						
							| 
									
										
										
										
											2022-02-23 12:37:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 02:47:34 +00:00
										 |  |  |     telemetry.withJitsu((jitsu) => | 
					
						
							|  |  |  |       jitsu.track( | 
					
						
							|  |  |  |         telemetryEventTypes.pageView, | 
					
						
							|  |  |  |         collectPageParameters("availability", { isTeamBooking: document.URL.includes("team/") }) | 
					
						
							|  |  |  |       ) | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |   }, [telemetry]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const changeDate = (newDate: Dayjs) => { | 
					
						
							|  |  |  |     router.replace( | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         query: { | 
					
						
							|  |  |  |           ...router.query, | 
					
						
							|  |  |  |           date: newDate.format("YYYY-MM-DDZZ"), | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       undefined, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         shallow: true, | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const handleSelectTimeZone = (selectedTimeZone: string): void => { | 
					
						
							|  |  |  |     if (selectedDate) { | 
					
						
							|  |  |  |       changeDate(selectedDate.tz(selectedTimeZone, true)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     timeZone(selectedTimeZone); | 
					
						
							|  |  |  |     setIsTimeOptionsOpen(false); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const handleToggle24hClock = (is24hClock: boolean) => { | 
					
						
							|  |  |  |     setTimeFormat(is24hClock ? "HH:mm" : "h:mma"); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2021-09-24 22:11:30 +00:00
										 |  |  |     <> | 
					
						
							| 
									
										
										
										
											2022-02-10 11:07:14 +00:00
										 |  |  |       <Theme /> | 
					
						
							| 
									
										
										
										
											2021-09-24 22:11:30 +00:00
										 |  |  |       <HeadSeo | 
					
						
							| 
									
										
										
										
											2021-10-08 11:43:48 +00:00
										 |  |  |         title={`${rescheduleUid ? t("reschedule") : ""} ${eventType.title} | ${profile.name}`} | 
					
						
							|  |  |  |         description={`${rescheduleUid ? t("reschedule") : ""} ${eventType.title}`} | 
					
						
							| 
									
										
										
										
											2021-11-18 01:03:19 +00:00
										 |  |  |         name={profile.name || undefined} | 
					
						
							| 
									
										
										
										
											2022-01-26 17:31:39 +00:00
										 |  |  |         username={profile.slug || undefined} | 
					
						
							|  |  |  |         // avatar={profile.image || undefined}
 | 
					
						
							| 
									
										
										
										
											2021-09-24 22:11:30 +00:00
										 |  |  |       /> | 
					
						
							| 
									
										
										
										
											2022-03-05 15:37:46 +00:00
										 |  |  |       <CustomBranding lightVal={profile.brandColor} darkVal={profile.darkBrandColor} /> | 
					
						
							| 
									
										
										
										
											2021-09-24 22:11:30 +00:00
										 |  |  |       <div> | 
					
						
							|  |  |  |         <main | 
					
						
							|  |  |  |           className={ | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  |             isEmbed | 
					
						
							| 
									
										
										
										
											2022-04-14 02:47:34 +00:00
										 |  |  |               ? classNames("m-auto", selectedDate ? "max-w-5xl" : "max-w-3xl") | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  |               : "transition-max-width mx-auto my-0 duration-500 ease-in-out md:my-24 " + | 
					
						
							|  |  |  |                 (selectedDate ? "max-w-5xl" : "max-w-3xl") | 
					
						
							| 
									
										
										
										
											2021-09-24 22:11:30 +00:00
										 |  |  |           }> | 
					
						
							|  |  |  |           {isReady && ( | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  |             <div | 
					
						
							|  |  |  |               style={availabilityDatePickerEmbedStyles} | 
					
						
							|  |  |  |               className={classNames( | 
					
						
							|  |  |  |                 isBackgroundTransparent ? "" : "bg-white dark:bg-gray-800 sm:dark:border-gray-600", | 
					
						
							|  |  |  |                 "border-bookinglightest rounded-sm md:border", | 
					
						
							|  |  |  |                 isEmbed ? "mx-auto" : selectedDate ? "max-w-5xl" : "max-w-3xl" | 
					
						
							|  |  |  |               )}> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |               {/* mobile: details */} | 
					
						
							|  |  |  |               <div className="block p-4 sm:p-8 md:hidden"> | 
					
						
							| 
									
										
										
										
											2022-04-04 10:20:49 +00:00
										 |  |  |                 <div className="block items-center sm:flex sm:space-x-4"> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                   <AvatarGroup | 
					
						
							| 
									
										
										
										
											2022-03-24 13:15:24 +00:00
										 |  |  |                     border="border-2 dark:border-gray-800 border-white" | 
					
						
							| 
									
										
										
										
											2021-11-18 01:03:19 +00:00
										 |  |  |                     items={ | 
					
						
							|  |  |  |                       [ | 
					
						
							|  |  |  |                         { image: profile.image, alt: profile.name, title: profile.name }, | 
					
						
							|  |  |  |                         ...eventType.users | 
					
						
							|  |  |  |                           .filter((user) => user.name !== profile.name) | 
					
						
							|  |  |  |                           .map((user) => ({ | 
					
						
							|  |  |  |                             title: user.name, | 
					
						
							| 
									
										
										
										
											2022-03-26 00:39:38 +00:00
										 |  |  |                             image: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/${user.username}/avatar.png`, | 
					
						
							| 
									
										
										
										
											2021-11-18 01:03:19 +00:00
										 |  |  |                             alt: user.name || undefined, | 
					
						
							|  |  |  |                           })), | 
					
						
							|  |  |  |                       ].filter((item) => !!item.image) as { image: string; alt?: string; title?: string }[] | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                     size={9} | 
					
						
							|  |  |  |                     truncateAfter={5} | 
					
						
							|  |  |  |                   /> | 
					
						
							| 
									
										
										
										
											2022-04-04 10:20:49 +00:00
										 |  |  |                   <div className="mt-4 sm:-mt-2"> | 
					
						
							|  |  |  |                     <p className="text-sm font-medium text-black dark:text-white">{profile.name}</p> | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                     <div className="mt-2  gap-2 dark:text-gray-100"> | 
					
						
							|  |  |  |                       <h1 className="text-bookingdark mb-4 text-xl font-semibold dark:text-white"> | 
					
						
							|  |  |  |                         {eventType.title} | 
					
						
							|  |  |  |                       </h1> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                       {eventType?.description && ( | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                         <p className="text-bookinglight mb-2 dark:text-white"> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                           <InformationCircleIcon className="mr-[10px] ml-[2px] -mt-1 inline-block h-4 w-4" /> | 
					
						
							|  |  |  |                           {eventType.description} | 
					
						
							|  |  |  |                         </p> | 
					
						
							|  |  |  |                       )} | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                       <p className="text-bookinglight mb-2 dark:text-white"> | 
					
						
							|  |  |  |                         <ClockIcon className="mr-[10px] -mt-1 ml-[2px] inline-block h-4 w-4 text-gray-400" /> | 
					
						
							| 
									
										
										
										
											2021-10-08 11:43:48 +00:00
										 |  |  |                         {eventType.length} {t("minutes")} | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                       </p> | 
					
						
							| 
									
										
										
										
											2021-09-22 18:36:13 +00:00
										 |  |  |                       {eventType.price > 0 && ( | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                         <div className="text-gray-600 dark:text-white"> | 
					
						
							|  |  |  |                           <CreditCardIcon className="mr-[10px] ml-[2px] -mt-1 inline-block h-4 w-4 dark:text-gray-400" /> | 
					
						
							| 
									
										
										
										
											2021-09-22 18:36:13 +00:00
										 |  |  |                           <IntlProvider locale="en"> | 
					
						
							|  |  |  |                             <FormattedNumber | 
					
						
							|  |  |  |                               value={eventType.price / 100.0} | 
					
						
							|  |  |  |                               style="currency" | 
					
						
							|  |  |  |                               currency={eventType.currency.toUpperCase()} | 
					
						
							|  |  |  |                             /> | 
					
						
							|  |  |  |                           </IntlProvider> | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                       )} | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                       <div className="md:hidden"> | 
					
						
							|  |  |  |                         {booking?.startTime && rescheduleUid && ( | 
					
						
							|  |  |  |                           <div> | 
					
						
							|  |  |  |                             <p | 
					
						
							|  |  |  |                               className="mt-8 mb-2 text-gray-600 dark:text-white" | 
					
						
							| 
									
										
										
										
											2022-04-18 10:25:56 +00:00
										 |  |  |                               data-testid="former_time_p_mobile"> | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                               {t("former_time")} | 
					
						
							|  |  |  |                             </p> | 
					
						
							|  |  |  |                             <p className="text-gray-500 line-through dark:text-white"> | 
					
						
							|  |  |  |                               <CalendarIcon className="mr-[10px] -mt-1 inline-block h-4 w-4 text-gray-400" /> | 
					
						
							|  |  |  |                               {typeof booking.startTime === "string" && | 
					
						
							|  |  |  |                                 parseDate(dayjs(booking.startTime), i18n)} | 
					
						
							|  |  |  |                             </p> | 
					
						
							|  |  |  |                           </div> | 
					
						
							|  |  |  |                         )} | 
					
						
							|  |  |  |                       </div> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                     </div> | 
					
						
							|  |  |  |                   </div> | 
					
						
							|  |  |  |                 </div> | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 00:05:13 +00:00
										 |  |  |               <div className="px-4 sm:flex sm:p-4 sm:py-5"> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                 <div | 
					
						
							|  |  |  |                   className={ | 
					
						
							| 
									
										
										
										
											2022-03-24 13:15:24 +00:00
										 |  |  |                     "hidden pr-8 sm:border-r sm:dark:border-gray-700 md:flex md:flex-col " + | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                     (selectedDate ? "sm:w-1/3" : "sm:w-1/2") | 
					
						
							|  |  |  |                   }> | 
					
						
							|  |  |  |                   <AvatarGroup | 
					
						
							| 
									
										
										
										
											2022-03-24 13:15:24 +00:00
										 |  |  |                     border="border-2 dark:border-gray-800 border-white" | 
					
						
							| 
									
										
										
										
											2021-11-18 01:03:19 +00:00
										 |  |  |                     items={ | 
					
						
							|  |  |  |                       [ | 
					
						
							|  |  |  |                         { image: profile.image, alt: profile.name, title: profile.name }, | 
					
						
							|  |  |  |                         ...eventType.users | 
					
						
							|  |  |  |                           .filter((user) => user.name !== profile.name) | 
					
						
							|  |  |  |                           .map((user) => ({ | 
					
						
							|  |  |  |                             title: user.name, | 
					
						
							|  |  |  |                             alt: user.name, | 
					
						
							| 
									
										
										
										
											2022-03-26 00:39:38 +00:00
										 |  |  |                             image: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/${user.username}/avatar.png`, | 
					
						
							| 
									
										
										
										
											2021-11-18 01:03:19 +00:00
										 |  |  |                           })), | 
					
						
							|  |  |  |                       ].filter((item) => !!item.image) as { image: string; alt?: string; title?: string }[] | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-09-14 13:27:41 +00:00
										 |  |  |                     size={10} | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                     truncateAfter={3} | 
					
						
							|  |  |  |                   /> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                   <h2 className="mt-3 font-medium text-gray-500 dark:text-gray-300">{profile.name}</h2> | 
					
						
							|  |  |  |                   <h1 className="font-cal mb-4 text-xl font-semibold text-gray-900 dark:text-white"> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                     {eventType.title} | 
					
						
							|  |  |  |                   </h1> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                   {eventType?.description && ( | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                     <p className="text-bookinglight mb-2 dark:text-white"> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                       <InformationCircleIcon className="mr-[10px] ml-[2px] -mt-1 inline-block h-4 w-4 text-gray-400" /> | 
					
						
							|  |  |  |                       {eventType.description} | 
					
						
							|  |  |  |                     </p> | 
					
						
							|  |  |  |                   )} | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  |                   <p className="text-bookinglight mb-2 dark:text-white"> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                     <ClockIcon className="mr-[10px] -mt-1 ml-[2px] inline-block h-4 w-4 text-gray-400" /> | 
					
						
							| 
									
										
										
										
											2021-10-08 11:43:48 +00:00
										 |  |  |                     {eventType.length} {t("minutes")} | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                   </p> | 
					
						
							| 
									
										
										
										
											2021-09-22 18:36:13 +00:00
										 |  |  |                   {eventType.price > 0 && ( | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                     <p className="mb-1 -ml-2 px-2 py-1 text-gray-600 dark:text-white"> | 
					
						
							|  |  |  |                       <CreditCardIcon className="mr-[10px] ml-[2px] -mt-1 inline-block h-4 w-4 text-gray-400" /> | 
					
						
							| 
									
										
										
										
											2021-09-22 18:36:13 +00:00
										 |  |  |                       <IntlProvider locale="en"> | 
					
						
							|  |  |  |                         <FormattedNumber | 
					
						
							|  |  |  |                           value={eventType.price / 100.0} | 
					
						
							|  |  |  |                           style="currency" | 
					
						
							|  |  |  |                           currency={eventType.currency.toUpperCase()} | 
					
						
							|  |  |  |                         /> | 
					
						
							|  |  |  |                       </IntlProvider> | 
					
						
							|  |  |  |                     </p> | 
					
						
							|  |  |  |                   )} | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |                   <TimezoneDropdown /> | 
					
						
							| 
									
										
										
										
											2022-03-07 15:48:51 +00:00
										 |  |  |                   {previousPage === `${BASE_URL}/${profile.slug}` && ( | 
					
						
							|  |  |  |                     <div className="flex h-full flex-col justify-end"> | 
					
						
							|  |  |  |                       <ArrowLeftIcon | 
					
						
							|  |  |  |                         className="h-4 w-4 text-black  transition-opacity hover:cursor-pointer dark:text-white" | 
					
						
							|  |  |  |                         onClick={() => router.back()} | 
					
						
							|  |  |  |                       /> | 
					
						
							|  |  |  |                       <p className="sr-only">Go Back</p> | 
					
						
							|  |  |  |                     </div> | 
					
						
							|  |  |  |                   )} | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                   {booking?.startTime && rescheduleUid && ( | 
					
						
							|  |  |  |                     <div> | 
					
						
							| 
									
										
										
										
											2022-04-18 10:25:56 +00:00
										 |  |  |                       <p | 
					
						
							|  |  |  |                         className="mt-4 mb-2 text-gray-600 dark:text-white" | 
					
						
							|  |  |  |                         data-testid="former_time_p_desktop"> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |                         {t("former_time")} | 
					
						
							|  |  |  |                       </p> | 
					
						
							|  |  |  |                       <p className="text-gray-500 line-through dark:text-white"> | 
					
						
							|  |  |  |                         <CalendarIcon className="mr-[10px] -mt-1 inline-block h-4 w-4 text-gray-400" /> | 
					
						
							|  |  |  |                         {typeof booking.startTime === "string" && parseDate(dayjs(booking.startTime), i18n)} | 
					
						
							|  |  |  |                       </p> | 
					
						
							|  |  |  |                     </div> | 
					
						
							|  |  |  |                   )} | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                 </div> | 
					
						
							| 
									
										
										
										
											2022-04-17 11:25:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                 <DatePicker | 
					
						
							|  |  |  |                   date={selectedDate} | 
					
						
							|  |  |  |                   periodType={eventType?.periodType} | 
					
						
							|  |  |  |                   periodStartDate={eventType?.periodStartDate} | 
					
						
							|  |  |  |                   periodEndDate={eventType?.periodEndDate} | 
					
						
							|  |  |  |                   periodDays={eventType?.periodDays} | 
					
						
							|  |  |  |                   periodCountCalendarDays={eventType?.periodCountCalendarDays} | 
					
						
							|  |  |  |                   onDatePicked={changeDate} | 
					
						
							| 
									
										
										
										
											2021-09-23 14:08:44 +00:00
										 |  |  |                   workingHours={workingHours} | 
					
						
							| 
									
										
										
										
											2021-10-02 20:16:51 +00:00
										 |  |  |                   weekStart={profile.weekStart || "Sunday"} | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                   eventLength={eventType.length} | 
					
						
							|  |  |  |                   minimumBookingNotice={eventType.minimumBookingNotice} | 
					
						
							|  |  |  |                 /> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 00:05:13 +00:00
										 |  |  |                 <div className="mt-4 ml-1 block sm:hidden"> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                   <TimezoneDropdown /> | 
					
						
							|  |  |  |                 </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 {selectedDate && ( | 
					
						
							|  |  |  |                   <AvailableTimes | 
					
						
							|  |  |  |                     timeFormat={timeFormat} | 
					
						
							|  |  |  |                     minimumBookingNotice={eventType.minimumBookingNotice} | 
					
						
							|  |  |  |                     eventTypeId={eventType.id} | 
					
						
							| 
									
										
										
										
											2022-04-06 17:20:30 +00:00
										 |  |  |                     eventTypeSlug={eventType.slug} | 
					
						
							| 
									
										
										
										
											2021-12-19 12:11:31 +00:00
										 |  |  |                     slotInterval={eventType.slotInterval} | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                     eventLength={eventType.length} | 
					
						
							|  |  |  |                     date={selectedDate} | 
					
						
							|  |  |  |                     users={eventType.users} | 
					
						
							|  |  |  |                     schedulingType={eventType.schedulingType ?? null} | 
					
						
							| 
									
										
										
										
											2022-03-04 10:19:03 +00:00
										 |  |  |                     beforeBufferTime={eventType.beforeEventBuffer} | 
					
						
							|  |  |  |                     afterBufferTime={eventType.afterEventBuffer} | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |                   /> | 
					
						
							|  |  |  |                 )} | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2021-09-24 22:11:30 +00:00
										 |  |  |           )} | 
					
						
							| 
									
										
										
										
											2022-04-08 05:33:24 +00:00
										 |  |  |           {(!eventType.users[0] || !isBrandingHidden(eventType.users[0])) && !isEmbed && <PoweredByCal />} | 
					
						
							| 
									
										
										
										
											2021-09-24 22:11:30 +00:00
										 |  |  |         </main> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     </> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function TimezoneDropdown() { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <Collapsible.Root open={isTimeOptionsOpen} onOpenChange={setIsTimeOptionsOpen}> | 
					
						
							| 
									
										
										
										
											2022-04-14 21:25:24 +00:00
										 |  |  |         <Collapsible.Trigger className="min-w-32 mb-1 -ml-2 px-2 py-1 text-left text-gray-600 dark:text-white"> | 
					
						
							|  |  |  |           <GlobeIcon className="mr-[10px] ml-[2px] -mt-1 inline-block h-4 w-4 text-gray-400" /> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |           {timeZone()} | 
					
						
							|  |  |  |           {isTimeOptionsOpen ? ( | 
					
						
							| 
									
										
										
										
											2022-02-09 00:05:13 +00:00
										 |  |  |             <ChevronUpIcon className="ml-1 -mt-1 inline-block h-4 w-4" /> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |           ) : ( | 
					
						
							| 
									
										
										
										
											2022-02-09 00:05:13 +00:00
										 |  |  |             <ChevronDownIcon className="ml-1 -mt-1 inline-block h-4 w-4" /> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |           )} | 
					
						
							|  |  |  |         </Collapsible.Trigger> | 
					
						
							|  |  |  |         <Collapsible.Content> | 
					
						
							| 
									
										
										
										
											2021-10-12 13:11:33 +00:00
										 |  |  |           <TimeOptions onSelectTimeZone={handleSelectTimeZone} onToggle24hClock={handleToggle24hClock} /> | 
					
						
							| 
									
										
										
										
											2021-09-14 08:45:28 +00:00
										 |  |  |         </Collapsible.Content> | 
					
						
							|  |  |  |       </Collapsible.Root> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default AvailabilityPage; |