contentoh-components-library 21.1.13 → 21.1.16

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.
@@ -60,21 +60,34 @@ var GeneralInput = function GeneralInput(_ref) {
60
60
  value: validateInput(evt, position, inputsArray)
61
61
  });
62
62
  } else if (updatedDatasheets || updatedDescriptions || inputType === "textarea") {
63
- setTextValue({
64
- value: inputType === "checkbox" ? evt.target.checked : evt.target.value
65
- });
63
+ var generalValue;
64
+
65
+ if ((optionList === null || optionList === void 0 ? void 0 : optionList.length) > 0) {
66
+ var index = evt.target.selectedIndex;
67
+ var valueSelected = evt.target.value;
68
+ generalValue = index > 0 ? valueSelected : undefined;
69
+ setTextValue({
70
+ value: generalValue
71
+ });
72
+ } else {
73
+ generalValue = inputType === "checkbox" ? evt.target.checked : evt.target.value;
74
+ setTextValue({
75
+ value: generalValue
76
+ });
77
+ }
78
+
66
79
  var dataSave = updatedDatasheets === null || updatedDatasheets === void 0 ? void 0 : updatedDatasheets.slice();
67
80
  if (dataSave.length === 0) dataSave.push({
68
81
  articleId: articleId,
69
82
  versionId: version,
70
83
  attributeId: inputId,
71
- value: inputType === "checkbox" ? evt.target.checked : evt.target.value
84
+ value: generalValue
72
85
  });else if (dataSave.some(function (e) {
73
86
  return e.attributeId === inputId;
74
87
  })) {
75
88
  dataSave.forEach(function (e) {
76
89
  if (e.attributeId === inputId) {
77
- e.value = inputType === "checkbox" ? evt.target.checked : evt.target.value;
90
+ e.value = generalValue;
78
91
  }
79
92
  });
80
93
  } else {
@@ -82,7 +95,7 @@ var GeneralInput = function GeneralInput(_ref) {
82
95
  articleId: articleId,
83
96
  versionId: version,
84
97
  attributeId: inputId,
85
- value: inputType === "checkbox" ? evt.target.checked : evt.target.value
98
+ value: generalValue
86
99
  });
87
100
  }
88
101
  setUpdatedDatasheets(dataSave);
@@ -102,19 +115,17 @@ var GeneralInput = function GeneralInput(_ref) {
102
115
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
103
116
  isRequired: requiredEmpty,
104
117
  children: [(optionList === null || optionList === void 0 ? void 0 : optionList.length) > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
105
- id: "dropdown".concat(inputId) //disabled={!enableInputs}
106
- ,
118
+ id: "dropdown".concat(inputId),
107
119
  onChange: function onChange(e) {
108
120
  return onHandleChange(e);
109
121
  },
122
+ defaultValue: textValue.value,
110
123
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
111
124
  value: "",
112
- disabled: true,
113
125
  children: description
114
126
  }), JSON.parse(optionList || "[]").map(function (element, index) {
115
127
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
116
128
  value: element,
117
- defaultValue: element === textValue.value ? "selected" : "",
118
129
  children: element
119
130
  }, element + "-" + index);
120
131
  })]
@@ -102,11 +102,13 @@ var ImageDataTable = function ImageDataTable(_ref) {
102
102
  action: "changeAttrValue",
103
103
  retailer: retailerSelected,
104
104
  index: index,
105
- value: e.target.value || "-"
105
+ value: e.target.value || "-",
106
+ name: attr.name,
107
+ retailersId: Object.keys(lists.attrForImgs).slice(0, -1)
106
108
  });
107
109
  }
108
110
  })]
109
- }, "row-" + index);
111
+ }, "row-" + index + "-" + (attr === null || attr === void 0 ? void 0 : attr.name));
110
112
  }))]
111
113
  });
112
114
  };
@@ -41,38 +41,38 @@ RetailerProductEditionDefault.args = {
41
41
  descriptions: 1,
42
42
  images: 1
43
43
  },
44
- orderId: 42,
45
- status: "RECEIVED",
46
- datasheet_status: null,
44
+ orderId: 83,
45
+ status: "ASSIGNED",
46
+ datasheet_status: "IN_PROGRESS",
47
47
  prio: "none",
48
48
  version: 2,
