mozrest-sdk-react-dev 0.2.11 → 0.2.13

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
@@ -6346,6 +6346,7 @@ const SETPASSWORD = "Set password";
6346
6346
  const EXPORTDATA = "Export data";
6347
6347
  const SELECTYOURRESTAURANTS = "Select your restaurants";
6348
6348
  const SelectXResturant = "Select {{value}} restaurant";
6349
+ const SelectAllFromX = "Select all from {{value}}";
6349
6350
  const ComparedPeriod = "Compared period";
6350
6351
  const CLOSE = "Close";
6351
6352
  const NoChannelsConnected = "No channels connected";
@@ -6354,6 +6355,7 @@ const AddWalKin = "Add a walk-in";
6354
6355
  const ConfirmCreateWalkInReservation = "Please confirm that you want to create a walk-in reservation for {{value}}";
6355
6356
  const NoBookingAvailability = "No booking availability";
6356
6357
  const NoAvailabilityForPartySize = "Sorry we have not availability for this party size: {{value}}";
6358
+ const ADDANEMAIL = "Add an email";
6357
6359
  var en = {
6358
6360
  errors,
6359
6361
  SPECIALCLOSINGDATES,
@@ -6658,6 +6660,7 @@ var en = {
6658
6660
  EXPORTDATA,
6659
6661
  SELECTYOURRESTAURANTS,
6660
6662
  SelectXResturant,
6663
+ SelectAllFromX,
6661
6664
  ComparedPeriod,
6662
6665
  CLOSE,
6663
6666
  NoChannelsConnected,
@@ -6665,7 +6668,9 @@ var en = {
6665
6668
  AddWalKin,
6666
6669
  ConfirmCreateWalkInReservation,
6667
6670
  NoBookingAvailability,
6668
- NoAvailabilityForPartySize
6671
+ NoAvailabilityForPartySize,
6672
+ ADDANEMAIL,
6673
+ "Provide at lease one email": "Provide at lease one email"
6669
6674
  };
6670
6675
  instance.use(initReactI18next).init({
6671
6676
  resources: {
@@ -34140,14 +34145,14 @@ var objectCreate = Object.create || function create(O2, Properties) {
34140
34145
  return Properties === void 0 ? result : definePropertiesModule.f(result, Properties);
34141
34146
  };
34142
34147
  var wellKnownSymbol = wellKnownSymbol$5;
34143
- var create$3 = objectCreate;
34148
+ var create$4 = objectCreate;
34144
34149
  var defineProperty$3 = objectDefineProperty.f;
34145
34150
  var UNSCOPABLES = wellKnownSymbol("unscopables");
34146
34151
  var ArrayPrototype = Array.prototype;
34147
34152
  if (ArrayPrototype[UNSCOPABLES] == void 0) {
34148
34153
  defineProperty$3(ArrayPrototype, UNSCOPABLES, {
34149
34154
  configurable: true,
34150
- value: create$3(null)
34155
+ value: create$4(null)
34151
34156
  });
34152
34157
  }
34153
34158
  var addToUnscopables$1 = function(key2) {
@@ -37085,6 +37090,59 @@ BaseSchema.prototype.optional = BaseSchema.prototype.notRequired;
37085
37090
  const Mixed = BaseSchema;
37086
37091
  Mixed.prototype;
37087
37092
  const isAbsent = (value2) => value2 == null;
37093
+ function create$3() {
37094
+ return new BooleanSchema();
37095
+ }
37096
+ class BooleanSchema extends BaseSchema {
37097
+ constructor() {
37098
+ super({
37099
+ type: "boolean"
37100
+ });
37101
+ this.withMutation(() => {
37102
+ this.transform(function(value2) {
37103
+ if (!this.isType(value2)) {
37104
+ if (/^(true|1)$/i.test(String(value2)))
37105
+ return true;
37106
+ if (/^(false|0)$/i.test(String(value2)))
37107
+ return false;
37108
+ }
37109
+ return value2;
37110
+ });
37111
+ });
37112
+ }
37113
+ _typeCheck(v2) {
37114
+ if (v2 instanceof Boolean)
37115
+ v2 = v2.valueOf();
37116
+ return typeof v2 === "boolean";
37117
+ }
37118
+ isTrue(message2 = boolean.isValue) {
37119
+ return this.test({
37120
+ message: message2,
37121
+ name: "is-value",
37122
+ exclusive: true,
37123
+ params: {
37124
+ value: "true"
37125
+ },
37126
+ test(value2) {
37127
+ return isAbsent(value2) || value2 === true;
37128
+ }
37129
+ });
37130
+ }
37131
+ isFalse(message2 = boolean.isValue) {
37132
+ return this.test({
37133
+ message: message2,
37134
+ name: "is-value",
37135
+ exclusive: true,
37136
+ params: {
37137
+ value: "false"
37138
+ },
37139
+ test(value2) {
37140
+ return isAbsent(value2) || value2 === false;
37141
+ }
37142
+ });
37143
+ }
37144
+ }
37145
+ create$3.prototype = BooleanSchema.prototype;
37088
37146
  let rEmail = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
37089
37147
  let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|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{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
@@ -52758,6 +52816,16 @@ const Form$b = ({
52758
52816
  reload
52759
52817
  }) => {
52760
52818
  const { t: t2 } = useTranslation();
52819
+ const { showMessageError } = useMessage();
52820
+ const emailValidationSchema = create$2().email("Please enter a valid email address");
52821
+ const dataValidationSchema = create$1().shape({
52822
+ dailyReport: create$3(),
52823
+ weeklyReport: create$3(),
52824
+ monthlyReport: create$3(),
52825
+ negativeReviewAlert: create$3(),
52826
+ allReviewAlert: create$3(),
52827
+ emails: create2().of(emailValidationSchema).required("Emails are required")
52828
+ });
52761
52829
  const { isExecuting, execute } = useService(UpdateUserNotificationSettings, {
52762
52830
  onSuccess: async () => {
52763
52831
  await reload();
@@ -52765,6 +52833,9 @@ const Form$b = ({
52765
52833
  }
52766
52834
  });
52767
52835
  const handleSubmit = (values) => {
52836
+ if (values.emails.length === 0 || values.emails[0] === "") {
52837
+ return showMessageError(t2("Provide at lease one email"));
52838
+ }
52768
52839
  execute({ data: { ...initialValues, ...values } });
52769
52840
  };
52770
52841
  return /* @__PURE__ */ React__default.createElement(Modal2, {
@@ -52774,8 +52845,9 @@ const Form$b = ({
52774
52845
  width: 700
52775
52846
  }, /* @__PURE__ */ React__default.createElement(Formik, {
52776
52847
  initialValues,
52777
- onSubmit: handleSubmit
52778
- }, ({ values }) => /* @__PURE__ */ React__default.createElement(Form$c, null, /* @__PURE__ */ React__default.createElement(FieldArray, {
52848
+ onSubmit: handleSubmit,
52849
+ validationSchema: dataValidationSchema
52850
+ }, ({ values, isValid: isValid2 }) => /* @__PURE__ */ React__default.createElement(Form$c, null, /* @__PURE__ */ React__default.createElement(FieldArray, {
52779
52851
  name: "emails",
52780
52852
  render: (arrayHelpers) => /* @__PURE__ */ React__default.createElement("div", null, values.emails && values.emails.length > 0 ? values.emails.map((email3, index2) => /* @__PURE__ */ React__default.createElement("div", {
52781
52853
  className: styles$1h.container,
@@ -52795,14 +52867,17 @@ const Form$b = ({
52795
52867
  onClick: () => arrayHelpers.insert(1, "")
52796
52868
  }, /* @__PURE__ */ React__default.createElement("span", {
52797
52869
  className: styles$1h.plus
52798
- }, "+")))) : /* @__PURE__ */ React__default.createElement("button", {
52870
+ }, "+")))) : /* @__PURE__ */ React__default.createElement(Button$3, {
52871
+ size: "small",
52872
+ mode: "secondary",
52799
52873
  type: "button",
52800
52874
  onClick: () => arrayHelpers.push("")
52801
- }, "Add an email"), /* @__PURE__ */ React__default.createElement("div", {
52875
+ }, t2("ADDANEMAIL")), /* @__PURE__ */ React__default.createElement("div", {
52802
52876
  className: styles$1h.footer
52803
52877
  }, /* @__PURE__ */ React__default.createElement(Button$3, {
52804
52878
  size: "small",
52805
52879
  type: "submit",
52880
+ disabled: !isValid2,
52806
52881
  isLoading: isExecuting
52807
52882
  }, t2("SAVE"))))
52808
52883
  }))));
@@ -101323,7 +101398,7 @@ const Chart = ({
101323
101398
  }, /* @__PURE__ */ React__default.createElement(NewSelect, {
101324
101399
  options: showStatsOptions,
101325
101400
  defaultValue: showStatsOptions[0],
101326
- label: t2("SHOW"),
101401
+ label: "",
101327
101402
  onChange: (data22) => setDisplayConcept(data22.value)
101328
101403
  })), /* @__PURE__ */ React__default.createElement(Col$1, {
101329
101404
  xs: { span: 24, order: 1 },
@@ -101347,13 +101422,14 @@ const Chart = ({
101347
101422
  }, /* @__PURE__ */ React__default.createElement(NewSelect, {
101348
101423
  options: displayStatsOptions,
101349
101424
  defaultValue: displayStatsOptions[totalDays > 60 ? 1 : 0],
101350
- label: t2("DISPLAYBY"),
101425
+ label: "",
101351
101426
  onChange: (data22) => setDisplayBy(data22.value)
101352
101427
  })))
101353
101428
  }, statsToDisplay && sources && !isLoading && !isLoadingSources && /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, /* @__PURE__ */ React__default.createElement(BarChart, {
101354
101429
  height: 300,
101355
101430
  data: statsToDisplay,
101356
- barSize: 100
101431
+ barSize: 100,
101432
+ style: { marginTop: 20 }
101357
101433
  }, /* @__PURE__ */ React__default.createElement(CartesianGrid, {
101358
101434
  strokeDasharray: "3 3"
101359
101435
  }), /* @__PURE__ */ React__default.createElement(XAxis, {
@@ -101412,8 +101488,8 @@ const partySizeOptions = [
101412
101488
  { value: 5, label: "5-6" },
101413
101489
  { value: 7, label: "7+" }
101414
101490
  ];
101415
- const filtersContainer = "_filtersContainer_4274u_1";
101416
- const filters = "_filters_4274u_1";
101491
+ const filtersContainer = "_filtersContainer_srxei_1";
101492
+ const filters = "_filters_srxei_1";
101417
101493
  var styles$3 = {
101418
101494
  filtersContainer,
101419
101495
  filters
@@ -101431,8 +101507,12 @@ const GetBrands = async () => {
101431
101507
  const SelectBrands = ({ handleSearchBrand }) => {
101432
101508
  const { t: t2 } = useTranslation();
101433
101509
  const { data: data2, isLoading } = useFetch(GetBrands, "brands");
101510
+ const mockData = [
101511
+ { id: "1", name: "Name1" },
101512
+ { id: "2", name: "Name2" }
101513
+ ];
101434
101514
  return /* @__PURE__ */ React__default.createElement(NewSelect, {
101435
- options: data2,
101515
+ options: mockData,
101436
101516
  placeholder: t2("ALL"),
101437
101517
  getOptionLabel: (option) => option.name,
101438
101518
  getOptionValue: (option) => option.id,
@@ -101441,7 +101521,7 @@ const SelectBrands = ({ handleSearchBrand }) => {
101441
101521
  isClearable: true
101442
101522
  });
101443
101523
  };
101444
- const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, setSelectedRestaurants }) => {
101524
+ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, setSelectedRestaurants, selectedBrand, setSelectedBrand }) => {
101445
101525
  const { t: t2 } = useTranslation();
101446
101526
  const [searchValue, setSearchValue] = useState("");
101447
101527
  const [currentPage, setCurrentPage] = useState(1);
@@ -101460,6 +101540,7 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
101460
101540
  setParams({ ...params, "filters[criteria]": e3.target.value });
101461
101541
  };
101462
101542
  const handleSearchBrand = (value2) => {
101543
+ setSelectedBrand(value2);
101463
101544
  setParams({ ...params, "filters[brand]": value2 ? value2.id : null });
101464
101545
  };
101465
101546
  const handleOnChangePage = (page) => {
@@ -101550,9 +101631,13 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
101550
101631
  className: ""
101551
101632
  }, /* @__PURE__ */ React__default.createElement("div", {
101552
101633
  className: styles$3.filtersContainer
101553
- }, selectedRestaurants.length > 0 && /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(Button$3, {
101634
+ }, /* @__PURE__ */ React__default.createElement("div", {
101635
+ style: { display: "flex", gap: 10, justifyContent: "center" }
101636
+ }, selectedRestaurants.length > 0 && /* @__PURE__ */ React__default.createElement(Button$3, {
101637
+ onClick: () => onClose2()
101638
+ }, t2("SelectXResturant", { value: selectedRestaurants.length })), selectedBrand && /* @__PURE__ */ React__default.createElement(Button$3, {
101554
101639
  onClick: () => onClose2()
101555
- }, t2("SelectXResturant", { value: selectedRestaurants.length }))), /* @__PURE__ */ React__default.createElement("div", {
101640
+ }, t2("SelectAllFromX", { value: selectedBrand.name }))), /* @__PURE__ */ React__default.createElement("div", {
101556
101641
  className: styles$3.filters
101557
101642
  }, /* @__PURE__ */ React__default.createElement("div", {
101558
101643
  style: { minWidth: 150 }
@@ -101585,6 +101670,7 @@ const ToolbarFormFields = ({ handleOnFilter }) => {
101585
101670
  const onOpenRestaurantsSelector = () => setOpenRestaurantsSelector(true);
101586
101671
  const onCloseRestaurantsSelector = () => setOpenRestaurantsSelector(false);
101587
101672
  const [selectedRestaurants, setSelectedRestaurants] = useState([]);
101673
+ const [selectedBrand, setSelectedBrand] = useState(null);
101588
101674
  const {
101589
101675
  handleChange,
101590
101676
  setFieldValue,
@@ -101595,23 +101681,31 @@ const ToolbarFormFields = ({ handleOnFilter }) => {
101595
101681
  isSubmitting
101596
101682
  } = useFormikContext();
101597
101683
  const handleOnClickRestaurantsButton = () => {
101598
- if (selectedRestaurants.length === 0) {
101684
+ if (selectedRestaurants.length === 0 && !selectedBrand) {
101599
101685
  onOpenRestaurantsSelector();
101600
101686
  } else {
101601
101687
  setSelectedRestaurants([]);
101688
+ setSelectedBrand(null);
101602
101689
  }
101603
101690
  };
101604
101691
  useEffect(() => {
101605
- handleOnFilter({ ...values, selectedRestaurants });
101606
- }, [values, selectedRestaurants]);
101692
+ let filters2 = values;
101693
+ if (selectedBrand) {
101694
+ filters2 = { ...filters2, selectedBrand };
101695
+ }
101696
+ if (selectedRestaurants) {
101697
+ filters2 = { ...filters2, selectedRestaurants };
101698
+ }
101699
+ handleOnFilter(filters2);
101700
+ }, [values, selectedRestaurants, selectedBrand]);
101607
101701
  return /* @__PURE__ */ React__default.createElement(Row$1, {
101608
101702
  gutter: [16, 16],
101609
101703
  align: "bottom"
101610
101704
  }, /* @__PURE__ */ React__default.createElement(Col$1, {
101611
101705
  xs: 24,
101612
101706
  sm: 12,
101613
- md: 8,
101614
- lg: 5
101707
+ md: 9,
101708
+ lg: 6
101615
101709
  }, /* @__PURE__ */ React__default.createElement(DatePicker, {
101616
101710
  id: "dateRange",
101617
101711
  label: t2("BOOKINGCREATIONDATERANGE"),
@@ -101633,8 +101727,8 @@ const ToolbarFormFields = ({ handleOnFilter }) => {
101633
101727
  })), /* @__PURE__ */ React__default.createElement(Col$1, {
101634
101728
  xs: 24,
101635
101729
  sm: 12,
101636
- md: 8,
101637
- lg: 5
101730
+ md: 7,
101731
+ lg: 4
101638
101732
  }, /* @__PURE__ */ React__default.createElement(NewSelect, {
101639
101733
  options: partySizeOptions,
101640
101734
  placeholder: t2("ALL"),
@@ -101655,9 +101749,11 @@ const ToolbarFormFields = ({ handleOnFilter }) => {
101655
101749
  mode: "secondary",
101656
101750
  className: classNames$2(styles$4.btn, styles$4["btn--all"]),
101657
101751
  onClick: () => handleOnClickRestaurantsButton()
101658
- }, selectedRestaurants.length > 0 ? `x ${selectedRestaurants.length}` : "All")), /* @__PURE__ */ React__default.createElement(RestaurantsSelector, {
101752
+ }, selectedRestaurants.length > 0 ? `x ${selectedRestaurants.length}` : selectedBrand ? `x All ${selectedBrand.name}` : "All")), /* @__PURE__ */ React__default.createElement(RestaurantsSelector, {
101659
101753
  selectedRestaurants,
101660
101754
  setSelectedRestaurants,
101755
+ selectedBrand,
101756
+ setSelectedBrand,
101661
101757
  open: openRestaurantsSelector,
101662
101758
  onClose: onCloseRestaurantsSelector
101663
101759
  }));
@@ -101769,6 +101865,9 @@ const ToolBar = ({ filters: filters2, setFilters, setTotalDays, userEmail, userF
101769
101865
  } : {},
101770
101866
  ...values.selectedRestaurants.length > 0 ? {
101771
101867
  "filters[venues]": values.selectedRestaurants.map((sr) => sr.id)
101868
+ } : {},
101869
+ ...values.selectedBrand ? {
101870
+ "filters[brandId]": values.selectedBrand.id
101772
101871
  } : {}
101773
101872
  };
101774
101873
  setTotalDays(hooks((_a2 = values.till) != null ? _a2 : null).diff(hooks((_b = values.from) != null ? _b : null), "day") + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": ["mozrest"],
6
6
  "author": {