contentoh-components-library 21.2.1 → 21.2.2
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.
|
@@ -81,8 +81,8 @@ var DashboardMetric = function DashboardMetric(_ref) {
|
|
|
81
81
|
setEndDate(end);
|
|
82
82
|
if (end) setQueryObject(function (current) {
|
|
83
83
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, current), {}, {
|
|
84
|
-
startDate: "".concat(start.getFullYear(), "-").concat(start.
|
|
85
|
-
endDate: "".concat(end
|
|
84
|
+
startDate: "".concat(start.getFullYear(), "-").concat(start.getMonth() + 1, "-").concat(start.getDate()),
|
|
85
|
+
endDate: "".concat(end.getFullYear(), "-").concat(end.getMonth() + 1, "-").concat(end.getDate())
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
};
|
|
@@ -21,6 +21,8 @@ var _DashboardMetric = require("../../organisms/DashboardMetric");
|
|
|
21
21
|
|
|
22
22
|
var _react = require("react");
|
|
23
23
|
|
|
24
|
+
var _Loading = require("../../atoms/Loading");
|
|
25
|
+
|
|
24
26
|
var _axios = _interopRequireDefault(require("axios"));
|
|
25
27
|
|
|
26
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -41,12 +43,20 @@ var Dashboard = function Dashboard() {
|
|
|
41
43
|
requiredProducts = _useState6[0],
|
|
42
44
|
setRequiredProducts = _useState6[1];
|
|
43
45
|
|
|
44
|
-
var _useState7 = (0, _react.useState)({
|
|
46
|
+
var _useState7 = (0, _react.useState)({
|
|
47
|
+
retailerId: null,
|
|
48
|
+
startDate: null,
|
|
49
|
+
endDate: null
|
|
50
|
+
}),
|
|
45
51
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
46
52
|
orderByStatus = _useState8[0],
|
|
47
53
|
setOrderByStatus = _useState8[1];
|
|
48
54
|
|
|
49
|
-
var _useState9 = (0, _react.useState)({
|
|
55
|
+
var _useState9 = (0, _react.useState)({
|
|
56
|
+
retailerId: null,
|
|
57
|
+
startDate: null,
|
|
58
|
+
endDate: null
|
|
59
|
+
}),
|
|
50
60
|
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
51
61
|
orderByRequired = _useState10[0],
|
|
52
62
|
setOrderByRequired = _useState10[1];
|
|
@@ -56,6 +66,11 @@ var Dashboard = function Dashboard() {
|
|
|
56
66
|
retailers = _useState12[0],
|
|
57
67
|
setRetailers = _useState12[1];
|
|
58
68
|
|
|
69
|
+
var _useState13 = (0, _react.useState)(true),
|
|
70
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
71
|
+
loading = _useState14[0],
|
|
72
|
+
setLoading = _useState14[1];
|
|
73
|
+
|
|
59
74
|
var loadProductVersions = /*#__PURE__*/function () {
|
|
60
75
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(byStatus, queryObject) {
|
|
61
76
|
var retailerId, startDate, endDate, fullData, query, response, versionList;
|
|
@@ -198,8 +213,8 @@ var Dashboard = function Dashboard() {
|
|
|
198
213
|
(0, _react.useEffect)(function () {
|
|
199
214
|
var today = new Date();
|
|
200
215
|
var firstWeekDay = today.getDate() - today.getDay();
|
|
201
|
-
var startDate = "".concat(today.getFullYear(), "-").concat(
|
|
202
|
-
var endDate = "".concat(today.getFullYear(), "-").concat(today.
|
|
216
|
+
var startDate = "".concat(today.getFullYear(), "-").concat(today.getMonth() + 1, "-").concat(firstWeekDay);
|
|
217
|
+
var endDate = "".concat(today.getFullYear(), "-").concat(today.getMonth() + 1, "-").concat(today.getDate());
|
|
203
218
|
var queryObject = {
|
|
204
219
|
retailerId: "58",
|
|
205
220
|
startDate: startDate,
|
|
@@ -215,7 +230,10 @@ var Dashboard = function Dashboard() {
|
|
|
215
230
|
(0, _react.useEffect)(function () {
|
|
216
231
|
loadRequiredProducts(orderByRequired);
|
|
217
232
|
}, [orderByRequired]);
|
|
218
|
-
|
|
233
|
+
(0, _react.useEffect)(function () {
|
|
234
|
+
(orderByRequired === null || orderByRequired === void 0 ? void 0 : orderByRequired.retailerId) && (orderByStatus === null || orderByStatus === void 0 ? void 0 : orderByStatus.retailerId) && metricsData.length > 0 && setLoading(false);
|
|
235
|
+
}, [orderByRequired, orderByStatus, metricsData]);
|
|
236
|
+
return loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
219
237
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
220
238
|
className: "metric-cards",
|
|
221
239
|
children: metricsData.map(function (metric, index) {
|
package/package.json
CHANGED
|
@@ -41,12 +41,10 @@ export const DashboardMetric = ({
|
|
|
41
41
|
if (end)
|
|
42
42
|
setQueryObject((current) => ({
|
|
43
43
|
...current,
|
|
44
|
-
startDate: `${start.getFullYear()}-${
|
|
44
|
+
startDate: `${start.getFullYear()}-${
|
|
45
45
|
start.getMonth() + 1
|
|
46
|
-
}`,
|
|
47
|
-
endDate: `${end
|
|
48
|
-
end?.getMonth() + 1
|
|
49
|
-
}`,
|
|
46
|
+
}-${start.getDate()}`,
|
|
47
|
+
endDate: `${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()}`,
|
|
50
48
|
}));
|
|
51
49
|
};
|
|
52
50
|
|
|
@@ -2,15 +2,25 @@ import { Container } from "./styles";
|
|
|
2
2
|
import { MetricCard } from "../../atoms/MetricCard";
|
|
3
3
|
import { DashboardMetric } from "../../organisms/DashboardMetric";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
|
+
import { Loading } from "../../atoms/Loading";
|
|
5
6
|
import axios from "axios";
|
|
6
7
|
|
|
7
8
|
export const Dashboard = () => {
|
|
8
9
|
const [metricsData, setMetricsData] = useState([]);
|
|
9
10
|
const [productsByStatus, setProductsByStatus] = useState({});
|
|
10
11
|
const [requiredProducts, setRequiredProducts] = useState([]);
|
|
11
|
-
const [orderByStatus, setOrderByStatus] = useState({
|
|
12
|
-
|
|
12
|
+
const [orderByStatus, setOrderByStatus] = useState({
|
|
13
|
+
retailerId: null,
|
|
14
|
+
startDate: null,
|
|
15
|
+
endDate: null,
|
|
16
|
+
});
|
|
17
|
+
const [orderByRequired, setOrderByRequired] = useState({
|
|
18
|
+
retailerId: null,
|
|
19
|
+
startDate: null,
|
|
20
|
+
endDate: null,
|
|
21
|
+
});
|
|
13
22
|
const [retailers, setRetailers] = useState({});
|
|
23
|
+
const [loading, setLoading] = useState(true);
|
|
14
24
|
|
|
15
25
|
const loadProductVersions = async (byStatus, queryObject) => {
|
|
16
26
|
const { retailerId, startDate, endDate, fullData } = queryObject;
|
|
@@ -62,12 +72,12 @@ export const Dashboard = () => {
|
|
|
62
72
|
useEffect(() => {
|
|
63
73
|
const today = new Date();
|
|
64
74
|
const firstWeekDay = today.getDate() - today.getDay();
|
|
65
|
-
const startDate = `${today.getFullYear()}-${
|
|
75
|
+
const startDate = `${today.getFullYear()}-${
|
|
66
76
|
today.getMonth() + 1
|
|
67
|
-
}`;
|
|
68
|
-
const endDate = `${today.getFullYear()}-${
|
|
77
|
+
}-${firstWeekDay}`;
|
|
78
|
+
const endDate = `${today.getFullYear()}-${
|
|
69
79
|
today.getMonth() + 1
|
|
70
|
-
}`;
|
|
80
|
+
}-${today.getDate()}`;
|
|
71
81
|
const queryObject = { retailerId: "58", startDate, endDate };
|
|
72
82
|
setOrderByStatus(queryObject);
|
|
73
83
|
setOrderByRequired(queryObject);
|
|
@@ -82,7 +92,16 @@ export const Dashboard = () => {
|
|
|
82
92
|
loadRequiredProducts(orderByRequired);
|
|
83
93
|
}, [orderByRequired]);
|
|
84
94
|
|
|
85
|
-
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
orderByRequired?.retailerId &&
|
|
97
|
+
orderByStatus?.retailerId &&
|
|
98
|
+
metricsData.length > 0 &&
|
|
99
|
+
setLoading(false);
|
|
100
|
+
}, [orderByRequired, orderByStatus, metricsData]);
|
|
101
|
+
|
|
102
|
+
return loading ? (
|
|
103
|
+
<Loading />
|
|
104
|
+
) : (
|
|
86
105
|
<Container>
|
|
87
106
|
<div className="metric-cards">
|
|
88
107
|
{metricsData.map((metric, index) => (
|