diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 45492c72a6..28e97d498a 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -1,8 +1,15 @@ -import { BanIcon, CheckIcon, ClockIcon, XIcon, PencilAltIcon } from "@heroicons/react/outline"; -import { PaperAirplaneIcon } from "@heroicons/react/outline"; +import { + BanIcon, + CheckIcon, + ClockIcon, + PaperAirplaneIcon, + PencilAltIcon, + XIcon, +} from "@heroicons/react/outline"; import { RefreshIcon } from "@heroicons/react/solid"; import { BookingStatus } from "@prisma/client"; import dayjs from "dayjs"; +import { useRouter } from "next/router"; import { useState } from "react"; import { useMutation } from "react-query"; import { Frequency as RRuleFrequency } from "rrule"; @@ -17,7 +24,7 @@ import { TextArea } from "@calcom/ui/form/fields"; import { HttpError } from "@lib/core/http/error"; import useMeQuery from "@lib/hooks/useMeQuery"; import { parseRecurringDates } from "@lib/parseDate"; -import { inferQueryOutput, trpc, inferQueryInput } from "@lib/trpc"; +import { inferQueryInput, inferQueryOutput, trpc } from "@lib/trpc"; import { RescheduleDialog } from "@components/dialog/RescheduleDialog"; import TableActions, { ActionType } from "@components/ui/TableActions"; @@ -37,6 +44,7 @@ function BookingListItem(booking: BookingItemProps) { const user = query.data; const { t, i18n } = useLocale(); const utils = trpc.useContext(); + const router = useRouter(); const [rejectionReason, setRejectionReason] = useState(""); const [rejectionDialogIsOpen, setRejectionDialogIsOpen] = useState(false); const mutation = useMutation( @@ -81,7 +89,10 @@ function BookingListItem(booking: BookingItemProps) { booking.listingStatus === "upcoming" && booking.recurringEventId !== null ? t("reject_all") : t("reject"), - onClick: () => setRejectionDialogIsOpen(true), + onClick: (e) => { + e.stopPropagation(); + setRejectionDialogIsOpen(true); + }, icon: BanIcon, disabled: mutation.isLoading, }, @@ -91,7 +102,10 @@ function BookingListItem(booking: BookingItemProps) { booking.listingStatus === "upcoming" && booking.recurringEventId !== null ? t("confirm_all") : t("confirm"), - onClick: () => mutation.mutate(true), + onClick: (e) => { + e.stopPropagation(); + mutation.mutate(true); + }, icon: CheckIcon, disabled: mutation.isLoading, color: "primary", @@ -120,7 +134,10 @@ function BookingListItem(booking: BookingItemProps) { id: "reschedule_request", icon: ClockIcon, label: t("send_reschedule_request"), - onClick: () => setIsOpenRescheduleDialog(true), + onClick: (e) => { + e.stopPropagation(); + setIsOpenRescheduleDialog(true); + }, }, ], }, @@ -150,6 +167,7 @@ function BookingListItem(booking: BookingItemProps) { i18n ); } + return ( <> - + + router.push({ + pathname: "/success", + query: { + date: booking.startTime, + type: booking.eventType.id, + eventSlug: booking.eventType.slug, + user: user?.username || "", + name: booking.attendees[0].name, + email: booking.attendees[0].email, + location: booking.location + ? booking.location.includes("integration") + ? (t("web_conferencing_details_to_follow") as string) + : booking.location + : "", + eventName: booking.eventType.eventName || "", + bookingId: booking.id, + recur: booking.recurringEventId, + reschedule: booking.confirmed, + }, + }) + }>
{startTime}
@@ -264,9 +305,12 @@ function BookingListItem(booking: BookingItemProps) { )} {booking.attendees.length !== 0 && ( -
- {booking.attendees[0].email} -
+ e.stopPropagation()}> + {booking.attendees[0].email} + )} {isCancelled && booking.rescheduled && (
diff --git a/apps/web/components/booking/CancelBooking.tsx b/apps/web/components/booking/CancelBooking.tsx new file mode 100644 index 0000000000..f71b18e16e --- /dev/null +++ b/apps/web/components/booking/CancelBooking.tsx @@ -0,0 +1,119 @@ +import { XIcon } from "@heroicons/react/solid"; +import { useRouter } from "next/router"; +import { useState } from "react"; + +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { Button } from "@calcom/ui/Button"; + +import useTheme from "@lib/hooks/useTheme"; +import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; + +type Props = { + booking: { + title?: string; + uid?: string; + }; + profile: { + name: string | null; + slug: string | null; + }; + team?: string | null; + setIsCancellationMode: (value: boolean) => void; + theme: string | null; +}; + +export default function CancelBooking(props: Props) { + const [cancellationReason, setCancellationReason] = useState(""); + const { t } = useLocale(); + const router = useRouter(); + const { booking, profile, team } = props; + const [loading, setLoading] = useState(false); + const telemetry = useTelemetry(); + const [error, setError] = useState(booking ? null : t("booking_already_cancelled")); + const { isReady, Theme } = useTheme(props.theme); + + if (isReady) { + return ( + <> + + {error && ( +
+
+ +
+
+ +
+
+ )} + {!error && ( +
+ +