49
- description_status: null,
50
- images_status: null,
49
+ description_status: "IN_PROGRESS",
50
+ images_status: "IN_PROGRESS",
51
51
  article: {
52
- id_article: 54413,
53
- id_category: "684",
54
- name: "Crema dental 120 gr",
55
- upc: "456463435",
56
- timestamp: "2022-06-17T16:21:59.000Z",
52
+ id_article: 55150,
53
+ id_category: "697",
54
+ name: "Shampoo hidratante",
55
+ upc: "4116665",
56
+ timestamp: "2022-06-21T19:47:57.000Z",
57
57
  id_user: 28,
58
58
  status: "NULL",
59
59
  active: 1,
60
60
  company_id: 1,
61
61
  company_name: "COMPANY DEV",
62
62
  country: "México",
63
- id_order: 42,
64
- id_datasheet_especialist: null,
65
- id_datasheet_facilitator: null,
66
- id_description_especialist: null,
67
- id_description_facilitator: null,
68
- id_images_especialist: null,
69
- id_images_facilitator: null,
70
- id_auditor: null,
63
+ id_order: 83,
64
+ id_datasheet_especialist: 54,
65
+ id_datasheet_facilitator: 52,
66
+ id_description_especialist: 54,
67
+ id_description_facilitator: 52,
68
+ id_images_especialist: 55,
69
+ id_images_facilitator: 53,
70
+ id_auditor: 30,
71
71
  id_recepcionist: null,
72
- category: "SALUD Y BELLEZA|CUIDADO BUCAL|PASTAS DENTALES Y ASEO BUCAL",
73
- missingAttributes: 22,
74
- missingDescriptions: 16,
75
- missingImages: 4
72
+ category: "SALUD Y BELLEZA|CUIDADO DEL CABELLO|SHAMPOOS Y ACONDICIONADORES",
73
+ missingAttributes: 31,
74
+ missingDescriptions: 6,
75
+ missingImages: 3
76
76
  },
77
77
  retailers: [{
78
78
  id: 4,
@@ -81,26 +81,14 @@ RetailerProductEditionDefault.args = {
81
81
  id_region: 1,
82
82
  active: 1
83
83
  }, {
84
- id: 5,
85
- name: "Chedraui",
86
- country: "México",
87
- id_region: 1,
88
- active: 1
89
- }, {
90
- id: 6,
91
- name: "HEB",
92
- country: "México",
93
- id_region: 1,
94
- active: 1
95
- }, {
96
- id: 13,
97
- name: "Soriana",
84
+ id: 26,
85
+ name: "Mercado Libre",
98
86
  country: "México",
99
87
  id_region: 1,
100
88
  active: 1
101
89
  }],
102
90
  country: "México",
103
- upc: "456463435"
91
+ upc: "4116665"
104
92
  },
105
93
  location: {
106
94
  product: {
@@ -98,7 +98,9 @@ var reducerImages = function reducerImages(state, action) {
98
98
  });
99
99
 
100
100
  case "changeAttrValue":
101
- attrForImgs[action.retailer][action.index].value = action.value;
101
+ action.retailersId.forEach(function (ret) {
102
+ attrForImgs[ret][action.index].name === action.name && (attrForImgs[ret][action.index].value = action.value);
103
+ });
102
104
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
103
105
  attrForImgs: attrForImgs,
104
106
  values: values
@@ -751,16 +753,17 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
751
753
  articleId: product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article,
752
754
  articleData: updatedDatasheets
753
755
  };
756
+ console.log(updatedDatasheets, "updatedDatasheets");
754
757
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
755
- _context6.prev = 4;
756
- _context6.next = 7;
758
+ _context6.prev = 5;
759
+ _context6.next = 8;
757
760
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
758
761
  headers: {
759
762
  Authorization: token
760
763
  }
761
764
  });
762
765
 
763
- case 7:
766
+ case 8:
764
767
  setMessage("Fichas técnicas guardadas");
765
768
 
766
769
  if (productTemp.status === "ASSIGNED") {
@@ -770,20 +773,20 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
770
773
  }
771
774
 
772
775
  loadData();
773
- _context6.next = 15;
776
+ _context6.next = 16;
774
777
  break;
775
778
 
776
- case 12:
777
- _context6.prev = 12;
778
- _context6.t0 = _context6["catch"](4);
779
+ case 13:
780
+ _context6.prev = 13;
781
+ _context6.t0 = _context6["catch"](5);
779
782
  console.log(_context6.t0);
780
783
 
781
- case 15:
784
+ case 16:
782
785
  case "end":
