contentoh-components-library 21.4.52 → 21.4.54

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,16 +1,24 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.TagAndInput = void 0;
7
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
13
+
8
14
  var _styles = require("./styles");
9
15
 
10
16
  var _index = require("../../atoms/ScreenHeader/index");
11
17
 
12
18
  var _index2 = require("../../atoms/GeneralInput/index");
13
19
 
20
+ var _react = require("react");
21
+
14
22
  var _jsxRuntime = require("react/jsx-runtime");
15
23
 
16
24
  var TagAndInput = function TagAndInput(_ref) {
@@ -39,7 +47,55 @@ var TagAndInput = function TagAndInput(_ref) {
39
47
  disabled = _ref.disabled,
40
48
  onKeyDown = _ref.onKeyDown,
41
49
  showTooltip = _ref.showTooltip,
42
- auditClass = _ref.auditClass;
50
+ auditClass = _ref.auditClass,
51
+ onChange = _ref.onChange,
52
+ dataInputs = _ref.dataInputs,
53
+ inputGroup = _ref.inputGroup;
54
+
55
+ var _useState = (0, _react.useState)(true),
56
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
57
+ isDeleteDisabled = _useState2[0],
58
+ setIsDeleteDisabled = _useState2[1];
59
+
60
+ var _useState3 = (0, _react.useState)([{
61
+ showAdd: true,
62
+ value: {}
63
+ }]),
64
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
65
+ boxOnboardingList = _useState4[0],
66
+ setBoxOnboardingList = _useState4[1];
67
+
68
+ (0, _react.useEffect)(function () {
69
+ var temp = {};
70
+ var maxBoxId = 0;
71
+ inputGroup === null || inputGroup === void 0 ? void 0 : inputGroup.inputs.forEach(function (attrId) {
72
+ if (!dataInputs[attrId].box) return;
73
+ Object.entries(dataInputs[attrId].box).forEach(function (_ref2) {
74
+ var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
75
+ boxId = _ref3[0],
76
+ value = _ref3[1];
77
+
78
+ if (boxId > maxBoxId) maxBoxId = boxId;
79
+ if (!temp[boxId]) temp[boxId] = {};
80
+ temp[boxId][attrId] = value;
81
+ });
82
+ });
83
+ var tempList = Object.values(temp);
84
+
85
+ if (tempList.length > 0) {
86
+ setBoxOnboardingList(tempList.map(function (value, index) {
87
+ return index === tempList.length - 1 ? {
88
+ showAdd: true,
89
+ value: value
90
+ } : {
91
+ value: value
92
+ };
93
+ }));
94
+ }
95
+ }, []);
96
+ (0, _react.useEffect)(function () {
97
+ onChange && onChange(boxOnboardingList);
98
+ }, [boxOnboardingList]);
43
99
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
44
100
  inputType: inputType,
45
101
  className: "input-container",
@@ -76,7 +132,20 @@ var TagAndInput = function TagAndInput(_ref) {
76
132
  description: description,
77
133
  inputOnChange: inputOnChange,
78
134
  onKeyDown: onKeyDown,
79
- auditClass: auditClass
135
+ auditClass: auditClass,
136
+ onChange: function onChange(e) {
137
+ setBoxOnboardingList(function (prev) {
138
+ return prev.map(function (box, i) {
139
+ if (i != index) {
140
+ return box;
141
+ }
142
+
143
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, box), {}, {
144
+ value: e
145
+ });
146
+ });
147
+ });
148
+ }
80
149
  })]
81
150
  }, "generalTagInput-".concat(inputType));
82
151
  };
