mozrest-sdk-react-dev 0.2.24 → 0.2.25

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.
Files changed (2) hide show
  1. package/mozrest-sdk.es.js +130 -71
  2. package/package.json +1 -1
package/mozrest-sdk.es.js CHANGED
@@ -6361,6 +6361,8 @@ const SHOWTEMPLATES = "Show templates";
6361
6361
  const NOSHOWRESERVATION = "No show reservation";
6362
6362
  const AREYOUSURENOSHOWRESERVATION = "Are you sure you want to change this reservation to no-show status?";
6363
6363
  const NOSHOW = "No show";
6364
+ const VENUEISCLOSED = "Venue is closed";
6365
+ const VenueClosedByConfigurationAtThisTime = "Venue is closed by configuration at this time";
6364
6366
  var en = {
6365
6367
  errors,
6366
6368
  SPECIALCLOSINGDATES,
@@ -6680,7 +6682,9 @@ var en = {
6680
6682
  SHOWTEMPLATES,
6681
6683
  NOSHOWRESERVATION,
6682
6684
  AREYOUSURENOSHOWRESERVATION,
6683
- NOSHOW
6685
+ NOSHOW,
6686
+ VENUEISCLOSED,
6687
+ VenueClosedByConfigurationAtThisTime
6684
6688
  };
6685
6689
  instance.use(initReactI18next).init({
6686
6690
  resources: {
@@ -97855,6 +97859,7 @@ const ReservationComp = ({
97855
97859
  value: value2,
97856
97860
  currentTimeZone,
97857
97861
  onClick,
97862
+ toggleArrivedConfirmed,
97858
97863
  isTablet = false
97859
97864
  }) => {
97860
97865
  return /* @__PURE__ */ React__default.createElement("tr", {
@@ -97880,13 +97885,50 @@ const ReservationComp = ({
97880
97885
  style: { textAlign: "center" }
97881
97886
  }, status === "arrived" ? /* @__PURE__ */ React__default.createElement(Button$3, {
97882
97887
  size: "mini",
97883
- className: styles$g.btnWarning
97884
- }, "Mark as Closed") : status === "confirmed" ? /* @__PURE__ */ React__default.createElement(Button$3, {
97888
+ className: styles$g.btnWarning,
97889
+ onClick: (e3) => {
97890
+ e3.stopPropagation();
97891
+ if (toggleArrivedConfirmed) {
97892
+ toggleArrivedConfirmed(value2, "confirmed");
97893
+ }
97894
+ }
97895
+ }, "Mark as Confirmed") : status === "confirmed" ? /* @__PURE__ */ React__default.createElement(Button$3, {
97885
97896
  size: "mini",
97886
- className: styles$g.btnWarning
97887
- }, "Mark as Arrived") : /* @__PURE__ */ React__default.createElement("span", null)));
97897
+ className: styles$g.btnWarning,
97898
+ onClick: (e3) => {
97899
+ e3.stopPropagation();
97900
+ if (toggleArrivedConfirmed) {
97901
+ toggleArrivedConfirmed(value2, "arrived");
97902
+ }
97903
+ }
97904
+ }, "Mark as Arrived") : null));
97905
+ };
97906
+ const UpdateBooking = async ({ venueId, bookingId, data: data2 }) => {
97907
+ await instance$1.put(`/resbook/venue/${venueId}/bookings/${bookingId}`, data2);
97908
+ return { data: "updated" };
97888
97909
  };
97889
- const Table$2 = ({ data: data2, setSelectedRow, currentTimeZone }) => {
97910
+ const UpdateBookingStatusBooking = async ({ venueId, bookingId, data: data2 }) => {
97911
+ await instance$1.put(`/resbook/venue/${venueId}/bookings/${bookingId}`, data2);
97912
+ return { data: "ok" };
97913
+ };
97914
+ const Table$2 = ({ data: data2, venueId, onOpenDetailReservation, selectedRow, setSelectedRow, currentTimeZone, reloadMainTable }) => {
97915
+ const [status, setStatus] = useState("");
97916
+ const { execute } = useService(UpdateBookingStatusBooking, {
97917
+ onSuccess: async () => {
97918
+ setSelectedRow({ ...selectedRow, status });
97919
+ reloadMainTable();
97920
+ }
97921
+ });
97922
+ const toggleArrivedConfirmed = async (row2, status2) => {
97923
+ setStatus(status2);
97924
+ execute({
97925
+ venueId,
97926
+ bookingId: row2.id,
97927
+ data: {
97928
+ status: status2
97929
+ }
97930
+ });
97931
+ };
97890
97932
  return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", {
97891
97933
  className: styles$g.mainTableTablet
97892
97934
  }, data2.map((bookingValue, index2) => /* @__PURE__ */ React__default.createElement("div", {
@@ -97917,17 +97959,26 @@ const Table$2 = ({ data: data2, setSelectedRow, currentTimeZone }) => {
97917
97959
  status: bookingValue.status,
97918
97960
  id: "",
97919
97961
  value: bookingValue,
97920
- onClick: (value2) => setSelectedRow(value2),
97962
+ onClick: (value2) => {
97963
+ onOpenDetailReservation();
97964
+ setSelectedRow(value2);
97965
+ },
97921
97966
  isTablet: true
97922
- }), /* @__PURE__ */ React__default.createElement("td", {
97967
+ }), (bookingValue.status === "arrived" || bookingValue.status === "confirmed") && /* @__PURE__ */ React__default.createElement("td", {
97923
97968
  style: { textAlign: "center", backgroundColor: "#F8F8F8", padding: 5 },
97924
97969
  colSpan: 10
97925
97970
  }, bookingValue.status === "arrived" ? /* @__PURE__ */ React__default.createElement(Button$3, {
97926
97971
  size: "mini",
97927
- className: styles$g.btnWarning
97928
- }, "Mark as Closed") : bookingValue.status === "confirmed" ? /* @__PURE__ */ React__default.createElement(Button$3, {
97972
+ className: styles$g.btnWarning,
97973
+ onClick: () => {
97974
+ toggleArrivedConfirmed(bookingValue, "confirmed");
97975
+ }
97976
+ }, "Mark as Confirmed") : bookingValue.status === "confirmed" ? /* @__PURE__ */ React__default.createElement(Button$3, {
97929
97977
  size: "mini",
97930
- className: styles$g.btnWarning
97978
+ className: styles$g.btnWarning,
97979
+ onClick: () => {
97980
+ toggleArrivedConfirmed(bookingValue, "arrived");
97981
+ }
97931
97982
  }, "Mark as Arrived") : /* @__PURE__ */ React__default.createElement("span", null))))))), /* @__PURE__ */ React__default.createElement("div", {
97932
97983
  className: styles$g.mainTableDesktop
97933
97984
  }, /* @__PURE__ */ React__default.createElement("table", {
@@ -97957,7 +98008,11 @@ const Table$2 = ({ data: data2, setSelectedRow, currentTimeZone }) => {
97957
98008
  status: bookingValue.status,
97958
98009
  id: "",
97959
98010
  value: bookingValue,
97960
- onClick: (value2) => setSelectedRow(value2)
98011
+ onClick: (value2) => {
98012
+ onOpenDetailReservation();
98013
+ setSelectedRow(value2);
98014
+ },
98015
+ toggleArrivedConfirmed
97961
98016
  }))))));
