mozrest-sdk-react-dev 0.2.74 → 0.2.75

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/mozrest-sdk.es.js CHANGED
@@ -47552,9 +47552,7 @@ const Input$2 = ({
47552
47552
  required: required4,
47553
47553
  disabled: disabled2,
47554
47554
  ...props
47555
- }), disabled2 && /* @__PURE__ */ React__default.createElement("div", {
47556
- style: { position: "absolute", top: "1rem", right: "1rem" }
47557
- }, /* @__PURE__ */ React__default.createElement(LockTooltip, null, disabledTooltip))));
47555
+ })));
47558
47556
  };
47559
47557
  const TextInputField$1 = (props) => {
47560
47558
  const [field2, meta] = useField(props.id);
@@ -92649,7 +92647,7 @@ const formatChannelsData = (data2) => {
92649
92647
  return [{ id: null, label: "All" }, ...reservationPortals.map((p2) => ({ id: p2.id, label: p2.name }))];
92650
92648
  };
92651
92649
  const formatSmartChannelsData = (data2) => {
92652
- return data2.map((p2) => ({ value: p2.id, label: p2.name }));
92650
+ return data2.map((p2) => ({ value: p2.id, label: p2.name, code: p2.code }));
92653
92651
  };
92654
92652
  const formatHoursData = (data2) => {
92655
92653
  if (!data2 || typeof data2 !== "object") {
@@ -106060,22 +106058,22 @@ const Label = ({
106060
106058
  }, tooltip2));
106061
106059
  return isHidden2 ? /* @__PURE__ */ React__default.createElement(SrOnly, null, label2) : label2;
106062
106060
  };
106063
- const inputWrapper = "_inputWrapper_zpxow_1";
106064
- const input$2 = "_input_zpxow_1";
106065
- const inputIcon = "_inputIcon_zpxow_74";
106061
+ const inputWrapper = "_inputWrapper_1v87g_1";
106062
+ const input$2 = "_input_1v87g_1";
106063
+ const inputIcon = "_inputIcon_1v87g_73";
106066
106064
  var styles$8 = {
106067
106065
  inputWrapper,
106068
106066
  input: input$2,
106069
- "input--r-md": "_input--r-md_zpxow_36",
106070
- "input--r-sm": "_input--r-sm_zpxow_41",
106071
- "input--with-icon-left": "_input--with-icon-left_zpxow_46",
106072
- "input--with-icon-right": "_input--with-icon-right_zpxow_49",
106073
- "input--filled": "_input--filled_zpxow_52",
106074
- "input--borderless": "_input--borderless_zpxow_55",
106075
- "input--rounded": "_input--rounded_zpxow_59",
106067
+ "input--r-md": "_input--r-md_1v87g_35",
106068
+ "input--r-sm": "_input--r-sm_1v87g_40",
106069
+ "input--with-icon-left": "_input--with-icon-left_1v87g_45",
106070
+ "input--with-icon-right": "_input--with-icon-right_1v87g_48",
106071
+ "input--filled": "_input--filled_1v87g_51",
106072
+ "input--borderless": "_input--borderless_1v87g_54",
106073
+ "input--rounded": "_input--rounded_1v87g_58",
106076
106074
  inputIcon,
106077
- "inputIcon--p-left": "_inputIcon--p-left_zpxow_83",
106078
- "inputIcon--p-right": "_inputIcon--p-right_zpxow_86"
106075
+ "inputIcon--p-left": "_inputIcon--p-left_1v87g_82",
106076
+ "inputIcon--p-right": "_inputIcon--p-right_1v87g_85"
106079
106077
  };
106080
106078
  const Input2 = ({
106081
106079
  id: id2,
@@ -106653,7 +106651,7 @@ var styles$7 = {
106653
106651
  const customStyles = {
106654
106652
  control: (provided, state) => ({
106655
106653
  ...provided,
106656
- backgroundColor: "transparent",
106654
+ backgroundColor: state.isDisabled ? "#25293C" : "transparent",
106657
106655
  border: "none",
106658
106656
  borderBottom: `1px solid ${state.isFocused ? "gray" : "#bbb"}`,
106659
106657
  borderRadius: 0,
@@ -106715,9 +106713,7 @@ const Select = ({
106715
106713
  ...props,
106716
106714
  id: id2,
106717
106715
  isDisabled
106718
- }), isDisabled && /* @__PURE__ */ React__default.createElement("div", {
106719
- className: styles$7.tooltip
106720
- }, /* @__PURE__ */ React__default.createElement(LockTooltip, null, disabledTooltip))));
106716
+ })));
106721
106717
  };
106722
106718
  const SelectField = ({ control, name, ...props }) => {
106723
106719
  return /* @__PURE__ */ React__default.createElement(Controller, {
@@ -106781,9 +106777,7 @@ const TextArea = React__default.forwardRef(
106781
106777
  disabled: disabled2,
106782
106778
  ...props,
106783
106779
  ref
106784
- }), disabled2 && /* @__PURE__ */ React__default.createElement("div", {
106785
- style: { position: "absolute", top: "1rem", right: "1rem" }
106786
- }, /* @__PURE__ */ React__default.createElement(LockTooltip, null, disabledTooltip))));
106780
+ })));
106787
106781
  }
106788
106782
  );
