You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/integration-with-widgets.md
+27-46Lines changed: 27 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,52 +19,39 @@ The integration primarily focuses on converting the Scheduler data into Booking
19
19
So what you actually need is to generate booking slots from the schedule (the [snippet below](#example) shows how to generate booking slots from the doctor's schedule using JSON data).
20
20
21
21
-**Recurring events limitation:**
22
-
- Booking supports only weekly recurring events (defined as INTERVAL=1;FREQ=WEEKLY in the Scheduler).
23
-
- Scheduler can handle any recurring pattern
22
+
- Booking supports only weekly recurring events (defined as INTERVAL=1;FREQ=WEEKLY in Scheduler).
23
+
- Scheduler can handle any recurring pattern so you will need to limit creating other recurring events in Scheduler config
24
24
25
25
-**Timezone handling:**
26
26
- Booking interprets timestamps in the local timezone.
27
-
- You need to convert timestamps between global and local timezones before sending them to Booking (and vice versa).
27
+
- If you use global timestamps, you need to convert them to local timezones before sending them to Booking (and vice versa before saving the data back).
28
+
For conversion instructions, refer to [Working with UTC data](/guides/configuration/saving-reservations/#working-with-utc-data).
28
29
29
-
-**Slot creation strategy:**
30
-
- Use the `slots` and `usedSlots` properties to build the schedule, ensuring that used slots are excluded.
30
+
-**Booking slot strategies:**
31
+
- Use `slots` and `usedSlots` to build the schedule, ensuring that used slots are excluded (we'll focus on this strategy)
32
+
- Use only `availableSlots`, which is suitable for events without recurrences.
31
33
34
+
## Example
32
35
33
-
## Main steps for integration and rules for generating events
36
+
The snippet below demonstrates how to integrate Booking with the Scheduler widget by converting doctors' schedules into booking slots. Key data endpoints used for integration:
34
37
35
-
We will show how to generate booking slots from the doctor's schedule using JSON data.
38
+
-`/doctors/worktime` - Scheduler data (doctor schedules) that includes recurring and single-time events. These events are used to create time slots for the Booking system.
39
+
-`/units` - final Booking slots generated from the Scheduler `worktime` data. The slots are generated on the server-side. Please, also refer to [backend](https://github.com/DHTMLX/scheduler-booking-go).
40
+
-`/doctors/reservations` - an auxiliary collection used to visualize `usedSlots` in the timeline view. This data comes from the Booking form, containing information about already reserved slots for doctors.
41
+
-`/doctors` - contains all doctors, including their names and IDs. It is used for displaying doctor information in both the Scheduler and Booking widgets.
36
42
37
-
**Step 1. Retrieve the doctor's schedule data (e.g., /doctors/worktime), which may contain both recurring and single events.**
43
+
Converting Scheduler events to Booking slots is the major part of integration and the rules for handling the events and converting them to slots are described in the [section below](#rules-for-converting-scheduler-events-to-booking-slots).
38
44
39
-
Scheduler data example:
45
+
We also ensure that the timestamps are converted correctly. When global (UTC) timestamps are used, they need to be converted to local time before loading them into the system (**l2g** function in the example). Similarly, before saving the data back, the timestamps should be converted from local time to global (UTC) time (**g2l** function in the example).
## Rules for converting Scheduler events to Booking slots
64
51
65
-
**Step 2. Convert Scheduler events to Booking slots following the next rules.**
52
+
We will show how to generate booking slots from the doctor's schedule using JSON data.
66
53
67
-
**Rule 1:** Single event slot creation.
54
+
**Rule 1. Single event slot creation.**
68
55
69
56
For each single event in the schedule, convert the start and end times to Booking slots by creating an entry in the slots array, including the corresponding date (dates).
70
57
@@ -97,7 +84,7 @@ Booking slot:
97
84
}
98
85
~~~
99
86
100
-
**Rule 2:** Recurring events.
87
+
**Rule 2. Recurring events.**
101
88
102
89
For recurring events, we use a weekly pattern. The start and end dates must be the same for each occurrence, as Booking only supports weekly recurring slots.
103
90
@@ -130,7 +117,7 @@ Booking Slots: In Booking, the weekly schedule is represented as a single rule,
130
117
}
131
118
~~~
132
119
133
-
**Rule 3:** Scheduling an event that spans multiple days.
120
+
**Rule 3. Scheduling an event that spans multiple days.**
134
121
135
122
If an event spans across multiple days (e.g., starts at 8 PM and ends at 4 AM), it should be split into two slots — one for each day.
136
123
@@ -170,7 +157,7 @@ Booking slot:
170
157
}
171
158
~~~
172
159
173
-
**Rule 4:** Additional single events added to recurring events.
160
+
**Rule 4. Additional single events added to recurring events.**
174
161
175
162
In this case, a single event is added to a recurring schedule. The Booking slots are generated for both the recurring and the single events. The single event dates are added to the recurring event's dates array.
176
163
@@ -237,7 +224,7 @@ Booking slots:
237
224
}
238
225
~~~
239
226
240
-
**Rule 5:** Modifying a single instance of an recurring event.
227
+
**Rule 5. Modifying a single instance of an recurring event.**
241
228
242
229
If a single instance of a recurring event is edited (e.g., time change for a specific date), generate a new slot with the updated time and date in the dates array, overriding the days array.
243
230
@@ -286,7 +273,7 @@ Booking slot:
286
273
}
287
274
~~~
288
275
289
-
**Rule 6:** Deleting a single instance of a recurring event
276
+
**Rule 6. Deleting a single instance of a recurring event.**
290
277
291
278
When a single occurrence is removed from a recurring event in Scheduler, we need to update Booking rules to reflect this removal. This is done by creating a special rule for the removed date, using an empty time interval and the dates property (which has higher priority than days).
292
279
@@ -329,7 +316,7 @@ Booking slot:
329
316
}
330
317
~~~
331
318
332
-
**Rule 7:** Events starting later than Booking start date
319
+
**Rule 7. Events starting later than Booking start date.**
333
320
334
321
If a recurring event starts after the Booking start date (default is today), create rules with empty time intervals for the dates prior to the event's start date. This simulates the dates being "removed" from the recurrence.
335
322
@@ -360,16 +347,10 @@ Booking slots:
360
347
}
361
348
~~~
362
349
363
-
**Step 3. Timezone Conversion**
364
-
365
-
Ensure that the timestamps are converted from global time to the local time of the user's timezone before sending them to Booking. This ensures correct slot display in the Booking widget.
366
350
367
351
368
-
## Example
369
352
370
-
The snippet below demonstrates how to convert doctor schedules into booking slots. The doctors' schedules that include recurring and single-time events are fetched from the Scheduler widget via the `/doctors/worktime` URL, while the final booking slots generated from the scheduler data are provided by the `/units` URL. The slots are generated on the server-side. Please, also refer to [backend](https://github.com/DHTMLX/scheduler-booking-go).
0 commit comments