redesigned cancel page to new design (#3923)

Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
Peer RichelsenandAlex van Andel authored and GitHub committed 2022-08-22 19:48:33 +00:00
1 parent b328527434
commit 1b942c4003
2 files changed
+82 -85

No files matched your search

+76 -84
View File
@@ -12,10 +12,10 @@ 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 { Button } from "@calcom/ui/Button";
import { Icon } from "@calcom/ui/Icon";
import { TextField } from "@calcom/ui/form/fields";
import { getSession } from "@lib/auth";
import { inferSSRProps } from "@lib/types/inferSSRProps";
@@ -43,24 +43,17 @@ export default function Type(props: inferSSRProps<typeof getServerSideProps>) {
const [moreEventsVisible, setMoreEventsVisible] = useState(false);
const telemetry = useTelemetry();
return (
<div>
<div className="h-screen bg-neutral-100 dark:bg-neutral-900">
<HeadSeo
title={`${t("cancel")} ${props.booking && props.booking.title} | ${props.profile?.name}`}
description={`${t("cancel")} ${props.booking && props.booking.title} | ${props.profile?.name}`}
/>
<CustomBranding lightVal={props.profile?.brandColor} darkVal={props.profile?.darkBrandColor} />
<main className="mx-auto my-24 max-w-3xl">
<div className="fixed inset-0 z-50 overflow-y-auto">
<div className="flex min-h-screen items-end justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div className="fixed inset-0 my-4 transition-opacity sm:my-0" aria-hidden="true">
<span className="hidden sm:inline-block sm:h-screen sm:align-middle" aria-hidden="true">
&#8203;
</span>
<div
className="inline-block transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm sm:p-6 sm:align-middle"
role="dialog"
aria-modal="true"
aria-labelledby="modal-headline">
<main className="h-full sm:flex sm:items-center">
<div className="mx-auto flex justify-center px-4 pt-4 pb-20 sm:block sm:p-0">
<div className="inline-block transform overflow-hidden rounded-md border bg-white px-8 pt-5 pb-4 text-left align-bottom transition-all dark:border-neutral-700 dark:bg-gray-800 sm:my-8 sm:w-full sm:max-w-lg sm:py-6 sm:align-middle">
<div>
<div>
{error && (
<div>
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-red-100">
@@ -79,16 +72,14 @@ export default function Type(props: inferSSRProps<typeof getServerSideProps>) {
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-red-100">
<Icon.FiX className="h-6 w-6 text-red-600" />
</div>
<div className="mt-3 sm:mt-5">
<h3
className="text-center text-lg font-medium leading-6 text-gray-900"
id="modal-headline">
<div className="mt-3 text-center sm:mt-5">
<h3 className="text-2xl font-semibold leading-6 text-neutral-900 dark:text-white">
{props.cancellationAllowed
? t("really_cancel_booking")
: t("cannot_cancel_booking")}
</h3>
<div className="mt-2">
<p className="text-center text-sm text-gray-500">
<p className="text-sm text-neutral-600 dark:text-gray-300">
{!props.booking?.eventType.recurringEvent
? props.cancellationAllowed
? t("reschedule_instead")
@@ -98,82 +89,83 @@ export default function Type(props: inferSSRProps<typeof getServerSideProps>) {
: t("cancelling_event_recurring")}
</p>
</div>
<div className="mt-4 border-t border-b py-4">
<h2 className="font-cal mb-2 text-center text-lg font-medium text-gray-600">
{props.booking?.title}
</h2>
{props.booking?.eventType.recurringEvent &&
props.booking?.eventType.recurringEvent.freq &&
props.recurringInstances && (
<div className="text-center text-gray-500">
<Icon.FiRefreshCcw className="mr-3 -mt-1 ml-[2px] inline-block h-4 w-4 text-gray-400" />
<p className="mb-1 -ml-2 inline px-2 py-1">
{getEveryFreqFor({
t,
recurringEvent: props.booking.eventType.recurringEvent,
recurringCount: props.recurringInstances.length,
})}
</p>
</div>
)}
<div className="text-gray-500">
<div className="flex flex-row items-start justify-center space-x-3">
{props.booking?.eventType.recurringEvent && props.recurringInstances ? (
<>
<Icon.FiCalendar className="mt-2 ml-1 h-4 w-4" />
<div className="mb-1 inline py-1 text-left">
<div className="">
{dayjs(props.recurringInstances[0].startTime).format(
detectBrowserTimeFormat + ", dddd DD MMMM YYYY"
)}
<Collapsible
open={moreEventsVisible}
onOpenChange={() => setMoreEventsVisible(!moreEventsVisible)}>
<CollapsibleTrigger
type="button"
className={classNames(
"-ml-4 block w-full text-center",
moreEventsVisible ? "hidden" : ""
)}>
{t("plus_more", { count: props.recurringInstances.length - 1 })}
</CollapsibleTrigger>
<CollapsibleContent>
{props.booking?.eventType.recurringEvent?.count &&
props.recurringInstances.slice(1).map((dateObj, idx) => (
<div key={idx} className="">
{dayjs(dateObj.startTime).format(
detectBrowserTimeFormat + ", dddd DD MMMM YYYY"
)}
</div>
))}
</CollapsibleContent>
</Collapsible>
</div>
<div className="border-bookinglightest text-bookingdark mt-4 grid grid-cols-3 border-t py-4 text-left dark:border-gray-900 dark:text-gray-300">
<div className="font-medium">{t("what")}</div>
<div className="col-span-2 mb-6">{props.booking?.title}</div>
<div className="font-medium">{t("when")}</div>
<div className="col-span-2 mb-6">
{props.booking?.eventType.recurringEvent && props.recurringInstances ? (
<>
<div className="mb-1 inline py-1 text-left">
<div>
{dayjs(props.recurringInstances[0].startTime).format(
detectBrowserTimeFormat + ", dddd DD MMMM YYYY"
)}
<Collapsible
open={moreEventsVisible}
onOpenChange={() => setMoreEventsVisible(!moreEventsVisible)}>
<CollapsibleTrigger
type="button"
className={classNames(
"-ml-4 block w-full text-center",
moreEventsVisible ? "hidden" : ""
)}>
{t("plus_more", { count: props.recurringInstances.length - 1 })}
</CollapsibleTrigger>
<CollapsibleContent>
{props.booking?.eventType.recurringEvent?.count &&
props.recurringInstances.slice(1).map((dateObj, idx) => (
<div key={idx} className="">
{dayjs(dateObj.startTime).format(
detectBrowserTimeFormat + ", dddd DD MMMM YYYY"
)}
</div>
))}
</CollapsibleContent>
</Collapsible>
</div>
</>
) : (
<>
<Icon.FiCalendar className="mt-1 mr-1 h-4 w-4" />
{dayjs(props.booking?.startTime).format(
detectBrowserTimeFormat + ", dddd DD MMMM YYYY"
)}
</>
)}
</div>
</div>
</>
) : (
<>
{dayjs(props.booking?.startTime).format(
detectBrowserTimeFormat + ", dddd DD MMMM YYYY"
)}{" "}
<span className="text-bookinglight">
({localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess()})
</span>
</>
)}
</div>
</div>
{props.booking?.eventType.recurringEvent &&
props.booking?.eventType.recurringEvent.freq &&
props.recurringInstances && (
<div className="border-b text-center text-gray-500">
<Icon.FiRefreshCcw className="mr-3 -mt-1 ml-[2px] inline-block h-4 w-4 text-gray-400" />
<p className="mb-1 -ml-2 inline px-2 py-1">
{getEveryFreqFor({
t,
recurringEvent: props.booking.eventType.recurringEvent,
recurringCount: props.recurringInstances.length,
})}
</p>
</div>
)}
</div>
</div>
{props.cancellationAllowed && (
<div className="mt-5 sm:mt-6">
<TextField
<div>
<textarea
autoFocus={true}
name={t("cancellation_reason")}
placeholder={t("cancellation_reason_placeholder")}
value={cancellationReason}
onChange={(e) => setCancellationReason(e.target.value)}
className="mb-5 sm:mb-6"
className="mt-2 mb-3 w-full dark:border-gray-900 dark:bg-gray-700 dark:text-white sm:mb-3 "
rows={3}
/>
<div className="space-x-2 text-center rtl:space-x-reverse">
<div className="flex justify-between space-x-2 text-center rtl:space-x-reverse">
{!props.booking.eventType?.recurringEvent && (
<Button color="secondary" onClick={() => router.push("/reschedule/" + uid)}>
{t("reschedule_this")}
+6 -1
View File
@@ -583,7 +583,12 @@ type RecurringBookingsProps = {
listingStatus: string;
};
function RecurringBookings({ eventType, recurringBookings, date, listingStatus }: RecurringBookingsProps) {
export function RecurringBookings({
eventType,
recurringBookings,
date,
listingStatus,
}: RecurringBookingsProps) {
const [moreEventsVisible, setMoreEventsVisible] = useState(false);
const { t } = useLocale();