@sawport/react-sdk 0.1.0-alpha.79 → 0.1.0-alpha.80

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.js CHANGED
@@ -70011,7 +70011,7 @@ When it is time for the meeting, follow these instructions to chat with an agent
70011
70011
  Step 1: Log into your bank's internet banking or mobile banking platform.
70012
70012
  Step 2: Open the video banking widget.
70013
70013
  Step 3: Click on the "Scheduled Meeting" button.
70014
- Step 4: Click the blue "Join" button to join meeting.`,
70014
+ Step 4: Click the blue "Join" button to start the meeting.`,
70015
70015
  location: window.location,
70016
70016
  startTime: hooks(`${date4}T${time2}`, "YYYY-MM-DDTHH:mm"),
70017
70017
  endTime: hooks(`${date4}T${time2}`, "YYYY-MM-DDTHH:mm").add(1, "h")
@@ -70262,12 +70262,15 @@ const defaultWorkHours = {
70262
70262
  Friday: { times: [["09:00", "17:00"]], closed: false },
70263
70263
  Saturday: { times: [["09:00", "17:00"]], closed: true }
70264
70264
  };
70265
+ dayjs.extend(customParseFormat);
70265
70266
  const SlotPicker = reactExports.memo(({
70266
70267
  errors,
70267
70268
  handleChange,
70268
70269
  workHours = defaultWorkHours,
70269
70270
  date: date4,
70270
- timezone: timezone2
70271
+ time: time2,
70272
+ timezone: timezone2,
70273
+ callRequestDuration = 30
70271
70274
  }) => {
70272
70275
  const {
70273
70276
  state: {
@@ -70277,36 +70280,9 @@ const SlotPicker = reactExports.memo(({
70277
70280
  asyncRequest: getSlots
70278
70281
  });
70279
70282
  const disabledTime = reactExports.useCallback(() => ({
70280
- disabledHours: () => {
70281
- var _a, _b, _c, _d;
70282
- if (!date4)
70283
- return [];
70284
- const times = [];
70285
- const timeformat = "HH:mm";
70286
- const currentDay = hooks.tz(date4, timezone2).format("dddd");
70287
- const [fromTime, toTime] = workHours[currentDay].times[0];
70288
- const from2 = hooks.tz(fromTime, timeformat, timezone2).local().get("h"), to2 = hooks.tz(toTime, timeformat, timezone2).local().get("h");
70289
- for (let index2 = 0; index2 <= 23; index2++) {
70290
- const half = parseFloat(`${index2}.3`);
70291
- if (!(index2 >= from2 && index2 < to2) || ((_b = (_a = data2 == null ? void 0 : data2[date4]) == null ? void 0 : _a[index2]) == null ? void 0 : _b.full) && ((_d = (_c = data2 == null ? void 0 : data2[date4]) == null ? void 0 : _c[half]) == null ? void 0 : _d.full)) {
70292
- times.push(index2);
70293
- }
70294
- }
70295
- return times;
70296
- },
70297
- disabledMinutes: (selectedHour) => {
70298
- var _a, _b, _c, _d;
70299
- const mins = [];
70300
- const half = parseFloat(`${selectedHour}.3`);
70301
- if ((_b = (_a = data2 == null ? void 0 : data2[date4]) == null ? void 0 : _a[half]) == null ? void 0 : _b.full) {
70302
- mins.push(30);
70303
- }
70304
- if ((_d = (_c = data2 == null ? void 0 : data2[date4]) == null ? void 0 : _c[selectedHour]) == null ? void 0 : _d.full) {
70305
- mins.push(0);
70306
- }
70307
- return mins;
70308
- }
70309
- }), [workHours, date4, data2, timezone2]);
70283
+ disabledHours: () => getDisabledHours(workHours, timezone2, date4),
70284
+ disabledMinutes: (selectedHour) => getDisabledMinutes(workHours, timezone2, date4, selectedHour, data2)
70285
+ }), [date4, workHours, timezone2, data2]);
70310
70286
  const disabledDate = reactExports.useCallback((current2) => {
70311
70287
  const day = current2.format("dddd");
70312
70288
  return workHours[day].closed || hooks(hooks().subtract(1, "d")).isSameOrAfter(current2.toDate());
@@ -70333,6 +70309,7 @@ const SlotPicker = reactExports.memo(({
70333
70309
  format: "YYYY-MM-DD",
70334
70310
  disabledDate,
70335
70311
  name: "date",
70312
+ defaultValue: date4 ? dayjs(date4) : void 0,
70336
70313
  showToday: false,
70337
70314
  onChange: (_2, date23) => handleChange({
70338
70315
  target: {
@@ -70360,13 +70337,14 @@ const SlotPicker = reactExports.memo(({
70360
70337
  }), /* @__PURE__ */ jsx(TimePicker$1, {
70361
70338
  className: styles$2.picker,
70362
70339
  format: "HH:mm A",
70363
- minuteStep: 30,
70340
+ minuteStep: callRequestDuration,
70364
70341
  disabledTime,
70342
+ defaultValue: time2 ? dayjs(time2, "HH:mm") : void 0,
70365
70343
  name: "time",
70366
70344
  showNow: false,
70367
- onChange: (_2, time2) => handleChange({
70345
+ onChange: (_2, time22) => handleChange({
70368
70346
  target: {
70369
- value: time2,
70347
+ value: time22,
70370
70348
  name: "time"
70371
70349
  }
70372
70350
  }),
@@ -70376,6 +70354,71 @@ const SlotPicker = reactExports.memo(({
70376
70354
  })]
70377
70355
  });
70378
70356
  });
70357
+ const getDisabledHours = (workHours, timezone2, date4, data2) => {
70358
+ if (!date4)
70359
+ return [];
70360
+ const foreignDate = hooks.tz(date4, timezone2);
70361
+ const day = foreignDate.format("dddd");
70362
+ const hoursSet = /* @__PURE__ */ new Set();
70363
+ const {
70364
+ times
70365
+ } = workHours[day];
70366
+ times.forEach(([start, end]) => {
70367
+ const startTime = hooks.tz(`${foreignDate.format("YYYY-MM-DD")} ${start}`, timezone2).local();
70368
+ const endTime = hooks.tz(`${foreignDate.format("YYYY-MM-DD")} ${end}`, timezone2).local();
70369
+ if (startTime.isSameOrAfter(endTime)) {
70370
+ for (let i2 = 0; i2 < startTime.hour(); i2++) {
70371
+ hoursSet.add(i2);
70372
+ }
70373
+ for (let i2 = endTime.hour(); i2 < 24; i2++) {
70374
+ hoursSet.add(i2);
70375
+ }
70376
+ } else {
70377
+ for (let i2 = 0; i2 < startTime.hour(); i2++) {
70378
+ hoursSet.add(i2);
70379
+ }
70380
+ for (let i2 = endTime.hour(); i2 < 24; i2++) {
70381
+ hoursSet.add(i2);
70382
+ }
70383
+ }
70384
+ });
70385
+ return [...hoursSet];
70386
+ };
70387
+ const getDisabledMinutes = (workHours, timezone2, date4, selectedHour, data2) => {
70388
+ if (!date4 || selectedHour)
70389
+ return [];
70390
+ const currentDate = hooks.tz(date4, timezone2);
70391
+ const day = currentDate.format("dddd");
70392
+ const minutesSet = /* @__PURE__ */ new Set();
70393
+ const {
70394
+ times
70395
+ } = workHours[day];
70396
+ times.forEach(([start, end]) => {
70397
+ var _a, _b;
70398
+ const startMoment = hooks.tz(`${currentDate.format("YYYY-MM-DD")} ${start}`, timezone2);
70399
+ const endMoment = hooks.tz(`${currentDate.format("YYYY-MM-DD")} ${end}`, timezone2);
70400
+ if ((_b = (_a = data2 == null ? void 0 : data2[date4]) == null ? void 0 : _a[selectedHour]) == null ? void 0 : _b.full) {
70401
+ minutesSet.push(0);
70402
+ }
70403
+ if (selectedHour === startMoment.hour() && selectedHour === endMoment.hour()) {
70404
+ for (let i2 = 0; i2 < startMoment.minute(); i2++) {
70405
+ minutesSet.add(i2);
70406
+ }
70407
+ for (let i2 = endMoment.minute(); i2 < 60; i2++) {
70408
+ minutesSet.add(i2);
70409
+ }
70410
+ } else if (selectedHour === startMoment.hour()) {
70411
+ for (let i2 = 0; i2 < startMoment.minute(); i2++) {
70412
+ minutesSet.add(i2);
70413
+ }
70414
+ } else if (selectedHour === endMoment.hour()) {
70415
+ for (let i2 = endMoment.minute(); i2 < 60; i2++) {
70416
+ minutesSet.add(i2);
70417
+ }
70418
+ }
70419
+ });
70420
+ return [...minutesSet];
70421
+ };
70379
70422
  const PhoneInput$1 = PI.default || PI;
70380
70423
  const Offline = reactExports.memo(({
70381
70424
  company_id,
@@ -70428,12 +70471,18 @@ const Offline = reactExports.memo(({
70428
70471
  return !workHours[day].closed;
70429
70472
  }),
70430
70473
  time: create$5().required("Please specify a time").test("time", "Selected time is out of Hours of Operation", function(value2, prop) {
70431
- const timeformat = "HH:mm";
70474
+ if (!prop.parent.date || !value2)
70475
+ return;
70432
70476
  const dayName = hooks.tz(prop.parent.date, companyTimezone).format("dddd");
70477
+ const dateString = hooks(prop.parent.date).format("YYYY-MM-DD");
70433
70478
  const [fromTime, toTime] = workHours[dayName].times[0];
70434
- const check2 = hooks(value2, timeformat), beforeTime = hooks.tz(fromTime, timeformat, companyTimezone).local(), afterTime = hooks.tz(toTime, timeformat, companyTimezone).local();
70435
- const isToday = hooks(prop.parent.date).isSame(hooks(), "D");
70436
- return isToday ? check2.isSameOrAfter(hooks()) && check2.isBefore(afterTime) : check2.isSameOrAfter(beforeTime) && check2.isBefore(afterTime);
70479
+ const datetime = hooks(prop.parent.date).clone().set({
70480
+ hours: parseInt(value2.split(":")[0], 10),
70481
+ minutes: parseInt(value2.split(":")[1], 10)
70482
+ }).tz(companyTimezone);
70483
+ const startTime = hooks.tz(`${dateString} ${fromTime}`, companyTimezone);
70484
+ const endTime = hooks.tz(`${dateString} ${toTime}`, companyTimezone);
70485
+ return datetime.isBetween(startTime, endTime, "minute", "[]");
70437
70486
  }),
70438
70487
  reason: create$5().min(1).required("Reason is required"),
70439
70488
  mobile: create$5().min(7).required()
@@ -70698,7 +70747,9 @@ const Offline = reactExports.memo(({
70698
70747
  handleChange,
70699
70748
  workHours,
70700
70749
  date: values.date,
70701
- timezone: companyTimezone
70750
+ time: values.time,
70751
+ timezone: companyTimezone,
70752
+ callRequestDuration: options == null ? void 0 : options.callRequestDuration
70702
70753
  }), /* @__PURE__ */ jsx(FInput, {
70703
70754
  style: {
70704
70755
  borderRight: void 0,
@@ -70831,7 +70882,7 @@ const Schedules = reactExports.memo(function({
70831
70882
  asyncRequest: calendars,
70832
70883
  params: [{
70833
70884
  customer: customer == null ? void 0 : customer.id,
70834
- status: ["accepted", "pending"],
70885
+ status: ["accepted", "pending", "reschedule"],
70835
70886
  isFuture: true,
70836
70887
  order: {
70837
70888
  "calendar.scheduledAt": "ASC"
@@ -78061,11 +78112,7 @@ const OngoingChat = ({
78061
78112
  };
78062
78113
  reactExports.useEffect(() => {
78063
78114
  if ((wait == null ? void 0 : wait.status) === "connected" && (conversation == null ? void 0 : conversation.offlineAt) && chatSession) {
78064
- const currentTimestamp = (/* @__PURE__ */ new Date()).getTime();
78065
- const offlineAt = (/* @__PURE__ */ new Date(`${conversation == null ? void 0 : conversation.offlineAt}`)).getTime();
78066
- const timeDifferenceInMilliseconds = currentTimestamp - offlineAt;
78067
- const timeDifferenceInMinutes = Math.floor(timeDifferenceInMilliseconds / chatSession);
78068
- if (timeDifferenceInMinutes >= chatSession) {
78115
+ if (hooks().diff(hooks(conversation == null ? void 0 : conversation.offlineAt), "minutes") > chatSession) {
78069
78116
  toast.info("Time expired for going off chat", {
78070
78117
  autoClose: 2e3
78071
78118
  });