mozrest-sdk-react-dev 0.2.38 → 0.2.40
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 +56 -58
- 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
|
-
|
|
102043
|
-
|
|
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
|
-
|
|
102053
|
-
|
|
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
|
-
|
|
102065
|
-
setIsLoading((_a2 = checkIfIsLoading()) != null ? _a2 : true);
|
|
102057
|
+
setIsLoading(checkIfIsLoading());
|
|
102066
102058
|
}, [data2, type4, dateType]);
|
|
102067
102059
|
return isLoading;
|
|
102068
102060
|
};
|
|
@@ -102101,7 +102093,7 @@ const Chart = ({
|
|
|
102101
102093
|
const [statsToDisplay, setStatsToDisplay] = useState(1);
|
|
102102
102094
|
const fetchBookingData = async (payload, dateType) => {
|
|
102103
102095
|
var _a2, _b, _c, _d;
|
|
102104
|
-
const params2 = { ...payload
|
|
102096
|
+
const params2 = { ...payload };
|
|
102105
102097
|
const [, response] = await handlePromise(dateType === "creationDate" ? ReservationAnalyticsService.getBookingItemCount(params2) : ReservationAnalyticsService.getBookingItemMealCount(params2));
|
|
102106
102098
|
if (!response)
|
|
102107
102099
|
return;
|
|
@@ -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 && !
|
|
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
|
-
}))),
|
|
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
|
-
|
|
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
|
-
|
|
102806
|
-
setIsLoading((_a2 = checkIfIsLoading()) != null ? _a2 : true);
|
|
102795
|
+
setIsLoading(checkIfIsLoading());
|
|
102807
102796
|
}, [data2, type4]);
|
|
102808
102797
|
return isLoading;
|
|
102809
102798
|
};
|
|
@@ -102813,7 +102802,10 @@ const StatsBar = ({ params }) => {
|
|
|
102813
102802
|
const [periodDates, setPeriodDates] = useState([]);
|
|
102814
102803
|
const [bookingStats, setBookingStats] = useState({});
|
|
102815
102804
|
const fetchBookingStat = async (payload, cancellations, prevPeriod) => {
|
|
102816
|
-
const params2 = { ...payload
|
|
102805
|
+
const params2 = { ...payload };
|
|
102806
|
+
if (cancellations) {
|
|
102807
|
+
params2["filters[status]"] = "canceled";
|
|
102808
|
+
}
|
|
102817
102809
|
const [, response] = await handlePromise(ReservationAnalyticsService.getBookingItemTotal(params2));
|
|
102818
102810
|
if (!response)
|
|
102819
102811
|
return;
|
|
@@ -102857,6 +102849,30 @@ const StatsBar = ({ params }) => {
|
|
|
102857
102849
|
]);
|
|
102858
102850
|
}
|
|
102859
102851
|
};
|
|
102852
|
+
const isLoadingBookings = LoadingStat({
|
|
102853
|
+
data: bookingStats,
|
|
102854
|
+
type: "bookings"
|
|
102855
|
+
});
|
|
102856
|
+
const isLoadingPrevBookings = LoadingPrevStat({
|
|
102857
|
+
data: bookingStats,
|
|
102858
|
+
type: "bookings"
|
|
102859
|
+
});
|
|
102860
|
+
const isLoadingCovers = LoadingStat({
|
|
102861
|
+
data: bookingStats,
|
|
102862
|
+
type: "covers"
|
|
102863
|
+
});
|
|
102864
|
+
const isLoadingPrevCovers = LoadingPrevStat({
|
|
102865
|
+
data: bookingStats,
|
|
102866
|
+
type: "covers"
|
|
102867
|
+
});
|
|
102868
|
+
const isLoadingCancelations = LoadingStat({
|
|
102869
|
+
data: bookingStats,
|
|
102870
|
+
type: "cancelations"
|
|
102871
|
+
});
|
|
102872
|
+
const isLoadingPrevCancelations = LoadingPrevStat({
|
|
102873
|
+
data: bookingStats,
|
|
102874
|
+
type: "cancelations"
|
|
102875
|
+
});
|
|
102860
102876
|
useEffect(() => {
|
|
102861
102877
|
if (periodDates.length > 0) {
|
|
102862
102878
|
fetchBookingStat({ ...params, "filters[from]": periodDates[2], "filters[till]": periodDates[3] }, true, true);
|
|
@@ -102888,14 +102904,8 @@ const StatsBar = ({ params }) => {
|
|
|
102888
102904
|
data: bookingStats,
|
|
102889
102905
|
type: "bookings"
|
|
102890
102906
|
})) != null ? _b : "-",
|
|
102891
|
-
loading:
|
|
102892
|
-
|
|
102893
|
-
type: "bookings"
|
|
102894
|
-
}),
|
|
102895
|
-
loadingComparison: LoadingPrevStat({
|
|
102896
|
-
data: bookingStats,
|
|
102897
|
-
type: "bookings"
|
|
102898
|
-
})
|
|
102907
|
+
loading: isLoadingBookings,
|
|
102908
|
+
loadingComparison: isLoadingPrevBookings
|
|
102899
102909
|
}, /* @__PURE__ */ React__default.createElement("small", null, t2("ComparedPeriod"), ": ", `${periodDates[0] ? periodDates[0] : ""}-${periodDates[1] ? periodDates[1] : ""}`))), /* @__PURE__ */ React__default.createElement(Col$1, {
|
|
102900
102910
|
xs: 24,
|
|
102901
102911
|
sm: 12,
|
|
@@ -102911,14 +102921,8 @@ const StatsBar = ({ params }) => {
|
|
|
102911
102921
|
data: bookingStats,
|
|
102912
102922
|
type: "covers"
|
|
102913
102923
|
})) != null ? _d : "-",
|
|
102914
|
-
loading:
|
|
102915
|
-
|
|
102916
|
-
type: "covers"
|
|
102917
|
-
}),
|
|
102918
|
-
loadingComparison: LoadingPrevStat({
|
|
102919
|
-
data: bookingStats,
|
|
102920
|
-
type: "covers"
|
|
102921
|
-
})
|
|
102924
|
+
loading: isLoadingCovers,
|
|
102925
|
+
loadingComparison: isLoadingPrevCovers
|
|
102922
102926
|
}, /* @__PURE__ */ React__default.createElement("small", null, t2("ComparedPeriod"), ": ", `${periodDates[0] ? periodDates[0] : ""}-${periodDates[1] ? periodDates[1] : ""}`))), /* @__PURE__ */ React__default.createElement(Col$1, {
|
|
102923
102927
|
xs: 24,
|
|
102924
102928
|
sm: 24,
|
|
@@ -102934,14 +102938,8 @@ const StatsBar = ({ params }) => {
|
|
|
102934
102938
|
data: bookingStats,
|
|
102935
102939
|
type: "cancelations"
|
|
102936
102940
|
})) != null ? _f : "-",
|
|
102937
|
-
loading:
|
|
102938
|
-
|
|
102939
|
-
type: "cancelations"
|
|
102940
|
-
}),
|
|
102941
|
-
loadingComparison: LoadingPrevStat({
|
|
102942
|
-
data: bookingStats,
|
|
102943
|
-
type: "cancelations"
|
|
102944
|
-
})
|
|
102941
|
+
loading: isLoadingCancelations,
|
|
102942
|
+
loadingComparison: isLoadingPrevCancelations
|
|
102945
102943
|
}, /* @__PURE__ */ React__default.createElement("small", null, t2("ComparedPeriod"), ": ", `${periodDates[0] ? periodDates[0] : ""}-${periodDates[1] ? periodDates[1] : ""}`))));
|
|
102946
102944
|
};
|
|
102947
102945
|
const ReservationsAnalytics = ({ userEmail, userFullName }) => {
|