mozrest-sdk-react-dev 0.2.38 → 0.2.39

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 +51 -56
  2. package/package.json +1 -1
package/mozrest-sdk.es.js CHANGED
@@ -102038,31 +102038,23 @@ const LoadingBarChart = ({ data: data2, type: type4, dateType }) => {
102038
102038
  const checkIfIsLoading = () => {
102039
102039
  if (data2) {
102040
102040
  if (type4 === "bookings") {
102041
- if (dateType === "creationDate") {
102042
- if ((data2 == null ? void 0 : data2.bookingsCreationDate) !== void 0) {
102043
- return false;
102044
- }
102045
- } else if (dateType === "mealDate") {
102046
- if ((data2 == null ? void 0 : data2.bookingsMealDate) !== void 0) {
102047
- return false;
102048
- }
102041
+ if (dateType === "creationDate" && (data2 == null ? void 0 : data2.bookingsCreationDate) !== void 0) {
102042
+ return false;
102043
+ } else if (dateType === "mealDate" && (data2 == null ? void 0 : data2.bookingsMealDate) !== void 0) {
102044
+ return false;
102049
102045
  }
102050
102046
  } else if (type4 === "covers") {
102051
- if (dateType === "creationDate") {
102052
- if ((data2 == null ? void 0 : data2.coversCreationDate) !== void 0) {
102053
- return false;
102054
- }
102055
- } else if (dateType === "mealDate") {
102056
- if ((data2 == null ? void 0 : data2.coversMealDate) !== void 0) {
102057
- return false;
102058
- }
102047
+ if (dateType === "creationDate" && (data2 == null ? void 0 : data2.coversCreationDate) !== void 0) {
102048
+ return false;
102049
+ } else if (dateType === "mealDate" && (data2 == null ? void 0 : data2.coversMealDate) !== void 0) {
102050
+ return false;
102059
102051
  }
102060
102052
  }
102061
102053
  }
102054
+ return true;
102062
102055
  };
102063
102056
  useEffect(() => {
102064
- var _a2;
102065
- setIsLoading((_a2 = checkIfIsLoading()) != null ? _a2 : true);
102057
+ setIsLoading(checkIfIsLoading());
102066
102058
  }, [data2, type4, dateType]);
102067
102059
  return isLoading;
102068
102060
  };
@@ -102129,6 +102121,11 @@ const Chart = ({
102129
102121
  { value: 1, label: t2("CREATIONDATE") },
102130
102122
  { value: 2, label: t2("MEALDATE") }
102131
102123
  ];
102124
+ const isLoading = LoadingBarChart({
102125
+ data: dataCollection,
102126
+ type: displayConcept === 1 ? "bookings" : "covers",
102127
+ dateType: displayType === 1 ? "creationDate" : "mealDate"
102128
+ });
102132
102129
  const calculateStats = useCallback(() => {
102133
102130
  const concept = displayConcept === 1 ? "bookings" : "covers", type4 = displayType === 1 ? "creation" : "meal", by = displayBy === 0 ? "day" : displayBy === 1 ? "week" : displayBy;
102134
102131
  let dataCollectionToShow = [];
@@ -102223,11 +102220,7 @@ const Chart = ({
102223
102220
  label: "",
102224
102221
  onChange: (data2) => setDisplayBy(data2.value)
102225
102222
  })))
102226
- }, statsToDisplay && sources && !LoadingBarChart({
102227
- data: dataCollection,
102228
- type: displayConcept === 1 ? "bookings" : "covers",
102229
- dateType: displayType === 1 ? "creationDate" : "mealDate"
102230
- }) && /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, /* @__PURE__ */ React__default.createElement(BarChart, {
102223
+ }, statsToDisplay && sources && !isLoading && /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, /* @__PURE__ */ React__default.createElement(BarChart, {
102231
102224
  height: 300,
102232
102225
  data: statsToDisplay,
102233
102226
  barSize: 100,
@@ -102246,11 +102239,7 @@ const Chart = ({
102246
102239
  });
102247
102240
  }), /* @__PURE__ */ React__default.createElement(Legend, {
102248
102241
  verticalAlign: "bottom"
102249
- }))), LoadingBarChart({
102250
- data: dataCollection,
102251
- type: displayConcept === 1 ? "bookings" : "covers",
102252
- dateType: displayType === 1 ? "creationDate" : "mealDate"
102253
- }) && /* @__PURE__ */ React__default.createElement("div", {
102242
+ }))), isLoading && /* @__PURE__ */ React__default.createElement("div", {
102254
102243
  style: { marginTop: 20 }
102255
102244
  }, /* @__PURE__ */ React__default.createElement(SkeletonDiv, null)));
102256
102245
  };
@@ -102781,10 +102770,10 @@ const LoadingStat = ({ data: data2, type: type4 }) => {
102781
102770
  return false;
102782
102771
  }
102783
102772
  }
102773
+ return true;
102784
102774
  };
