feat(bookings): improve bookings redesign (#25251)

* use booking.uid instead of booking.id for url param

* show timezone on calendar

* fix type

* restore horizontal tab and remove header and subtitle

* clean up sidebar items

* fix event propagation from attendees

* fetch all statuses except for cancelled on calendar view

* clean up styles of the badges on BookingListItem

* fix useMediaQuery

* add close button to the header

* add assignment reason to the details sheet

* use separator row

* use ToggleGroup for the top bookings tab

* move ViewToggleButton

* resize the action button

* remove wrong prop

* fix type error

* fix type error

* hide view toggle button on mobile (and fix the breakpoint)

* remove unused e2e tests

* fix e2e tests

* hide toggle button when feature flag is off

* update skeleton

* improve attendees on booking list item and slide over

* improve attendee dropdown

* fix type error

* move query to containers

* select attendee email

* infinite fetching for calendar view

* update styles

* fix compatibility

* fix: add backward compatibility for status field in getAllUserBookings

* increase calendar height

* fix type error

* support Member filter only for admin / owners

* add debug log (TEMP)

* add event border color

* show Reject / Accept buttons on BookingDetailsSheet

* move description section to the top

* update When section

* update style of Who section

* add CancelBookingDialog WIP

* fix CancelBookingDialog

* increase clickable area

* add schedule info section WIP

* fix flaky reject button

* fixing reschedule info WIP

* add fromReschedule index to Booking

* improve rescheduled information

* improve reassignment

* fix type error

* fix unit test

* respect user's weekStart value on the booking calendar view

* update debug log

* improve payment section

* clean up

* fix log message

* reposition filters on list view

* fix bookings controller api2 e2e test

* clean up file by extracting logic into custom hooks

* rename files

* merge BookingCalendar into its container

* extract logic into separate hook files

* remove redundant logic

* rearrange items on calendar view

* add WeekPicker

* extract filter button

* responsive header on list view

* horizontal scroll for ToggleGroup WIP

* fix type error

* fix cancelling recurring event

* address feedback

* fix e2e tests

* fix unit test

* fix e2e tests

* make hover style more visible for ToggleGroup

* fix margin on CancelBookingDialog

* update styles on the slide over (mostly font weight)

* update style of CancelBookingDialog

* update styles

* update margin top for the header

* refactor getBookingDetails handler

* fix gap in who section

* auto-filter the current user on the calendar view

* calculate calendar height considering top banners

* improve booking details sheet interaction without overlay

* update calendar event styles

* update reject dialog style

* put uid first in the query params

* fix class name

* memoize functions in useMediaQuery

* query attendee with id instead of email

* update margins

* replace TRPCError with ErrorWithCode

* move calculation outside loop

* remove dead code
This commit is contained in:
Eunjae Lee authored and GitHub committed 2025-12-10 13:40:04 +00:00
1 parent 41b71d845c
commit 3986d61f40
90 files changed
+3741 -2079

No files matched your search

@@ -16,14 +16,6 @@ import { NavigationItem, MobileNavigationItem, MobileNavigationMoreItem } from "
export const MORE_SEPARATOR_NAME = "more";
const preserveBookingsQueryParams = ({
prevPathname,
nextPathname,
}: {
prevPathname: string | null;
nextPathname: string;
}) => Boolean(prevPathname?.startsWith("/bookings/")) && nextPathname.startsWith("/bookings/");
const getNavigationItems = (orgBranding: OrganizationBranding): NavigationItemType[] => [
{
name: "event_types_page_title",
@@ -36,38 +28,6 @@ const getNavigationItems = (orgBranding: OrganizationBranding): NavigationItemTy
icon: "calendar",
badge: <UnconfirmedBookingBadge />,
isCurrent: ({ pathname }) => pathname?.startsWith("/bookings") ?? false,
child: [
{
name: "upcoming",
href: "/bookings/upcoming",
preserveQueryParams: preserveBookingsQueryParams,
isCurrent: ({ pathname }) => pathname === "/bookings/upcoming",
},
{
name: "unconfirmed",
href: "/bookings/unconfirmed",
preserveQueryParams: preserveBookingsQueryParams,
isCurrent: ({ pathname }) => pathname === "/bookings/unconfirmed",
},
{
name: "recurring",
href: "/bookings/recurring",
preserveQueryParams: preserveBookingsQueryParams,
isCurrent: ({ pathname }) => pathname === "/bookings/recurring",
},
{
name: "past",
href: "/bookings/past",
preserveQueryParams: preserveBookingsQueryParams,
isCurrent: ({ pathname }) => pathname === "/bookings/past",
},
{
name: "cancelled",
href: "/bookings/cancelled",
preserveQueryParams: preserveBookingsQueryParams,
isCurrent: ({ pathname }) => pathname === "/bookings/cancelled",
},
],
},
{
name: "availability",
@@ -1,7 +1,7 @@
import Link from "next/link";
import { usePathname, useSearchParams } from "next/navigation";
import React, { Fragment, useState, useEffect, useRef } from "react";
import { usePathname } from "next/navigation";
import posthog from "posthog-js";
import React, { Fragment, useState, useEffect } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
@@ -33,29 +33,6 @@ const usePersistedExpansionState = (itemName: string) => {
return [isExpanded, setPersistedExpansion] as const;
};
const useBuildHref = () => {
const pathname = usePathname();
const searchParams = useSearchParams();
const prevPathnameRef = useRef<string | null>(null);
useEffect(() => {
prevPathnameRef.current = pathname;
}, [pathname]);
const buildHref = (childItem: NavigationItemType) => {
if (
childItem.preserveQueryParams &&
childItem.preserveQueryParams({ prevPathname: prevPathnameRef.current, nextPathname: childItem.href })
) {
const params = searchParams?.toString();
return params ? `${childItem.href}?${params}` : childItem.href;
}
return childItem.href;
};
return buildHref;
};
const trackNavigationClick = (itemName: string, parentItemName?: string) => {
posthog.capture("navigation_item_clicked", {
item_name: itemName,
@@ -85,7 +62,6 @@ export type NavigationItemType = {
isChild?: boolean;
pathname: string | null;
}) => boolean;
preserveQueryParams?: (context: { prevPathname: string | null; nextPathname: string }) => boolean;
};
const defaultIsCurrent: NavigationItemType["isCurrent"] = ({ isChild, item, pathname }) => {
@@ -104,7 +80,6 @@ export const NavigationItem: React.FC<{
const current = isCurrent({ isChild: !!isChild, item, pathname });
const shouldDisplayNavigationItem = useShouldDisplayNavigationItem(props.item);
const [isExpanded, setIsExpanded] = usePersistedExpansionState(item.name);
const buildHref = useBuildHref();
const isTablet = useMediaQuery("(max-width: 1024px)");
const [isTooltipOpen, setIsTooltipOpen] = useState(false);
@@ -126,7 +101,7 @@ export const NavigationItem: React.FC<{
open={isTooltipOpen}
content={
hasChildren ? (
<div className="pointer-events-auto flex flex-col stack-y-1 p-1">
<div className="stack-y-1 pointer-events-auto flex flex-col p-1">
<span className="text-subtle px-2 text-xs font-semibold uppercase tracking-wide">
{t(item.name)}
</span>
@@ -139,7 +114,7 @@ export const NavigationItem: React.FC<{
return (
<Link
key={childItem.name}
href={buildHref(childItem)}
href={childItem.href}
aria-current={childIsCurrent ? "page" : undefined}
onClick={() => {
setIsTooltipOpen(false);
@@ -211,7 +186,7 @@ export const NavigationItem: React.FC<{
<Link
data-test-id={item.name}
onClick={() => trackNavigationClick(item.name)}
href={isChild ? buildHref(item) : item.href}
href={item.href}
aria-label={t(item.name)}
target={item.target}
className={classNames(
@@ -220,8 +195,9 @@ export const NavigationItem: React.FC<{
? `aria-[aria-current='page']:bg-transparent!`
: `[&[aria-current='page']]:bg-emphasis`,
isChild
? `[&[aria-current='page']]:text-emphasis [&[aria-current='page']]:bg-emphasis hidden h-8 pl-16 lg:flex lg:pl-11 ${props.index === 0 ? "mt-0" : "mt-px"
}`
? `[&[aria-current='page']]:text-emphasis [&[aria-current='page']]:bg-emphasis hidden h-8 pl-16 lg:flex lg:pl-11 ${
props.index === 0 ? "mt-0" : "mt-px"
}`
: "[&[aria-current='page']]:text-emphasis mt-0.5 text-sm",
isLocaleReady
? "hover:bg-subtle todesktop:[&[aria-current='page']]:bg-emphasis todesktop:hover:bg-transparent hover:text-emphasis"
@@ -232,7 +208,7 @@ export const NavigationItem: React.FC<{
<Icon
name={item.isLoading ? "rotate-cw" : item.icon}
className={classNames(
"todesktop:!text-blue-500 mr-2 h-4 w-4 shrink-0 rtl:ml-2 md:ltr:mx-auto lg:ltr:mr-2 aria-[aria-current='page']:text-inherit",
"todesktop:!text-blue-500 mr-2 h-4 w-4 shrink-0 aria-[aria-current='page']:text-inherit rtl:ml-2 md:ltr:mx-auto lg:ltr:mr-2",
item.isLoading && "animate-spin"
)}
aria-hidden="true"
@@ -281,7 +257,7 @@ export const MobileNavigationItem: React.FC<{
key={item.name}
href={item.href}
target={item.target}
className="[&[aria-current='page']]:text-emphasis hover:text-default text-muted relative my-2 min-w-0 flex-1 overflow-hidden rounded-md bg-transparent! p-1 text-center text-xs font-medium focus:z-10 sm:text-sm"
className="[&[aria-current='page']]:text-emphasis hover:text-default text-muted bg-transparent! relative my-2 min-w-0 flex-1 overflow-hidden rounded-md p-1 text-center text-xs font-medium focus:z-10 sm:text-sm"
aria-current={current ? "page" : undefined}>
{item.badge && <div className="absolute right-1 top-1">{item.badge}</div>}
{item.icon && (
@@ -305,7 +281,6 @@ export const MobileNavigationMoreItem: React.FC<{
const { t, isLocaleReady } = useLocale();
const shouldDisplayNavigationItem = useShouldDisplayNavigationItem(props.item);
const [isExpanded, setIsExpanded] = usePersistedExpansionState(item.name);
const buildHref = useBuildHref();
if (!shouldDisplayNavigationItem) return null;
@@ -320,11 +295,7 @@ export const MobileNavigationMoreItem: React.FC<{
className="hover:bg-subtle flex w-full items-center justify-between p-5 text-left transition">
<span className="text-default flex items-center font-semibold">
{item.icon && (
<Icon
name={item.icon}
className="h-5 w-5 shrink-0 ltr:mr-3 rtl:ml-3"
aria-hidden="true"
/>
<Icon name={item.icon} className="h-5 w-5 shrink-0 ltr:mr-3 rtl:ml-3" aria-hidden="true" />
)}
{isLocaleReady ? t(item.name) : <SkeletonText />}
</span>
@@ -335,7 +306,7 @@ export const MobileNavigationMoreItem: React.FC<{
{item.child.map((childItem) => (
<li key={childItem.name} className="border-subtle border-t">
<Link
href={buildHref(childItem)}
href={childItem.href}
className="hover:bg-cal-muted flex items-center p-4 pl-12 transition">
<span className="text-default font-medium">
{isLocaleReady ? t(childItem.name) : <SkeletonText />}