import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible"; import { GetServerSidePropsContext } from "next"; import { useRouter } from "next/router"; import { useState } from "react"; import z from "zod"; import dayjs from "@calcom/dayjs"; import CustomBranding from "@calcom/lib/CustomBranding"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent"; import { getEveryFreqFor } from "@calcom/lib/recurringStrings"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import { detectBrowserTimeFormat } from "@calcom/lib/timeFormat"; import { localStorage } from "@calcom/lib/webstorage"; import prisma, { bookingMinimalSelect } from "@calcom/prisma"; import { Icon } from "@calcom/ui/Icon"; import { Button } from "@calcom/ui/v2/core/Button"; import { getSession } from "@lib/auth"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import { HeadSeo } from "@components/seo/head-seo"; import { ssrInit } from "@server/lib/ssr"; const querySchema = z.object({ uid: z.string(), allRemainingBookings: z .string() .optional() .transform((val) => (val ? JSON.parse(val) : false)), }); export default function Type(props: inferSSRProps) { const { t } = useLocale(); // Get router variables const router = useRouter(); const { uid, allRemainingBookings } = querySchema.parse(router.query); const [loading, setLoading] = useState(false); const [error, setError] = useState(props.booking ? null : t("booking_already_cancelled")); const [cancellationReason, setCancellationReason] = useState(""); const [moreEventsVisible, setMoreEventsVisible] = useState(false); const telemetry = useTelemetry(); return (
{error && (
)} {!error && ( <>

{props.cancellationAllowed ? t("really_cancel_booking") : t("cannot_cancel_booking")}

{!props.booking?.eventType.recurringEvent ? props.cancellationAllowed ? t("reschedule_instead") : t("event_is_in_the_past") : allRemainingBookings ? t("cancelling_all_recurring") : t("cancelling_event_recurring")}

{t("what")}
{props.booking?.title}
{t("when")}
{props.booking?.eventType.recurringEvent && props.recurringInstances ? ( <>
{dayjs(props.recurringInstances[0].startTime).format( detectBrowserTimeFormat + ", dddd DD MMMM YYYY" )} setMoreEventsVisible(!moreEventsVisible)}> {t("plus_more", { count: props.recurringInstances.length - 1 })} {props.booking?.eventType.recurringEvent?.count && props.recurringInstances.slice(1).map((dateObj, idx) => (
{dayjs(dateObj.startTime).format( detectBrowserTimeFormat + ", dddd DD MMMM YYYY" )}
))}
) : ( <> {dayjs(props.booking?.startTime).format( detectBrowserTimeFormat + ", dddd DD MMMM YYYY" )}{" "} ({localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess()}) )}
{props.booking?.eventType.recurringEvent && props.booking?.eventType.recurringEvent.freq && props.recurringInstances && (

{getEveryFreqFor({ t, recurringEvent: props.booking.eventType.recurringEvent, recurringCount: props.recurringInstances.length, })}

)}
{props.cancellationAllowed && (