@blazeo.com/appointment-client 1.0.13 → 1.0.14
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/blazeo.com-appointment-client-1.0.14.tgz +0 -0
- package/package.json +3 -2
- package/sample/src/EventTab.jsx +435 -395
- package/src/calendar/calendarCreation.ts +62 -15
- package/src/events/getAppointmentsByFilter.ts +98 -0
- package/src/index.ts +15 -4
- package/blazeo.com-appointment-client-1.0.11.tgz +0 -0
- package/blazeo.com-appointment-client-1.0.13.tgz +0 -0
- package/dist/calendar/blazeoCalendarRelationMethods.d.ts +0 -8
- package/dist/calendar/blazeoCalendarRelationMethods.d.ts.map +0 -1
- package/dist/calendar/blazeoCalendarRelationMethods.js +0 -16
- package/dist/calendar/blazeoCalendarRelationMethods.js.map +0 -1
- package/dist/calendar/buildUnifiedCalendarView.d.ts +0 -39
- package/dist/calendar/buildUnifiedCalendarView.js +0 -301
- package/dist/calendar/calendarCreation.d.ts +0 -27
- package/dist/calendar/calendarCreation.js +0 -191
- package/dist/calendar/calendarCreationFacade.d.ts +0 -27
- package/dist/calendar/calendarCreationFacade.d.ts.map +0 -1
- package/dist/calendar/calendarCreationFacade.js +0 -167
- package/dist/calendar/calendarCreationFacade.js.map +0 -1
- package/dist/calendar/createCalendar.d.ts +0 -81
- package/dist/calendar/createCalendar.d.ts.map +0 -1
- package/dist/calendar/createCalendar.js +0 -206
- package/dist/calendar/createCalendar.js.map +0 -1
- package/dist/calendar/fetchCalendarDetails.d.ts +0 -41
- package/dist/calendar/fetchCalendarDetails.js +0 -265
- package/dist/calendar/fetchCalendarWithOpeningHours.d.ts +0 -25
- package/dist/calendar/fetchCalendarWithOpeningHours.js +0 -114
- package/dist/calendar/getAllParticipantOpeningHours.d.ts +0 -22
- package/dist/calendar/getAllParticipantOpeningHours.js +0 -22
- package/dist/calendar/getCalendarsByCompany.d.ts +0 -9
- package/dist/calendar/getCalendarsByCompany.js +0 -62
- package/dist/calendar/getOpeningHours.d.ts +0 -8
- package/dist/calendar/getOpeningHours.js +0 -9
- package/dist/calendar/getParticipantOpeningHours.d.ts +0 -37
- package/dist/calendar/getParticipantOpeningHours.js +0 -48
- package/dist/calendar/getParticipants.d.ts +0 -7
- package/dist/calendar/getParticipants.js +0 -13
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.d.ts +0 -10
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.d.ts.map +0 -1
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.js +0 -44
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.js.map +0 -1
- package/dist/calendar/mapCalendarToBlazeoSnapshot.d.ts +0 -29
- package/dist/calendar/mapCalendarToBlazeoSnapshot.d.ts.map +0 -1
- package/dist/calendar/mapCalendarToBlazeoSnapshot.js +0 -44
- package/dist/calendar/mapCalendarToBlazeoSnapshot.js.map +0 -1
- package/dist/calendar/mapToDesiredResponse.d.ts +0 -56
- package/dist/calendar/mapToDesiredResponse.js +0 -111
- package/dist/config/applyBlazeoClientConfig.d.ts +0 -3
- package/dist/config/applyBlazeoClientConfig.d.ts.map +0 -1
- package/dist/config/applyBlazeoClientConfig.js +0 -14
- package/dist/config/applyBlazeoClientConfig.js.map +0 -1
- package/dist/config/applyBlazeoDefaults.d.ts +0 -2
- package/dist/config/applyBlazeoDefaults.d.ts.map +0 -1
- package/dist/config/applyBlazeoDefaults.js +0 -14
- package/dist/config/applyBlazeoDefaults.js.map +0 -1
- package/dist/config/blazeo.config.d.ts +0 -11
- package/dist/config/blazeo.config.d.ts.map +0 -1
- package/dist/config/blazeo.config.js +0 -11
- package/dist/config/blazeo.config.js.map +0 -1
- package/dist/config/blazeoClientDefaults.d.ts +0 -11
- package/dist/config/blazeoClientDefaults.d.ts.map +0 -1
- package/dist/config/blazeoClientDefaults.js +0 -11
- package/dist/config/blazeoClientDefaults.js.map +0 -1
- package/dist/config/ensureBlazeoHttpReady.d.ts +0 -17
- package/dist/config/ensureBlazeoHttpReady.js +0 -31
- package/dist/config/initializeAppointmentClient.d.ts +0 -11
- package/dist/config/initializeAppointmentClient.d.ts.map +0 -1
- package/dist/config/initializeAppointmentClient.js +0 -15
- package/dist/config/initializeAppointmentClient.js.map +0 -1
- package/dist/config/syncBlazeoConnection.d.ts +0 -6
- package/dist/config/syncBlazeoConnection.js +0 -18
- package/dist/events/appointmentEventFacade.d.ts +0 -67
- package/dist/events/appointmentEventFacade.d.ts.map +0 -1
- package/dist/events/appointmentEventFacade.js +0 -124
- package/dist/events/appointmentEventFacade.js.map +0 -1
- package/dist/events/mapAppointmentToEventSnapshot.d.ts +0 -5
- package/dist/events/mapAppointmentToEventSnapshot.d.ts.map +0 -1
- package/dist/events/mapAppointmentToEventSnapshot.js +0 -57
- package/dist/events/mapAppointmentToEventSnapshot.js.map +0 -1
- package/dist/exampleData.d.ts +0 -119
- package/dist/exampleData.d.ts.map +0 -1
- package/dist/exampleData.js +0 -71
- package/dist/exampleData.js.map +0 -1
- package/dist/facade/calendarCreationFacade.d.ts +0 -40
- package/dist/facade/calendarCreationFacade.d.ts.map +0 -1
- package/dist/facade/calendarCreationFacade.js +0 -96
- package/dist/facade/calendarCreationFacade.js.map +0 -1
- package/dist/facade/mapCalendarBOToSnapshot.d.ts +0 -10
- package/dist/facade/mapCalendarBOToSnapshot.d.ts.map +0 -1
- package/dist/facade/mapCalendarBOToSnapshot.js +0 -44
- package/dist/facade/mapCalendarBOToSnapshot.js.map +0 -1
- package/dist/facades/index.d.ts +0 -12
- package/dist/facades/index.d.ts.map +0 -1
- package/dist/facades/index.js +0 -12
- package/dist/facades/index.js.map +0 -1
- package/dist/index.d.ts +0 -79
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -39
- package/dist/index.js.map +0 -1
- package/dist/lead/fetchLeadDetails.d.ts +0 -56
- package/dist/lead/fetchLeadDetails.js +0 -61
- package/dist/models/CalendarRootModel.d.ts +0 -56
- package/dist/models/CalendarRootModel.d.ts.map +0 -1
- package/dist/models/CalendarRootModel.js +0 -54
- package/dist/models/CalendarRootModel.js.map +0 -1
- package/dist/models/CalendarSlotModel.d.ts +0 -9
- package/dist/models/CalendarSlotModel.d.ts.map +0 -1
- package/dist/models/CalendarSlotModel.js +0 -8
- package/dist/models/CalendarSlotModel.js.map +0 -1
- package/dist/models/EventModel.d.ts +0 -11
- package/dist/models/EventModel.d.ts.map +0 -1
- package/dist/models/EventModel.js +0 -10
- package/dist/models/EventModel.js.map +0 -1
- package/dist/models/ParticipantModel.d.ts +0 -9
- package/dist/models/ParticipantModel.d.ts.map +0 -1
- package/dist/models/ParticipantModel.js +0 -8
- package/dist/models/ParticipantModel.js.map +0 -1
- package/dist/models/index.d.ts +0 -5
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -5
- package/dist/models/index.js.map +0 -1
- package/dist/types/appointment.d.ts +0 -28
- package/dist/types/appointment.d.ts.map +0 -1
- package/dist/types/appointment.js +0 -6
- package/dist/types/appointment.js.map +0 -1
- package/dist/types/calendar.d.ts +0 -52
- package/dist/types/calendar.d.ts.map +0 -1
- package/dist/types/calendar.js +0 -6
- package/dist/types/calendar.js.map +0 -1
- package/dist/types/calendarBo.d.ts +0 -62
- package/dist/types/calendarBo.d.ts.map +0 -1
- package/dist/types/calendarBo.js +0 -6
- package/dist/types/calendarBo.js.map +0 -1
- package/sample/package-lock.json +0 -1778
package/sample/src/EventTab.jsx
CHANGED
|
@@ -1,395 +1,435 @@
|
|
|
1
|
-
import { useMemo, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
cancelAppointmentEventAsync,
|
|
4
|
-
createAppointmentEventAsync,
|
|
5
|
-
ensureBlazeoHttpReady,
|
|
6
|
-
EventModel,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
start
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
start
|
|
39
|
-
start.
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (result
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
const [
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const [
|
|
90
|
-
const [
|
|
91
|
-
|
|
92
|
-
d
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const [
|
|
119
|
-
const [
|
|
120
|
-
const [
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (!
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (!
|
|
220
|
-
if (!
|
|
221
|
-
if (!
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
<
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
cancelAppointmentEventAsync,
|
|
4
|
+
createAppointmentEventAsync,
|
|
5
|
+
ensureBlazeoHttpReady,
|
|
6
|
+
EventModel,
|
|
7
|
+
getAppointmentsByFilter,
|
|
8
|
+
rescheduleAppointmentEventAsync,
|
|
9
|
+
} from "appointment-client";
|
|
10
|
+
import { getSnapshot, isStateTreeNode } from "mobx-state-tree";
|
|
11
|
+
import {
|
|
12
|
+
configureBlazeoFromEffective,
|
|
13
|
+
useBlazeoConnection,
|
|
14
|
+
} from "./BlazeoConnectionSettings.jsx";
|
|
15
|
+
import { mapBlazeoDemoError } from "./blazeoDemoError.js";
|
|
16
|
+
|
|
17
|
+
function getExampleCreatePayload() {
|
|
18
|
+
const start = new Date();
|
|
19
|
+
start.setHours(10, 0, 0, 0);
|
|
20
|
+
const end = new Date(start);
|
|
21
|
+
end.setHours(10, 30, 0, 0);
|
|
22
|
+
return {
|
|
23
|
+
thirdPartyCalendarId: "your-calendar-id",
|
|
24
|
+
participantId: "00000000-0000-0000-0000-000000000000",
|
|
25
|
+
title: "Sample appointment",
|
|
26
|
+
description: "Created via appointment-client sample",
|
|
27
|
+
startDate: start.toISOString(),
|
|
28
|
+
endDate: end.toISOString(),
|
|
29
|
+
email: "visitor@example.com",
|
|
30
|
+
visitorName: "Visitor",
|
|
31
|
+
timeZone: "Pakistan Standard Time",
|
|
32
|
+
rescheduleUrl: "https://example.com/reschedule",
|
|
33
|
+
cancelUrl: "https://example.com/cancel",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getExampleReschedulePayload() {
|
|
38
|
+
const start = new Date();
|
|
39
|
+
start.setDate(start.getDate() + 1);
|
|
40
|
+
start.setHours(14, 0, 0, 0);
|
|
41
|
+
const end = new Date(start);
|
|
42
|
+
end.setHours(14, 45, 0, 0);
|
|
43
|
+
return {
|
|
44
|
+
thirdPartyAppointmentId: "existing-blazeo-event-id",
|
|
45
|
+
thirdPartyCalendarId: "your-calendar-id",
|
|
46
|
+
participantId: "00000000-0000-0000-0000-000000000000",
|
|
47
|
+
title: "Rescheduled title",
|
|
48
|
+
notes: "Reschedule body",
|
|
49
|
+
startDate: start.toISOString(),
|
|
50
|
+
endDate: end.toISOString(),
|
|
51
|
+
email: "visitor@example.com",
|
|
52
|
+
timeZone: "Pakistan Standard Time",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resultToJson(result) {
|
|
57
|
+
if (!result) return "";
|
|
58
|
+
if (result.ok && result.event && isStateTreeNode(result.event)) {
|
|
59
|
+
return JSON.stringify(
|
|
60
|
+
{
|
|
61
|
+
ok: true,
|
|
62
|
+
eventSnapshot: getSnapshot(result.event),
|
|
63
|
+
apiResponse: result.apiResponse ?? null,
|
|
64
|
+
},
|
|
65
|
+
null,
|
|
66
|
+
2
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return JSON.stringify(result, null, 2);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function safeJsonParse(text, fallback) {
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(text);
|
|
75
|
+
} catch {
|
|
76
|
+
return fallback;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function EventTab() {
|
|
81
|
+
const { effective, connectionOpts } = useBlazeoConnection();
|
|
82
|
+
const [offsetMinutes, setOffsetMinutes] = useState(-new Date().getTimezoneOffset());
|
|
83
|
+
const [createJson, setCreateJson] = useState(() =>
|
|
84
|
+
JSON.stringify(getExampleCreatePayload(), null, 2)
|
|
85
|
+
);
|
|
86
|
+
const [rescheduleJson, setRescheduleJson] = useState(() =>
|
|
87
|
+
JSON.stringify(getExampleReschedulePayload(), null, 2)
|
|
88
|
+
);
|
|
89
|
+
const [searchCompanyKey, setSearchCompanyKey] = useState("");
|
|
90
|
+
const [searchFrom, setSearchFrom] = useState(() => new Date().toISOString().slice(0, 10));
|
|
91
|
+
const [searchTo, setSearchTo] = useState(() => {
|
|
92
|
+
const d = new Date();
|
|
93
|
+
d.setDate(d.getDate() + 7);
|
|
94
|
+
return d.toISOString().slice(0, 10);
|
|
95
|
+
});
|
|
96
|
+
const [searchFiltersJson, setSearchFiltersJson] = useState(() =>
|
|
97
|
+
JSON.stringify(
|
|
98
|
+
{
|
|
99
|
+
calendarId: "",
|
|
100
|
+
participantId: "",
|
|
101
|
+
leadId: "",
|
|
102
|
+
visitorName: "",
|
|
103
|
+
visitorEmail: "",
|
|
104
|
+
visitorPhone: "",
|
|
105
|
+
title: "",
|
|
106
|
+
search: "",
|
|
107
|
+
attendeeStatus: "",
|
|
108
|
+
eventSource: "",
|
|
109
|
+
sort: "",
|
|
110
|
+
sortOrder: "desc",
|
|
111
|
+
page: 1,
|
|
112
|
+
page_size: 25,
|
|
113
|
+
},
|
|
114
|
+
null,
|
|
115
|
+
2
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
const [cancelEventId, setCancelEventId] = useState("");
|
|
119
|
+
const [busy, setBusy] = useState(false);
|
|
120
|
+
const [error, setError] = useState("");
|
|
121
|
+
const [output, setOutput] = useState("");
|
|
122
|
+
|
|
123
|
+
const opts = useMemo(() => ({ offsetMinutes: Number(offsetMinutes) || 0 }), [offsetMinutes]);
|
|
124
|
+
const eventOpts = useMemo(() => ({ ...opts, ...connectionOpts }), [opts, connectionOpts]);
|
|
125
|
+
|
|
126
|
+
function ensureBase() {
|
|
127
|
+
if (!effective.baseUrl) {
|
|
128
|
+
setError("Set Base URL in the connection card above.");
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function handleCreate(e) {
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
setError("");
|
|
137
|
+
setOutput("");
|
|
138
|
+
if (!ensureBase()) return;
|
|
139
|
+
configureBlazeoFromEffective(effective);
|
|
140
|
+
ensureBlazeoHttpReady({
|
|
141
|
+
baseUrl: effective.baseUrl,
|
|
142
|
+
...(effective.consumer ? { consumer: effective.consumer } : {}),
|
|
143
|
+
});
|
|
144
|
+
let payload;
|
|
145
|
+
try {
|
|
146
|
+
payload = JSON.parse(createJson);
|
|
147
|
+
} catch (err) {
|
|
148
|
+
setError(`Create JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
setBusy(true);
|
|
152
|
+
try {
|
|
153
|
+
const result = await createAppointmentEventAsync(payload, eventOpts);
|
|
154
|
+
setOutput(resultToJson(result));
|
|
155
|
+
if (!result.ok) setError(mapBlazeoDemoError(result.error));
|
|
156
|
+
} finally {
|
|
157
|
+
setBusy(false);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function handleReschedule(e) {
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
setError("");
|
|
164
|
+
setOutput("");
|
|
165
|
+
if (!ensureBase()) return;
|
|
166
|
+
configureBlazeoFromEffective(effective);
|
|
167
|
+
ensureBlazeoHttpReady({
|
|
168
|
+
baseUrl: effective.baseUrl,
|
|
169
|
+
...(effective.consumer ? { consumer: effective.consumer } : {}),
|
|
170
|
+
});
|
|
171
|
+
let payload;
|
|
172
|
+
try {
|
|
173
|
+
payload = JSON.parse(rescheduleJson);
|
|
174
|
+
} catch (err) {
|
|
175
|
+
setError(`Reschedule JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setBusy(true);
|
|
179
|
+
try {
|
|
180
|
+
const result = await rescheduleAppointmentEventAsync(payload, eventOpts);
|
|
181
|
+
setOutput(resultToJson(result));
|
|
182
|
+
if (!result.ok) setError(mapBlazeoDemoError(result.error));
|
|
183
|
+
} finally {
|
|
184
|
+
setBusy(false);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function handleCancel(e) {
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
setError("");
|
|
191
|
+
setOutput("");
|
|
192
|
+
const id = cancelEventId.trim();
|
|
193
|
+
if (!id) return setError("Enter Blazeo event id to cancel.");
|
|
194
|
+
if (!ensureBase()) return;
|
|
195
|
+
configureBlazeoFromEffective(effective);
|
|
196
|
+
ensureBlazeoHttpReady({
|
|
197
|
+
baseUrl: effective.baseUrl,
|
|
198
|
+
...(effective.consumer ? { consumer: effective.consumer } : {}),
|
|
199
|
+
});
|
|
200
|
+
setBusy(true);
|
|
201
|
+
try {
|
|
202
|
+
const result = await cancelAppointmentEventAsync(id, {
|
|
203
|
+
...connectionOpts,
|
|
204
|
+
baseUrl: effective.baseUrl,
|
|
205
|
+
...(effective.consumer ? { consumer: effective.consumer } : {}),
|
|
206
|
+
});
|
|
207
|
+
setOutput(JSON.stringify(result, null, 2));
|
|
208
|
+
if (!result.ok) setError(mapBlazeoDemoError(result.error));
|
|
209
|
+
} finally {
|
|
210
|
+
setBusy(false);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function handleSearchByDateRange(e) {
|
|
215
|
+
e.preventDefault();
|
|
216
|
+
setError("");
|
|
217
|
+
setOutput("");
|
|
218
|
+
const companyKey = searchCompanyKey.trim();
|
|
219
|
+
if (!companyKey) return setError("Enter company key.");
|
|
220
|
+
if (!searchFrom) return setError("Pick start date.");
|
|
221
|
+
if (!searchTo) return setError("Pick end date.");
|
|
222
|
+
if (!ensureBase()) return;
|
|
223
|
+
configureBlazeoFromEffective(effective);
|
|
224
|
+
ensureBlazeoHttpReady({
|
|
225
|
+
baseUrl: effective.baseUrl,
|
|
226
|
+
...(effective.consumer ? { consumer: effective.consumer } : {}),
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const optsFromJson = safeJsonParse(searchFiltersJson, {});
|
|
230
|
+
const startDateFrom = new Date(`${searchFrom}T00:00:00.000Z`).toISOString();
|
|
231
|
+
const startDateTo = new Date(`${searchTo}T23:59:59.999Z`).toISOString();
|
|
232
|
+
|
|
233
|
+
setBusy(true);
|
|
234
|
+
try {
|
|
235
|
+
const res = await EventModel.getByDateRangeWithFilters(
|
|
236
|
+
companyKey,
|
|
237
|
+
startDateFrom,
|
|
238
|
+
startDateTo,
|
|
239
|
+
optsFromJson
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
const events = (res?.events ?? []).map((e) =>
|
|
243
|
+
isStateTreeNode(e) ? getSnapshot(e) : (e?.toJSON?.() ?? e)
|
|
244
|
+
);
|
|
245
|
+
const totalCount = res?.totalCount ?? events.length;
|
|
246
|
+
setOutput(JSON.stringify({ totalCount, events }, null, 2));
|
|
247
|
+
} finally {
|
|
248
|
+
setBusy(false);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async function handleEnrichedSearch(e) {
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
setError("");
|
|
255
|
+
setOutput("");
|
|
256
|
+
const companyKey = searchCompanyKey.trim();
|
|
257
|
+
if (!companyKey) return setError("Enter company key.");
|
|
258
|
+
if (!searchFrom) return setError("Pick start date.");
|
|
259
|
+
if (!searchTo) return setError("Pick end date.");
|
|
260
|
+
if (!ensureBase()) return;
|
|
261
|
+
configureBlazeoFromEffective(effective);
|
|
262
|
+
ensureBlazeoHttpReady({
|
|
263
|
+
baseUrl: effective.baseUrl,
|
|
264
|
+
...(effective.consumer ? { consumer: effective.consumer } : {}),
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const optsFromJson = safeJsonParse(searchFiltersJson, {});
|
|
268
|
+
const startDateFrom = new Date(`${searchFrom}T00:00:00.000Z`).toISOString();
|
|
269
|
+
const startDateTo = new Date(`${searchTo}T23:59:59.999Z`).toISOString();
|
|
270
|
+
|
|
271
|
+
setBusy(true);
|
|
272
|
+
try {
|
|
273
|
+
const res = await getAppointmentsByFilter(
|
|
274
|
+
companyKey,
|
|
275
|
+
startDateFrom,
|
|
276
|
+
startDateTo,
|
|
277
|
+
optsFromJson
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
setOutput(JSON.stringify(res, null, 2));
|
|
281
|
+
} catch (err) {
|
|
282
|
+
setError(mapBlazeoDemoError(err instanceof Error ? err.message : String(err)));
|
|
283
|
+
} finally {
|
|
284
|
+
setBusy(false);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return (
|
|
289
|
+
<>
|
|
290
|
+
<div className="card">
|
|
291
|
+
<h2>Appointment events</h2>
|
|
292
|
+
<p className="muted small">
|
|
293
|
+
Create/reschedule/cancel Blazeo events via <code>appointment-client</code>.
|
|
294
|
+
</p>
|
|
295
|
+
<label className="form__label">
|
|
296
|
+
<span>Offset minutes</span>
|
|
297
|
+
<input
|
|
298
|
+
type="number"
|
|
299
|
+
className="form__input"
|
|
300
|
+
value={offsetMinutes}
|
|
301
|
+
onChange={(e) => setOffsetMinutes(e.target.value)}
|
|
302
|
+
/>
|
|
303
|
+
</label>
|
|
304
|
+
</div>
|
|
305
|
+
|
|
306
|
+
<div className="card">
|
|
307
|
+
<h2>Search events (date range + filters)</h2>
|
|
308
|
+
<p className="muted small">
|
|
309
|
+
Calls <code>EventModel.getByDateRangeWithFilters</code> →
|
|
310
|
+
<code> GET /event/search/daterange/get</code> (company scope). Offset header comes from the{" "}
|
|
311
|
+
<code>offset</code> field above.
|
|
312
|
+
</p>
|
|
313
|
+
<form onSubmit={handleSearchByDateRange} className="form">
|
|
314
|
+
<label className="form__label">
|
|
315
|
+
<span>Company key</span>
|
|
316
|
+
<input
|
|
317
|
+
className="form__input"
|
|
318
|
+
value={searchCompanyKey}
|
|
319
|
+
onChange={(e) => setSearchCompanyKey(e.target.value)}
|
|
320
|
+
placeholder="company_key"
|
|
321
|
+
autoComplete="off"
|
|
322
|
+
/>
|
|
323
|
+
</label>
|
|
324
|
+
<div className="connection-card__row">
|
|
325
|
+
<label className="form__label">
|
|
326
|
+
<span>Start date (from)</span>
|
|
327
|
+
<input
|
|
328
|
+
type="date"
|
|
329
|
+
className="form__input"
|
|
330
|
+
value={searchFrom}
|
|
331
|
+
onChange={(e) => setSearchFrom(e.target.value)}
|
|
332
|
+
/>
|
|
333
|
+
</label>
|
|
334
|
+
<label className="form__label">
|
|
335
|
+
<span>Start date (to)</span>
|
|
336
|
+
<input
|
|
337
|
+
type="date"
|
|
338
|
+
className="form__input"
|
|
339
|
+
value={searchTo}
|
|
340
|
+
onChange={(e) => setSearchTo(e.target.value)}
|
|
341
|
+
/>
|
|
342
|
+
</label>
|
|
343
|
+
</div>
|
|
344
|
+
<label className="form__label">
|
|
345
|
+
<span>Filters (JSON)</span>
|
|
346
|
+
<textarea
|
|
347
|
+
className="form__textarea"
|
|
348
|
+
value={searchFiltersJson}
|
|
349
|
+
onChange={(e) => setSearchFiltersJson(e.target.value)}
|
|
350
|
+
spellCheck={false}
|
|
351
|
+
rows={10}
|
|
352
|
+
/>
|
|
353
|
+
</label>
|
|
354
|
+
<div className="connection-card__row">
|
|
355
|
+
<button type="button" className="btn btn--secondary" onClick={handleSearchByDateRange} disabled={busy}>
|
|
356
|
+
{busy ? "Loading…" : "Raw Search"}
|
|
357
|
+
</button>
|
|
358
|
+
<button type="button" className="btn btn--primary" onClick={handleEnrichedSearch} disabled={busy}>
|
|
359
|
+
{busy ? "Loading…" : "Enriched Search (New)"}
|
|
360
|
+
</button>
|
|
361
|
+
</div>
|
|
362
|
+
</form>
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
<div className="card">
|
|
366
|
+
<h2>Create event</h2>
|
|
367
|
+
<form onSubmit={handleCreate} className="form">
|
|
368
|
+
<label className="form__label">
|
|
369
|
+
<span>Payload (JSON)</span>
|
|
370
|
+
<textarea
|
|
371
|
+
className="form__textarea"
|
|
372
|
+
value={createJson}
|
|
373
|
+
onChange={(e) => setCreateJson(e.target.value)}
|
|
374
|
+
spellCheck={false}
|
|
375
|
+
rows={14}
|
|
376
|
+
/>
|
|
377
|
+
</label>
|
|
378
|
+
<button type="submit" className="btn btn--primary" disabled={busy}>
|
|
379
|
+
{busy ? "Working…" : "Create"}
|
|
380
|
+
</button>
|
|
381
|
+
</form>
|
|
382
|
+
</div>
|
|
383
|
+
|
|
384
|
+
<div className="card">
|
|
385
|
+
<h2>Reschedule event</h2>
|
|
386
|
+
<form onSubmit={handleReschedule} className="form">
|
|
387
|
+
<label className="form__label">
|
|
388
|
+
<span>Payload (JSON)</span>
|
|
389
|
+
<textarea
|
|
390
|
+
className="form__textarea"
|
|
391
|
+
value={rescheduleJson}
|
|
392
|
+
onChange={(e) => setRescheduleJson(e.target.value)}
|
|
393
|
+
spellCheck={false}
|
|
394
|
+
rows={14}
|
|
395
|
+
/>
|
|
396
|
+
</label>
|
|
397
|
+
<button type="submit" className="btn btn--primary" disabled={busy}>
|
|
398
|
+
{busy ? "Working…" : "Reschedule"}
|
|
399
|
+
</button>
|
|
400
|
+
</form>
|
|
401
|
+
</div>
|
|
402
|
+
|
|
403
|
+
<div className="card">
|
|
404
|
+
<h2>Cancel event</h2>
|
|
405
|
+
<form onSubmit={handleCancel} className="form">
|
|
406
|
+
<label className="form__label">
|
|
407
|
+
<span>Event id</span>
|
|
408
|
+
<input
|
|
409
|
+
className="form__input"
|
|
410
|
+
value={cancelEventId}
|
|
411
|
+
onChange={(e) => setCancelEventId(e.target.value)}
|
|
412
|
+
/>
|
|
413
|
+
</label>
|
|
414
|
+
<button type="submit" className="btn btn--secondary" disabled={busy}>
|
|
415
|
+
{busy ? "Working…" : "Cancel"}
|
|
416
|
+
</button>
|
|
417
|
+
</form>
|
|
418
|
+
</div>
|
|
419
|
+
|
|
420
|
+
{error ? (
|
|
421
|
+
<div className="card card--error" role="alert">
|
|
422
|
+
<h2>Error</h2>
|
|
423
|
+
<pre className="pre-block">{error}</pre>
|
|
424
|
+
</div>
|
|
425
|
+
) : null}
|
|
426
|
+
|
|
427
|
+
{output ? (
|
|
428
|
+
<div className="card card--success">
|
|
429
|
+
<h2>Result</h2>
|
|
430
|
+
<pre className="pre-block">{output}</pre>
|
|
431
|
+
</div>
|
|
432
|
+
) : null}
|
|
433
|
+
</>
|
|
434
|
+
);
|
|
435
|
+
}
|