@timum/booking 0.7.1 → 0.7.2
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 +74 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Content
|
|
4
4
|
|
|
5
|
+
- [Features](#features)
|
|
5
6
|
- [Basic Usage](#basicUsage)
|
|
6
7
|
- [In a Script Tag](#inAScriptTag)
|
|
7
8
|
- [As ESM import](#asEsmImport)
|
|
@@ -20,16 +21,36 @@
|
|
|
20
21
|
- [The Scenario](#theScenario)
|
|
21
22
|
- [The Implementation](#theImplementation)
|
|
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=”basicUsage”></a>
|
|
41
|
+
|
|
42
|
+
## Basic Usage
|
|
43
|
+
|
|
44
|
+
<a name=”inAScriptTag”></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.2/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.2/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=”asEsmImport”></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=”advancedUsage”></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=”muiTheme”></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=”fcConfig”></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=”appConfig”></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=”howToUseCallbacks”></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=”bookingRelated”></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=”cancelationRelated”></a>
|
|
236
|
+
|
|
237
|
+
##### Cancelation Related {#cancelationRelated}
|
|
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=”dataFetchingRelated”></a>
|
|
248
|
+
|
|
249
|
+
##### Data Fetching Related {#dataFetchingRelated}
|
|
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,7 @@ localization: {
|
|
|
393
435
|
},
|
|
394
436
|
```
|
|
395
437
|
|
|
396
|
-
|
|
438
|
+
#### How to define fields {#howToDefineFields}
|
|
397
439
|
|
|
398
440
|
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
441
|
|
|
@@ -454,7 +496,9 @@ The standard configuration can be overridden except for the aforementioned field
|
|
|
454
496
|
},
|
|
455
497
|
```
|
|
456
498
|
|
|
457
|
-
|
|
499
|
+
<a name=”anatomyOfAField”></a>
|
|
500
|
+
|
|
501
|
+
##### Anatomy of a field
|
|
458
502
|
|
|
459
503
|
```
|
|
460
504
|
<fieldName> : {
|
|
@@ -489,25 +533,31 @@ Type `select`:
|
|
|
489
533
|
|
|
490
534
|
- 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
535
|
|
|
492
|
-
|
|
536
|
+
<a name=”anExample”></a>
|
|
537
|
+
|
|
538
|
+
### An Example {#anExample}
|
|
493
539
|
|
|
494
540
|
Here is an example Tying all of the aforementioned concepts together.
|
|
495
541
|
|
|
496
|
-
|
|
542
|
+
<a name=”theScenario”></a>
|
|
543
|
+
|
|
544
|
+
#### The Scenario {#theScenario}
|
|
497
545
|
|
|
498
546
|
For whatever reason it is important to know the gender of customers.
|
|
499
547
|
On the other side the optional fields `mobile` and `message` aren't important for you and you wish to remove them.
|
|
500
548
|
This new gender field must be filled, therefore a validation is required.
|
|
501
549
|
Both the title of the field and it's validations must be localized.
|
|
502
550
|
|
|
503
|
-
|
|
551
|
+
<a name=”theImplementation”></a>
|
|
552
|
+
|
|
553
|
+
#### The Implementation {#theImplementation}
|
|
504
554
|
|
|
505
555
|
This is the base configuration. As it is it uses the standard field configuration shown in [How to define fields](#howToDefineFields).
|
|
506
556
|
|
|
507
557
|
```html
|
|
508
558
|
<div id="bookingjs" style="margin: 32px"></div>
|
|
509
559
|
<script type="module">
|
|
510
|
-
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.
|
|
560
|
+
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.2/build/timum-booking.js';
|
|
511
561
|
|
|
512
562
|
timum.init({ ref: 'booking-widget-demo-resource@timum' });
|
|
513
563
|
</script>
|
|
@@ -518,7 +568,7 @@ Let's add the necessary changes:
|
|
|
518
568
|
```html
|
|
519
569
|
<div id="bookingjs" style="margin: 32px"></div>
|
|
520
570
|
<script type="module">
|
|
521
|
-
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.
|
|
571
|
+
import * as timum from 'https://cdn.jsdelivr.net/npm/@timum/booking@0.7.2/build/timum-booking.js';
|
|
522
572
|
|
|
523
573
|
timum.init(
|
|
524
574
|
{
|
|
@@ -609,7 +659,8 @@ Let's add the necessary changes:
|
|
|
609
659
|
}
|
|
610
660
|
}
|
|
611
661
|
|
|
612
|
-
// the following callback consumes the customers input, allowing you to act on
|
|
662
|
+
// the following callback consumes the customers input, allowing you to act on
|
|
663
|
+
//the entered gender value.
|
|
613
664
|
callback: {
|
|
614
665
|
createBookingStarted: ({data}) => {
|
|
615
666
|
console.log(data.gender);
|