97962
98017
  };
97963
98018
  const container$1 = "_container_1iezk_1";
@@ -99532,7 +99587,7 @@ const TableRow$1 = ({ row: row2, setSelectedTable }) => {
99532
99587
  onClick: () => setSelectedTable(row2)
99533
99588
  }, /* @__PURE__ */ React__default.createElement("td", {
99534
99589
  style: { textAlign: "left", paddingTop: 10, paddingBottom: 10 }
99535
- }, `${row2.name} ${row2.area ? "(" + row2.area + ")" : ""}`), /* @__PURE__ */ React__default.createElement("td", {
99590
+ }, `${row2.name} ${row2.area ? "(" + row2.area.name + ")" : ""}`), /* @__PURE__ */ React__default.createElement("td", {
99536
99591
  style: { textAlign: "center" }
99537
99592
  }, `${(_a2 = row2.minCapacity) != null ? _a2 : "?"} - ${(_b = row2.maxCapacity) != null ? _b : "?"}`), /* @__PURE__ */ React__default.createElement("td", {
99538
99593
  style: { textAlign: "center" }
@@ -99897,18 +99952,6 @@ const TableSelectField = ({ value: value2, tableOptions, isEdit, setIsEdit }) =>
99897
99952
  onClick: () => handleSubmit()
99898
99953
  }, "SAVE"));
99899
99954
  };