783
786
  return _context6.stop();
784
787
  }
785
788
  }
786
- }, _callee6, null, [[4, 12]]);
789
+ }, _callee6, null, [[5, 13]]);
787
790
  }));
788
791
 
789
792
  return function saveDatasheets() {
@@ -1459,7 +1462,8 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1459
1462
  if (imgsInBack.length > 0) {
1460
1463
  var data = {
1461
1464
  articleId: product.article.id_article,
1462
- deleteImages: imgsInBack
1465
+ deleteImages: imgsInBack,
1466
+ orderId: product.orderId
1463
1467
  };
1464
1468
 
1465
1469
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.1.13",
3
+ "version": "21.1.16",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -38,23 +38,32 @@ export const GeneralInput = ({
38
38
  updatedDescriptions ||
39
39
  inputType === "textarea"
40
40
  ) {
41
- setTextValue({
42
- value: inputType === "checkbox" ? evt.target.checked : evt.target.value,
43
- });
41
+ let generalValue;
42
+ if (optionList?.length > 0) {
43
+ let index = evt.target.selectedIndex;
44
+ let valueSelected = evt.target.value;
45
+ generalValue = index > 0 ? valueSelected : undefined;
46
+ setTextValue({ value: generalValue });
47
+ } else {
48
+ generalValue =
49
+ inputType === "checkbox" ? evt.target.checked : evt.target.value;
50
+ setTextValue({
51
+ value: generalValue,
52
+ });
53
+ }
44
54
  let dataSave = updatedDatasheets?.slice();
55
+
45
56
  if (dataSave.length === 0)
46
57
  dataSave.push({
47
58
  articleId: articleId,
48
59
  versionId: version,
49
60
  attributeId: inputId,
50
- value:
51
- inputType === "checkbox" ? evt.target.checked : evt.target.value,
61
+ value: generalValue,
52
62
  });
53
63
  else if (dataSave.some((e) => e.attributeId === inputId)) {
54
64
  dataSave.forEach((e) => {
55
65
  if (e.attributeId === inputId) {
56
- e.value =
57
- inputType === "checkbox" ? evt.target.checked : evt.target.value;
66
+ e.value = generalValue;
58
67
  }
59
68
  });
60
69
  } else {
@@ -62,8 +71,7 @@ export const GeneralInput = ({
62
71
  articleId: articleId,
63
72
  versionId: version,
64
73
  attributeId: inputId,
65
- value:
66
- inputType === "checkbox" ? evt.target.checked : evt.target.value,
74
+ value: generalValue,
67
75
  });
68
76
  }
69
77
  setUpdatedDatasheets(dataSave);
@@ -86,18 +94,12 @@ export const GeneralInput = ({
86
94
  <select
87
95
  key={`dropdownK${inputId}`}
88
96
  id={`dropdown${inputId}`}
89
- //disabled={!enableInputs}
90
97
  onChange={(e) => onHandleChange(e)}
98
+ defaultValue={textValue.value}
91
99
  >
92
- <option value="" disabled>
93
- {description}
94
- </option>
100
+ <option value="">{description}</option>
95
101
  {JSON.parse(optionList || "[]").map((element, index) => (
96
- <option
97
- key={element + "-" + index}
98
- value={element}
99
- defaultValue={element === textValue.value ? "selected" : ""}
100
- >
102
+ <option key={element + "-" + index} value={element}>
101
103
  {element}
102
104
  </option>
103
105
  ))}
@@ -80,7 +80,7 @@ export const ImageDataTable = ({
80
80
  {retailerSelected &&
81
81
  lists?.attrForImgs &&
82
82
  lists?.attrForImgs[retailerSelected]?.map((attr, index) => (
83
- <Row key={"row-" + index}>
83
+ <Row key={"row-" + index + "-" + attr?.name}>
84
84
  <ScreenHeader
85
85
  headerType={"table-row-text"}
86
86
  text={attr?.name || "-"}
@@ -94,6 +94,8 @@ export const ImageDataTable = ({
94
94
  retailer: retailerSelected,
95
95
  index,
96
96
  value: e.target.value || "-",
97
+ name: attr.name,
98
+ retailersId: Object.keys(lists.attrForImgs).slice(0, -1),
97
99
  });
98
100
  }}
99
101
  />
@@ -26,38 +26,39 @@ RetailerProductEditionDefault.args = {
26
26
  descriptions: 1,
27
27
  images: 1,
28
28
  },
29
- orderId: 42,
30
- status: "RECEIVED",
31
- datasheet_status: null,
29
+ orderId: 83,
30
+ status: "ASSIGNED",
31
+ datasheet_status: "IN_PROGRESS",
32
32
  prio: "none",
33
33
  version: 2,
34
- description_status: null,
35
- images_status: null,
34
+ description_status: "IN_PROGRESS",
35
+ images_status: "IN_PROGRESS",
36
36
  article: {
37
- id_article: 54413,
38
- id_category: "684",
39
- name: "Crema dental 120 gr",
40
- upc: "456463435",
41
- timestamp: "2022-06-17T16:21:59.000Z",
37
+ id_article: 55150,
38
+ id_category: "697",
39
+ name: "Shampoo hidratante",
40
+ upc: "4116665",
41
+ timestamp: "2022-06-21T19:47:57.000Z",
42
42
  id_user: 28,
43
43
  status: "NULL",
44
44
  active: 1,
45
45
  company_id: 1,
46
46
  company_name: "COMPANY DEV",
47
47
  country: "México",
48
- id_order: 42,
49
- id_datasheet_especialist: null,
50
- id_datasheet_facilitator: null,
51
- id_description_especialist: null,
52
- id_description_facilitator: null,
53
- id_images_especialist: null,
54
- id_images_facilitator: null,
55
- id_auditor: null,
48
+ id_order: 83,
49
+ id_datasheet_especialist: 54,
50
+ id_datasheet_facilitator: 52,
51
+ id_description_especialist: 54,
52
+ id_description_facilitator: 52,
53
+ id_images_especialist: 55,
54
+ id_images_facilitator: 53,
55
+ id_auditor: 30,
56
56
  id_recepcionist: null,
57
- category: "SALUD Y BELLEZA|CUIDADO BUCAL|PASTAS DENTALES Y ASEO BUCAL",
58
- missingAttributes: 22,
59
- missingDescriptions: 16,
60
- missingImages: 4,
57
+ category:
58
+ "SALUD Y BELLEZA|CUIDADO DEL CABELLO|SHAMPOOS Y ACONDICIONADORES",
59
+ missingAttributes: 31,
60
+ missingDescriptions: 6,
61
+ missingImages: 3,
61
62
  },
62
63
  retailers: [
63
64
  {
@@ -68,29 +69,15 @@ RetailerProductEditionDefault.args = {
68
69
  active: 1,
69
70
  },
70
71
  {
71
- id: 5,
72
- name: "Chedraui",
73
- country: "México",
74
- id_region: 1,
75
- active: 1,
76
- },
77
- {
78
- id: 6,
79
- name: "HEB",
80
- country: "México",
81
- id_region: 1,
82
- active: 1,
83
- },
84
- {
85
- id: 13,
86
- name: "Soriana",
72
+ id: 26,
73
+ name: "Mercado Libre",
87
74
  country: "México",
88
75
  id_region: 1,
89
76
  active: 1,
90
77
  },
91
78
  ],
92
79
  country: "México",
93
- upc: "456463435",
80
+ upc: "4116665",
94
81
  },
95
82
  location: {
96
83
  product: { articleId: 109485, versionId: 3 },
@@ -44,7 +44,11 @@ const reducerImages = (state, action) => {
44
44
  values[action.index][action.attribute] = action.value;
45
45
  return { ...state, values };
46
46
  case "changeAttrValue":
47
- attrForImgs[action.retailer][action.index].value = action.value;
47
+ action.retailersId.forEach((ret) => {
48
+ attrForImgs[ret][action.index].name === action.name &&
49
+ (attrForImgs[ret][action.index].value = action.value);
50
+ });
51
+
48
52
  return { ...state, attrForImgs, values };
49
53
  case "deleteImage":
50
54
  values = values.filter(
@@ -420,6 +424,7 @@ export const RetailerProductEdition = ({
420
424
  articleId: product?.article?.id_article,
421
425
  articleData: updatedDatasheets,
422
426
  };
427
+ console.log(updatedDatasheets, "updatedDatasheets");
423
428
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
424
429
  try {
425
430
  await axios.put(
@@ -978,6 +983,7 @@ export const RetailerProductEdition = ({
978
983
  const data = {
979
984
  articleId: product.article.id_article,
980
985
  deleteImages: imgsInBack,
986
+ orderId: product.orderId,
981
987
  };
982
988
  try {
983
989
  axios.put(