mozrest-sdk-react-dev 0.1.19 → 0.1.20
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 +262 -70
- package/package.json +1 -1
package/mozrest-sdk.es.js
CHANGED
|
@@ -41205,9 +41205,9 @@ const GetVenueListing = async ({
|
|
|
41205
41205
|
}
|
|
41206
41206
|
});
|
|
41207
41207
|
sessionStorage.setItem("sdk_venue_vertical", data2 == null ? void 0 : data2.vertical);
|
|
41208
|
-
return formatData$
|
|
41208
|
+
return formatData$d(data2);
|
|
41209
41209
|
};
|
|
41210
|
-
const formatData$
|
|
41210
|
+
const formatData$d = async (values = {}) => {
|
|
41211
41211
|
var _a2;
|
|
41212
41212
|
const {
|
|
41213
41213
|
country,
|
|
@@ -41781,9 +41781,9 @@ const GetVenueListingModule = async ({
|
|
|
41781
41781
|
Authorization: `Bearer ${accessToken}`
|
|
41782
41782
|
}
|
|
41783
41783
|
});
|
|
41784
|
-
return formatData$
|
|
41784
|
+
return formatData$c(data2);
|
|
41785
41785
|
};
|
|
41786
|
-
const formatData$
|
|
41786
|
+
const formatData$c = (values = {}) => {
|
|
41787
41787
|
const { country, ...rest } = values;
|
|
41788
41788
|
const _country = countries == null ? void 0 : countries.find(({ id }) => id === country);
|
|
41789
41789
|
return {
|
|
@@ -48748,9 +48748,9 @@ const GetListingAttributes = async ({
|
|
|
48748
48748
|
Authorization: `Bearer ${accessToken}`
|
|
48749
48749
|
}
|
|
48750
48750
|
});
|
|
48751
|
-
return formatData$
|
|
48751
|
+
return formatData$b(data2.data);
|
|
48752
48752
|
};
|
|
48753
|
-
const formatData$
|
|
48753
|
+
const formatData$b = (data2 = []) => {
|
|
48754
48754
|
const dd = [...data2].sort((a2, b2) => {
|
|
48755
48755
|
if (a2.position < b2.position) {
|
|
48756
48756
|
return 1;
|
|
@@ -55289,7 +55289,7 @@ const GetReviews = async ({
|
|
|
55289
55289
|
"sortby[createdAt]": "DESC"
|
|
55290
55290
|
}
|
|
55291
55291
|
});
|
|
55292
|
-
return formatData$
|
|
55292
|
+
return formatData$a(data2);
|
|
55293
55293
|
};
|
|
55294
55294
|
const formatParams$5 = (params) => {
|
|
55295
55295
|
const all2 = {};
|
|
@@ -55314,7 +55314,7 @@ const formatParams$5 = (params) => {
|
|
|
55314
55314
|
limit: 30
|
|
55315
55315
|
};
|
|
55316
55316
|
};
|
|
55317
|
-
const formatData$
|
|
55317
|
+
const formatData$a = (data2) => {
|
|
55318
55318
|
return data2.map(({ reviewerProfilePhoto, reviewerName, reply: reply2, createdAt, ...item2 }) => ({
|
|
55319
55319
|
...item2,
|
|
55320
55320
|
reviewer: {
|
|
@@ -56003,7 +56003,7 @@ const GetReplyTemplates = async ({
|
|
|
56003
56003
|
offset: page * limit
|
|
56004
56004
|
}
|
|
56005
56005
|
});
|
|
56006
|
-
return formatData$
|
|
56006
|
+
return formatData$9(data2);
|
|
56007
56007
|
};
|
|
56008
56008
|
const formatParams$4 = (params = {}) => {
|
|
56009
56009
|
let all2 = {};
|
|
@@ -56022,7 +56022,7 @@ const formatParams$4 = (params = {}) => {
|
|
|
56022
56022
|
limit: 30
|
|
56023
56023
|
};
|
|
56024
56024
|
};
|
|
56025
|
-
const formatData$
|
|
56025
|
+
const formatData$9 = (data2) => {
|
|
56026
56026
|
return data2.map((item2) => {
|
|
56027
56027
|
return {
|
|
56028
56028
|
id: item2.id,
|
|
@@ -62235,9 +62235,9 @@ const GetVenueListingsOptions = async () => {
|
|
|
62235
62235
|
limit: 1e3
|
|
62236
62236
|
}
|
|
62237
62237
|
});
|
|
62238
|
-
return formatData$
|
|
62238
|
+
return formatData$8(data2);
|
|
62239
62239
|
};
|
|
62240
|
-
const formatData$
|
|
62240
|
+
const formatData$8 = (data2) => {
|
|
62241
62241
|
return {
|
|
62242
62242
|
data: data2.data.map(({ id, businessName }) => ({
|
|
62243
62243
|
id,
|
|
@@ -63939,10 +63939,10 @@ const GetUserNotificationSettings = async ({}) => {
|
|
|
63939
63939
|
const UpdateUserNotificationSettings = async ({
|
|
63940
63940
|
data: data2
|
|
63941
63941
|
}) => {
|
|
63942
|
-
await instance$1.put(`listing/notification-settings`, formatData$
|
|
63942
|
+
await instance$1.put(`listing/notification-settings`, formatData$7(data2));
|
|
63943
63943
|
return { data: data2 };
|
|
63944
63944
|
};
|
|
63945
|
-
const formatData$
|
|
63945
|
+
const formatData$7 = (data2) => {
|
|
63946
63946
|
return {
|
|
63947
63947
|
dailyReport: data2.dailyReport ? "true" : "false",
|
|
63948
63948
|
weeklyReport: data2.weeklyReport ? "true" : "false",
|
|
@@ -64203,21 +64203,21 @@ const UpsertReplyTemplates = async ({
|
|
|
64203
64203
|
accessToken
|
|
64204
64204
|
}) => {
|
|
64205
64205
|
if (data2.id) {
|
|
64206
|
-
await instance$1.put(`/listing/review-reply-template/${data2.id}`, formatData$
|
|
64206
|
+
await instance$1.put(`/listing/review-reply-template/${data2.id}`, formatData$6(data2), {
|
|
64207
64207
|
headers: {
|
|
64208
64208
|
Authorization: `Bearer ${accessToken}`
|
|
64209
64209
|
}
|
|
64210
64210
|
});
|
|
64211
64211
|
return { data: data2 };
|
|
64212
64212
|
}
|
|
64213
|
-
await instance$1.post(`/listing/review-reply-template`, formatData$
|
|
64213
|
+
await instance$1.post(`/listing/review-reply-template`, formatData$6(data2), {
|
|
64214
64214
|
headers: {
|
|
64215
64215
|
Authorization: `Bearer ${accessToken}`
|
|
64216
64216
|
}
|
|
64217
64217
|
});
|
|
64218
64218
|
return { data: data2 };
|
|
64219
64219
|
};
|
|
64220
|
-
const formatData$
|
|
64220
|
+
const formatData$6 = (data2) => {
|
|
64221
64221
|
return {
|
|
64222
64222
|
locale: data2.language.value === "gb" ? "en" : data2.language.value,
|
|
64223
64223
|
comment: data2.reply,
|
|
@@ -64756,52 +64756,52 @@ const Header$1 = ({ value: value2, onChangeFilter, multiVenue }) => {
|
|
|
64756
64756
|
multiVenue
|
|
64757
64757
|
})))));
|
|
64758
64758
|
};
|
|
64759
|
-
const formatData$
|
|
64760
|
-
const compare2 = groupByDate(dataToFormat.compare);
|
|
64761
|
-
const inPeriod = groupByDate(dataToFormat.data);
|
|
64759
|
+
const formatData$5 = (dataToFormat) => {
|
|
64760
|
+
const compare2 = groupByDate$1(dataToFormat.compare);
|
|
64761
|
+
const inPeriod = groupByDate$1(dataToFormat.data);
|
|
64762
64762
|
return {
|
|
64763
|
-
reviews: formatReviews(inPeriod, compare2),
|
|
64764
|
-
treatment: formatTreatment(inPeriod, compare2),
|
|
64765
|
-
replyTime: formatAvgReplyTime(inPeriod, compare2),
|
|
64766
|
-
average: formatAvgChart(inPeriod, compare2),
|
|
64767
|
-
chart: formatChart(inPeriod)
|
|
64763
|
+
reviews: formatReviews$1(inPeriod, compare2),
|
|
64764
|
+
treatment: formatTreatment$1(inPeriod, compare2),
|
|
64765
|
+
replyTime: formatAvgReplyTime$1(inPeriod, compare2),
|
|
64766
|
+
average: formatAvgChart$1(inPeriod, compare2),
|
|
64767
|
+
chart: formatChart$1(inPeriod)
|
|
64768
64768
|
};
|
|
64769
64769
|
};
|
|
64770
|
-
const sumReviews = (data2) => data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2 }) => acc + positive2 + negative2 + neutral2, 0);
|
|
64771
|
-
const fixed = (value2) => {
|
|
64770
|
+
const sumReviews$1 = (data2) => data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2 }) => acc + positive2 + negative2 + neutral2, 0);
|
|
64771
|
+
const fixed$1 = (value2) => {
|
|
64772
64772
|
return Number(value2.toFixed(2)) || 0;
|
|
64773
64773
|
};
|
|
64774
|
-
const getPercentageDiff = (inPeriod, compare2) => {
|
|
64774
|
+
const getPercentageDiff$1 = (inPeriod, compare2) => {
|
|
64775
64775
|
if (compare2 === 0) {
|
|
64776
64776
|
return 0;
|
|
64777
64777
|
}
|
|
64778
|
-
return fixed((inPeriod - compare2) * 100 / compare2);
|
|
64778
|
+
return fixed$1((inPeriod - compare2) * 100 / compare2);
|
|
64779
64779
|
};
|
|
64780
|
-
const formatReviews = (inPeriod, compare2) => {
|
|
64781
|
-
const totalInPeriod = sumReviews(inPeriod);
|
|
64782
|
-
const totalCompare = sumReviews(compare2);
|
|
64780
|
+
const formatReviews$1 = (inPeriod, compare2) => {
|
|
64781
|
+
const totalInPeriod = sumReviews$1(inPeriod);
|
|
64782
|
+
const totalCompare = sumReviews$1(compare2);
|
|
64783
64783
|
return {
|
|
64784
64784
|
value: totalInPeriod,
|
|
64785
|
-
comparison: getPercentageDiff(totalInPeriod, totalCompare)
|
|
64785
|
+
comparison: getPercentageDiff$1(totalInPeriod, totalCompare)
|
|
64786
64786
|
};
|
|
64787
64787
|
};
|
|
64788
|
-
const sumTreatment = (data2) => data2.reduce((acc, { treatment }) => acc + treatment, 0);
|
|
64789
|
-
const getPercentage = (part, total) => {
|
|
64790
|
-
return fixed(part * 100 / total);
|
|
64788
|
+
const sumTreatment$1 = (data2) => data2.reduce((acc, { treatment }) => acc + treatment, 0);
|
|
64789
|
+
const getPercentage$1 = (part, total) => {
|
|
64790
|
+
return fixed$1(part * 100 / total);
|
|
64791
64791
|
};
|
|
64792
|
-
const formatTreatment = (inPeriod, compare2) => {
|
|
64793
|
-
const totalTreatmentInPeriod = sumTreatment(inPeriod);
|
|
64794
|
-
const totalTreatmentCompare = sumTreatment(compare2);
|
|
64795
|
-
const totalReviewsInPeriod = sumReviews(inPeriod);
|
|
64792
|
+
const formatTreatment$1 = (inPeriod, compare2) => {
|
|
64793
|
+
const totalTreatmentInPeriod = sumTreatment$1(inPeriod);
|
|
64794
|
+
const totalTreatmentCompare = sumTreatment$1(compare2);
|
|
64795
|
+
const totalReviewsInPeriod = sumReviews$1(inPeriod);
|
|
64796
64796
|
return {
|
|
64797
64797
|
value: {
|
|
64798
|
-
value: getPercentage(totalTreatmentInPeriod, totalReviewsInPeriod),
|
|
64798
|
+
value: getPercentage$1(totalTreatmentInPeriod, totalReviewsInPeriod),
|
|
64799
64799
|
units: "%"
|
|
64800
64800
|
},
|
|
64801
|
-
comparison: getPercentageDiff(totalTreatmentInPeriod, totalTreatmentCompare)
|
|
64801
|
+
comparison: getPercentageDiff$1(totalTreatmentInPeriod, totalTreatmentCompare)
|
|
64802
64802
|
};
|
|
64803
64803
|
};
|
|
64804
|
-
const getAvgReplyTime = (data2) => {
|
|
64804
|
+
const getAvgReplyTime$1 = (data2) => {
|
|
64805
64805
|
if (data2.length === 0) {
|
|
64806
64806
|
return 0;
|
|
64807
64807
|
}
|
|
@@ -64812,20 +64812,20 @@ const getAvgReplyTime = (data2) => {
|
|
|
64812
64812
|
const totalReplyTime = data2.reduce((acc, { avgReplyTime, treatment }) => acc + avgReplyTime * treatment, 0);
|
|
64813
64813
|
return Math.round(totalReplyTime / totalTreatment);
|
|
64814
64814
|
};
|
|
64815
|
-
const formatAvgReplyTime = (inPeriod, compare2) => {
|
|
64816
|
-
const inPeriodReplyTime = getAvgReplyTime(inPeriod);
|
|
64817
|
-
const compareReplyTime = getAvgReplyTime(compare2);
|
|
64815
|
+
const formatAvgReplyTime$1 = (inPeriod, compare2) => {
|
|
64816
|
+
const inPeriodReplyTime = getAvgReplyTime$1(inPeriod);
|
|
64817
|
+
const compareReplyTime = getAvgReplyTime$1(compare2);
|
|
64818
64818
|
return {
|
|
64819
64819
|
value: humanizeMinutes(inPeriodReplyTime),
|
|
64820
|
-
comparison: getPercentageDiff(inPeriodReplyTime, compareReplyTime)
|
|
64820
|
+
comparison: getPercentageDiff$1(inPeriodReplyTime, compareReplyTime)
|
|
64821
64821
|
};
|
|
64822
64822
|
};
|
|
64823
|
-
const getAvg = (data2) => {
|
|
64823
|
+
const getAvg$1 = (data2) => {
|
|
64824
64824
|
const total = data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2 }) => acc + positive2 + negative2 + neutral2, 0);
|
|
64825
64825
|
const rating = data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2, avg }) => acc + avg * (positive2 + negative2 + neutral2), 0);
|
|
64826
|
-
return fixed(rating / total);
|
|
64826
|
+
return fixed$1(rating / total);
|
|
64827
64827
|
};
|
|
64828
|
-
const circleChart = (data2) => {
|
|
64828
|
+
const circleChart$1 = (data2) => {
|
|
64829
64829
|
const value2 = data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2 }) => ({
|
|
64830
64830
|
positive: positive2 + acc.positive,
|
|
64831
64831
|
negative: negative2 + acc.negative,
|
|
@@ -64837,23 +64837,23 @@ const circleChart = (data2) => {
|
|
|
64837
64837
|
{ name: instance.t("NEUTRAL"), value: value2.neutral }
|
|
64838
64838
|
];
|
|
64839
64839
|
};
|
|
64840
|
-
const formatAvgChart = (inPeriod, compare2) => {
|
|
64840
|
+
const formatAvgChart$1 = (inPeriod, compare2) => {
|
|
64841
64841
|
return {
|
|
64842
64842
|
inPeriod: {
|
|
64843
|
-
avg: getAvg(inPeriod),
|
|
64844
|
-
chart: circleChart(inPeriod)
|
|
64843
|
+
avg: getAvg$1(inPeriod),
|
|
64844
|
+
chart: circleChart$1(inPeriod)
|
|
64845
64845
|
},
|
|
64846
64846
|
compare: {
|
|
64847
|
-
avg: getAvg(compare2),
|
|
64848
|
-
chart: circleChart(compare2)
|
|
64847
|
+
avg: getAvg$1(compare2),
|
|
64848
|
+
chart: circleChart$1(compare2)
|
|
64849
64849
|
}
|
|
64850
64850
|
};
|
|
64851
64851
|
};
|
|
64852
|
-
const formatChart = (inPeriod) => inPeriod.map((item2) => ({
|
|
64852
|
+
const formatChart$1 = (inPeriod) => inPeriod.map((item2) => ({
|
|
64853
64853
|
...item2,
|
|
64854
64854
|
date: dateFromString(item2.date)
|
|
64855
64855
|
}));
|
|
64856
|
-
const groupByDate = (data2) => {
|
|
64856
|
+
const groupByDate$1 = (data2) => {
|
|
64857
64857
|
const grouped = groupBy(data2, "date");
|
|
64858
64858
|
return Object.values(grouped).map((items) => {
|
|
64859
64859
|
const { total, ...rest } = items.reduce((acc, item2) => {
|
|
@@ -64879,8 +64879,8 @@ const groupByDate = (data2) => {
|
|
|
64879
64879
|
});
|
|
64880
64880
|
return {
|
|
64881
64881
|
...rest,
|
|
64882
|
-
avg: fixed(rest.avg / total),
|
|
64883
|
-
avgReplyTime: rest.treatment > 0 ? fixed(rest.avgReplyTime / rest.treatment) : 0
|
|
64882
|
+
avg: fixed$1(rest.avg / total),
|
|
64883
|
+
avgReplyTime: rest.treatment > 0 ? fixed$1(rest.avgReplyTime / rest.treatment) : 0
|
|
64884
64884
|
};
|
|
64885
64885
|
});
|
|
64886
64886
|
};
|
|
@@ -87173,7 +87173,7 @@ const formatDateChart = (date4, mode) => {
|
|
|
87173
87173
|
return formatDate(date4, "DD/MM/YYYY");
|
|
87174
87174
|
}
|
|
87175
87175
|
};
|
|
87176
|
-
const formatData$
|
|
87176
|
+
const formatData$4 = (data2, mode) => {
|
|
87177
87177
|
const formatedData = data2.reduce((acc, { date: _date, ...item2 }) => {
|
|
87178
87178
|
var _a2, _b, _c;
|
|
87179
87179
|
const date4 = formatDateChart(_date, mode);
|
|
@@ -87241,7 +87241,7 @@ const ReviewsChart = ({
|
|
|
87241
87241
|
const handleChanDisplayBy = (ev) => {
|
|
87242
87242
|
setDisplayBy(ev.target.value);
|
|
87243
87243
|
};
|
|
87244
|
-
const chartData = formatData$
|
|
87244
|
+
const chartData = formatData$4(data2, displayBy);
|
|
87245
87245
|
const options2 = limitDisplaByOptions(days2);
|
|
87246
87246
|
return /* @__PURE__ */ React__default.createElement(Card, {
|
|
87247
87247
|
header: { title: t2("REVIEWSEVOLUTIION") }
|
|
@@ -87372,6 +87372,12 @@ const getCurrentRange = () => {
|
|
|
87372
87372
|
till: subtractDate(void 0, 0, "day")
|
|
87373
87373
|
};
|
|
87374
87374
|
};
|
|
87375
|
+
const getTodaysRange = () => {
|
|
87376
|
+
return {
|
|
87377
|
+
from: subtractDate(void 0, 0, "day"),
|
|
87378
|
+
till: subtractDate(void 0, 0, "day")
|
|
87379
|
+
};
|
|
87380
|
+
};
|
|
87375
87381
|
const COLORS$1 = ["#82ca9d", "#ffc658", "#8884d8"];
|
|
87376
87382
|
const LabelsScoreChart = ({
|
|
87377
87383
|
title: title2,
|
|
@@ -87533,7 +87539,7 @@ const formatComparedPeriod = (range4) => {
|
|
|
87533
87539
|
return "";
|
|
87534
87540
|
return `${formatDate(range4.from, dateFormat)} - ${formatDate(range4.till, dateFormat)}`;
|
|
87535
87541
|
};
|
|
87536
|
-
const Analytics$
|
|
87542
|
+
const Analytics$2 = ({ venueListingId }) => {
|
|
87537
87543
|
const { t: t2 } = useTranslation();
|
|
87538
87544
|
const [filter, setFilters] = useState({
|
|
87539
87545
|
range: getCurrentRange(),
|
|
@@ -87544,7 +87550,7 @@ const Analytics$1 = ({ venueListingId }) => {
|
|
|
87544
87550
|
const { data: data2, isLoading, error: error3 } = useFetch(GetReviewAnalytics, {
|
|
87545
87551
|
cacheId: `reviews-analytics-${venueListingId}`,
|
|
87546
87552
|
params: filter
|
|
87547
|
-
}, { formatData: formatData$
|
|
87553
|
+
}, { formatData: formatData$5 });
|
|
87548
87554
|
const { data: venues } = useFetch(GetVenueListingsOptions, {
|
|
87549
87555
|
cacheId: `venueListing-options`
|
|
87550
87556
|
});
|
|
@@ -87800,7 +87806,7 @@ const formatStats = (stat) => {
|
|
|
87800
87806
|
});
|
|
87801
87807
|
return sum;
|
|
87802
87808
|
};
|
|
87803
|
-
const formatData$
|
|
87809
|
+
const formatData$3 = (dataToFormat) => {
|
|
87804
87810
|
return {
|
|
87805
87811
|
totals: {
|
|
87806
87812
|
queries: {
|
|
@@ -87874,7 +87880,7 @@ const singleVenue$1 = async () => {
|
|
|
87874
87880
|
}
|
|
87875
87881
|
});
|
|
87876
87882
|
};
|
|
87877
|
-
const Analytics = ({ venueListingId }) => {
|
|
87883
|
+
const Analytics$1 = ({ venueListingId }) => {
|
|
87878
87884
|
const { t: t2 } = useTranslation();
|
|
87879
87885
|
const [listingId, setListingId] = useState(venueListingId);
|
|
87880
87886
|
const [formattedStats, setFormattedStats] = useState();
|
|
@@ -87899,7 +87905,7 @@ const Analytics = ({ venueListingId }) => {
|
|
|
87899
87905
|
if (data2 && (data2 == null ? void 0 : data2.BUSINESS_IMPRESSIONS_DESKTOP_SEARCH.error)) {
|
|
87900
87906
|
setNotAuthorized(true);
|
|
87901
87907
|
} else {
|
|
87902
|
-
setFormattedStats(formatData$
|
|
87908
|
+
setFormattedStats(formatData$3(data2));
|
|
87903
87909
|
}
|
|
87904
87910
|
}
|
|
87905
87911
|
}, [data2]);
|
|
@@ -87982,6 +87988,191 @@ const Analytics = ({ venueListingId }) => {
|
|
|
87982
87988
|
data: formattedStats == null ? void 0 : formattedStats.actions
|
|
87983
87989
|
}))));
|
|
87984
87990
|
};
|
|
87991
|
+
const formatData$2 = (dataToFormat) => {
|
|
87992
|
+
const compare2 = groupByDate(dataToFormat.compare);
|
|
87993
|
+
const inPeriod = groupByDate(dataToFormat.data);
|
|
87994
|
+
return {
|
|
87995
|
+
reviews: formatReviews(inPeriod, compare2),
|
|
87996
|
+
treatment: formatTreatment(inPeriod, compare2),
|
|
87997
|
+
replyTime: formatAvgReplyTime(inPeriod, compare2),
|
|
87998
|
+
average: formatAvgChart(inPeriod, compare2),
|
|
87999
|
+
chart: formatChart(inPeriod)
|
|
88000
|
+
};
|
|
88001
|
+
};
|
|
88002
|
+
const sumReviews = (data2) => data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2 }) => acc + positive2 + negative2 + neutral2, 0);
|
|
88003
|
+
const fixed = (value2) => {
|
|
88004
|
+
return Number(value2.toFixed(2)) || 0;
|
|
88005
|
+
};
|
|
88006
|
+
const getPercentageDiff = (inPeriod, compare2) => {
|
|
88007
|
+
if (compare2 === 0) {
|
|
88008
|
+
return 0;
|
|
88009
|
+
}
|
|
88010
|
+
return fixed((inPeriod - compare2) * 100 / compare2);
|
|
88011
|
+
};
|
|
88012
|
+
const formatReviews = (inPeriod, compare2) => {
|
|
88013
|
+
const totalInPeriod = sumReviews(inPeriod);
|
|
88014
|
+
const totalCompare = sumReviews(compare2);
|
|
88015
|
+
return {
|
|
88016
|
+
value: totalInPeriod,
|
|
88017
|
+
comparison: getPercentageDiff(totalInPeriod, totalCompare)
|
|
88018
|
+
};
|
|
88019
|
+
};
|
|
88020
|
+
const sumTreatment = (data2) => data2.reduce((acc, { treatment }) => acc + treatment, 0);
|
|
88021
|
+
const getPercentage = (part, total) => {
|
|
88022
|
+
return fixed(part * 100 / total);
|
|
88023
|
+
};
|
|
88024
|
+
const formatTreatment = (inPeriod, compare2) => {
|
|
88025
|
+
const totalTreatmentInPeriod = sumTreatment(inPeriod);
|
|
88026
|
+
const totalTreatmentCompare = sumTreatment(compare2);
|
|
88027
|
+
const totalReviewsInPeriod = sumReviews(inPeriod);
|
|
88028
|
+
return {
|
|
88029
|
+
value: {
|
|
88030
|
+
value: getPercentage(totalTreatmentInPeriod, totalReviewsInPeriod),
|
|
88031
|
+
units: "%"
|
|
88032
|
+
},
|
|
88033
|
+
comparison: getPercentageDiff(totalTreatmentInPeriod, totalTreatmentCompare)
|
|
88034
|
+
};
|
|
88035
|
+
};
|
|
88036
|
+
const getAvgReplyTime = (data2) => {
|
|
88037
|
+
if (data2.length === 0) {
|
|
88038
|
+
return 0;
|
|
88039
|
+
}
|
|
88040
|
+
const totalTreatment = data2.reduce((acc, { treatment }) => acc + treatment, 0);
|
|
88041
|
+
if (totalTreatment === 0) {
|
|
88042
|
+
return 0;
|
|
88043
|
+
}
|
|
88044
|
+
const totalReplyTime = data2.reduce((acc, { avgReplyTime, treatment }) => acc + avgReplyTime * treatment, 0);
|
|
88045
|
+
return Math.round(totalReplyTime / totalTreatment);
|
|
88046
|
+
};
|
|
88047
|
+
const formatAvgReplyTime = (inPeriod, compare2) => {
|
|
88048
|
+
const inPeriodReplyTime = getAvgReplyTime(inPeriod);
|
|
88049
|
+
const compareReplyTime = getAvgReplyTime(compare2);
|
|
88050
|
+
return {
|
|
88051
|
+
value: humanizeMinutes(inPeriodReplyTime),
|
|
88052
|
+
comparison: getPercentageDiff(inPeriodReplyTime, compareReplyTime)
|
|
88053
|
+
};
|
|
88054
|
+
};
|
|
88055
|
+
const getAvg = (data2) => {
|
|
88056
|
+
const total = data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2 }) => acc + positive2 + negative2 + neutral2, 0);
|
|
88057
|
+
const rating = data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2, avg }) => acc + avg * (positive2 + negative2 + neutral2), 0);
|
|
88058
|
+
return fixed(rating / total);
|
|
88059
|
+
};
|
|
88060
|
+
const circleChart = (data2) => {
|
|
88061
|
+
const value2 = data2.reduce((acc, { positive: positive2, negative: negative2, neutral: neutral2 }) => ({
|
|
88062
|
+
positive: positive2 + acc.positive,
|
|
88063
|
+
negative: negative2 + acc.negative,
|
|
88064
|
+
neutral: neutral2 + acc.neutral
|
|
88065
|
+
}), { positive: 0, negative: 0, neutral: 0 });
|
|
88066
|
+
return [
|
|
88067
|
+
{ name: instance.t("SATISFIED"), value: value2.positive },
|
|
88068
|
+
{ name: instance.t("DISSATISFIED"), value: value2.negative },
|
|
88069
|
+
{ name: instance.t("NEUTRAL"), value: value2.neutral }
|
|
88070
|
+
];
|
|
88071
|
+
};
|
|
88072
|
+
const formatAvgChart = (inPeriod, compare2) => {
|
|
88073
|
+
return {
|
|
88074
|
+
inPeriod: {
|
|
88075
|
+
avg: getAvg(inPeriod),
|
|
88076
|
+
chart: circleChart(inPeriod)
|
|
88077
|
+
},
|
|
88078
|
+
compare: {
|
|
88079
|
+
avg: getAvg(compare2),
|
|
88080
|
+
chart: circleChart(compare2)
|
|
88081
|
+
}
|
|
88082
|
+
};
|
|
88083
|
+
};
|
|
88084
|
+
const formatChart = (inPeriod) => inPeriod.map((item2) => ({
|
|
88085
|
+
...item2,
|
|
88086
|
+
date: dateFromString(item2.date)
|
|
88087
|
+
}));
|
|
88088
|
+
const groupByDate = (data2) => {
|
|
88089
|
+
const grouped = groupBy(data2, "date");
|
|
88090
|
+
return Object.values(grouped).map((items) => {
|
|
88091
|
+
const { total, ...rest } = items.reduce((acc, item2) => {
|
|
88092
|
+
const total2 = item2.positive + item2.negative + item2.neutral;
|
|
88093
|
+
return {
|
|
88094
|
+
...item2,
|
|
88095
|
+
positive: acc.positive + item2.positive,
|
|
88096
|
+
negative: acc.negative + item2.negative,
|
|
88097
|
+
neutral: acc.neutral + item2.neutral,
|
|
88098
|
+
treatment: acc.treatment + item2.treatment,
|
|
88099
|
+
avg: acc.avg + total2 * item2.avg,
|
|
88100
|
+
avgReplyTime: acc.avgReplyTime + item2.treatment * item2.avgReplyTime,
|
|
88101
|
+
total: acc.total + total2
|
|
88102
|
+
};
|
|
88103
|
+
}, {
|
|
88104
|
+
positive: 0,
|
|
88105
|
+
negative: 0,
|
|
88106
|
+
neutral: 0,
|
|
88107
|
+
treatment: 0,
|
|
88108
|
+
avg: 0,
|
|
88109
|
+
avgReplyTime: 0,
|
|
88110
|
+
total: 0
|
|
88111
|
+
});
|
|
88112
|
+
return {
|
|
88113
|
+
...rest,
|
|
88114
|
+
avg: fixed(rest.avg / total),
|
|
88115
|
+
avgReplyTime: rest.treatment > 0 ? fixed(rest.avgReplyTime / rest.treatment) : 0
|
|
88116
|
+
};
|
|
88117
|
+
});
|
|
88118
|
+
};
|
|
88119
|
+
const Analytics = ({ venueListingId }) => {
|
|
88120
|
+
const { t: t2 } = useTranslation();
|
|
88121
|
+
const [filter, setFilters] = useState({
|
|
88122
|
+
range: getTodaysRange(),
|
|
88123
|
+
compare: getCompareRange(getTodaysRange(), "period"),
|
|
88124
|
+
platform: "",
|
|
88125
|
+
compareType: "period"
|
|
88126
|
+
});
|
|
88127
|
+
const { data: data2, isLoading, error: error3 } = useFetch(GetReviewAnalytics, {
|
|
88128
|
+
cacheId: `reviews-analytics-${venueListingId}`,
|
|
88129
|
+
params: filter
|
|
88130
|
+
}, { formatData: formatData$2 });
|
|
88131
|
+
const comparedPeriod = formatComparedPeriod(filter.compare);
|
|
88132
|
+
if (error3) {
|
|
88133
|
+
return /* @__PURE__ */ React__default.createElement(Error$1, {
|
|
88134
|
+
error: error3
|
|
88135
|
+
});
|
|
88136
|
+
}
|
|
88137
|
+
return /* @__PURE__ */ React__default.createElement(LayoutPage$1, null, /* @__PURE__ */ React__default.createElement("div", null, isLoading && /* @__PURE__ */ React__default.createElement(SkeletonPage, null), !isLoading && /* @__PURE__ */ React__default.createElement(Row$1, {
|
|
88138
|
+
gutter: [28, 28]
|
|
88139
|
+
}, /* @__PURE__ */ React__default.createElement(Col$1, {
|
|
88140
|
+
xs: 24,
|
|
88141
|
+
sm: 12,
|
|
88142
|
+
md: 8
|
|
88143
|
+
}, /* @__PURE__ */ React__default.createElement(StatsCard, {
|
|
88144
|
+
...data2.reviews,
|
|
88145
|
+
comparedPeriod,
|
|
88146
|
+
title: t2("MYREVIEWS"),
|
|
88147
|
+
icon: /* @__PURE__ */ React__default.createElement(CircleIcon, {
|
|
88148
|
+
icon: MessageCircle$1
|
|
88149
|
+
})
|
|
88150
|
+
})), /* @__PURE__ */ React__default.createElement(Col$1, {
|
|
88151
|
+
xs: 24,
|
|
88152
|
+
sm: 12,
|
|
88153
|
+
md: 8
|
|
88154
|
+
}, /* @__PURE__ */ React__default.createElement(StatsCard, {
|
|
88155
|
+
...data2.treatment,
|
|
88156
|
+
comparedPeriod,
|
|
88157
|
+
title: t2("TREATMENTRATE"),
|
|
88158
|
+
icon: /* @__PURE__ */ React__default.createElement(CircleIcon, {
|
|
88159
|
+
icon: Star$1,
|
|
88160
|
+
color: "blue"
|
|
88161
|
+
})
|
|
88162
|
+
})), /* @__PURE__ */ React__default.createElement(Col$1, {
|
|
88163
|
+
xs: 24,
|
|
88164
|
+
sm: 24,
|
|
88165
|
+
md: 8
|
|
88166
|
+
}, /* @__PURE__ */ React__default.createElement(StatsCard, {
|
|
88167
|
+
...data2.replyTime,
|
|
88168
|
+
comparedPeriod,
|
|
88169
|
+
title: t2("AVERAGETIMEREPLY"),
|
|
88170
|
+
icon: /* @__PURE__ */ React__default.createElement(CircleIcon, {
|
|
88171
|
+
icon: Clock$1,
|
|
88172
|
+
color: "red"
|
|
88173
|
+
})
|
|
88174
|
+
})))));
|
|
88175
|
+
};
|
|
87985
88176
|
const WorkingPage = () => {
|
|
87986
88177
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Heading, null, "Work in progress"), /* @__PURE__ */ React__default.createElement("iframe", {
|
|
87987
88178
|
src: "https://giphy.com/embed/aNqEFrYVnsS52",
|
|
@@ -89135,12 +89326,12 @@ function App({
|
|
|
89135
89326
|
element: /* @__PURE__ */ React__default.createElement(Permissions, null)
|
|
89136
89327
|
}), /* @__PURE__ */ React__default.createElement(Route, {
|
|
89137
89328
|
path: "/analytics/listing",
|
|
89138
|
-
element: /* @__PURE__ */ React__default.createElement(Analytics, {
|
|
89329
|
+
element: /* @__PURE__ */ React__default.createElement(Analytics$1, {
|
|
89139
89330
|
venueListingId
|
|
89140
89331
|
})
|
|
89141
89332
|
}), /* @__PURE__ */ React__default.createElement(Route, {
|
|
89142
89333
|
path: "/analytics/review",
|
|
89143
|
-
element: /* @__PURE__ */ React__default.createElement(Analytics$
|
|
89334
|
+
element: /* @__PURE__ */ React__default.createElement(Analytics$2, {
|
|
89144
89335
|
venueListingId
|
|
89145
89336
|
})
|
|
89146
89337
|
}), /* @__PURE__ */ React__default.createElement(Route, {
|
|
@@ -89155,8 +89346,9 @@ const pages = {
|
|
|
89155
89346
|
Roles: App$1,
|
|
89156
89347
|
Notifications,
|
|
89157
89348
|
ReplyTemplates,
|
|
89158
|
-
ReviewAnalytics: Analytics$
|
|
89159
|
-
ListingAnalytics: Analytics,
|
|
89349
|
+
ReviewAnalytics: Analytics$2,
|
|
89350
|
+
ListingAnalytics: Analytics$1,
|
|
89351
|
+
DashboardAnalytics: Analytics,
|
|
89160
89352
|
Users: App$2,
|
|
89161
89353
|
ProfileManagement,
|
|
89162
89354
|
App
|