feat: add optional startTime prop to BookerPlatformWrapper (#22731)
* feat: add optional startTime prop to BookerPlatformWrapper - Add startTime prop to BookerPlatformWrapperAtomProps interface - Allow users to override calculated startTime from useTimesForSchedule - Maintain backward compatibility when prop is not provided - Add JSDoc documentation for proper usage Co-Authored-By: somay@cal.com <somay@cal.com> * feat: add custom start time support to Booker component with date object input * feat: update documentation and added changelog --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: somay@cal.com <somay@cal.com> Co-authored-by: Somay Chauhan <somaychauhan98@gmail.com>
This commit is contained in:
4 files changed
+15
-1
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@calcom/atoms": patch
|
||||
---
|
||||
|
||||
Added new startTime prop to the Booker component that allows users to decide the first available date when the booker loads
|
||||
@@ -90,6 +90,7 @@ Below is a list of props that can be passed to the booker atom.
|
||||
| customClassNames | No | To pass in custom classnames from outside for styling the atom |
|
||||
| month | No | The exact month for displaying a user's availability; defaults to the current month |
|
||||
| selectedDate | No | Default selected date for which the slot picker opens |
|
||||
| startTime | No | Custom start time for the Booker that allows users to decide the first available date. Accepts JavaScript Date object or date string in format `YYYY-MM-DD` (e.g., `"2025-08-20"` or `new Date("2025-08-20")`) |
|
||||
| hideBranding | No | For hiding any branding on the booker |
|
||||
| isAway | No | Sets the booker component to the away state |
|
||||
| allowsDynamicBooking | No | Boolean indicating if the booking is a dynamic booking |
|
||||
|
||||
@@ -57,6 +57,7 @@ export const BookerPlatformWrapper = (
|
||||
isBookingDryRun,
|
||||
handleSlotReservation,
|
||||
onTimeslotsLoaded,
|
||||
startTime: customStartTime,
|
||||
} = props;
|
||||
const layout = BookerLayouts[view];
|
||||
|
||||
@@ -220,7 +221,7 @@ export const BookerPlatformWrapper = (
|
||||
: undefined;
|
||||
const { timezone } = useTimePreferences();
|
||||
|
||||
const [startTime, endTime] = useTimesForSchedule({
|
||||
const [calculatedStartTime, calculatedEndTime] = useTimesForSchedule({
|
||||
month,
|
||||
monthCount,
|
||||
dayCount,
|
||||
@@ -228,6 +229,12 @@ export const BookerPlatformWrapper = (
|
||||
selectedDate,
|
||||
});
|
||||
|
||||
const startTime =
|
||||
customStartTime && dayjs(customStartTime).isAfter(dayjs(calculatedStartTime))
|
||||
? dayjs(customStartTime).toISOString()
|
||||
: calculatedStartTime;
|
||||
const endTime = calculatedEndTime;
|
||||
|
||||
const [routingParams, setRoutingParams] = useState<{
|
||||
routedTeamMemberIds?: number[];
|
||||
_shouldServeCache?: boolean;
|
||||
|
||||
@@ -83,6 +83,7 @@ export type BookerPlatformWrapperAtomProps = Omit<
|
||||
isBookingDryRun?: boolean;
|
||||
eventMetaChildren?: React.ReactNode;
|
||||
onTimeslotsLoaded?: (slots: Record<string, Slot[]>) => void;
|
||||
startTime?: string | Date;
|
||||
};
|
||||
|
||||
type VIEW_TYPE = keyof typeof BookerLayouts;
|
||||
|
||||
Reference in new issue
Block a user