99900
- const UpdateBooking = async ({ venueId, bookingId, data: data2 }) => {
99901
- await instance$1.put(`/resbook/venue/${venueId}/bookings/${bookingId}`, data2);
99902
- return { data: "updated" };
99903
- };
99904
- const CancelBooking = async ({ venueId, bookingId, data: data2 }) => {
99905
- await instance$1.put(`/resbook/venue/${venueId}/bookings/${bookingId}/cancel`, data2);
99906
- return { data: "canceled" };
99907
- };
99908
- const NoShowBooking = async ({ venueId, bookingId }) => {
99909
- await instance$1.put(`/resbook/venue/${venueId}/bookings/${bookingId}`, { status: "no-show" });
99910
- return { data: "no show ok" };
99911
- };
99912
99955
  const TableSelectForm = ({ table: table2, id: id2, tableOptions, initialValues, isEdit, setIsEdit, reloadMainTable, onClose: onClose2, venueId }) => {
99913
99956
  const emptyVal = {
99914
99957
  table: { id: null, label: "Not selected" }
@@ -99934,32 +99977,10 @@ const TableSelectForm = ({ table: table2, id: id2, tableOptions, initialValues,
99934
99977
  };
99935
99978
  const CancelReservationModal = ({ onAccept, isLoading, message: message2, title: title2, ...props }) => {
99936
99979
  const { t: t2 } = useTranslation();
99937
- const initialValues = {
99938
- cancelActor: "",
99939
- cancelReason: ""
99940
- };
99941
- const bookingSchema = create$1().shape({
99942
- cancelActor: create$2().required(t2("errors.required")),
99943
- cancelReason: create$2()
99944
- });
99945
99980
  return /* @__PURE__ */ React__default.createElement(Modal2, {
99946
99981
  ...props,
99947
99982
  title: t2("CANCELRESERVATION")
99948
- }, /* @__PURE__ */ React__default.createElement("h5", null, t2("AREYOUSURECANCELRESERVATION")), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(Formik, {
99949
- initialValues,
99950
- validationSchema: bookingSchema,
99951
- onSubmit: (values, { resetForm }) => {
99952
- onAccept(values);
99953
- resetForm({ values: initialValues });
99954
- }
99955
- }, ({ values, errors: errors2, touched, isValid: isValid2 }) => /* @__PURE__ */ React__default.createElement(Form$c, null, /* @__PURE__ */ React__default.createElement(TextInputField, {
99956
- id: "cancelActor",
99957
- label: t2("FIRSTNAME")
99958
- }), /* @__PURE__ */ React__default.createElement(TextAreaField, {
99959
- id: "cancelReason",
99960
- label: t2("CANCELREASON"),
99961
- maxLength: 100
99962
- }), /* @__PURE__ */ React__default.createElement("div", {
99983
+ }, /* @__PURE__ */ React__default.createElement("h5", null, t2("AREYOUSURECANCELRESERVATION")), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", {
99963
99984
  style: { display: "flex", justifyContent: "center", gap: 20, marginTop: 20 }
99964
99985
  }, /* @__PURE__ */ React__default.createElement(Button$3, {
99965
99986
  size: "small",
@@ -99969,9 +99990,9 @@ const CancelReservationModal = ({ onAccept, isLoading, message: message2, title:
99969
99990
  }, t2("CANCEL")), /* @__PURE__ */ React__default.createElement(Button$3, {
99970
99991
  size: "small",
99971
99992
  type: "submit",
99972
- disabled: !isValid2,
99993
+ onClick: () => onAccept(),
99973
99994
  isLoading
99974
- }, t2("ACCEPT")))))));
99995
+ }, t2("ACCEPT")))));
99975
99996
  };
99976
99997
  const NoShowReservationModal = ({ onAccept, isLoading, message: message2, title: title2, ...props }) => {
99977
99998
  const { t: t2 } = useTranslation();
@@ -100011,29 +100032,37 @@ const ReservationDetail = ({ open, onClose: onClose2, venueId, reloadMainTable,
100011
100032
  partySize: selectedRow.partySize
100012
100033
  } : { startSec: null }
100013
100034
  });
