feat: add booking details sheet for /bookings (#24795)

* spike: initial booking detail sheet

* rename button

* revert some changes

* remove unnecessary test

* disable booking details sheet

---------

Co-authored-by: Eunjae Lee <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-11-11 08:40:55 -03:00
1 parent dc3742d322
commit 4407a1952c
14 files changed
+967 -61

No files matched your search

@@ -0,0 +1,2 @@
export { useBookerUrl, useEmbedBookerUrl } from "./useBookerUrl";
export { useBookingLocation } from "./useBookingLocation";
@@ -0,0 +1,77 @@
import type { TFunction } from "i18next";
import { useMemo } from "react";
import { getSuccessPageLocationMessage, guessEventLocationType } from "@calcom/app-store/locations";
import type { BookingStatus } from "@calcom/prisma/enums";
interface UseBookingLocationParams {
/**
* The booking location value from the booking object
*/
location: string | null | undefined;
/**
* The video call URL from booking metadata (if available)
*/
videoCallUrl?: string | null;
/**
* Translation function
*/
t: TFunction;
/**
* Booking status (optional)
*/
bookingStatus?: BookingStatus;
}
interface UseBookingLocationReturn {
/**
* The location message to display (URL or text)
*/
locationToDisplay: string | null;
/**
* The provider information (label, iconUrl, etc.)
*/
provider: ReturnType<typeof guessEventLocationType>;
/**
* Whether the location is a URL that can be clicked
*/
isLocationURL: boolean;
}
/**
* Custom hook to process booking location information
*
* This hook handles the common pattern of:
* 1. Determining the actual location (video call URL vs. raw location)
* 2. Getting the display message for the location
* 3. Determining the provider type
* 4. Checking if the location is a clickable URL
*/
export function useBookingLocation({
location,
videoCallUrl,
t,
bookingStatus,
}: UseBookingLocationParams): UseBookingLocationReturn {
const locationToDisplay = useMemo(() => {
if (!location) return null;
const effectiveLocation = videoCallUrl ?? location;
return getSuccessPageLocationMessage(effectiveLocation, t, bookingStatus);
}, [location, videoCallUrl, t, bookingStatus]);
const provider = useMemo(() => {
if (!location) return null;
return guessEventLocationType(location);
}, [location]);
const isLocationURL = useMemo(() => {
return typeof locationToDisplay === "string" && locationToDisplay.startsWith("http");
}, [locationToDisplay]);
return {
locationToDisplay,
provider,
isLocationURL,
};
}
+17
View File
@@ -16,3 +16,20 @@ export const SystemField = z.enum([
export const SMS_REMINDER_NUMBER_FIELD = "smsReminderNumber";
export const CAL_AI_AGENT_PHONE_NUMBER_FIELD = "aiAgentCallPhoneNumber";
export const TITLE_FIELD = "title";
/**
* Check if a field should be displayed in custom responses section.
* System fields are filtered out except for SMS_REMINDER_NUMBER_FIELD and TITLE_FIELD
* which don't have dedicated sections in the UI.
*/
export function shouldShowFieldInCustomResponses(fieldName: string): boolean {
const isSystemField = SystemField.safeParse(fieldName);
// Filter out system fields except SMS_REMINDER_NUMBER_FIELD and TITLE_FIELD
// These don't have dedicated sections in the UI
if (isSystemField.success && fieldName !== SMS_REMINDER_NUMBER_FIELD && fieldName !== TITLE_FIELD) {
return false;
}
return true;
}
@@ -498,6 +498,7 @@ export async function getBookings({
"EventType.currency",
"EventType.metadata",
"EventType.disableGuests",
"EventType.bookingFields",
"EventType.seatsPerTimeSlot",
"EventType.seatsShowAttendees",
"EventType.seatsShowAvailabilityCount",
+9 -7
View File
@@ -91,16 +91,18 @@ SheetContent.displayName = "SheetContent";
const SheetHeader = React.forwardRef<
HTMLDivElement,
React.ComponentPropsWithoutRef<"div"> & { showCloseButton?: boolean }
>(({ children, className, showCloseButton = true, ...props }, ref) => {
React.ComponentPropsWithoutRef<"div"> & { showCloseButton?: boolean; rightContent?: React.ReactNode }
>(({ children, className, showCloseButton = true, rightContent, ...props }, ref) => {
return (
<div ref={ref} className="flex items-start justify-between gap-x-4 pb-2" {...props}>
<div className={classNames("mt-1 flex flex-col gap-y-1", className)}>{children}</div>
{showCloseButton && (
<SheetPrimitives.Close asChild>
<Button variant="icon" StartIcon="x" color="minimal" className="aspect-square p-1" />
</SheetPrimitives.Close>
)}
{rightContent !== undefined
? rightContent
: showCloseButton && (
<SheetPrimitives.Close asChild>
<Button variant="icon" StartIcon="x" color="minimal" className="aspect-square p-1" />
</SheetPrimitives.Close>
)}
</div>
);
});