import type { Person } from '../../core'; import type { SpreadAsyncHandler } from '../../utils/types'; import type { AvailableSlot, BookingRequestOptions, RoutingStrategy } from '../types'; export interface UseAvailableSlotsArgs { /** * Identifier or Key of an Appointment Type that has been created in Source. * * Typically, Source recommends providing an Appointment Type ID where possible. However, many * use cases (such as simple intake scheduling flows) may want to hardcode the Key instead. This * is acceptable as well. */ appointmentType: string; /** * Start date from which to look for available time slots. * * Defaults to starting the search from the time at which the hook was first called. */ from?: Date; /** * End date through which to look for available time slots. * * Defaults to 7 days from the provided from date. If no from date is provided, defaults to 7 days * from the time at which the hook is first called. */ until?: Date; /** * Override the routing strategy for this booking request * * The default routing strategy will be selected based on the configuration associated with the * appointment type */ routingStrategy?: RoutingStrategy; /** * Override the time zone to use in this scheduling request * * By default, the time zone will be set to the browser's current time zone, as determined by the * Intl API */ outputTimeZone?: string; /** * Filter the returned partcipants to a subet of those which are allowed by the appointment type * * You may pass either an array of Group or User IDs here. However, note that members are unable to * search for groups using the Experience API, so those Group IDs must be hardcoded or derived from * your backend. */ participants?: ReadonlyArray; /** * Whether or not to include all available users in the returned time slot. * * Defaults to only returning the preferred user for a given time slot. If true is provided here, you * will receive all available users back as well. Note that this can result in a large amount of data * when searching over longer date ranges in groups with many people. */ includeAvailable?: boolean; /** * Whether or not to include all available participants */ includeParticipants?: boolean; } export interface UseAvailableSlotsReturn { /** * All time slots which have at least one user available for booking */ slots: ReadonlyArray; /** * The immediately next available appointment matching this criteria, if any */ nextAvailable: AvailableSlot | null; /** * All participants who were considered for scheduling this appointment */ participants: ReadonlyArray; /** * Available time slots grouped by date */ days: ReadonlyArray<[string, ReadonlyArray]>; /** * Whether the list of available time slots is currently loading. */ loading: boolean; /** * An error encountered during the slot lookup request, if one was encountered. * * This error will not capture any errors that occured during a booking request. Those errors * must be captured by .catch()'ing the promise returned from the book method. */ error: Error | null | undefined; /** * Function to call in order to book an appointment * * This method can be called directly with any slot returned from the slots array in this * method. Carbon will fill any other arguments that are required by the API. * * Having a slot previously returned from this hook does not guarantee the booking request * will be successful. Depending on the time delay between requesting available time slots * and booking one, the requested user may be unavailable, the slot may have been taken, or * might even be in the past. You should always handle errors that are returned from this * hook. */ book: SpreadAsyncHandler<[slot: AvailableSlot, options?: BookingRequestOptions], string>; } export declare function useScheduler({ appointmentType, from, until, participants, routingStrategy, outputTimeZone, includeAvailable, includeParticipants, }: UseAvailableSlotsArgs): UseAvailableSlotsReturn;