@licklist/design 0.71.11 → 0.71.12
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/events/event-statistic-modal/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAA;AAKjG,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE;QACT,aAAa,EAAE,MAAM,CAAA;QACrB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF,CAAA;AAED,eAAO,MAAM,gCAAgC,SACrC,MAAM,kBACI,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/events/event-statistic-modal/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAA;AAKjG,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE;QACT,aAAa,EAAE,MAAM,CAAA;QACrB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF,CAAA;AAED,eAAO,MAAM,gCAAgC,SACrC,MAAM,kBACI,cAAc,sBA6G/B,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateTime } from 'luxon';
|
|
2
2
|
import { DATE_FORMAT, DATE_TIME_FULL_FORMAT } from '@licklist/core/dist/Config';
|
|
3
|
-
import {
|
|
3
|
+
import { values, maxBy } from 'lodash';
|
|
4
4
|
|
|
5
5
|
function _array_like_to_array(arr, len) {
|
|
6
6
|
if (len == null || len > arr.length) len = arr.length;
|
|
@@ -45,19 +45,18 @@ var convertEventStatisticToTableData = function(date, eventStatistic) {
|
|
|
45
45
|
return DateTime.fromFormat(date, DATE_TIME_FULL_FORMAT).toFormat(DATE_FORMAT) === summaryFormattedDate;
|
|
46
46
|
})) !== null && _Object_keys_filter !== void 0 ? _Object_keys_filter : [];
|
|
47
47
|
var summaryMap = new Map();
|
|
48
|
+
var allProductsSummary = values(eventStatistic === null || eventStatistic === void 0 ? void 0 : eventStatistic.productCategorySummary).flat().flatMap(function(categorySummary) {
|
|
49
|
+
return categorySummary.productsSummary;
|
|
50
|
+
});
|
|
51
|
+
var maxTotalQuantity = maxBy(allProductsSummary, 'id').totalQuantity || 0;
|
|
48
52
|
summaryDays.map(function(day) {
|
|
49
53
|
return eventStatistic === null || eventStatistic === void 0 ? void 0 : eventStatistic.productCategorySummary[day];
|
|
50
54
|
}).flat().sort(function(prev, next) {
|
|
51
55
|
return prev.categoryName === next.categoryName ? 0 : prev.categoryName > next.categoryName ? 1 : -1;
|
|
52
|
-
}).forEach(function(param
|
|
56
|
+
}).forEach(function(param) {
|
|
53
57
|
var totalPerCategory = param.totalPerCategory, _param_productsSummary = param.productsSummary, productsSummary = _param_productsSummary === void 0 ? [] : _param_productsSummary, categoryName = param.categoryName, eventId = param.eventId;
|
|
54
58
|
var quantity = 0;
|
|
55
59
|
totalAmount += totalPerCategory || 0;
|
|
56
|
-
var allProductSummaryAtCategory = selfCategory.filter(function(category) {
|
|
57
|
-
return category.categoryName === categoryName;
|
|
58
|
-
}).flatMap(function(categorySummary) {
|
|
59
|
-
return categorySummary.productsSummary;
|
|
60
|
-
});
|
|
61
60
|
if (!summaryMap.has("".concat(categoryName))) {
|
|
62
61
|
summaryMap.set("".concat(categoryName), {
|
|
63
62
|
name: categoryName,
|
|
@@ -68,37 +67,24 @@ var convertEventStatisticToTableData = function(date, eventStatistic) {
|
|
|
68
67
|
total: TRANSLATION_KEYS.total
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
|
-
productsSummary === null || productsSummary === void 0 ? void 0 : productsSummary.forEach(function(
|
|
72
|
-
|
|
70
|
+
productsSummary === null || productsSummary === void 0 ? void 0 : productsSummary.forEach(function(param) {
|
|
71
|
+
var productsSold = param.productsSold, name = param.name, totalQuantity = param.totalQuantity, total = param.total;
|
|
72
|
+
quantity += productsSold;
|
|
73
73
|
var _summaryMap_get;
|
|
74
|
-
var existingProduct = (_summaryMap_get = summaryMap.get("".concat(categoryName, ".").concat(
|
|
74
|
+
var existingProduct = (_summaryMap_get = summaryMap.get("".concat(categoryName, ".").concat(name))) !== null && _summaryMap_get !== void 0 ? _summaryMap_get : {
|
|
75
75
|
metadata: {
|
|
76
76
|
_productsSold: 0,
|
|
77
77
|
_total: 0
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (override.totalQuantity > (acc || 0)) {
|
|
86
|
-
return override.totalQuantity;
|
|
87
|
-
}
|
|
88
|
-
return acc;
|
|
89
|
-
}, null);
|
|
90
|
-
var totalQuantity = (productSummary.totalQuantity || highestOverrideTotalQuantity) && max([
|
|
91
|
-
productSummary.totalQuantity,
|
|
92
|
-
highestOverrideTotalQuantity
|
|
93
|
-
]);
|
|
94
|
-
summaryMap.set("".concat(categoryName, ".").concat(productSummary.name), {
|
|
95
|
-
name: productSummary.name,
|
|
96
|
-
key: "".concat(eventId, ".").concat(categoryName).concat(productIndex).concat(productSummary.name),
|
|
97
|
-
quantity: totalQuantity ? "".concat(existingProduct.metadata._productsSold + productSummary.productsSold, " / ").concat(totalQuantity) : String(existingProduct.metadata._productsSold + productSummary.productsSold),
|
|
98
|
-
total: String(existingProduct.metadata._total + productSummary.total),
|
|
80
|
+
summaryMap.set("".concat(categoryName, ".").concat(name), {
|
|
81
|
+
name: name,
|
|
82
|
+
key: "".concat(eventId, ".").concat(categoryName, ".").concat(name),
|
|
83
|
+
quantity: totalQuantity ? "".concat(existingProduct.metadata._productsSold + productsSold, " / ").concat(maxTotalQuantity) : String(existingProduct.metadata._productsSold + productsSold),
|
|
84
|
+
total: String(existingProduct.metadata._total + total),
|
|
99
85
|
metadata: {
|
|
100
|
-
_productsSold: existingProduct.metadata._productsSold +
|
|
101
|
-
_total: existingProduct.metadata._total +
|
|
86
|
+
_productsSold: existingProduct.metadata._productsSold + productsSold,
|
|
87
|
+
_total: existingProduct.metadata._total + total
|
|
102
88
|
}
|
|
103
89
|
});
|
|
104
90
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventStatistic } from '@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper'
|
|
2
2
|
import { DateTime } from 'luxon'
|
|
3
3
|
import { DATE_FORMAT, DATE_TIME_FULL_FORMAT } from '@licklist/core/dist/Config'
|
|
4
|
-
import {
|
|
4
|
+
import { values, maxBy } from 'lodash'
|
|
5
5
|
|
|
6
6
|
export const TRANSLATION_KEYS = {
|
|
7
7
|
shortQuantity: 'shortQuantity',
|
|
@@ -36,7 +36,6 @@ export const convertEventStatisticToTableData = (
|
|
|
36
36
|
const summaryFormattedDate = DateTime.fromISO(date)
|
|
37
37
|
.toUTC()
|
|
38
38
|
.toFormat(DATE_FORMAT)
|
|
39
|
-
|
|
40
39
|
const summaryDays =
|
|
41
40
|
Object.keys(eventStatistic?.productCategorySummary)?.filter(
|
|
42
41
|
(date) =>
|
|
@@ -46,6 +45,11 @@ export const convertEventStatisticToTableData = (
|
|
|
46
45
|
) ?? []
|
|
47
46
|
|
|
48
47
|
const summaryMap = new Map<string, TableDataRecord>()
|
|
48
|
+
const allProductsSummary = values(eventStatistic?.productCategorySummary)
|
|
49
|
+
.flat()
|
|
50
|
+
.flatMap((categorySummary) => categorySummary.productsSummary)
|
|
51
|
+
|
|
52
|
+
const maxTotalQuantity = maxBy(allProductsSummary, 'id').totalQuantity || 0
|
|
49
53
|
|
|
50
54
|
summaryDays
|
|
51
55
|
.map((day) => eventStatistic?.productCategorySummary[day])
|
|
@@ -58,18 +62,9 @@ export const convertEventStatisticToTableData = (
|
|
|
58
62
|
: -1,
|
|
59
63
|
)
|
|
60
64
|
.forEach(
|
|
61
|
-
(
|
|
62
|
-
{ totalPerCategory, productsSummary = [], categoryName, eventId },
|
|
63
|
-
_,
|
|
64
|
-
selfCategory,
|
|
65
|
-
) => {
|
|
65
|
+
({ totalPerCategory, productsSummary = [], categoryName, eventId }) => {
|
|
66
66
|
let quantity = 0
|
|
67
67
|
totalAmount += totalPerCategory || 0
|
|
68
|
-
|
|
69
|
-
const allProductSummaryAtCategory = selfCategory
|
|
70
|
-
.filter((category) => category.categoryName === categoryName)
|
|
71
|
-
.flatMap((categorySummary) => categorySummary.productsSummary)
|
|
72
|
-
|
|
73
68
|
if (!summaryMap.has(`${categoryName}`)) {
|
|
74
69
|
summaryMap.set(`${categoryName}`, {
|
|
75
70
|
name: categoryName,
|
|
@@ -81,70 +76,43 @@ export const convertEventStatisticToTableData = (
|
|
|
81
76
|
})
|
|
82
77
|
}
|
|
83
78
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const totalQuantity =
|
|
115
|
-
(productSummary.totalQuantity || highestOverrideTotalQuantity) &&
|
|
116
|
-
max([productSummary.totalQuantity, highestOverrideTotalQuantity])
|
|
117
|
-
|
|
118
|
-
summaryMap.set(`${categoryName}.${productSummary.name}`, {
|
|
119
|
-
name: productSummary.name,
|
|
120
|
-
key: `${eventId}.${categoryName}${productIndex}${productSummary.name}`,
|
|
121
|
-
quantity: totalQuantity
|
|
122
|
-
? `${
|
|
123
|
-
existingProduct.metadata._productsSold +
|
|
124
|
-
productSummary.productsSold
|
|
125
|
-
} / ${totalQuantity}`
|
|
126
|
-
: String(
|
|
127
|
-
existingProduct.metadata._productsSold +
|
|
128
|
-
productSummary.productsSold,
|
|
129
|
-
),
|
|
130
|
-
total: String(
|
|
131
|
-
existingProduct.metadata._total + productSummary.total,
|
|
132
|
-
),
|
|
133
|
-
metadata: {
|
|
134
|
-
_productsSold:
|
|
135
|
-
existingProduct.metadata._productsSold +
|
|
136
|
-
productSummary.productsSold,
|
|
137
|
-
_total: existingProduct.metadata._total + productSummary.total,
|
|
138
|
-
},
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
|
|
79
|
+
productsSummary?.forEach(
|
|
80
|
+
({ productsSold, name, totalQuantity, total }) => {
|
|
81
|
+
quantity += productsSold
|
|
82
|
+
|
|
83
|
+
const existingProduct = summaryMap.get(
|
|
84
|
+
`${categoryName}.${name}`,
|
|
85
|
+
) ?? {
|
|
86
|
+
metadata: {
|
|
87
|
+
_productsSold: 0,
|
|
88
|
+
_total: 0,
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
summaryMap.set(`${categoryName}.${name}`, {
|
|
93
|
+
name,
|
|
94
|
+
key: `${eventId}.${categoryName}.${name}`,
|
|
95
|
+
quantity: totalQuantity
|
|
96
|
+
? `${
|
|
97
|
+
existingProduct.metadata._productsSold + productsSold
|
|
98
|
+
} / ${maxTotalQuantity}`
|
|
99
|
+
: String(existingProduct.metadata._productsSold + productsSold),
|
|
100
|
+
total: String(existingProduct.metadata._total + total),
|
|
101
|
+
metadata: {
|
|
102
|
+
_productsSold:
|
|
103
|
+
existingProduct.metadata._productsSold + productsSold,
|
|
104
|
+
_total: existingProduct.metadata._total + total,
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
)
|
|
142
109
|
const prevTotalPerCategory = summaryMap.get(
|
|
143
110
|
`${categoryName}.${TRANSLATION_KEYS.totalPerCategory}`,
|
|
144
111
|
) ?? {
|
|
145
112
|
quantity: 0,
|
|
146
113
|
total: 0,
|
|
147
114
|
}
|
|
115
|
+
|
|
148
116
|
summaryMap.set(`${categoryName}.${TRANSLATION_KEYS.totalPerCategory}`, {
|
|
149
117
|
name: TRANSLATION_KEYS.totalPerCategory,
|
|
150
118
|
key: `${eventId}.${categoryName}.${TRANSLATION_KEYS.totalPerCategory}`,
|
|
@@ -152,7 +120,6 @@ export const convertEventStatisticToTableData = (
|
|
|
152
120
|
total: String(Number(prevTotalPerCategory.total) + totalPerCategory),
|
|
153
121
|
isBold: true,
|
|
154
122
|
})
|
|
155
|
-
|
|
156
123
|
totalQuantity += quantity
|
|
157
124
|
},
|
|
158
125
|
)
|