@@ -37,18 +37,13 @@ var Box = function Box(_ref) {
37
37
  isDeleteDisabled = _useState2[0],
38
38
  setIsDeleteDisabled = _useState2[1];
39
39
 
40
- var _useState3 = (0, _react.useState)(false),
41
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
42
- isEditEnabled = _useState4[0],
43
- setIsEditEnabled = _useState4[1];
44
-
45
- var _useState5 = (0, _react.useState)([{
40
+ var _useState3 = (0, _react.useState)([{
46
41
  showAdd: true,
47
42
  value: {}
48
43
  }]),
49
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
50
- boxOnboardingList = _useState6[0],
51
- setBoxOnboardingList = _useState6[1];
44
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
45
+ boxOnboardingList = _useState4[0],
46
+ setBoxOnboardingList = _useState4[1];
52
47
 
53
48
  (0, _react.useEffect)(function () {
54
49
  var temp = {};
@@ -97,10 +92,6 @@ var Box = function Box(_ref) {
97
92
  }
98
93
  };
99
94
 
100
- var handleToggleEdit = function handleToggleEdit() {
101
- setIsEditEnabled(!isEditEnabled);
102
- };
103
-
104
95
  (0, _react.useEffect)(function () {
105
96
  onChange && onChange(boxOnboardingList);
106
97
  }, [boxOnboardingList]);
@@ -122,7 +113,6 @@ var Box = function Box(_ref) {
122
113
  data: boxOnboarding.value,
123
114
  dataInputs: dataInputs,
124
115
  inputs: inputGroup.inputs,
125
- isEditEnabled: isEditEnabled,
126
116
  onChange: function onChange(e) {
127
117
  setBoxOnboardingList(function (prev) {
128
118
  return prev.map(function (box, i) {
@@ -143,9 +133,7 @@ var Box = function Box(_ref) {
143
133
  onDelete: function onDelete() {
144
134
  return handleDeleteBoxOnboarding(index);
145
135
  },
146
- isDeleteDisabled: isDeleteDisabled,
147
- onToggleEdit: handleToggleEdit,
148
- isEditEnabled: isEditEnabled
136
+ isDeleteDisabled: isDeleteDisabled
149
137
  }, index)]
150
138
  })
151
139
  });
@@ -178,6 +178,9 @@ var InputGroup = function InputGroup(_ref) {
178
178
  optionList: (_dataInputs$input23 = dataInputs[input]) === null || _dataInputs$input23 === void 0 ? void 0 : _dataInputs$input23.option_list,
179
179
  description: (_dataInputs$input24 = dataInputs[input]) === null || _dataInputs$input24 === void 0 ? void 0 : _dataInputs$input24.description,
180
180
  showTooltip: true,
181
+ inputGroup: inputGroup,
182
+ dataInputs: dataInputs,
183
+ onChange: setUpdatedBoxData,
181
184
  auditClass: compare && !isEquals(dataInputs[input].value, auditInputs[input].value) ? "audit-class" : ""
182
185
  }, index + "-" + ((_dataInputs$input13 = dataInputs[input]) === null || _dataInputs$input13 === void 0 ? void 0 : _dataInputs$input13.value) + "-" + ((_dataInputs$input14 = dataInputs[input]) === null || _dataInputs$input14 === void 0 ? void 0 : _dataInputs$input14.id) + "-" + compare)
183
186
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_TagAndInput.TagAndInput, {
@@ -231,7 +231,7 @@ var Dashboard = function Dashboard(_ref) {
231
231
 
232
232
  var loadProductsByStatus = /*#__PURE__*/function () {
233
233
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(orderByStatus) {
234
- var isRetailer, isProvider, isCollaborator, _ref5, ordersBydate, ordersByStatus, _ordersByStatus$total, total, _ordersByStatus$R, R, _ordersByStatus$PA, PA, _ordersByStatus$Ex, Ex, _ordersByStatus$ACA, ACA, productsFinished, inProcess, metricsArray;
234
+ var isRetailer, isProvider, isCollaborator, _ref5, ordersBydate, ordersByStatus, ordersByActive, _ordersByStatus$total, total, _ordersByStatus$R, R, _ordersByStatus$PA, PA, _ordersByStatus$Ex, Ex, _ordersByStatus$ACA, ACA, productsFinished, inProcess, registeredProducts, metricsArray;
235
235
 
236
236
  return _regenerator.default.wrap(function _callee3$(_context3) {
237
237
  while (1) {
@@ -257,6 +257,7 @@ var Dashboard = function Dashboard(_ref) {
257
257
  _ref5 = _context3.t0;
258
258
  ordersBydate = _ref5.ordersBydate;
259
259
  ordersByStatus = _ref5.ordersByStatus;
260
+ ordersByActive = _ref5.ordersByActive;
260
261
  _ordersByStatus$total = ordersByStatus.total, total = _ordersByStatus$total === void 0 ? 0 : _ordersByStatus$total, _ordersByStatus$R = ordersByStatus.R, R = _ordersByStatus$R === void 0 ? 0 : _ordersByStatus$R, _ordersByStatus$PA = ordersByStatus.PA, PA = _ordersByStatus$PA === void 0 ? 0 : _ordersByStatus$PA, _ordersByStatus$Ex = ordersByStatus.Ex, Ex = _ordersByStatus$Ex === void 0 ? 0 : _ordersByStatus$Ex, _ordersByStatus$ACA = ordersByStatus.ACA, ACA = _ordersByStatus$ACA === void 0 ? 0 : _ordersByStatus$ACA;
261
262
  productsFinished = 0;
262
263
  if (isRetailer) productsFinished = Ex;
@@ -265,11 +266,16 @@ var Dashboard = function Dashboard(_ref) {
265
266
  inProcess = Object.keys(ordersByStatus).reduce(function (prev, curr) {
266
267
  return !["total", "PA", "R", "Ex", "ACA"].includes(curr) ? prev + ordersByStatus[curr] : prev;
267
268
  }, 0);
269
+ registeredProducts = ordersByActive.registered;
268
270
  metricsArray = [metricsData[0] ? metricsData[0] : {
269
271
  label: "Productos totales",
270
272
  value: total
271
273
  }];
274
+ console.log(registeredProducts);
272
275
  metricsArray.push({
276
+ label: "Productos activos",
277
+ value: registeredProducts
278
+ }, {
273
279
  label: "Productos filtrados",
274
280
  value: total
275
281
  }, {
@@ -288,7 +294,7 @@ var Dashboard = function Dashboard(_ref) {
288
294
  setRequiredProducts(ordersBydate);
289
295
  setProductsByStatus(ordersByStatus);
290
296
 
291
- case 24:
297
+ case 27:
292
298
  case "end":
293
299
  return _context3.stop();
294
300
  }
@@ -1240,11 +1240,12 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1240
1240
  });
1241
1241
  });
1242
1242
  });
1243
- dataObject = {
1243
+ dataObject = (0, _objectSpread3.default)({
1244
1244
  articleId: product === null || product === void 0 ? void 0 : product.id_article,
1245
- articleData: updatedDatasheets,
1245
+ articleData: updatedDatasheets
1246
+ }, parseBoxData.length > 0 && {
1246
1247
  boxData: parseBoxData
1247
- };
1248
+ });
1248
1249
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1249
1250
  _context12.prev = 4;
1250
1251
  _context12.next = 7;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.52",
3
+ "version": "21.4.54",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -1,6 +1,7 @@
1
1
  import { Container } from "./styles";
2
2
  import { ScreenHeader } from "../../atoms/ScreenHeader/index";
3
3
  import { GeneralInput } from "../../atoms/GeneralInput/index";
4
+ import { useState, useEffect } from "react";
4
5
 
5
6
  export const TagAndInput = ({
6
7
  inputType,
@@ -29,7 +30,42 @@ export const TagAndInput = ({
29
30
  onKeyDown,
30
31
  showTooltip,
31
32
  auditClass,
33
+ onChange,
34
+ dataInputs,
35
+ inputGroup
32
36
  }) => {
37
+ const [isDeleteDisabled, setIsDeleteDisabled] = useState(true);
38
+ const [boxOnboardingList, setBoxOnboardingList] = useState([
39
+ {
40
+ showAdd: true,
41
+ value: {},
42
+ },
43
+ ]);
44
+
45
+ useEffect(() => {
46
+ const temp = {};
47
+ let maxBoxId = 0;
48
+ inputGroup?.inputs.forEach((attrId) => {
49
+ if (!dataInputs[attrId].box) return;
50
+ Object.entries(dataInputs[attrId].box).forEach(([boxId, value]) => {
51
+ if (boxId > maxBoxId) maxBoxId = boxId;
52
+ if (!temp[boxId]) temp[boxId] = {};
53
+ temp[boxId][attrId] = value;
54
+ });
55
+ });
56
+ const tempList = Object.values(temp);
57
+ if (tempList.length > 0) {
58
+ setBoxOnboardingList(
59
+ tempList.map((value, index) =>
60
+ index === tempList.length - 1 ? { showAdd: true, value } : { value }
61
+ )
62
+ );
63
+ }
64
+ }, []);
65
+
66
+ useEffect(() => {
67
+ onChange && onChange(boxOnboardingList);
68
+ }, [boxOnboardingList]);
33
69
  return (
34
70
  <Container
35
71
  inputType={inputType}
@@ -70,6 +106,16 @@ export const TagAndInput = ({
70
106
  inputOnChange={inputOnChange}
71
107
  onKeyDown={onKeyDown}
72
108
  auditClass={auditClass}
109
+ onChange={(e) => {
110
+ setBoxOnboardingList((prev) => {
111
+ return prev.map((box, i) => {
112
+ if (i != index) {
113
+ return box;
114
+ }
115
+ return { ...box, value: e };
116
+ });
117
+ });
118
+ }}
73
119
  />
74
120
  </Container>
75
121
  );
@@ -6,7 +6,6 @@ import { BoxButtons } from "../../molecules/BoxButtons";
6
6
 
7
7
  export const Box = ({ onChange, dataInputs, inputGroup }) => {
8
8
  const [isDeleteDisabled, setIsDeleteDisabled] = useState(true);
9
- const [isEditEnabled, setIsEditEnabled] = useState(false);
10
9
  const [boxOnboardingList, setBoxOnboardingList] = useState([
11
10
  {
12
11
  showAdd: true,
@@ -53,9 +52,6 @@ export const Box = ({ onChange, dataInputs, inputGroup }) => {
53
52
  setIsDeleteDisabled(true);
54
53
  }
55
54
  };
56
- const handleToggleEdit = () => {
57
- setIsEditEnabled(!isEditEnabled);
58
- };
59
55
 
60
56
  useEffect(() => {
61
57
  onChange && onChange(boxOnboardingList);
@@ -79,7 +75,6 @@ export const Box = ({ onChange, dataInputs, inputGroup }) => {
79
75
  data={boxOnboarding.value}
80
76
  dataInputs={dataInputs}
81
77
  inputs={inputGroup.inputs}
82
- isEditEnabled={isEditEnabled}
83
78
  onChange={(e) => {
84
79
  setBoxOnboardingList((prev) => {
85
80
  return prev.map((box, i) => {
@@ -98,8 +93,6 @@ export const Box = ({ onChange, dataInputs, inputGroup }) => {
98
93
  onAdd={handleAddBoxOnboarding}
99
94
  onDelete={() => handleDeleteBoxOnboarding(index)}
100
95
  isDeleteDisabled={isDeleteDisabled}
101
- onToggleEdit={handleToggleEdit}
102
- isEditEnabled={isEditEnabled}
103
96
  />
104
97
  </div>
105
98
  </>
@@ -228,6 +228,9 @@ export const InputGroup = ({
228
228
  optionList={dataInputs[input]?.option_list}
229
229
  description={dataInputs[input]?.description}
230
230
  showTooltip={true}
231
+ inputGroup={inputGroup}
232
+ dataInputs={dataInputs}
233
+ onChange={setUpdatedBoxData}
231
234
  auditClass={
232
235
  compare &&
233
236
  !isEquals(dataInputs[input].value, auditInputs[input].value)
@@ -270,4 +273,4 @@ export const InputGroup = ({
270
273
  )}
271
274
  </>
272
275
  );
273
- }
276
+ }
@@ -84,7 +84,7 @@ export const Dashboard = ({ jwt, user, company }) => {
84
84
  const isRetailer = user.is_retailer && company.retailers;
85
85
  const isProvider = !user.is_retailer && user.id_role === 0;
86
86
  const isCollaborator = user.id_role > 0;
87
- const { ordersBydate, ordersByStatus } =
87
+ const { ordersBydate, ordersByStatus, ordersByActive } =
88
88
  (await loadProductVersions(orderByStatus)) || {};
89
89
 
90
90
  const { total = 0, R = 0, PA = 0, Ex = 0, ACA = 0 } = ordersByStatus;
@@ -100,13 +100,18 @@ export const Dashboard = ({ jwt, user, company }) => {
100
100
  : prev,
101
101
  0
102
102
  );
103
+
104
+ const registeredProducts = ordersByActive.registered;
103
105
  let metricsArray = [
104
106
  metricsData[0]
105
107
  ? metricsData[0]
106
108
  : { label: "Productos totales", value: total },
107
109
  ];
108
110
 
111
+ console.log(registeredProducts);
112
+
109
113
  metricsArray.push(
114
+ { label: "Productos activos", value: registeredProducts },
110
115
  { label: "Productos filtrados", value: total },
111
116
  { label: "Productos sin asignar", value: PA + R },
112
117
  { label: "Productos en proceso", value: inProcess },
@@ -699,7 +699,7 @@ export const ProviderProductEdition = ({
699
699
  const dataObject = {
700
700
  articleId: product?.id_article,
701
701
  articleData: updatedDatasheets,
702
- boxData: parseBoxData,
702
+ ...(parseBoxData.length > 0 && { boxData: parseBoxData }),
703
703
  };
704
704
 
705
705
  if (product?.orderId) dataObject["orderId"] = product?.orderId;