@tebuto/react-booking-widget 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types.d.ts +13 -25
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -347,8 +347,7 @@ type UseClaimSlotReturn = ClaimState & {
|
|
|
347
347
|
*/
|
|
348
348
|
declare function useClaimSlot(): UseClaimSlotReturn;
|
|
349
349
|
|
|
350
|
-
type
|
|
351
|
-
booking: BookingResponse | null;
|
|
350
|
+
type BookingRequestState = {
|
|
352
351
|
isLoading: boolean;
|
|
353
352
|
error: Error | null;
|
|
354
353
|
isSuccess: boolean;
|
|
@@ -358,44 +357,33 @@ type BookAppointmentParams = {
|
|
|
358
357
|
client: ClientInfo;
|
|
359
358
|
locationSelection?: AppointmentLocation;
|
|
360
359
|
};
|
|
361
|
-
type UseBookAppointmentReturn =
|
|
362
|
-
/**
|
|
363
|
-
book: (params: BookAppointmentParams) => Promise<
|
|
364
|
-
/** Reset the
|
|
360
|
+
type UseBookAppointmentReturn = BookingRequestState & {
|
|
361
|
+
/** Submit booking request - returns true on success */
|
|
362
|
+
book: (params: BookAppointmentParams) => Promise<boolean>;
|
|
363
|
+
/** Reset the state */
|
|
365
364
|
reset: () => void;
|
|
366
|
-
/** Download the calendar file (.ics) */
|
|
367
|
-
downloadCalendar: () => void;
|
|
368
365
|
};
|
|
369
366
|
/**
|
|
370
|
-
* useBookAppointment -
|
|
367
|
+
* useBookAppointment - Submit a public booking request
|
|
371
368
|
*
|
|
372
|
-
* Submits
|
|
373
|
-
* the
|
|
369
|
+
* Submits a booking request with client information. For public bookings,
|
|
370
|
+
* the client will receive a confirmation email to verify the appointment.
|
|
374
371
|
*
|
|
375
372
|
* @example
|
|
376
373
|
* ```tsx
|
|
377
|
-
* const { book,
|
|
374
|
+
* const { book, isLoading, isSuccess, error, reset } = useBookAppointment()
|
|
378
375
|
*
|
|
379
376
|
* const handleSubmit = async (clientInfo: ClientInfo) => {
|
|
380
|
-
* const
|
|
377
|
+
* const success = await book({
|
|
381
378
|
* slot: claimedSlot,
|
|
382
379
|
* client: clientInfo,
|
|
383
380
|
* locationSelection: selectedLocation
|
|
384
381
|
* })
|
|
385
382
|
*
|
|
386
|
-
* if (
|
|
383
|
+
* if (success) {
|
|
387
384
|
* setStep('confirmation')
|
|
388
385
|
* }
|
|
389
386
|
* }
|
|
390
|
-
*
|
|
391
|
-
* if (isSuccess) {
|
|
392
|
-
* return (
|
|
393
|
-
* <SuccessMessage>
|
|
394
|
-
* <button onClick={downloadCalendar}>Add to Calendar</button>
|
|
395
|
-
* <button onClick={reset}>Book Another</button>
|
|
396
|
-
* </SuccessMessage>
|
|
397
|
-
* )
|
|
398
|
-
* }
|
|
399
387
|
* ```
|
|
400
388
|
*/
|
|
401
389
|
declare function useBookAppointment(): UseBookAppointmentReturn;
|
|
@@ -404,8 +392,8 @@ type BookingStep = 'loading' | 'date-selection' | 'time-selection' | 'booking-fo
|
|
|
404
392
|
type UseBookingFlowOptions = {
|
|
405
393
|
/** Categories to filter by */
|
|
406
394
|
categories?: number[];
|
|
407
|
-
/** Callback when booking is
|
|
408
|
-
onBookingComplete?: (
|
|
395
|
+
/** Callback when booking request is submitted successfully */
|
|
396
|
+
onBookingComplete?: () => void;
|
|
409
397
|
/** Callback on any error */
|
|
410
398
|
onError?: (error: Error) => void;
|
|
411
399
|
};
|