Skip to content

Commit 9b0cccc

Browse files
committed
[update] working with server updated
1 parent 774c2ab commit 9b0cccc

2 files changed

Lines changed: 17 additions & 25 deletions

File tree

docs/guides/loading-data.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ description: You can learn how to load data into Booking in the documentation of
66

77
# Loading data
88

9-
## Preparing data
10-
119
The following information can be loaded into Booking:
1210

1311
- [`data`](/api/config/booking-data) - an array of objects containing cards data
@@ -93,8 +91,6 @@ const data = [
9391
];
9492
~~~
9593

96-
## Loading data
97-
9894
You can load JSON data into Booking from an external file or the server-side script after the component has been initialized.
9995

10096
To load local data from a separate file, first prepare the source file with data.
@@ -163,22 +159,9 @@ const { data } = getData();
163159
const booking = new booking.Booking("#root", { data });
164160
~~~
165161

166-
To get server data, you can send the request for data using the native **fetch** method (or any other way):
162+
About loading data from the server, refer to [Working with server](/guides/saving-reservations)
167163

168-
~~~jsx {}
169-
const booking = new booking.Booking("#booking", {data: []});
170-
const server = "https://some-backend-url";
171-
172-
fetch(server + "/data").then((res) => res.json()).then((data) => {
173-
booking.setConfig({data});
174-
});
175-
~~~
176-
177-
## Example
178-
179-
The snippet below shows how to save slots reservations to the server:
180-
181-
<iframe src="https://snippet.dhtmlx.com/dpbmyr8j?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
164+
---
182165

183166
**Related articles**:
184167
- [confirm-slot](/api/events/booking-confirmslot-event) event

docs/guides/saving-reservations.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ description: You can learn about working with server in the documentation of the
66

77
# Working with server
88

9-
About loading data from the server see here: [Loading data](/guides/loading-data#loading-data-1).
9+
## Loading data
10+
11+
To get server data, you can send the request for data using the native **fetch** method (or any other way):
12+
13+
~~~jsx {}
14+
const booking = new booking.Booking("#booking", {data: []});
15+
const server = "https://some-backend-url";
16+
17+
fetch(server + "/data").then((res) => res.json()).then((data) => {
18+
booking.setConfig({data});
19+
});
20+
~~~
1021

1122
## Saving slots reservations to the server
1223

@@ -53,13 +64,11 @@ fetch("/server/url")
5364
});
5465
~~~
5566

56-
## Converting timestamps
57-
58-
In case the widget is applied in different timezones, you can convert timestamps when loading data and sending data to the server.
67+
## Working with UTC data
5968

60-
The next example demonstrates how to convert a UTC timestamp into the local timezone during the loading process and how to convert the local time back to UTC when sending data to the server.
69+
The widget applies a local timezone but if you have UTC data it's necessary to convert data to a local timezone.
6170

62-
In the example below, the **g2l** function converts a UTC timestamp into the local timezone. During the data loading process, this function is used to convert the times in *usedSlots* and *slots* from UTC to the local time. The **l2g** function converts a local time back to UTC. It's applied during slots reservation, namely, the **l2g** function is used to convert the local time (from slot.time[0]) to UTC before sending it to the server.
71+
For example, if you have UTC timestamps, you can apply the functions provided in the example below to convert them. The **g2l** function converts a UTC timestamp into the local timezone. During the data loading process, this function is used to convert the times in *usedSlots* and *slots* from UTC to the local time. The **l2g** function converts a local time back to UTC. It's applied during slots reservation, namely, the **l2g** function is used to convert the local time (from slot.time[0]) to UTC before sending it to the server.
6372

6473
~~~jsx
6574
const serverURL = "https://some-backend-url";

0 commit comments

Comments
 (0)