100014
- const { isExecuting, execute } = useService(CancelBooking, {
100035
+ const { isExecuting, execute } = useService(UpdateBookingStatusBooking, {
100015
100036
  onSuccess: async () => {
100016
100037
  setSelectedRow({ ...selectedRow, status: "canceled" });
100017
100038
  onCloseCancelRevModal();
100018
100039
  reloadMainTable();
100019
100040
  }
100020
100041
  });
100021
- const { isExecuting: isExecutingNoShow, execute: executoNoShow } = useService(NoShowBooking, {
100042
+ const { isExecuting: isExecutingNoShow, execute: executoNoShow } = useService(UpdateBookingStatusBooking, {
100022
100043
  onSuccess: async () => {
100023
100044
  setSelectedRow({ ...selectedRow, status: "no-show" });
100024
100045
  onCloseNoShowRevModal();
100025
100046
  reloadMainTable();
100026
100047
  }
100027
100048
  });
100028
- const cancelReservation = async (values) => {
100029
- const toSend = {
100030
- cancelActor: values.cancelActor,
100031
- cancelReason: values.cancelReason
100032
- };
100033
- execute({ data: toSend, venueId, bookingId: selectedRow.id });
100049
+ const cancelReservation = async () => {
100050
+ execute({
100051
+ venueId,
100052
+ bookingId: selectedRow.id,
100053
+ data: {
100054
+ status: "canceled"
100055
+ }
100056
+ });
100034
100057
  };
100035
100058
  const noShowReservation = async () => {
100036
- executoNoShow({ venueId, bookingId: selectedRow.id });
100059
+ executoNoShow({
100060
+ venueId,
100061
+ bookingId: selectedRow.id,
100062
+ data: {
100063
+ status: "no-show"
100064
+ }
100065
+ });
100037
100066
  };
100038
100067
  useEffect(() => {
100039
100068
  if (selectedRow && selectedRow.table && open) {
@@ -100127,14 +100156,14 @@ const ReservationDetail = ({ open, onClose: onClose2, venueId, reloadMainTable,
100127
100156
  type: "submit",
100128
100157
  className: styles$g.btnDanger,
100129
100158
  onClick: () => onOpenNoShowRevModal()
100130
- }, t2("NOSHOW")))), selectedRow && selectedRow.status && selectedRow.status !== "canceled" && /* @__PURE__ */ React__default.createElement(CancelReservationModal, {
100159
+ }, t2("NOSHOW")))), /* @__PURE__ */ React__default.createElement(CancelReservationModal, {
100131
100160
  width: 400,
100132
100161
  message: t2("AREYOUSURECANCELRESERVATION"),
100133
100162
  onAccept: cancelReservation,
100134
100163
  open: openCancelReservationModal,
100135
100164
  onClose: onCloseCancelRevModal,
100136
100165
  isLoading: isExecuting || isExecutingNoShow
100137
- }), selectedRow && selectedRow.status && selectedRow.status === "confirmed" && /* @__PURE__ */ React__default.createElement(NoShowReservationModal, {
100166
+ }), /* @__PURE__ */ React__default.createElement(NoShowReservationModal, {
100138
100167
  width: 400,
100139
100168
  message: t2("AREYOUSURENOSHOWRESERVATION"),
100140
100169
  onAccept: noShowReservation,
@@ -100309,11 +100338,16 @@ const WalkinButton = ({ partyOptions, onOpenCreateWalkInReservation, walkInParty
100309
100338
  };
100310
100339
  const CreateWalkInReservation = ({ open, onClose: onClose2, venueId, reloadMainTable, currentTimeZone, currentDate, partySize }) => {
100311
100340
  const { t: t2 } = useTranslation();
100341
+ const [hourOpen, setHourOpen] = useState(true);
100312
100342
  const params = {
100313
100343
  partySize,
100314
- startSec: moment$1.tz(`${currentDate} 12:00`, currentTimeZone ? currentTimeZone : "").valueOf() / 1e3
100344
+ startSec: moment$1.tz(`${currentDate} ${moment$1().format("HH:mm")}`, currentTimeZone ? currentTimeZone : "").valueOf() / 1e3
100315
100345
  };
100316
- const { data: data2, isLoading, reload } = useFetch(GetTableWalkInAvailability, { cacheId: "walkIntableAvailability", venue_id: venueId, params });
100346
+ const { data: data2, isLoading } = useFetch(GetTableWalkInAvailability, { cacheId: "walkIntableAvailability", venue_id: venueId, params });
100347
+ const { data: openingHours, isLoading: isLoadingOpeningHours } = useFetch(GetOpeningHours, {
100348
+ cacheId: "opening0hours",
100349
+ venue_id: venueId
100350
+ });
100317
100351
  const { execute, isExecuting } = useService(AddBooking);
100318
100352
  const handleOnSubmit = async () => {
100319
100353
  const toSend = {
@@ -100336,18 +100370,40 @@ const CreateWalkInReservation = ({ open, onClose: onClose2, venueId, reloadMainT
100336
100370
  reloadMainTable();
100337
100371
  onClose2();
100338
100372
  };
100339
- return /* @__PURE__ */ React__default.createElement(ModalConfirmation, {
100340
- title: data2 && data2.id ? t2("AREYOUSURE?") : t2("NoBookingAvailability"),
100341
- icon: data2 && data2.id ? "calendar" : "no",
100342
- message: data2 && data2.id ? t2("ConfirmCreateWalkInReservation", { value: partySize }) : t2("NoAvailabilityForPartySize", { value: partySize }),
100343
- showSubmitButton: data2 && data2.id ? true : false,
100344
- cancelButtonText: data2 && data2.id ? void 0 : t2("CLOSE"),
100373
+ const isTimeBetween = (targetTime, startTime, endTime) => {
100374
+ const targetMoment = moment$1(targetTime, "HH:mm");
100375
+ const startMoment = moment$1(startTime, "HH:mm");
100376
+ const endMoment = moment$1(endTime, "HH:mm");
100377
+ return targetMoment.isBetween(startMoment, endMoment, null, "[]");
100378
+ };
100379
+ useEffect(() => {
100380
+ if (openingHours && openingHours.length > 0) {
100381
+ const dayWeekName = moment$1(currentDate).format("dddd").toLocaleLowerCase();
100382
+ const dayWeek = openingHours.find((d2) => d2.day === dayWeekName && !d2.closed);
100383
+ if (dayWeek && dayWeek.timeslots && dayWeek.timeslots.length > 0) {
100384
+ const time2 = moment$1.tz(moment$1(), currentTimeZone ? currentTimeZone : "").format("HH:mm");
100385
+ let isBetween2 = false;
100386
+ dayWeek.timeslots.map((ts) => {
100387
+ if (isTimeBetween(time2, ts.start, ts.end)) {
100388
+ isBetween2 = true;
100389
+ }
100390
+ });
100391
+ setHourOpen(isBetween2);
100392
+ }
100393
+ }
100394
+ }, [openingHours]);
100395
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, !isLoading && !isLoadingOpeningHours && /* @__PURE__ */ React__default.createElement(ModalConfirmation, {
100396
+ title: !hourOpen ? t2("VENUEISCLOSED") : data2 && data2.id ? t2("AREYOUSURE?") : t2("NoBookingAvailability"),
100397
+ icon: hourOpen && data2 && data2.id ? "calendar" : "no",
100398
+ message: !hourOpen ? t2("VenueClosedByConfigurationAtThisTime") : data2 && data2.id ? t2("ConfirmCreateWalkInReservation", { value: partySize }) : t2("NoAvailabilityForPartySize", { value: partySize }),
100399
+ showSubmitButton: hourOpen && data2 && data2.id ? true : false,
100400
+ cancelButtonText: hourOpen && data2 && data2.id ? void 0 : t2("CLOSE"),
100345
100401
  onAccept: () => handleOnSubmit(),
100346
100402
  open,
100347
100403
  onClose: onClose2,
100348
100404
  isLoading: isLoading || isExecuting,
100349
100405
  width: 500
100350
- });
100406
+ }));
100351
100407
  };
100352
100408
  const ReservationDashboard = ({
100353
100409
  Header: Header2,
@@ -100475,9 +100531,12 @@ const ReservationDashboard = ({
100475
100531
  currentDate
100476
100532
  })), isLoading ? /* @__PURE__ */ React__default.createElement(SkeletonPage, null) : /* @__PURE__ */ React__default.createElement(Table$2, {
100477
100533
  currentTimeZone: currentTimeZone.current,
100534
+ venueId,
100478
100535
  data: data2,
100536
+ reloadMainTable: reload,
100537
+ onOpenDetailReservation,
100538
+ selectedRow,
100479
100539
  setSelectedRow: (row2) => {
100480
- onOpenDetailReservation();
100481
100540
  setSelectedRow(row2);
100482
100541
  }
100483
100542
  })), /* @__PURE__ */ React__default.createElement(HoursAvailability, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": ["mozrest"],
6
6
  "author": {