contentoh-components-library 21.3.79 → 21.3.80

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.
@@ -485,28 +485,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
485
485
  var _useState83 = (0, _react.useState)(false),
486
486
  _useState84 = (0, _slicedToArray2.default)(_useState83, 2),
487
487
  valRejAll = _useState84[0],
488
- setValRejAll = _useState84[1]; //! ==========================================Daniel===========================================
489
-
490
- /* ====================================== Cambios =================================*/
491
-
492
-
493
- var _useState85 = (0, _react.useState)([]),
494
- _useState86 = (0, _slicedToArray2.default)(_useState85, 2),
495
- desc = _useState86[0],
496
- setDesc = _useState86[1];
497
-
498
- var _useState87 = (0, _react.useState)([]),
499
- _useState88 = (0, _slicedToArray2.default)(_useState87, 2),
500
- fich = _useState88[0],
501
- setFich = _useState88[1];
502
-
503
- var _useState89 = (0, _react.useState)([]),
504
- _useState90 = (0, _slicedToArray2.default)(_useState89, 2),
505
- imag = _useState90[0],
506
- setImag = _useState90[1];
507
- /* ------------------------------------- Cambios ----------------------------------*/
508
- //! ==========================================Daniel===========================================
509
-
488
+ setValRejAll = _useState84[1];
510
489
 
511
490
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
512
491
  var _ref3, id_article;
@@ -1993,14 +1972,9 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1993
1972
  isRetailer: isRetailer,
1994
1973
  showSaveButton: auditorAssigned() || userAssigned(),
1995
1974
  version: version,
1996
- desc: desc,
1997
- setDesc: setDesc,
1998
- fich: fich,
1999
- setFich: setFich,
2000
- imag: imag,
2001
- setImag: setImag,
2002
1975
  updatedDescriptions: updatedDescriptions,
2003
1976
  updatedDatasheets: updatedDatasheets,
1977
+ images: images,
2004
1978
  selectedImages: selectedImages,
2005
1979
  setUpdatedDescriptions: setUpdatedDescriptions,
2006
1980
  setUpdatedDatasheets: setUpdatedDatasheets,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.3.79",
