mozrest-sdk-react-dev 0.1.63 → 0.1.64

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 +86 -5
  2. package/package.json +1 -1
package/mozrest-sdk.es.js CHANGED
@@ -6305,6 +6305,9 @@ const CREATEDAT = "Created at";
6305
6305
  const CHANNEL = "Channel";
6306
6306
  const NOTABLESAVAILABLE = "No tables available";
6307
6307
  const NOTES = "Notes";
6308
+ const CANCELRESERVATION = "Cancel reservation";
6309
+ const AREYOUSURECANCELRESERVATION = "Are you sure you want to cancel this reservation?";
6310
+ const CANCELREASON = "Cancel reason";
6308
6311
  var en = {
6309
6312
  errors,
6310
6313
  SPECIALCLOSINGDATES,
@@ -6571,7 +6574,10 @@ var en = {
6571
6574
  CREATEDAT,
6572
6575
  CHANNEL,
6573
6576
  NOTABLESAVAILABLE,
6574
- NOTES
6577
+ NOTES,
6578
+ CANCELRESERVATION,
6579
+ AREYOUSURECANCELRESERVATION,
6580
+ CANCELREASON
6575
6581
  };
6576
6582
  instance.use(initReactI18next).init({
6577
6583
  resources: {
@@ -96718,7 +96724,7 @@ const SelectedDateDisplay = ({ selectedDate, onSelectDate, datesSummary }) => {
96718
96724
  index2 === selectedCardIndex && styles$8.cardActive
96719
96725
  ])
96720
96726
  }, /* @__PURE__ */ React__default.createElement("p", {
96721
- style: { fontSize: "12px", marginBottom: "0px !important", textAlign: "center", fontWeight: "bold" }
96727
+ style: { fontSize: "12px", marginBottom: 0, textAlign: "center", fontWeight: "bold" }
96722
96728
  }, " ", d2.date.toLocaleDateString([], { weekday: "short" }).toUpperCase(), " "), /* @__PURE__ */ React__default.createElement("div", {
96723
96729
  style: { textAlign: "center", position: "relative", bottom: "10px" }
96724
96730
  }, /* @__PURE__ */ React__default.createElement("strong", {
@@ -98963,7 +98969,11 @@ const TableSelectField = ({ value: value2, tableOptions, isEdit, setIsEdit }) =>
98963
98969
  };
98964
98970
  const UpdateBooking = async ({ venueId, bookingId, data: data2 }) => {
98965
98971
  await instance$1.put(`/resbook/venue/${venueId}/bookings/${bookingId}`, data2);
98966
- return { data: "created" };
98972
+ return { data: "updated" };
98973
+ };
98974
+ const CancelBooking = async ({ venueId, bookingId, data: data2 }) => {
98975
+ await instance$1.put(`/resbook/venue/${venueId}/bookings/${bookingId}/cancel`, data2);
98976
+ return { data: "canceled" };
98967
98977
  };
98968
98978
  const TableSelectForm = ({ table: table2, id: id2, tableOptions, initialValues, isEdit, setIsEdit, reloadMainTable, onClose: onClose2, venueId }) => {
98969
98979
  const emptyVal = {
@@ -98988,9 +98998,53 @@ const TableSelectForm = ({ table: table2, id: id2, tableOptions, initialValues,
98988
98998
  setIsEdit
98989
98999
  }));
98990
99000
  };
98991
- const ReservationDetail = ({ open, onClose: onClose2, venueId, reloadMainTable, selectedRow, currentTimeZone }) => {
99001
+ const CancelReservationModal = ({ onAccept, isLoading, message: message2, title: title2, ...props }) => {
99002
+ const { t: t2 } = useTranslation();
99003
+ const initialValues = {
99004
+ cancelActor: "",
99005
+ cancelReason: ""
99006
+ };
99007
+ const bookingSchema = create$1().shape({
99008
+ cancelActor: create$2().required(t2("errors.required")),
99009
+ cancelReason: create$2()
99010
+ });
99011
+ return /* @__PURE__ */ React__default.createElement(Modal2, {
99012
+ ...props,
99013
+ title: t2("CANCELRESERVATION")
99014
+ }, /* @__PURE__ */ React__default.createElement("h5", null, t2("AREYOUSURECANCELRESERVATION")), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(Formik, {
99015
+ initialValues,
99016
+ validationSchema: bookingSchema,
99017
+ onSubmit: (values, { resetForm }) => {
99018
+ onAccept(values);
99019
+ resetForm({ values: initialValues });
99020
+ }
99021
+ }, ({ values, errors: errors2, touched, isValid: isValid2 }) => /* @__PURE__ */ React__default.createElement(Form$c, null, /* @__PURE__ */ React__default.createElement(TextInputField, {
99022
+ id: "cancelActor",
99023
+ label: t2("FIRSTNAME")
99024
+ }), /* @__PURE__ */ React__default.createElement(TextAreaField, {
99025
+ id: "cancelReason",
99026
+ label: t2("CANCELREASON"),
99027
+ maxLength: 100
99028
+ }), /* @__PURE__ */ React__default.createElement("div", {
99029
+ style: { display: "flex", justifyContent: "center", gap: 20, marginTop: 20 }
99030
+ }, /* @__PURE__ */ React__default.createElement(Button$3, {
99031
+ size: "small",
99032
+ mode: "tertiary",
99033
+ onClick: props.onClose,
99034
+ disabled: isLoading
99035
+ }, t2("CANCEL")), /* @__PURE__ */ React__default.createElement(Button$3, {
99036
+ size: "small",
99037
+ type: "submit",
99038
+ disabled: !isValid2,
99039
+ isLoading
99040
+ }, t2("ACCEPT")))))));
99041
+ };
99042
+ const ReservationDetail = ({ open, onClose: onClose2, venueId, reloadMainTable, selectedRow, currentTimeZone, setSelectedRow }) => {
98992
99043
  var _a2, _b, _c, _d, _e2, _f, _g;
98993
99044
  const { t: t2 } = useTranslation();
99045
+ const [openCancelReservationModal, setOpenCancelReservationModal] = useState(false);
99046
+ const onOpenCancelRevModal = () => setOpenCancelReservationModal(true);
99047
+ const onCloseCancelRevModal = () => setOpenCancelReservationModal(false);
98994
99048
  const [isEdit, setIsEdit] = useState(false);
98995
99049
  const [initialValues, setInitialValues] = useState(null);
98996
99050
  const { data: data2 } = useFetch(GetTableAvailability, {
@@ -99001,6 +99055,20 @@ const ReservationDetail = ({ open, onClose: onClose2, venueId, reloadMainTable,
99001
99055
  partySize: selectedRow.partySize
99002
99056
  } : { startSec: null }
99003
99057
  });
99058
+ const { isExecuting, execute } = useService(CancelBooking, {
99059
+ onSuccess: async () => {
99060
+ setSelectedRow({ ...selectedRow, status: "canceled" });
99061
+ onCloseCancelRevModal();
99062
+ reloadMainTable();
99063
+ }
99064
+ });
99065
+ const cancelReservation = async (values) => {
99066
+ const toSend = {
99067
+ cancelActor: values.cancelActor,
99068
+ cancelReason: values.cancelReason
99069
+ };
99070
+ execute({ data: toSend, venueId, bookingId: selectedRow.id });
99071
+ };
99004
99072
  useEffect(() => {
99005
99073
  if (selectedRow && selectedRow.table && open) {
99006
99074
  setInitialValues({ id: selectedRow.table.id, label: selectedRow.table.name });
@@ -99081,7 +99149,19 @@ const ReservationDetail = ({ open, onClose: onClose2, venueId, reloadMainTable,
99081
99149
  reloadMainTable,
99082
99150
  onClose: onClose2,
99083
99151
  venueId
99084
- }))));
99152
+ })), selectedRow && selectedRow.status && selectedRow.status !== "canceled" && /* @__PURE__ */ React__default.createElement(Button$3, {
99153
+ style: { marginTop: 10 },
99154
+ type: "submit",
99155
+ className: styles$8.btnDanger,
99156
+ onClick: () => onOpenCancelRevModal()
99157
+ }, t2("CANCELRESERVATION"))), selectedRow && selectedRow.status && selectedRow.status !== "canceled" && /* @__PURE__ */ React__default.createElement(CancelReservationModal, {
99158
+ width: 400,
99159
+ message: t2("AREYOUSURECANCELRESERVATION"),
99160
+ onAccept: cancelReservation,
99161
+ open: openCancelReservationModal,
99162
+ onClose: onCloseCancelRevModal,
99163
+ isLoading: isExecuting
99164
+ }));
99085
99165
  };
99086
99166
  const ReservationDashboard = ({
99087
99167
  Header: Header2,
@@ -99194,6 +99274,7 @@ const ReservationDashboard = ({
99194
99274
  open: openDetailReservation,
99195
99275
  onClose: onCloseDetailReservation,
99196
99276
  selectedRow,
99277
+ setSelectedRow,
99197
99278
  currentTimeZone,
99198
99279
  venueId,
99199
99280
  reloadMainTable: reload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.1.63",
3
+ "version": "0.1.64",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": ["mozrest"],
6
6
  "author": {