106789
106783
  const TextAreaField = ({ control, name, ...props }) => {
@@ -107017,10 +107011,14 @@ const index$6 = ({ filtersData, venueId }) => {
107017
107011
  "Table is required",
107018
107012
  (value2) => value2 !== null && typeof value2 === "object" && !!value2.value
107019
107013
  ).required(),
107020
- firstName: create$2().required(t2("errors.required")),
107021
- lastName: create$2().required(t2("errors.required")),
107022
- email: create$2().email(t2("errors.email")).required(t2("errors.required")),
107023
- phone: create$2().required(t2("errors.required")).matches(new RegExp(/^\+?[1-9]\d{8,14}$/), t2("errors.phone")),
107014
+ firstName: create$2(),
107015
+ lastName: create$2(),
107016
+ email: create$2().email(t2("errors.email")),
107017
+ phone: create$2().nullable().notRequired().test(
107018
+ "is-valid-phone",
107019
+ t2("errors.phone"),
107020
+ (value2) => !value2 || new RegExp(/^\+?[1-9]\d{8,14}$/).test(value2)
107021
+ ),
107024
107022
  notes: create$2()
107025
107023
  });
107026
107024
  const {
@@ -107028,6 +107026,7 @@ const index$6 = ({ filtersData, venueId }) => {
107028
107026
  reset,
107029
107027
  trigger,
107030
107028
  getValues,
107029
+ setValue: setValue2,
107031
107030
  handleSubmit
107032
107031
  } = useForm({
107033
107032
  mode: "onChange",
@@ -107065,7 +107064,7 @@ const index$6 = ({ filtersData, venueId }) => {
107065
107064
  }
107066
107065
  });
107067
107066
  const onSubmit = async () => {
107068
- var _a2, _b, _c, _d, _e2;
107067
+ var _a2, _b, _c, _d, _e2, _f, _g;
107069
107068
  const data22 = await getValues();
107070
107069
  const result = await trigger();
107071
107070
  if (!result) {
@@ -107093,7 +107092,12 @@ const index$6 = ({ filtersData, venueId }) => {
107093
107092
  });
107094
107093
  reloadMainTable();
107095
107094
  } else {
107096
- executeUpdate({ data: { table: (_e2 = data22 == null ? void 0 : data22.table) == null ? void 0 : _e2.value }, venueId, bookingId: selectedBooking.id });
107095
+ const toSend = {
107096
+ partySize: (_e2 = data22 == null ? void 0 : data22.partySize) == null ? void 0 : _e2.value,
107097
+ table: (_f = data22 == null ? void 0 : data22.table) == null ? void 0 : _f.value,
107098
+ date: data22.date ? moment$1.tz(`${data22.date} ${(_g = data22.time) == null ? void 0 : _g.value}`, currentTimeZone ? currentTimeZone : "").valueOf() / 1e3 : moment$1.tz(moment$1(), currentTimeZone ? currentTimeZone : "").valueOf() / 1e3
107099
+ };
107100
+ executeUpdate({ data: toSend, venueId, bookingId: selectedBooking.id });
107097
107101
  }
107098
107102
  };
107099
107103
  useEffect(() => {
@@ -107167,6 +107171,26 @@ const index$6 = ({ filtersData, venueId }) => {
107167
107171
  }
107168
107172
  }
107169
107173
  }, [date4]);
107174
+ useEffect(() => {
107175
+ if (source2 && source2.code === "WALK-IN") {
107176
+ const currentTime = moment$1();
107177
+ setValue2("date", currentTime.format("YYYY-MM-DD"));
107178
+ if (timeOptions.length > 0) {
107179
+ const validFutureTimes = timeOptions.filter((option) => option.value).map((option) => ({
107180
+ ...option,
107181
+ momentValue: moment$1(option.value, "HH:mm")
107182
+ })).filter((option) => option.momentValue.isSameOrAfter(currentTime));
107183
+ if (validFutureTimes.length > 0) {
107184
+ const closestTime = validFutureTimes.reduce((prev2, curr) => {
107185
+ const prevDiff = Math.abs(currentTime.diff(prev2.momentValue, "minutes"));
107186
+ const currDiff = Math.abs(currentTime.diff(curr.momentValue, "minutes"));
107187
+ return currDiff < prevDiff ? curr : prev2;
107188
+ });
107189
+ setValue2("time", closestTime);
107190
+ }
107191
+ }
107192
+ }
107193
+ }, [source2, timeOptions, setValue2]);
107170
107194
  return /* @__PURE__ */ React__default.createElement("div", {
107171
107195
  style: { display: "flex", flexDirection: "column", gap: 10 },
107172
107196
  onSubmit: handleSubmit(onSubmit)
@@ -107183,7 +107207,6 @@ const index$6 = ({ filtersData, venueId }) => {
107183
107207
  }, /* @__PURE__ */ React__default.createElement("div", {
107184
107208
  style: { width: "50%" }
107185
107209
  }, /* @__PURE__ */ React__default.createElement(TextInputField, {
107186
- disabled: selectedBooking,
107187
107210
  control,
107188
107211
  id: "date",
107189
107212
  name: "date",
@@ -107194,7 +107217,6 @@ const index$6 = ({ filtersData, venueId }) => {
107194
107217
  })), /* @__PURE__ */ React__default.createElement("div", {
107195
107218
  style: { width: "50%" }
107196
107219
  }, /* @__PURE__ */ React__default.createElement(SelectField, {
107197
- isDisabled: selectedBooking,
107198
107220
  control,
107199
107221
  isClearable: true,
107200
107222
  id: "time",
@@ -107206,7 +107228,6 @@ const index$6 = ({ filtersData, venueId }) => {
107206
107228
  }, /* @__PURE__ */ React__default.createElement("div", {
107207
107229
  style: { width: "50%" }
107208
107230
  }, /* @__PURE__ */ React__default.createElement(SelectField, {
107209
- isDisabled: selectedBooking,
107210
107231
  control,
107211
107232
  isClearable: true,
107212
107233
  id: "partySize",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.2.74",
3
+ "version": "0.2.75",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": ["mozrest"],
6
6
  "author": {