3
+ "version": "21.3.80",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -7,7 +7,7 @@ export const GeneralInput = ({
7
7
  inputType,
8
8
  inputId,
9
9
  inputName,
10
- inputValue,
10
+ inputValue = "",
11
11
  inputPlaceholder,
12
12
  validateInput,
13
13
  position,
@@ -43,7 +43,6 @@ export const GeneralInput = ({
43
43
  ) {
44
44
  let generalValue;
45
45
  if (optionList?.length > 0) {
46
- let index = evt.target.selectedIndex;
47
46
  let valueSelected = evt.target.value;
48
47
  generalValue = valueSelected;
49
48
  setTextValue({ value: generalValue });
@@ -56,26 +55,26 @@ export const GeneralInput = ({
56
55
  }
57
56
  let dataSave = updatedDatasheets?.slice();
58
57
 
59
- if (dataSave.length === 0)
60
- dataSave.push({
61
- articleId: articleId,
62
- versionId: version,
63
- attributeId: inputId,
64
- value: generalValue,
65
- });
66
- else if (dataSave.some((e) => e.attributeId === inputId)) {
67
- dataSave.forEach((e) => {
68
- if (e.attributeId === inputId) {
69
- e.value = generalValue;
70
- }
71
- });
58
+ if (dataSave?.length > 0) {
59
+ const index = dataSave.findIndex((e) => e.attributeId === inputId);
60
+ if (index !== -1) {
61
+ if (generalValue !== inputValue) dataSave[index].value = generalValue;
62
+ else dataSave.splice(index, 1);
63
+ } else {
64
+ dataSave.push({
65
+ articleId: articleId,
66
+ attributeId: inputId,
67
+ value: generalValue,
68
+ });
69
+ }
72
70
  } else {
73
- dataSave.push({
74
- articleId: articleId,
75
- versionId: version,
76
- attributeId: inputId,
77
- value: generalValue,
78
- });
71
+ if (generalValue !== inputValue) {
72
+ dataSave.push({
73
+ articleId: articleId,
74
+ attributeId: inputId,
75
+ value: generalValue,
76
+ });
77
+ }
79
78
  }
80
79
  setUpdatedDatasheets(dataSave);
81
80
  } else {
@@ -1,6 +1,6 @@
1
1
  import ReactQuill from "react-quill";
2
2
  import "react-quill/dist/quill.snow.css";
3
- import { useEffect, useState } from "react";
3
+ import { useState } from "react";
4
4
  import { Container } from "./styles";
5
5
 
6
6
  export const InputFormatter = ({
@@ -9,8 +9,6 @@ export const InputFormatter = ({
9
9
  articleId,
10
10
  updatedDescriptions,
11
11
  setUpdatedDescriptions,
12
- addTextAreaToArray,
13
- name,
14
12
  isRequired,
15
13
  maxChar,
16
14
  }) => {
@@ -44,7 +42,7 @@ export const InputFormatter = ({
44
42
  .replace(/\&/gm, "&");
45
43
  };
46
44
 
47
- const onChange = (valueInput, delta, user, h) => {
45
+ const onChange = (valueInput, h) => {
48
46
  let value = "";
49
47
  try {
50
48
  if (h.getLength() - 1 <= maxLength) {
@@ -72,12 +70,10 @@ export const InputFormatter = ({
72
70
  let idInput = inputId;
73
71
  let dataSave = updatedDescriptions?.slice();
74
72
  if (dataSave?.length > 0) {
75
- if (dataSave.filter((e) => e.attributeId === idInput).length > 0) {
76
- dataSave.forEach((e) => {
77
- if (e.attributeId === idInput) {
78
- e.value = value;
79
- }
80
- });
73
+ const index = dataSave.findIndex((e) => e.attributeId === idInput);
74
+ if (index !== -1) {
75
+ if (value !== mainValue) dataSave[index].value = value;
76
+ else dataSave.splice(index, 1);
81
77
  } else {
82
78
  dataSave.push({
83
79
  articleId: articleId,
@@ -86,11 +82,13 @@ export const InputFormatter = ({
86
82
  });
87
83
  }
88
84
  } else {
89
- dataSave.push({
90
- articleId: articleId,
91
- attributeId: idInput,
92
- value: value,
93
- });
85
+ if (value !== mainValue) {
86
+ dataSave.push({
87
+ articleId: articleId,
88
+ attributeId: idInput,
89
+ value: value,
90
+ });
91
+ }
94
92
  }
95
93
  setUpdatedDescriptions(dataSave);
96
94
  }
@@ -142,9 +140,7 @@ export const InputFormatter = ({
142
140
  e.preventDefault();
143
141
  }
144
142
  }}
145
- onChange={(valueInput, user, range, h) => {
146
- onChange(valueInput, user, range, h);
147
- }}
143
+ onChange={(valueInput, user, range, h) => onChange(valueInput, h)}
148
144
  onChangeSelection={getSelection}
149
145
  />
150
146
  <p className="description-limit">
@@ -72,4 +72,4 @@ export const AvatarAndValidation = ({
72
72
  )}
73
73
  </Container>
74
74
  );
75
- };
75
+ };
@@ -2,156 +2,103 @@ import { Container } from "./styles";
2
2
  import { TabSection } from "../../atoms/TabSection";
3
3
  import { useEffect, useState } from "react";
4
4
 
5
-
6
5
  import { Modal } from "../../organisms/Modal";
7
6
  import { ButtonV2 } from "../../atoms/ButtonV2";
8
7
 
9
-
10
8
  export const TabsMenu = ({
11
9
  tabsSections = {},
12
10
  setImagesSection,
13
11
  setActiveTab,
14
12
  activeTab,
15
-
16
- desc,
17
- setDesc,
18
- fich,
19
- setFich,
20
- imag,
21
- setImag,
22
13
  updatedDescriptions,
23
14
  updatedDatasheets,
24
- selectedImages,
25
- setUpdatedDescriptions,
26
- setUpdatedDatasheets,
27
- setSelectedImages
15
+ images,
28
16
  }) => {
29
17
  const [sections, setSections] = useState(tabsSections);
30
18
 
31
-
32
- const [modal, setModal] = useState(false)
33
- const [isFirstExecution, setIsFirstExecution] = useState(true)
34
- const [detectaTab, setDetectaTab] = useState('')
35
- const [cancelAccept, setCancelAccept] = useState('')
36
- const [llave, setLlave] = useState('')
37
- const [objeto, setObjeto] = useState()
38
-
39
-
40
-
19
+ const [modal, setModal] = useState(false);
20
+ const [cancelAccept, setCancelAccept] = useState("");
21
+ const [llave, setLlave] = useState("");
22
+ const [objeto, setObjeto] = useState();
41
23
 
42
24
  const activeSection = (key, array = {}) => {
43
25
  let tempArray = {};
44
26
  setImagesSection(key === "Imágenes");
45
27
  Object.keys(array).forEach((section) => {
46
28
  tempArray[section] = section === key;
47
- if (section === key) {
48
-
49
- setUpdatedDatasheets([])
50
- setUpdatedDescriptions([])
51
- setSelectedImages([])
52
- setDesc([])
53
- setFich([])
54
- setImag([])
55
- return setActiveTab(key)
56
- };
29
+ if (section === key) return setActiveTab(key);
57
30
  });
58
31
  setSections(tempArray);
59
32
  };
60
33
 
34
+ useEffect(() => {
35
+ if ((cancelAccept === "Aceptar") & (llave !== "")) {
36
+ setCancelAccept("");
37
+ setModal(false);
38
+ activeSection(llave, objeto);
39
+ } else if ((cancelAccept === "Cancelar") & (llave !== "")) {
40
+ setModal(false);
41
+ setCancelAccept("");
42
+ }
43
+ }, [cancelAccept]);
61
44
 
62
-
63
-
64
- //! ==========================================Daniel===========================================
65
- {/*=============================================================================
66
- UseEffect para poder recolectar la info
67
- ==============================================================================*/}
68
-
69
- useEffect(() => {
70
- if (cancelAccept==='Aceptar' & llave!==''){
71
- setCancelAccept('')
72
- setModal(false)
73
- activeSection(llave, objeto)
74
- } else if (cancelAccept==='Cancelar' & llave!=='') {
75
- setModal(false)
76
- setCancelAccept('')
77
- }
78
- },[cancelAccept])
79
-
80
-
81
-
82
- function detectClickFunction (e,key,sections) {
83
-
84
-
45
+ const detectClickFunction = (e, key, sections) => {
85
46
  const targetIsTheCurrentTab = e.target.innerHTML === activeTab;
86
47
  const descriptionsWereUpdated = updatedDescriptions.length > 0;
87
48
  const datasheetWereUpdated = updatedDatasheets.length > 0;
88
- const imagesWereUpdated = selectedImages.length > 0;
89
- const dataWereUpdated = descriptionsWereUpdated || datasheetWereUpdated || imagesWereUpdated;
90
-
91
- if (!targetIsTheCurrentTab && !dataWereUpdated ){
92
- setLlave(key)
93
- setObjeto(sections)
94
- activeSection(key, sections)
95
- }
96
- else if(!targetIsTheCurrentTab && dataWereUpdated ){
97
- setModal(true)
98
- setLlave(key)
99
- setObjeto(sections)
100
-
101
-
49
+ const imagesWereUpdated = images?.values?.filter((f) => !f.id)?.length > 0;
50
+ const dataWereUpdated =
51
+ descriptionsWereUpdated || datasheetWereUpdated || imagesWereUpdated;
52
+
53
+ if (!targetIsTheCurrentTab && !dataWereUpdated) {
54
+ setLlave(key);
55
+ setObjeto(sections);
56
+ activeSection(key, sections);
57
+ } else if (!targetIsTheCurrentTab && dataWereUpdated) {
58
+ setModal(true);
59
+ setLlave(key);
60
+ setObjeto(sections);
102
61
  }
103
- }
104
-
105
-
106
-
107
-
108
- //! ==========================================Daniel===========================================
109
-
62
+ };
110
63
 
111
64
  return (
112
65
  <>
113
- {/* //! ==========================================Daniel=========================================== */ }
114
- {/*=============================================================================
115
- Llamado al componente para poder renderizar la alerta
116
- ==============================================================================*/}
117
- {activeTab && <Modal
118
- show={modal}
119
- title='Cambios sin Guardar'
120
- message= 'Estás cambiando de vista y aun no guardas cambios ¿Estás seguro?'
121
- buttons={ [
122
- <ButtonV2
123
- key={"btn-Cancelar"}
124
- type={"white"}
125
- label={"Cancelar"}
126
- size={12}
127
- onClick={(event) => setCancelAccept(event.target.textContent)}
128
- />,
129
- <ButtonV2
130
- key={"btn-Aceptar"}
131
- type={"pink"}
132
- label={"Aceptar"}
133
- size={12}
134
- onClick={(event) => setCancelAccept(event.target.textContent)}
135
- />,
136
- ]}
137
- />
138
- }
139
- {/*=============================================================================
140
- Llamado al componente para poder renderizar la alerta
141
- ==============================================================================*/}
142
- {/* //! ==========================================Daniel=========================================== */ }
143
- <Container>
144
- {Object.keys(sections).map((key, index) => (
145
- <TabSection
146
- key={index}
147
- label={key}
148
- active={sections[key]}
149
- onClick={(e)=>{
150
- detectClickFunction (e, key, sections)
151
- }}
66
+ {activeTab && (
67
+ <Modal
68
+ show={modal}
69
+ title="Cambios sin Guardar"
70
+ message="Estás cambiando de vista y aun no guardas cambios ¿Estás seguro?"
71
+ buttons={[
72
+ <ButtonV2
73
+ key={"btn-Cancelar"}
74
+ type={"white"}
75
+ label={"Cancelar"}
76
+ size={12}
77
+ onClick={(event) => setCancelAccept(event.target.textContent)}
78
+ />,
79
+ <ButtonV2
80
+ key={"btn-Aceptar"}
81
+ type={"pink"}
82
+ label={"Aceptar"}
83
+ size={12}
84
+ onClick={(event) => setCancelAccept(event.target.textContent)}
85
+ />,
86
+ ]}
152
87
  />
153
- ))}
154
- </Container>
88
+ )}
89
+
90
+ <Container>
91
+ {Object.keys(sections).map((key, index) => (
92
+ <TabSection
93
+ key={index}
94
+ label={key}
95
+ active={sections[key]}
96
+ onClick={(e) => {
97
+ detectClickFunction(e, key, sections);
98
+ }}
99
+ />
100
+ ))}
101
+ </Container>
155
102
  </>
156
103
  );
157
- };
104
+ };
@@ -1,8 +1,6 @@
1
1
  import { Container } from "./styles";
2
2
  import { ScreenHeader } from "../../atoms/ScreenHeader/index";
3
3
  import { GeneralInput } from "../../atoms/GeneralInput/index";
4
- import { useEffect } from "react";
5
- import { useState } from "react";
6
4
 
7
5
  export const TagAndInput = ({
8
6
  inputType,
@@ -32,7 +30,6 @@ export const TagAndInput = ({
32
30
  showTooltip,
33
31
  auditClass,
34
32
  }) => {
35
-
36
33
  return (
37
34
  <Container
38
35
  inputType={inputType}
@@ -76,5 +73,4 @@ export const TagAndInput = ({
76
73
  />
77
74
  </Container>
78
75
  );
79
-
80
76
  };
@@ -19,19 +19,13 @@ export const FullTabsMenu = ({
19
19
  canAssign,
20
20
  version,
21
21
  setShowVersionSelector,
22
-
23
- desc,
24
- setDesc,
25
- fich,
26
- setFich,
27
- imag,
28
- setImag,
22
+ images,
29
23
  updatedDescriptions,
30
24
  updatedDatasheets,
31
25
  selectedImages,
32
26
  setUpdatedDescriptions,
33
27
  setUpdatedDatasheets,
34
- setSelectedImages
28
+ setSelectedImages,
35
29
  }) => {
36
30
  const [imagesSection, setImagesSection] = useState(false);
37
31
 
@@ -42,13 +36,7 @@ export const FullTabsMenu = ({
42
36
  setImagesSection={setImagesSection}
43
37
  setActiveTab={setActiveTab}
44
38
  activeTab={activeTab}
45
-
46
- desc={ desc }
47
- setDesc={ setDesc }
48
- fich={fich}
49
- setFich={setFich}
50
- imag={imag}
51
- setImag={setImag}
39
+ images={images}
52
40
  updatedDescriptions={updatedDescriptions}
53
41
  updatedDatasheets={updatedDatasheets}
54
42
  selectedImages={selectedImages}
@@ -74,4 +62,4 @@ export const FullTabsMenu = ({
74
62
  />
75
63
  </Container>
76
64
  );
77
- };
65
+ };
@@ -3,7 +3,6 @@ import { TableHeader } from "../../molecules/TableHeader";
3
3
  import { Container as Row } from "../../molecules/TableRow/styles";
4
4
  import { ScreenHeader } from "../../atoms/ScreenHeader";
5
5
  import LabelToInput from "../../atoms/LabelToInput";
6
- import { useState, useEffect } from "react";
7
6
 
8
7
  export const ImageDataTable = ({
9
8
  activeImage,
@@ -21,7 +20,6 @@ export const ImageDataTable = ({
21
20
  setShowVersionSelector,
22
21
  shotThd,
23
22
  }) => {
24
-
25
23
  return (
26
24
  <Container darkMode={darkMode}>
27
25
  <TableHeader
@@ -45,7 +43,6 @@ export const ImageDataTable = ({
45
43
  }
46
44
  />
47
45
  </Row>
48
-
49
46
  <Row>
50
47
  <ScreenHeader headerType={"table-row-text"} text="Tipo de empaque" />
51
48
  <ScreenHeader
@@ -47,7 +47,6 @@ export const InputGroup = ({
47
47
  text={inputGroup?.dataGroup}
48
48
  />
49
49
  )}
50
-
51
50
  <div className="inputs-container">
52
51
  {inputGroup?.inputs?.map((input, index) =>
53
52
  activeSection === "Ficha técnica" ? (
@@ -119,11 +118,9 @@ export const InputGroup = ({
119
118
  ? "audit-class"
120
119
  : ""
121
120
  }
122
- />
123
-
121
+ />
124
122
  )
125
- )
126
- }
123
+ )}
127
124
  </div>
128
125
  </Container>
129
126
  );
@@ -225,19 +225,6 @@ export const ProviderProductEdition = ({
225
225
  Imágenes: null,
226
226
  });
227
227
 
228
-
229
- //! ==========================================Daniel===========================================
230
- /* ====================================== Cambios =================================*/
231
- const [desc, setDesc] = useState([])
232
- const [fich, setFich] = useState([])
233
- const [imag, setImag] = useState([])
234
-
235
- /* ------------------------------------- Cambios ----------------------------------*/
236
- //! ==========================================Daniel===========================================
237
-
238
-
239
-
240
-
241
228
  const [inCart, setInCart] = useState(false);
242
229
  const [dataGenericModal, setDataGenericModal] = useState({
243
230
  message: "¿Estás seguro de continuar?",
@@ -1259,6 +1246,7 @@ export const ProviderProductEdition = ({
1259
1246
  },
1260
1247
  ];
1261
1248
  const sendToEvaluation = (result) => {
1249
+ console.log({ result });
1262
1250
  if (result === "A") {
1263
1251
  if (
1264
1252
  origin[activeTab] === "RequestWithoutContentoh" &&
@@ -1291,7 +1279,7 @@ export const ProviderProductEdition = ({
1291
1279
  }
1292
1280
  } else {
1293
1281
  if (
1294
- originProp === "RequestWithoutContentoh" &&
1282
+ origin === "RequestWithoutContentoh" &&
1295
1283
  !user.is_retailer &&
1296
1284
  (!product.id_order || !product.orderId)
1297
1285
  ) {
@@ -1314,6 +1302,7 @@ export const ProviderProductEdition = ({
1314
1302
  }
1315
1303
  }
1316
1304
  };
1305
+
1317
1306
  return (
1318
1307
  <Container headerTop={headerTop}>
1319
1308
  <HeaderTop
@@ -1359,7 +1348,7 @@ export const ProviderProductEdition = ({
1359
1348
  showApproveRejectAll={isRevision() && getSectionStatus()}
1360
1349
  approveAll={() => {
1361
1350
  if (
1362
- originProp === "RequestWithoutContentoh" &&
1351
+ origin === "RequestWithoutContentoh" &&
1363
1352
  !user.is_retailer &&
1364
1353
  (!product.id_order || !product.orderId)
1365
1354
  ) {
@@ -1390,7 +1379,7 @@ export const ProviderProductEdition = ({
1390
1379
  }}
1391
1380
  rejectAll={() => {
1392
1381
  if (
1393
- originProp === "RequestWithoutContentoh" &&
1382
+ origin === "RequestWithoutContentoh" &&
1394
1383
  !user.is_retailer &&
1395
1384
  (!product.id_order || !product.orderId)
1396
1385
  ) {
@@ -1439,20 +1428,13 @@ export const ProviderProductEdition = ({
1439
1428
  isRetailer={isRetailer}
1440
1429
  showSaveButton={enableActions(product.version_status)}
1441
1430
  version={version}
1442
-
1443
- desc={ desc }
1444
- setDesc={ setDesc }
1445
- fich={fich}
1446
- setFich={setFich}
1447
- imag={imag}
1448
- setImag={setImag}
1449
1431
  updatedDescriptions={updatedDescriptions}
1450
1432
  updatedDatasheets={updatedDatasheets}
1433
+ images={images}
1451
1434
  selectedImages={selectedImages}
1452
1435
  setUpdatedDescriptions={setUpdatedDescriptions}
1453
1436
  setUpdatedDatasheets={setUpdatedDatasheets}
1454
1437
  setSelectedImages={setSelectedImages}
1455
-
1456
1438
  setShowVersionSelector={setShowVersionSelector}
1457
1439
  onClickSave={() => {
1458
1440
  switch (activeTab) {