102785
102775
  useEffect(() => {
102786
- var _a2;
102787
- setIsLoading((_a2 = checkIfIsLoading()) != null ? _a2 : true);
102776
+ setIsLoading(checkIfIsLoading());
102788
102777
  }, [data2, type4]);
102789
102778
  return isLoading;
102790
102779
  };
@@ -102800,10 +102789,10 @@ const LoadingPrevStat = ({ data: data2, type: type4 }) => {
102800
102789
  return false;
102801
102790
  }
102802
102791
  }
102792
+ return true;
102803
102793
  };
102804
102794
  useEffect(() => {
102805
- var _a2;
102806
- setIsLoading((_a2 = checkIfIsLoading()) != null ? _a2 : true);
102795
+ setIsLoading(checkIfIsLoading());
102807
102796
  }, [data2, type4]);
102808
102797
  return isLoading;
102809
102798
  };
@@ -102857,6 +102846,30 @@ const StatsBar = ({ params }) => {
102857
102846
  ]);
102858
102847
  }
102859
102848
  };
102849
+ const isLoadingBookings = LoadingStat({
102850
+ data: bookingStats,
102851
+ type: "bookings"
102852
+ });
102853
+ const isLoadingPrevBookings = LoadingPrevStat({
102854
+ data: bookingStats,
102855
+ type: "bookings"
102856
+ });
102857
+ const isLoadingCovers = LoadingStat({
102858
+ data: bookingStats,
102859
+ type: "covers"
102860
+ });
102861
+ const isLoadingPrevCovers = LoadingPrevStat({
102862
+ data: bookingStats,
102863
+ type: "covers"
102864
+ });
102865
+ const isLoadingCancelations = LoadingStat({
102866
+ data: bookingStats,
102867
+ type: "cancelations"
102868
+ });
102869
+ const isLoadingPrevCancelations = LoadingPrevStat({
102870
+ data: bookingStats,
102871
+ type: "cancelations"
102872
+ });
102860
102873
  useEffect(() => {
102861
102874
  if (periodDates.length > 0) {
102862
102875
  fetchBookingStat({ ...params, "filters[from]": periodDates[2], "filters[till]": periodDates[3] }, true, true);
@@ -102888,14 +102901,8 @@ const StatsBar = ({ params }) => {
102888
102901
  data: bookingStats,
102889
102902
  type: "bookings"
102890
102903
  })) != null ? _b : "-",
102891
- loading: LoadingStat({
102892
- data: bookingStats,
102893
- type: "bookings"
102894
- }),
102895
- loadingComparison: LoadingPrevStat({
102896
- data: bookingStats,
102897
- type: "bookings"
102898
- })
102904
+ loading: isLoadingBookings,
102905
+ loadingComparison: isLoadingPrevBookings
102899
102906
  }, /* @__PURE__ */ React__default.createElement("small", null, t2("ComparedPeriod"), ": ", `${periodDates[0] ? periodDates[0] : ""}-${periodDates[1] ? periodDates[1] : ""}`))), /* @__PURE__ */ React__default.createElement(Col$1, {
102900
102907
  xs: 24,
102901
102908
  sm: 12,
@@ -102911,14 +102918,8 @@ const StatsBar = ({ params }) => {
102911
102918
  data: bookingStats,
102912
102919
  type: "covers"
102913
102920
  })) != null ? _d : "-",
102914
- loading: LoadingStat({
102915
- data: bookingStats,
102916
- type: "covers"
102917
- }),
102918
- loadingComparison: LoadingPrevStat({
102919
- data: bookingStats,
102920
- type: "covers"
102921
- })
102921
+ loading: isLoadingCovers,
102922
+ loadingComparison: isLoadingPrevCovers
102922
102923
  }, /* @__PURE__ */ React__default.createElement("small", null, t2("ComparedPeriod"), ": ", `${periodDates[0] ? periodDates[0] : ""}-${periodDates[1] ? periodDates[1] : ""}`))), /* @__PURE__ */ React__default.createElement(Col$1, {
102923
102924
  xs: 24,
102924
102925
  sm: 24,
@@ -102934,14 +102935,8 @@ const StatsBar = ({ params }) => {
102934
102935
  data: bookingStats,
102935
102936
  type: "cancelations"
102936
102937
  })) != null ? _f : "-",
102937
- loading: LoadingStat({
102938
- data: bookingStats,
102939
- type: "cancelations"
102940
- }),
102941
- loadingComparison: LoadingPrevStat({
102942
- data: bookingStats,
102943
- type: "cancelations"
102944
- })
102938
+ loading: isLoadingCancelations,
102939
+ loadingComparison: isLoadingPrevCancelations
102945
102940
  }, /* @__PURE__ */ React__default.createElement("small", null, t2("ComparedPeriod"), ": ", `${periodDates[0] ? periodDates[0] : ""}-${periodDates[1] ? periodDates[1] : ""}`))));
102946
102941
  };
102947
102942
  const ReservationsAnalytics = ({ userEmail, userFullName }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.2.38",
3
+ "version": "0.2.39",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": ["mozrest"],
6
6
  "author": {