@timum/booking 0.7.1 → 0.7.3
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/README.md +92 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,34 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
## Content
|
|
4
4
|
|
|
5
|
-
- [
|
|
6
|
-
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
5
|
+
- [Features](#features)
|
|
6
|
+
- [Basic Usage](#basic_usage)
|
|
7
|
+
- [In a Script Tag](#in_a_script_tag)
|
|
8
|
+
- [As ESM import](#as_esm_import)
|
|
9
|
+
- [Advanced Usage](#advanced_usage)
|
|
10
|
+
- [muiTheme](#mui_theme)
|
|
11
|
+
- [fcConfig](#fc_config)
|
|
12
|
+
- [appConfig](#app_config)
|
|
13
|
+
- [How to use Callbacks](#how_to_use_callbacks)
|
|
14
|
+
- [Booking Related](#booking_related)
|
|
15
|
+
- [Cancelation Related](#cancelation_related)
|
|
16
|
+
- [Data Fetching Related](#data_fetching_related)
|
|
16
17
|
- [Localisation](#localisation)
|
|
17
|
-
- [How to Define Fields](#
|
|
18
|
-
- [Anatomy of a Field](#
|
|
19
|
-
- [An Example](#
|
|
20
|
-
- [The Scenario](#
|
|
21
|
-
- [The Implementation](#
|
|
18
|
+
- [How to Define Fields](#how_to_define_fields)
|
|
19
|
+
- [Anatomy of a Field](#anatomy_of_a_field)
|
|
20
|
+
- [An Example](#an_example)
|
|
21
|
+
- [The Scenario](#the_scenario)
|
|
22
|
+
- [The Implementation](#the_implementation)
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
<a name=”features”></a>
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Direct booking or appointment requests for public appointments
|
|
29
|
+
- Approval required for requested appointments
|
|
30
|
+
- Option to show/hide fully booked appointments
|
|
31
|
+
- Option to prevent booking if appointment is too close to current time
|
|
32
|
+
- Customer ability to cancel appointments with proper authentication
|
|
33
|
+
- Customizable wording across languages
|
|
34
|
+
- Support for multiple languages (English and German included)
|
|
35
|
+
- Callbacks for custom code execution and event response (e.g. booking created, appointments loaded, booking canceled)
|
|
36
|
+
- Customizable look and feel with mui theming (available with professional plan)
|
|
37
|
+
- Dynamic definition of input fields with localized labels and validation
|
|
38
|
+
- Therefore, ability to request additional information from customers during booking process
|
|
39
|
+
|
|
40
|
+
<a name=”basic_usage”></a>
|
|
41
|
+
|
|
42
|
+
## Basic Usage
|
|
43
|
+
|
|
44
|
+
<a name=”in_a_script_tag”></a>
|
|
45
|
+
|
|
46
|
+
### In a Script Tag
|
|
26
47
|
|
|
27
48
|
Add the following code to your webpage:
|
|
28
49
|
|
|
29
50
|
```html
|
|
30
51
|
<div id="bookingjs" style="margin: 32px"></div>
|
|
31
52
|
<script type="module">
|
|
32
|
-
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.
|
|
53
|
+
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.3/build/timum-booking.js';
|
|
33
54
|
|
|
34
55
|
timum.init({ ref: 'booking-widget-demo-resource@timum' });
|
|
35
56
|
</script>
|
|
@@ -44,13 +65,15 @@ Alternatively, you can add `ref` to your url as a parameter. This allows you to
|
|
|
44
65
|
```html
|
|
45
66
|
<div id="bookingjs" style="margin: 32px"></div>
|
|
46
67
|
<script type="module">
|
|
47
|
-
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.
|
|
68
|
+
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.3/build/timum-booking.js';
|
|
48
69
|
|
|
49
70
|
timum.init(); //<- no need for the reference here
|
|
50
71
|
</script>
|
|
51
72
|
```
|
|
52
73
|
|
|
53
|
-
|
|
74
|
+
<a name=”as_esm_import”></a>
|
|
75
|
+
|
|
76
|
+
### As ESM import
|
|
54
77
|
|
|
55
78
|
1. Add timum-booking to your project with
|
|
56
79
|
`yarn add @timum/booking`
|
|
@@ -71,7 +94,9 @@ A example project can be found [here](https://stackblitz.com/edit/react-8q6r8b?f
|
|
|
71
94
|
|
|
72
95
|
---
|
|
73
96
|
|
|
74
|
-
|
|
97
|
+
<a name=”advanced_usage”></a>
|
|
98
|
+
|
|
99
|
+
## Advanced usage
|
|
75
100
|
|
|
76
101
|
timum booking has a lot of customisation options.
|
|
77
102
|
|
|
@@ -84,21 +109,27 @@ The following table gives a rough overview over each.
|
|
|
84
109
|
| muiTheme | object, mui theme allowing you to change the look and feel of timum. Requires a professional plan. |
|
|
85
110
|
| fcConfig | object, only used if you use full calendar as a booking frontend (settable in appConfig). |
|
|
86
111
|
|
|
87
|
-
|
|
112
|
+
<a name=”mui_theme”></a>
|
|
113
|
+
|
|
114
|
+
### muiTheme
|
|
88
115
|
|
|
89
116
|
timum uses mui components for all frontends. The muiTheme object allows global design changes.
|
|
90
117
|
See [here](https://mui.com/) for a general overview. <br> See [here](https://mui.com/material-ui/customization/default-theme/) for theme related documentation.
|
|
91
118
|
|
|
92
119
|
When you open the file `config.js` in [this](https://stackblitz.com/edit/react-8q6r8b?file=src/index.js) example, you can find an elaborate custom configuration which includes a redesign of the standard timum theme.
|
|
93
120
|
|
|
94
|
-
|
|
121
|
+
<a name=”fc_config”></a>
|
|
122
|
+
|
|
123
|
+
### fcConfig
|
|
95
124
|
|
|
96
125
|
FullCalendar can be set as one of the frontends in appConfig.
|
|
97
126
|
See [here](https://fullcalendar.io/docs#toc) for a full list of configuration options.
|
|
98
127
|
|
|
99
128
|
> Note that since fullCalendar isn't mui based, it does not consider the muiTheme object.
|
|
100
129
|
|
|
101
|
-
|
|
130
|
+
<a name=”app_config”></a>
|
|
131
|
+
|
|
132
|
+
### appConfig
|
|
102
133
|
|
|
103
134
|
This object's options directly affect timum's behaviour or allow you to react to it.
|
|
104
135
|
|
|
@@ -109,7 +140,8 @@ This object's options directly affect timum's behaviour or allow you to react to
|
|
|
109
140
|
</tr>
|
|
110
141
|
<tr>
|
|
111
142
|
<td>ref</td>
|
|
112
|
-
<td>string, Reference of the resource to show the appointments of. <br><em> This is the only prop that is mandatory.</em><br> Everything else is optional. <br>Can also be a url parameter
|
|
143
|
+
<td>string, Reference of the resource to show the appointments of. <br><em> This is the only prop that is mandatory.</em><br> Everything else is optional. <br>Can also be a url parameter.
|
|
144
|
+
</td>
|
|
113
145
|
</tr>
|
|
114
146
|
<tr>
|
|
115
147
|
<td>height</td>
|
|
@@ -151,11 +183,15 @@ This object's options directly affect timum's behaviour or allow you to react to
|
|
|
151
183
|
</tr>
|
|
152
184
|
</table>
|
|
153
185
|
|
|
154
|
-
|
|
186
|
+
<a name=”how_to_use_callbacks”></a>
|
|
187
|
+
|
|
188
|
+
#### How to use callbacks
|
|
155
189
|
|
|
156
190
|
The callbacks object may contain any of the following functions.
|
|
157
191
|
|
|
158
|
-
|
|
192
|
+
<a name=”booking_related”></a>
|
|
193
|
+
|
|
194
|
+
##### Booking related
|
|
159
195
|
|
|
160
196
|
- `createBookingStarted`
|
|
161
197
|
- `createBookingSuccessfull`
|
|
@@ -196,7 +232,9 @@ All Booking related callbacks receive a <em>single obejct</em> as argument conta
|
|
|
196
232
|
|
|
197
233
|
Additionally, `createBookingFailed` and `createBookingSuccessfull` also have a RTKQ `response` object in their respecive argument. See [here](https://redux-toolkit.js.org/rtk-query/usage-with-typescript#type-safe-error-handling) for a reference.
|
|
198
234
|
|
|
199
|
-
|
|
235
|
+
<a name=”cancelation_related”></a>
|
|
236
|
+
|
|
237
|
+
##### Cancelation Related
|
|
200
238
|
|
|
201
239
|
- `cancelationStarted`
|
|
202
240
|
- `cancelationSuccessful`
|
|
@@ -206,7 +244,9 @@ All cancelation related callbacks receive a single obejct as argument containing
|
|
|
206
244
|
|
|
207
245
|
Additionally, `cancelationSuccessful` and `cancelationFailed` also have a RTKQ response object in their respecive argument. See here for a reference.
|
|
208
246
|
|
|
209
|
-
|
|
247
|
+
<a name=”data_fetching_related”></a>
|
|
248
|
+
|
|
249
|
+
##### Data Fetching Related
|
|
210
250
|
|
|
211
251
|
In order to display public appointments, resource and calendar information timum sends several requests.
|
|
212
252
|
|
|
@@ -283,7 +323,9 @@ In order to display public appointments, resource and calendar information timum
|
|
|
283
323
|
receives a single RTKQ error object. See [here](https://redux-toolkit.js.org/rtk-query/usage-with-typescript#type-safe-error-handling) for a reference.
|
|
284
324
|
<br>
|
|
285
325
|
|
|
286
|
-
|
|
326
|
+
<a name=”localisation”></a>
|
|
327
|
+
|
|
328
|
+
#### Localisation
|
|
287
329
|
|
|
288
330
|
timum booking has the ability to change all of its text. It comes with English and German pre-installed, but you can add additional translations as well. You can also change the text for these languages to your preference. You don't have to redefine the entire localization object; you can just add or change the specific texts you want. Any missing texts will be taken from the default.
|
|
289
331
|
The code snippet provided shows the complete localization object and the standard text for both English and German. For each language, it includes text for different parts of the booking process such as product selection, appointment booking, appointment request, appointment cancellation, form fields, and more.
|
|
@@ -393,7 +435,9 @@ localization: {
|
|
|
393
435
|
},
|
|
394
436
|
```
|
|
395
437
|
|
|
396
|
-
|
|
438
|
+
<a name=”how_to_define_fields”></a>
|
|
439
|
+
|
|
440
|
+
#### How to define fields
|
|
397
441
|
|
|
398
442
|
You can customize the information required from customers before booking by defining fields. The minimum required fields for timum are firstName, lastName, email, and agbs. By default, timum also requests mobile and message fields, but you can add your own fields as well.
|
|
399
443
|
|
|
@@ -454,7 +498,9 @@ The standard configuration can be overridden except for the aforementioned field
|
|
|
454
498
|
},
|
|
455
499
|
```
|
|
456
500
|
|
|
457
|
-
|
|
501
|
+
<a name=”anatomy_of_a_field”></a>
|
|
502
|
+
|
|
503
|
+
##### Anatomy of a field
|
|
458
504
|
|
|
459
505
|
```
|
|
460
506
|
<fieldName> : {
|
|
@@ -489,25 +535,31 @@ Type `select`:
|
|
|
489
535
|
|
|
490
536
|
- options: array of objects with structure { title: string, key: string }. The title is displayed and the key is passed in the data object to callbacks.
|
|
491
537
|
|
|
492
|
-
|
|
538
|
+
<a name=”an_example”></a>
|
|
539
|
+
|
|
540
|
+
### An Example
|
|
493
541
|
|
|
494
542
|
Here is an example Tying all of the aforementioned concepts together.
|
|
495
543
|
|
|
496
|
-
|
|
544
|
+
<a name=”the_scenario”></a>
|
|
545
|
+
|
|
546
|
+
#### The Scenario
|
|
497
547
|
|
|
498
548
|
For whatever reason it is important to know the gender of customers.
|
|
499
549
|
On the other side the optional fields `mobile` and `message` aren't important for you and you wish to remove them.
|
|
500
550
|
This new gender field must be filled, therefore a validation is required.
|
|
501
551
|
Both the title of the field and it's validations must be localized.
|
|
502
552
|
|
|
503
|
-
|
|
553
|
+
<a name=”the_implementation”></a>
|
|
554
|
+
|
|
555
|
+
#### The Implementation
|
|
504
556
|
|
|
505
557
|
This is the base configuration. As it is it uses the standard field configuration shown in [How to define fields](#howToDefineFields).
|
|
506
558
|
|
|
507
559
|
```html
|
|
508
560
|
<div id="bookingjs" style="margin: 32px"></div>
|
|
509
561
|
<script type="module">
|
|
510
|
-
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.
|
|
562
|
+
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.3/build/timum-booking.js';
|
|
511
563
|
|
|
512
564
|
timum.init({ ref: 'booking-widget-demo-resource@timum' });
|
|
513
565
|
</script>
|
|
@@ -518,7 +570,7 @@ Let's add the necessary changes:
|
|
|
518
570
|
```html
|
|
519
571
|
<div id="bookingjs" style="margin: 32px"></div>
|
|
520
572
|
<script type="module">
|
|
521
|
-
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.
|
|
573
|
+
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.3/build/timum-booking.js';
|
|
522
574
|
|
|
523
575
|
timum.init(
|
|
524
576
|
{
|
|
@@ -609,7 +661,8 @@ Let's add the necessary changes:
|
|
|
609
661
|
}
|
|
610
662
|
}
|
|
611
663
|
|
|
612
|
-
// the following callback consumes the customers input, allowing you to act on
|
|
664
|
+
// the following callback consumes the customers input, allowing you to act on
|
|
665
|
+
//the entered gender value.
|
|
613
666
|
callback: {
|
|
614
667
|
createBookingStarted: ({data}) => {
|
|
615
668
|
console.log(data.gender);
|