@blazeo.com/calendar-client 1.0.9 → 1.0.11
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/dist/index.d.ts +170 -146
- package/dist/index.js +357 -196
- package/dist/index.mjs +345 -184
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
module.exports = __toCommonJS(index_exports);
|
|
53
53
|
|
|
54
54
|
// src/models/appointment/Calendar.js
|
|
55
|
-
var
|
|
55
|
+
var import_mobx_state_tree8 = require("mobx-state-tree");
|
|
56
56
|
|
|
57
57
|
// src/ConfigModel.js
|
|
58
58
|
var import_mobx_state_tree = require("mobx-state-tree");
|
|
@@ -226,7 +226,7 @@ var DayOfWeek = {
|
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
// src/models/appointment/Event.js
|
|
229
|
-
var
|
|
229
|
+
var import_mobx_state_tree4 = require("mobx-state-tree");
|
|
230
230
|
|
|
231
231
|
// src/models/appointment/TimeSlot.js
|
|
232
232
|
var import_mobx_state_tree2 = require("mobx-state-tree");
|
|
@@ -254,55 +254,109 @@ var TimeSlotModel = import_mobx_state_tree2.types.model("TimeSlot", {
|
|
|
254
254
|
}));
|
|
255
255
|
var TimeSlot_default = TimeSlotModel;
|
|
256
256
|
|
|
257
|
+
// src/models/appointment/TimeFrame.js
|
|
258
|
+
var import_mobx_state_tree3 = require("mobx-state-tree");
|
|
259
|
+
var TimeFrameModel = import_mobx_state_tree3.types.model("TimeFrame", {
|
|
260
|
+
start: import_mobx_state_tree3.types.string,
|
|
261
|
+
end: import_mobx_state_tree3.types.string
|
|
262
|
+
}).actions((self) => ({
|
|
263
|
+
buffer(bufferMinutes, unit) {
|
|
264
|
+
const bfr = unit === Unit.Hours ? bufferMinutes * 60 : bufferMinutes;
|
|
265
|
+
const s = new Date(self.start);
|
|
266
|
+
const e = new Date(self.end);
|
|
267
|
+
s.setMinutes(s.getMinutes() - bfr);
|
|
268
|
+
e.setMinutes(e.getMinutes() + bfr);
|
|
269
|
+
self.start = s.toISOString();
|
|
270
|
+
self.end = e.toISOString();
|
|
271
|
+
},
|
|
272
|
+
conflicts(start, end) {
|
|
273
|
+
const thisStart = new Date(self.start).getTime();
|
|
274
|
+
const thisEnd = new Date(self.end).getTime();
|
|
275
|
+
const startT = start.getTime();
|
|
276
|
+
const endT = end.getTime();
|
|
277
|
+
return startT >= thisStart && startT <= thisEnd || endT >= thisStart && endT <= thisEnd || startT <= thisStart && endT >= thisEnd;
|
|
278
|
+
},
|
|
279
|
+
breakIntoSlots(slotDurationMinutes) {
|
|
280
|
+
const start = new Date(self.start);
|
|
281
|
+
const end = new Date(self.end);
|
|
282
|
+
const slots = [];
|
|
283
|
+
let current = new Date(start);
|
|
284
|
+
const align = (m) => {
|
|
285
|
+
if (m === 0 || m === 15 || m === 30 || m === 45) return m;
|
|
286
|
+
if (m > 0 && m < 15) return 15;
|
|
287
|
+
if (m > 15 && m < 30) return 30;
|
|
288
|
+
if (m > 30 && m < 45) return 45;
|
|
289
|
+
return 0;
|
|
290
|
+
};
|
|
291
|
+
current.setMinutes(align(current.getMinutes()), 0, 0);
|
|
292
|
+
let slotEnd = new Date(current.getTime());
|
|
293
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
294
|
+
while (slotEnd.getTime() <= end.getTime()) {
|
|
295
|
+
slots.push({
|
|
296
|
+
startHour: current.getHours(),
|
|
297
|
+
startMinute: current.getMinutes(),
|
|
298
|
+
endHour: slotEnd.getHours(),
|
|
299
|
+
endMinute: slotEnd.getMinutes(),
|
|
300
|
+
startDate: current.toISOString(),
|
|
301
|
+
endDate: slotEnd.toISOString()
|
|
302
|
+
});
|
|
303
|
+
current = new Date(slotEnd.getTime());
|
|
304
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
305
|
+
}
|
|
306
|
+
return slots;
|
|
307
|
+
}
|
|
308
|
+
}));
|
|
309
|
+
var TimeFrame_default = TimeFrameModel;
|
|
310
|
+
|
|
257
311
|
// src/models/appointment/Event.js
|
|
258
312
|
function getDefaultOffset() {
|
|
259
313
|
var _a;
|
|
260
314
|
const cfg = getConfig();
|
|
261
315
|
return ((_a = cfg == null ? void 0 : cfg.getDefaultOffset) == null ? void 0 : _a.call(cfg)) ?? -(/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
262
316
|
}
|
|
263
|
-
var EventModel =
|
|
264
|
-
id:
|
|
265
|
-
eventId:
|
|
266
|
-
calendarId:
|
|
267
|
-
participantId:
|
|
268
|
-
title:
|
|
269
|
-
description:
|
|
270
|
-
isRecurring:
|
|
271
|
-
recurringFrequency:
|
|
272
|
-
startDate:
|
|
273
|
-
endDate:
|
|
274
|
-
startHour:
|
|
275
|
-
startMinute:
|
|
276
|
-
endHour:
|
|
277
|
-
endMinute:
|
|
278
|
-
visitorName:
|
|
279
|
-
visitorEmail:
|
|
280
|
-
visitorPhone:
|
|
281
|
-
createdOn:
|
|
282
|
-
modifiedOn:
|
|
283
|
-
externalEventId:
|
|
284
|
-
attendeeStatus:
|
|
285
|
-
rescheduleLink:
|
|
286
|
-
cancelLink:
|
|
287
|
-
timeZone:
|
|
288
|
-
offset:
|
|
317
|
+
var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
318
|
+
id: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.number), null),
|
|
319
|
+
eventId: import_mobx_state_tree4.types.identifier,
|
|
320
|
+
calendarId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.string, ""),
|
|
321
|
+
participantId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
322
|
+
title: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
323
|
+
description: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
324
|
+
isRecurring: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.boolean, false),
|
|
325
|
+
recurringFrequency: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, RecurringFrequency.None),
|
|
326
|
+
startDate: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.string, ""),
|
|
327
|
+
endDate: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.string, ""),
|
|
328
|
+
startHour: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
329
|
+
startMinute: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
330
|
+
endHour: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
331
|
+
endMinute: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
332
|
+
visitorName: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
333
|
+
visitorEmail: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
334
|
+
visitorPhone: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
335
|
+
createdOn: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
336
|
+
modifiedOn: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
337
|
+
externalEventId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
338
|
+
attendeeStatus: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, AttendeeStatus.Tentative),
|
|
339
|
+
rescheduleLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
340
|
+
cancelLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
341
|
+
timeZone: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
342
|
+
offset: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0)
|
|
289
343
|
}).actions((self) => {
|
|
290
|
-
const { req, reqGet, reqPost } = createRequestHelpers(self,
|
|
344
|
+
const { req, reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree4.getEnv);
|
|
291
345
|
const getOffset = () => {
|
|
292
346
|
var _a, _b;
|
|
293
|
-
return ((_b = (_a = (0,
|
|
347
|
+
return ((_b = (_a = (0, import_mobx_state_tree4.getEnv)(self)).getDefaultOffset) == null ? void 0 : _b.call(_a)) ?? getDefaultOffset();
|
|
294
348
|
};
|
|
295
349
|
return {
|
|
296
350
|
/** GET /event/get – fetch this event by eventId or externalEventId */
|
|
297
351
|
async get(params) {
|
|
298
352
|
if ((params == null ? void 0 : params.eventId) ?? (params == null ? void 0 : params.event_id)) {
|
|
299
353
|
const res = await reqGet("/event/get", { event_id: params.eventId ?? params.event_id });
|
|
300
|
-
if (res.status === "success" && res.data) (0,
|
|
354
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
301
355
|
return res;
|
|
302
356
|
}
|
|
303
357
|
if ((params == null ? void 0 : params.externalEventId) ?? (params == null ? void 0 : params.externalevent_id)) {
|
|
304
358
|
const res = await reqGet("/event/get", { externalevent_id: params.externalEventId ?? params.externalevent_id });
|
|
305
|
-
if (res.status === "success" && res.data) (0,
|
|
359
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
306
360
|
return res;
|
|
307
361
|
}
|
|
308
362
|
return { status: "failure", message: "Provide eventId or externalEventId" };
|
|
@@ -326,7 +380,7 @@ var EventModel = import_mobx_state_tree3.types.model("Event", {
|
|
|
326
380
|
visitorPhone: self.visitorPhone ?? void 0
|
|
327
381
|
};
|
|
328
382
|
const res = await reqPost("/event/create", payload, null, { headers: { offset: String(offset) } });
|
|
329
|
-
if (res.status === "success" && res.data) (0,
|
|
383
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
330
384
|
return res;
|
|
331
385
|
},
|
|
332
386
|
/** POST /event/update – update event */
|
|
@@ -369,7 +423,7 @@ var EventModel = import_mobx_state_tree3.types.model("Event", {
|
|
|
369
423
|
visitorPhone: self.visitorPhone ?? void 0
|
|
370
424
|
};
|
|
371
425
|
const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
|
|
372
|
-
if (res.status === "success" && res.data) (0,
|
|
426
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
373
427
|
return res;
|
|
374
428
|
},
|
|
375
429
|
/** GET /event/cancel – cancel this event */
|
|
@@ -558,6 +612,32 @@ EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) =>
|
|
|
558
612
|
}
|
|
559
613
|
return [];
|
|
560
614
|
};
|
|
615
|
+
EventModel.getExternalUnavailability = async (participantId, opts = {}) => {
|
|
616
|
+
if (!participantId) throw new Error("participantId required");
|
|
617
|
+
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
618
|
+
const query = { participant_id: participantId };
|
|
619
|
+
if (opts.startUtc && opts.endUtc) {
|
|
620
|
+
query.start_utc = opts.startUtc;
|
|
621
|
+
query.end_utc = opts.endUtc;
|
|
622
|
+
} else {
|
|
623
|
+
if (opts.year == null || opts.month == null || opts.day == null) {
|
|
624
|
+
throw new Error("Provide startUtc/endUtc or year/month/day");
|
|
625
|
+
}
|
|
626
|
+
query.year = opts.year;
|
|
627
|
+
query.month = opts.month;
|
|
628
|
+
query.day = opts.day;
|
|
629
|
+
if (opts.days != null) query.days = opts.days;
|
|
630
|
+
}
|
|
631
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
632
|
+
const res = await req("/externalcalendar/unavailability/get", { method: "GET", query, headers: { offset: String(offset) } });
|
|
633
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
634
|
+
return res.data.map((f) => TimeFrame_default.create({
|
|
635
|
+
start: f.start ?? f.Start,
|
|
636
|
+
end: f.end ?? f.End
|
|
637
|
+
}));
|
|
638
|
+
}
|
|
639
|
+
return [];
|
|
640
|
+
};
|
|
561
641
|
EventModel.cancel = async (eventId) => {
|
|
562
642
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
563
643
|
return reqGet("/event/cancel", { event_id: eventId });
|
|
@@ -620,29 +700,29 @@ EventModel.setAttendeeStatus = async (eventId, attendeeStatus) => {
|
|
|
620
700
|
var Event_default = EventModel;
|
|
621
701
|
|
|
622
702
|
// src/models/appointment/CalendarParticipant.js
|
|
623
|
-
var
|
|
703
|
+
var import_mobx_state_tree6 = require("mobx-state-tree");
|
|
624
704
|
|
|
625
705
|
// src/models/appointment/ParticipantInfo.js
|
|
626
|
-
var
|
|
627
|
-
var ParticipantInfoModel =
|
|
628
|
-
participantId:
|
|
629
|
-
calendarParticipantId:
|
|
630
|
-
alias:
|
|
631
|
-
email:
|
|
632
|
-
isApproved:
|
|
633
|
-
emailProvider:
|
|
634
|
-
isAvailable:
|
|
706
|
+
var import_mobx_state_tree5 = require("mobx-state-tree");
|
|
707
|
+
var ParticipantInfoModel = import_mobx_state_tree5.types.model("ParticipantInfo", {
|
|
708
|
+
participantId: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.string, ""),
|
|
709
|
+
calendarParticipantId: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.string, ""),
|
|
710
|
+
alias: import_mobx_state_tree5.types.maybeNull(import_mobx_state_tree5.types.string),
|
|
711
|
+
email: import_mobx_state_tree5.types.maybeNull(import_mobx_state_tree5.types.string),
|
|
712
|
+
isApproved: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.boolean, false),
|
|
713
|
+
emailProvider: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.number, 0),
|
|
714
|
+
isAvailable: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.boolean, false)
|
|
635
715
|
});
|
|
636
716
|
var ParticipantInfo_default = ParticipantInfoModel;
|
|
637
717
|
|
|
638
718
|
// src/models/appointment/CalendarParticipant.js
|
|
639
|
-
var CalendarParticipantModel =
|
|
640
|
-
id:
|
|
641
|
-
calendarParticipantId:
|
|
642
|
-
participantId:
|
|
643
|
-
calendarId:
|
|
644
|
-
createdOn:
|
|
645
|
-
modifiedOn:
|
|
719
|
+
var CalendarParticipantModel = import_mobx_state_tree6.types.model("CalendarParticipant", {
|
|
720
|
+
id: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.maybeNull(import_mobx_state_tree6.types.number), null),
|
|
721
|
+
calendarParticipantId: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.string, ""),
|
|
722
|
+
participantId: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.string, ""),
|
|
723
|
+
calendarId: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.string, ""),
|
|
724
|
+
createdOn: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.maybeNull(import_mobx_state_tree6.types.string), null),
|
|
725
|
+
modifiedOn: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.maybeNull(import_mobx_state_tree6.types.string), null)
|
|
646
726
|
});
|
|
647
727
|
function mapFromApi(d) {
|
|
648
728
|
if (!d) return d;
|
|
@@ -695,45 +775,45 @@ CalendarParticipantModel.getByParticipant = async (participantId) => {
|
|
|
695
775
|
var CalendarParticipant_default = CalendarParticipantModel;
|
|
696
776
|
|
|
697
777
|
// src/models/appointment/CalendarDay.js
|
|
698
|
-
var
|
|
699
|
-
var CalendarDayModel =
|
|
700
|
-
date:
|
|
778
|
+
var import_mobx_state_tree7 = require("mobx-state-tree");
|
|
779
|
+
var CalendarDayModel = import_mobx_state_tree7.types.model("CalendarDay", {
|
|
780
|
+
date: import_mobx_state_tree7.types.optional(import_mobx_state_tree7.types.string, "")
|
|
701
781
|
});
|
|
702
782
|
var CalendarDay_default = CalendarDayModel;
|
|
703
783
|
|
|
704
784
|
// src/models/appointment/Calendar.js
|
|
705
|
-
var CalendarModel =
|
|
706
|
-
id:
|
|
707
|
-
companyKey:
|
|
708
|
-
calendarId:
|
|
709
|
-
name:
|
|
785
|
+
var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
786
|
+
id: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.number),
|
|
787
|
+
companyKey: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
788
|
+
calendarId: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.identifier, "new"),
|
|
789
|
+
name: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
710
790
|
// location: types.maybeNull(types.string),
|
|
711
|
-
timeZoneId:
|
|
712
|
-
purpose:
|
|
713
|
-
description:
|
|
714
|
-
assignmentMethod:
|
|
715
|
-
duration:
|
|
716
|
-
durationUnit:
|
|
717
|
-
minimumBookingNotice:
|
|
718
|
-
minimumBookingNoticeUnit:
|
|
719
|
-
minimumCancelationNotice:
|
|
720
|
-
minimumCancelationNoticeUnit:
|
|
721
|
-
futureLimit:
|
|
722
|
-
futureLimitUnit:
|
|
723
|
-
bufferTime:
|
|
724
|
-
bufferTimeUnit:
|
|
725
|
-
bookingLimit:
|
|
726
|
-
createdOn:
|
|
727
|
-
modifiedOn:
|
|
791
|
+
timeZoneId: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
792
|
+
purpose: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.string, ""),
|
|
793
|
+
description: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
794
|
+
assignmentMethod: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, AssignmentMethod.RoundRobin),
|
|
795
|
+
duration: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
796
|
+
durationUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
797
|
+
minimumBookingNotice: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
798
|
+
minimumBookingNoticeUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
799
|
+
minimumCancelationNotice: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
800
|
+
minimumCancelationNoticeUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
801
|
+
futureLimit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
802
|
+
futureLimitUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Days),
|
|
803
|
+
bufferTime: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
804
|
+
bufferTimeUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
805
|
+
bookingLimit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
806
|
+
createdOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
807
|
+
modifiedOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string)
|
|
728
808
|
}).actions((self) => {
|
|
729
|
-
const { req, reqGet, reqPost } = createRequestHelpers(self,
|
|
809
|
+
const { req, reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree8.getEnv);
|
|
730
810
|
return {
|
|
731
811
|
/** GET Calendar/Get – fetch this calendar by calendarId */
|
|
732
812
|
async get() {
|
|
733
813
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
734
814
|
const res = await reqGet("/Calendar/Get", { calendar_id: self.calendarId });
|
|
735
815
|
if (res.status === "success" && res.data) {
|
|
736
|
-
(0,
|
|
816
|
+
(0, import_mobx_state_tree8.applySnapshot)(self, { ...res.data, calendarId: self.calendarId });
|
|
737
817
|
}
|
|
738
818
|
return res;
|
|
739
819
|
},
|
|
@@ -863,9 +943,25 @@ var CalendarModel = import_mobx_state_tree7.types.model("Calendar", {
|
|
|
863
943
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
864
944
|
return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
|
|
865
945
|
},
|
|
866
|
-
/** GET Calendar/All – calendars by company_key */
|
|
867
|
-
async getByCompany(companyKey) {
|
|
868
|
-
|
|
946
|
+
/** GET Calendar/All – calendars by company_key with paging options */
|
|
947
|
+
async getByCompany(companyKey, opts = {}) {
|
|
948
|
+
const resolvedCompanyKey = companyKey || self.companyKey;
|
|
949
|
+
const q = { company_key: resolvedCompanyKey };
|
|
950
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
951
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
952
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
953
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
954
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
955
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
956
|
+
}
|
|
957
|
+
if (opts.page != null) {
|
|
958
|
+
q.page = opts.page;
|
|
959
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
960
|
+
} else {
|
|
961
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
962
|
+
if (opts.take != null) q.take = opts.take;
|
|
963
|
+
}
|
|
964
|
+
return reqGet("/Calendar/All", q);
|
|
869
965
|
},
|
|
870
966
|
/** GET Calendar/TimeZones/Get */
|
|
871
967
|
async getTimeZones() {
|
|
@@ -940,13 +1036,34 @@ CalendarModel.get = async (calendarId) => {
|
|
|
940
1036
|
}
|
|
941
1037
|
return null;
|
|
942
1038
|
};
|
|
943
|
-
CalendarModel.getByCompany = async (companyKey) => {
|
|
1039
|
+
CalendarModel.getByCompany = async (companyKey, opts = {}) => {
|
|
1040
|
+
var _a, _b, _c, _d;
|
|
944
1041
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
945
|
-
const
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1042
|
+
const query = { company_key: companyKey };
|
|
1043
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1044
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
1045
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1046
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1047
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1048
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1049
|
+
}
|
|
1050
|
+
if (opts.page != null) {
|
|
1051
|
+
query.page = opts.page;
|
|
1052
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
1053
|
+
} else {
|
|
1054
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
1055
|
+
if (opts.take != null) query.take = opts.take;
|
|
1056
|
+
}
|
|
1057
|
+
const res = await reqGet("/Calendar/All", query);
|
|
1058
|
+
if (res.status === "success") {
|
|
1059
|
+
const calendarsRaw = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Calendars) ? res.data.Calendars : Array.isArray((_b = res.data) == null ? void 0 : _b.calendars) ? res.data.calendars : null;
|
|
1060
|
+
if (calendarsRaw) {
|
|
1061
|
+
const calendars = calendarsRaw.map(
|
|
1062
|
+
(c) => CalendarModel.create(mapCalendarFromApi(c), { env: getConfig() })
|
|
1063
|
+
);
|
|
1064
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1065
|
+
return { calendars, totalCount };
|
|
1066
|
+
}
|
|
950
1067
|
}
|
|
951
1068
|
return null;
|
|
952
1069
|
};
|
|
@@ -1066,73 +1183,73 @@ CalendarModel.editWithParticipants = async (calendarId, name, participantIds, de
|
|
|
1066
1183
|
var Calendar_default = CalendarModel;
|
|
1067
1184
|
|
|
1068
1185
|
// src/models/appointment/Availability.js
|
|
1069
|
-
var import_mobx_state_tree8 = require("mobx-state-tree");
|
|
1070
|
-
var AvailabilityModel = import_mobx_state_tree8.types.model("Availability", {
|
|
1071
|
-
id: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.number),
|
|
1072
|
-
availabilityId: import_mobx_state_tree8.types.string,
|
|
1073
|
-
calendarId: import_mobx_state_tree8.types.string,
|
|
1074
|
-
participantId: import_mobx_state_tree8.types.string,
|
|
1075
|
-
createdOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
1076
|
-
modifiedOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string)
|
|
1077
|
-
});
|
|
1078
|
-
var Availability_default = AvailabilityModel;
|
|
1079
|
-
|
|
1080
|
-
// src/models/appointment/AvailabilityDetail.js
|
|
1081
1186
|
var import_mobx_state_tree9 = require("mobx-state-tree");
|
|
1082
|
-
var
|
|
1187
|
+
var AvailabilityModel = import_mobx_state_tree9.types.model("Availability", {
|
|
1083
1188
|
id: import_mobx_state_tree9.types.maybeNull(import_mobx_state_tree9.types.number),
|
|
1084
1189
|
availabilityId: import_mobx_state_tree9.types.string,
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
tuesday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1088
|
-
wednesday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1089
|
-
thursday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1090
|
-
friday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1091
|
-
saturday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1092
|
-
startHour: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1093
|
-
startMinute: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1094
|
-
endHour: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1095
|
-
endMinute: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1190
|
+
calendarId: import_mobx_state_tree9.types.string,
|
|
1191
|
+
participantId: import_mobx_state_tree9.types.string,
|
|
1096
1192
|
createdOn: import_mobx_state_tree9.types.maybeNull(import_mobx_state_tree9.types.string),
|
|
1097
1193
|
modifiedOn: import_mobx_state_tree9.types.maybeNull(import_mobx_state_tree9.types.string)
|
|
1098
1194
|
});
|
|
1195
|
+
var Availability_default = AvailabilityModel;
|
|
1196
|
+
|
|
1197
|
+
// src/models/appointment/AvailabilityDetail.js
|
|
1198
|
+
var import_mobx_state_tree10 = require("mobx-state-tree");
|
|
1199
|
+
var AvailabilityDetailModel = import_mobx_state_tree10.types.model("AvailabilityDetail", {
|
|
1200
|
+
id: import_mobx_state_tree10.types.maybeNull(import_mobx_state_tree10.types.number),
|
|
1201
|
+
availabilityId: import_mobx_state_tree10.types.string,
|
|
1202
|
+
sunday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1203
|
+
monday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1204
|
+
tuesday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1205
|
+
wednesday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1206
|
+
thursday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1207
|
+
friday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1208
|
+
saturday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1209
|
+
startHour: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1210
|
+
startMinute: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1211
|
+
endHour: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1212
|
+
endMinute: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1213
|
+
createdOn: import_mobx_state_tree10.types.maybeNull(import_mobx_state_tree10.types.string),
|
|
1214
|
+
modifiedOn: import_mobx_state_tree10.types.maybeNull(import_mobx_state_tree10.types.string)
|
|
1215
|
+
});
|
|
1099
1216
|
var AvailabilityDetail_default = AvailabilityDetailModel;
|
|
1100
1217
|
|
|
1101
1218
|
// src/models/appointment/Participant.js
|
|
1102
|
-
var
|
|
1103
|
-
var ParticipantModel =
|
|
1104
|
-
id:
|
|
1105
|
-
participantId:
|
|
1106
|
-
companyKey:
|
|
1107
|
-
alias:
|
|
1108
|
-
email:
|
|
1109
|
-
isApproved:
|
|
1110
|
-
isAvailable:
|
|
1111
|
-
provider:
|
|
1112
|
-
createdOn:
|
|
1113
|
-
modifiedOn:
|
|
1114
|
-
isDeleted:
|
|
1219
|
+
var import_mobx_state_tree11 = require("mobx-state-tree");
|
|
1220
|
+
var ParticipantModel = import_mobx_state_tree11.types.model("Participant", {
|
|
1221
|
+
id: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.number), null),
|
|
1222
|
+
participantId: import_mobx_state_tree11.types.identifier,
|
|
1223
|
+
companyKey: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
|
|
1224
|
+
alias: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.string, ""),
|
|
1225
|
+
email: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.string, ""),
|
|
1226
|
+
isApproved: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false),
|
|
1227
|
+
isAvailable: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false),
|
|
1228
|
+
provider: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.number, 0),
|
|
1229
|
+
createdOn: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
|
|
1230
|
+
modifiedOn: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
|
|
1231
|
+
isDeleted: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false)
|
|
1115
1232
|
}).actions((self) => {
|
|
1116
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1233
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree11.getEnv);
|
|
1117
1234
|
return {
|
|
1118
1235
|
/** GET participant/get – fetch this participant */
|
|
1119
1236
|
async get() {
|
|
1120
1237
|
const res = await reqGet("/participant/get", { participant_id: self.participantId });
|
|
1121
|
-
if (res.status === "success" && res.data) (0,
|
|
1238
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree11.applySnapshot)(self, mapFromApi2(res.data));
|
|
1122
1239
|
return res;
|
|
1123
1240
|
},
|
|
1124
1241
|
/** POST participant/save – save participant (add or update) */
|
|
1125
1242
|
async save() {
|
|
1126
1243
|
const payload = toPayload(self);
|
|
1127
1244
|
const res = await reqPost("/participant/save", payload);
|
|
1128
|
-
if (res.status === "success" && res.data) (0,
|
|
1245
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree11.applySnapshot)(self, mapFromApi2(res.data));
|
|
1129
1246
|
return res;
|
|
1130
1247
|
},
|
|
1131
1248
|
/** POST participant/update – update participant */
|
|
1132
1249
|
async update() {
|
|
1133
1250
|
const payload = toPayload(self);
|
|
1134
1251
|
const res = await reqPost("/participant/update", payload);
|
|
1135
|
-
if (res.status === "success" && res.data) (0,
|
|
1252
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree11.applySnapshot)(self, mapFromApi2(res.data));
|
|
1136
1253
|
return res;
|
|
1137
1254
|
},
|
|
1138
1255
|
/** GET participant/remove – remove this participant */
|
|
@@ -1142,6 +1259,41 @@ var ParticipantModel = import_mobx_state_tree10.types.model("Participant", {
|
|
|
1142
1259
|
/** GET participant/sendemail – send email to this participant */
|
|
1143
1260
|
async sendEmail() {
|
|
1144
1261
|
return reqGet("/participant/sendemail", { participant_id: self.participantId });
|
|
1262
|
+
},
|
|
1263
|
+
/** POST participant/migrate – migrate this participant id to user id */
|
|
1264
|
+
async migrate(userId) {
|
|
1265
|
+
return reqPost("/participant/migrate", {}, { participant_id: self.participantId, user_id: userId });
|
|
1266
|
+
},
|
|
1267
|
+
/** GET participant/calendars/get – calendars for this participant (paged) */
|
|
1268
|
+
async getCalendars(opts = {}) {
|
|
1269
|
+
var _a, _b, _c, _d;
|
|
1270
|
+
const q = { participant_id: self.participantId };
|
|
1271
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1272
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
1273
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1274
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1275
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1276
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1277
|
+
}
|
|
1278
|
+
if (opts.page != null) {
|
|
1279
|
+
q.page = opts.page;
|
|
1280
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
1281
|
+
} else {
|
|
1282
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
1283
|
+
if (opts.take != null) q.take = opts.take;
|
|
1284
|
+
}
|
|
1285
|
+
const res = await reqGet("/participant/calendars/get", q);
|
|
1286
|
+
if (res.status === "success") {
|
|
1287
|
+
const calendarsRaw = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Calendars) ? res.data.Calendars : Array.isArray((_b = res.data) == null ? void 0 : _b.calendars) ? res.data.calendars : null;
|
|
1288
|
+
if (calendarsRaw) {
|
|
1289
|
+
const calendars = calendarsRaw.map(
|
|
1290
|
+
(c) => Calendar_default.create(mapCalendarFromApi2(c), { env: getConfig() })
|
|
1291
|
+
);
|
|
1292
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1293
|
+
return { calendars, totalCount };
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return null;
|
|
1145
1297
|
}
|
|
1146
1298
|
};
|
|
1147
1299
|
});
|
|
@@ -1173,6 +1325,34 @@ function toPayload(self) {
|
|
|
1173
1325
|
provider: self.provider
|
|
1174
1326
|
};
|
|
1175
1327
|
}
|
|
1328
|
+
function mapCalendarFromApi2(d) {
|
|
1329
|
+
if (!d) return d;
|
|
1330
|
+
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
1331
|
+
const n = (v) => v != null && v !== "" ? Number(v) : void 0;
|
|
1332
|
+
return {
|
|
1333
|
+
id: pick("id", "Id"),
|
|
1334
|
+
companyKey: pick("companyKey", "CompanyKey", "company_key") ?? null,
|
|
1335
|
+
calendarId: String(pick("calendarId", "CalendarId", "calendar_id") ?? ""),
|
|
1336
|
+
name: pick("name", "Name") ?? null,
|
|
1337
|
+
timeZoneId: pick("timeZoneId", "TimeZoneId", "time_zone_id") ?? null,
|
|
1338
|
+
purpose: pick("purpose", "Purpose") ?? "",
|
|
1339
|
+
description: pick("description", "Description") ?? null,
|
|
1340
|
+
assignmentMethod: n(pick("assignmentMethod", "AssignmentMethod", "assignment_method")) ?? void 0,
|
|
1341
|
+
duration: n(pick("duration", "Duration")) ?? void 0,
|
|
1342
|
+
durationUnit: n(pick("durationUnit", "DurationUnit", "duration_unit")) ?? void 0,
|
|
1343
|
+
minimumBookingNotice: n(pick("minimumBookingNotice", "MinimumBookingNotice", "minimum_booking_notice")) ?? void 0,
|
|
1344
|
+
minimumBookingNoticeUnit: n(pick("minimumBookingNoticeUnit", "MinimumBookingNoticeUnit", "minimum_booking_notice_unit")) ?? void 0,
|
|
1345
|
+
minimumCancelationNotice: n(pick("minimumCancelationNotice", "MinimumCancelationNotice", "minimum_cancelation_notice")) ?? void 0,
|
|
1346
|
+
minimumCancelationNoticeUnit: n(pick("minimumCancelationNoticeUnit", "MinimumCancelationNoticeUnit", "minimum_cancelation_notice_unit")) ?? void 0,
|
|
1347
|
+
futureLimit: n(pick("futureLimit", "FutureLimit", "future_limit")) ?? void 0,
|
|
1348
|
+
futureLimitUnit: n(pick("futureLimitUnit", "FutureLimitUnit", "future_limit_unit")) ?? void 0,
|
|
1349
|
+
bufferTime: n(pick("bufferTime", "BufferTime", "buffer_time")) ?? void 0,
|
|
1350
|
+
bufferTimeUnit: n(pick("bufferTimeUnit", "BufferTimeUnit", "buffer_time_unit")) ?? void 0,
|
|
1351
|
+
bookingLimit: n(pick("bookingLimit", "BookingLimit", "booking_limit")) ?? void 0,
|
|
1352
|
+
createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1353
|
+
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1176
1356
|
ParticipantModel.get = async (participantId) => {
|
|
1177
1357
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1178
1358
|
const res = await reqGet("/participant/get", { participant_id: participantId });
|
|
@@ -1227,80 +1407,61 @@ ParticipantModel.sendEmail = async (participantId) => {
|
|
|
1227
1407
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1228
1408
|
return reqGet("/participant/sendemail", { participant_id: participantId });
|
|
1229
1409
|
};
|
|
1410
|
+
ParticipantModel.migrate = async (participantId, userId) => {
|
|
1411
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
1412
|
+
return reqPost("/participant/migrate", {}, { participant_id: participantId, user_id: userId });
|
|
1413
|
+
};
|
|
1414
|
+
ParticipantModel.getCalendars = async (participantId, opts = {}) => {
|
|
1415
|
+
var _a, _b, _c, _d;
|
|
1416
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1417
|
+
const q = { participant_id: participantId };
|
|
1418
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1419
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
1420
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1421
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1422
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1423
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1424
|
+
}
|
|
1425
|
+
if (opts.page != null) {
|
|
1426
|
+
q.page = opts.page;
|
|
1427
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
1428
|
+
} else {
|
|
1429
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
1430
|
+
if (opts.take != null) q.take = opts.take;
|
|
1431
|
+
}
|
|
1432
|
+
const res = await reqGet("/participant/calendars/get", q);
|
|
1433
|
+
if (res.status === "success") {
|
|
1434
|
+
const calendarsRaw = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Calendars) ? res.data.Calendars : Array.isArray((_b = res.data) == null ? void 0 : _b.calendars) ? res.data.calendars : null;
|
|
1435
|
+
if (calendarsRaw) {
|
|
1436
|
+
const calendars = calendarsRaw.map(
|
|
1437
|
+
(c) => Calendar_default.create(mapCalendarFromApi2(c), { env: getConfig() })
|
|
1438
|
+
);
|
|
1439
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1440
|
+
return { calendars, totalCount };
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return null;
|
|
1444
|
+
};
|
|
1230
1445
|
var Participant_default = ParticipantModel;
|
|
1231
1446
|
|
|
1232
1447
|
// src/models/appointment/OpeningHour.js
|
|
1233
|
-
var
|
|
1234
|
-
var OpeningHourModel =
|
|
1235
|
-
id:
|
|
1236
|
-
openingHourId:
|
|
1237
|
-
calendarId:
|
|
1238
|
-
participantId:
|
|
1239
|
-
day:
|
|
1240
|
-
startHour:
|
|
1241
|
-
startMinute:
|
|
1242
|
-
endHour:
|
|
1243
|
-
endMinute:
|
|
1244
|
-
off:
|
|
1245
|
-
createdOn:
|
|
1246
|
-
modifiedOn:
|
|
1448
|
+
var import_mobx_state_tree12 = require("mobx-state-tree");
|
|
1449
|
+
var OpeningHourModel = import_mobx_state_tree12.types.model("OpeningHour", {
|
|
1450
|
+
id: import_mobx_state_tree12.types.maybeNull(import_mobx_state_tree12.types.number),
|
|
1451
|
+
openingHourId: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.string, ""),
|
|
1452
|
+
calendarId: import_mobx_state_tree12.types.string,
|
|
1453
|
+
participantId: import_mobx_state_tree12.types.string,
|
|
1454
|
+
day: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1455
|
+
startHour: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1456
|
+
startMinute: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1457
|
+
endHour: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1458
|
+
endMinute: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1459
|
+
off: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.boolean, false),
|
|
1460
|
+
createdOn: import_mobx_state_tree12.types.maybeNull(import_mobx_state_tree12.types.string),
|
|
1461
|
+
modifiedOn: import_mobx_state_tree12.types.maybeNull(import_mobx_state_tree12.types.string)
|
|
1247
1462
|
});
|
|
1248
1463
|
var OpeningHour_default = OpeningHourModel;
|
|
1249
1464
|
|
|
1250
|
-
// src/models/appointment/TimeFrame.js
|
|
1251
|
-
var import_mobx_state_tree12 = require("mobx-state-tree");
|
|
1252
|
-
var TimeFrameModel = import_mobx_state_tree12.types.model("TimeFrame", {
|
|
1253
|
-
start: import_mobx_state_tree12.types.string,
|
|
1254
|
-
end: import_mobx_state_tree12.types.string
|
|
1255
|
-
}).actions((self) => ({
|
|
1256
|
-
buffer(bufferMinutes, unit) {
|
|
1257
|
-
const bfr = unit === Unit.Hours ? bufferMinutes * 60 : bufferMinutes;
|
|
1258
|
-
const s = new Date(self.start);
|
|
1259
|
-
const e = new Date(self.end);
|
|
1260
|
-
s.setMinutes(s.getMinutes() - bfr);
|
|
1261
|
-
e.setMinutes(e.getMinutes() + bfr);
|
|
1262
|
-
self.start = s.toISOString();
|
|
1263
|
-
self.end = e.toISOString();
|
|
1264
|
-
},
|
|
1265
|
-
conflicts(start, end) {
|
|
1266
|
-
const thisStart = new Date(self.start).getTime();
|
|
1267
|
-
const thisEnd = new Date(self.end).getTime();
|
|
1268
|
-
const startT = start.getTime();
|
|
1269
|
-
const endT = end.getTime();
|
|
1270
|
-
return startT >= thisStart && startT <= thisEnd || endT >= thisStart && endT <= thisEnd || startT <= thisStart && endT >= thisEnd;
|
|
1271
|
-
},
|
|
1272
|
-
breakIntoSlots(slotDurationMinutes) {
|
|
1273
|
-
const start = new Date(self.start);
|
|
1274
|
-
const end = new Date(self.end);
|
|
1275
|
-
const slots = [];
|
|
1276
|
-
let current = new Date(start);
|
|
1277
|
-
const align = (m) => {
|
|
1278
|
-
if (m === 0 || m === 15 || m === 30 || m === 45) return m;
|
|
1279
|
-
if (m > 0 && m < 15) return 15;
|
|
1280
|
-
if (m > 15 && m < 30) return 30;
|
|
1281
|
-
if (m > 30 && m < 45) return 45;
|
|
1282
|
-
return 0;
|
|
1283
|
-
};
|
|
1284
|
-
current.setMinutes(align(current.getMinutes()), 0, 0);
|
|
1285
|
-
let slotEnd = new Date(current.getTime());
|
|
1286
|
-
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1287
|
-
while (slotEnd.getTime() <= end.getTime()) {
|
|
1288
|
-
slots.push({
|
|
1289
|
-
startHour: current.getHours(),
|
|
1290
|
-
startMinute: current.getMinutes(),
|
|
1291
|
-
endHour: slotEnd.getHours(),
|
|
1292
|
-
endMinute: slotEnd.getMinutes(),
|
|
1293
|
-
startDate: current.toISOString(),
|
|
1294
|
-
endDate: slotEnd.toISOString()
|
|
1295
|
-
});
|
|
1296
|
-
current = new Date(slotEnd.getTime());
|
|
1297
|
-
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1298
|
-
}
|
|
1299
|
-
return slots;
|
|
1300
|
-
}
|
|
1301
|
-
}));
|
|
1302
|
-
var TimeFrame_default = TimeFrameModel;
|
|
1303
|
-
|
|
1304
1465
|
// src/models/appointment/Setting.js
|
|
1305
1466
|
var import_mobx_state_tree13 = require("mobx-state-tree");
|
|
1306
1467
|
var SettingModel = import_mobx_state_tree13.types.model("Setting", {
|