contentoh-components-library 21.4.96 → 21.4.98

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.
@@ -44,58 +44,43 @@ var ObservationFlag = function ObservationFlag(_ref) {
44
44
 
45
45
  var observation = _ref.observation,
46
46
  contentObservation = _ref.contentObservation,
47
- dataProduct = _ref.dataProduct;
48
- var PriorityFlags = (_PriorityFlags = {}, (0, _defineProperty2.default)(_PriorityFlags, "none", _noPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "low", _lowPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "medium", _mediumPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "high", _highPriority.default), _PriorityFlags);
49
-
50
- var _useState = (0, _react.useState)(false),
47
+ dataProduct = _ref.dataProduct,
48
+ isObservationVisible = _ref.isObservationVisible,
49
+ toggleObservation = _ref.toggleObservation,
50
+ handleClickOutside = _ref.handleClickOutside,
51
+ hideObservation = _ref.hideObservation;
52
+ var PriorityFlags = (_PriorityFlags = {}, (0, _defineProperty2.default)(_PriorityFlags, "none", _noPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "low", _lowPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "medium", _mediumPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "high", _highPriority.default), _PriorityFlags); // const [isObservationVisible, setObservationVisible] = useState(false);
53
+
54
+ var _useState = (0, _react.useState)(contentObservation || ""),
51
55
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
52
- isObservationVisible = _useState2[0],
53
- setObservationVisible = _useState2[1];
56
+ material = _useState2[0],
57
+ setMaterial = _useState2[1];
54
58
 
55
- var _useState3 = (0, _react.useState)(contentObservation || ""),
59
+ var _useState3 = (0, _react.useState)(observation),
56
60
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
57
- material = _useState4[0],
58
- setMaterial = _useState4[1];
61
+ currentObservation = _useState4[0],
62
+ setCurrentObservation = _useState4[1];
59
63
 
60
- var _useState5 = (0, _react.useState)(observation),
64
+ var _useState5 = (0, _react.useState)(false),
61
65
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
62
- currentObservation = _useState6[0],
63
- setCurrentObservation = _useState6[1];
66
+ showModal = _useState6[0],
67
+ setShowModal = _useState6[1];
64
68
 
65
- var _useState7 = (0, _react.useState)(false),
69
+ var _useState7 = (0, _react.useState)({}),
66
70
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
67
- showModal = _useState8[0],
68
- setShowModal = _useState8[1];
69
-
70
- var _useState9 = (0, _react.useState)({}),
71
- _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
72
- modalData = _useState10[0],
73
- setModalData = _useState10[1];
71
+ modalData = _useState8[0],
72
+ setModalData = _useState8[1];
74
73
 
75
74
  var textareaRef = (0, _react.useRef)(null);
76
-
77
- var toggleObservation = function toggleObservation() {
78
- console.log("VENTANA");
79
- evt.stopPropagation();
80
- setObservationVisible(!isObservationVisible);
81
- };
82
-
83
75
  (0, _react.useEffect)(function () {
84
- var handleClickOutside = function handleClickOutside(event) {
85
- if (isObservationVisible && !event.target.closest(".Observation") && !event.target.closest(".Container")) {
86
- setObservationVisible(false);
87
- }
88
- };
89
-
90
76
  document.addEventListener("click", handleClickOutside);
91
77
  return function () {
92
78
  document.removeEventListener("click", handleClickOutside);
93
79
  };
94
- }, [isObservationVisible]);
80
+ }, [isObservationVisible, handleClickOutside]);
95
81
  (0, _react.useEffect)(function () {
96
- setMaterial(contentObservation || ""); // Establecer material después de montar el componente
97
- }, [contentObservation]); // Volver a establecer material cuando contentObservation cambia
98
-
82
+ setMaterial(contentObservation || "");
83
+ }, [contentObservation]);
99
84
  (0, _react.useEffect)(function () {
100
85
  setCurrentObservation(observation);
101
86
  }, [observation]);
@@ -133,7 +118,7 @@ var ObservationFlag = function ObservationFlag(_ref) {
133
118
  setShowModal(true);
134
119
  setModalData(response.data.statusCode === 200 ? succesResponse : errorResponse);
135
120
  setCurrentObservation(material !== "" ? "high" : "low");
136
- setObservationVisible(false);
121
+ hideObservation();
137
122
  return _context.abrupt("return", response);
138
123
 
139
124
  case 14:
@@ -26,7 +26,11 @@ var ProductNameHeader = function ProductNameHeader(_ref) {
26
26
  date = _ref.date,
27
27
  percentRequired = _ref.percentRequired,
28
28
  productObservation = _ref.productObservation,
29
- dataProduct = _ref.dataProduct;
29
+ dataProduct = _ref.dataProduct,
30
+ isObservationVisible = _ref.isObservationVisible,
31
+ toggleObservation = _ref.toggleObservation,
32
+ handleClickOutside = _ref.handleClickOutside,
33
+ hideObservation = _ref.hideObservation;
30
34
  var typeFlag = productObservation !== null && productObservation !== "" ? "high" : "low";
31
35
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
32
36
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ScreenHeader, {
@@ -41,7 +45,11 @@ var ProductNameHeader = function ProductNameHeader(_ref) {
41
45
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index5.ObservationFlag, {
42
46
  observation: typeFlag,
43
47
  contentObservation: productObservation,
44
- dataProduct: dataProduct
48
+ dataProduct: dataProduct,
49
+ isObservationVisible: isObservationVisible,
50
+ toggleObservation: toggleObservation,
51
+ handleClickOutside: handleClickOutside,
52
+ hideObservation: hideObservation
45
53
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ScreenHeader, {
46
54
  headerType: "date-header",
47
55
  text: date
@@ -35,7 +35,11 @@ var FullProductNameHeader = function FullProductNameHeader(_ref) {
35
35
  rejectAll = _ref.rejectAll,
36
36
  servicesData = _ref.servicesData,
37
37
  showApproveRejectAll = _ref.showApproveRejectAll,
38
- productObservation = _ref.productObservation;
38
+ productObservation = _ref.productObservation,
39
+ isObservationVisible = _ref.isObservationVisible,
40
+ toggleObservation = _ref.toggleObservation,
41
+ handleClickOutside = _ref.handleClickOutside,
42
+ hideObservation = _ref.hideObservation;
39
43
 
40
44
  var _useState = (0, _react.useState)([]),
41
45
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -71,7 +75,11 @@ var FullProductNameHeader = function FullProductNameHeader(_ref) {
71
75
  priority: headerData === null || headerData === void 0 ? void 0 : headerData.prio,
72
76
  productObservation: productObservation,
73
77
  date: getTime((headerData === null || headerData === void 0 ? void 0 : (_headerData$article2 = headerData.article) === null || _headerData$article2 === void 0 ? void 0 : _headerData$article2.timestamp) || (headerData === null || headerData === void 0 ? void 0 : headerData.timestamp)),
74
- dataProduct: headerData
78
+ dataProduct: headerData,
79
+ isObservationVisible: isObservationVisible,
80
+ toggleObservation: toggleObservation,
81
+ handleClickOutside: handleClickOutside,
82
+ hideObservation: hideObservation
75
83
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
76
84
  className: "features-bar-container",
77
85
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FeaturesBar.FeaturesBar, {
@@ -15,6 +15,6 @@ var _variables = require("../../../global-files/variables");
15
15
 
16
16
  var _templateObject;
17
17
 
18
- var ContainerModal = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n overflow: auto;\n display: grid;\n place-items: center;\n background-color: rgba(0, 0, 0, 0.4);\n\n .contentModal {\n width: fit-content;\n max-width: 80%;\n min-width: 80px;\n height: fit-content;\n max-height: 90%;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: white;\n border-radius: 10px;\n padding: 25px 25px 20px 25px;\n box-shadow: 0px 2px 4px 0px #00000040;\n\n header {\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n gap: 6px;\n\n .label-title {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 17px;\n line-height: 1.2;\n color: #262626;\n white-space: pre-wrap;\n }\n\n & + * {\n margin-top: 20px;\n }\n }\n\n .iconModal {\n width: 50px;\n height: 50px;\n font-size: 30px;\n border-width: 4px;\n margin-bottom: 20px;\n overflow: hidden;\n\n &.iconModal-error {\n background-color: #953737;\n border-color: #953737;\n color: white;\n }\n &.iconModal-warning {\n font-size: 27px;\n padding-bottom: 8px;\n color: #af9647;\n border-color: #af9647;\n }\n &.iconModal-info {\n border-color: #9e3e26;\n color: #9e3e26;\n }\n &.iconModal-success {\n }\n &.iconModal-successv2{\n border-color: #85BC5B;\n color: #85BC5B;\n }\n }\n\n .label-message {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 13px;\n color: #707070;\n white-space: pre-wrap;\n }\n\n .container-customComponent {\n width: 100%;\n max-height: 50vh;\n display: flex;\n flex-direction: column;\n margin-top: 20px;\n padding: 0px 0px;\n //border: 1px solid red;\n }\n\n .container-buttons {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 12px;\n margin-top: 20px;\n //border: 1px solid red;\n }\n }\n"])), _variables.FontFamily.RobotoMedium, _variables.FontFamily.RobotoRegular);
18
+ var ContainerModal = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n overflow: auto;\n display: grid;\n place-items: center;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 10100;\n\n .contentModal {\n width: fit-content;\n max-width: 80%;\n min-width: 80px;\n height: fit-content;\n max-height: 90%;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: white;\n border-radius: 10px;\n padding: 25px 25px 20px 25px;\n box-shadow: 0px 2px 4px 0px #00000040;\n\n header {\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n gap: 6px;\n\n .label-title {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 17px;\n line-height: 1.2;\n color: #262626;\n white-space: pre-wrap;\n }\n\n & + * {\n margin-top: 20px;\n }\n }\n\n .iconModal {\n width: 50px;\n height: 50px;\n font-size: 30px;\n border-width: 4px;\n margin-bottom: 20px;\n overflow: hidden;\n\n &.iconModal-error {\n background-color: #953737;\n border-color: #953737;\n color: white;\n }\n &.iconModal-warning {\n font-size: 27px;\n padding-bottom: 8px;\n color: #af9647;\n border-color: #af9647;\n }\n &.iconModal-info {\n border-color: #9e3e26;\n color: #9e3e26;\n }\n &.iconModal-success {\n }\n &.iconModal-successv2{\n border-color: #85BC5B;\n color: #85BC5B;\n }\n }\n\n .label-message {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 13px;\n color: #707070;\n white-space: pre-wrap;\n }\n\n .container-customComponent {\n width: 100%;\n max-height: 50vh;\n display: flex;\n flex-direction: column;\n margin-top: 20px;\n padding: 0px 0px;\n //border: 1px solid red;\n }\n\n .container-buttons {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 12px;\n margin-top: 20px;\n //border: 1px solid red;\n }\n }\n"])), _variables.FontFamily.RobotoMedium, _variables.FontFamily.RobotoRegular);
19
19
 
20
20
  exports.ContainerModal = ContainerModal;
@@ -507,6 +507,32 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
507
507
  imag = _useState92[0],
508
508
  setImag = _useState92[1];
509
509
 
510
+ var _useState93 = (0, _react.useState)(false),
511
+ _useState94 = (0, _slicedToArray2.default)(_useState93, 2),
512
+ isObservationVisible = _useState94[0],
513
+ setObservationVisible = _useState94[1];
514
+
515
+ var toggleObservation = function toggleObservation() {
516
+ setObservationVisible(!isObservationVisible);
517
+ };
518
+
519
+ var handleClickOutside = function handleClickOutside(event) {
520
+ if (isObservationVisible && !event.target.closest(".Observation") && !event.target.closest(".Container")) {
521
+ setObservationVisible(false);
522
+ }
523
+ };
524
+
525
+ (0, _react.useEffect)(function () {
526
+ document.addEventListener("click", handleClickOutside);
527
+ return function () {
528
+ document.removeEventListener("click", handleClickOutside);
529
+ };
530
+ }, [isObservationVisible]);
531
+
532
+ var hideObservation = function hideObservation() {
533
+ setObservationVisible(false);
534
+ };
535
+
510
536
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
511
537
  var _ref3, id_article;
512
538
 
@@ -2022,7 +2048,11 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
2022
2048
  rejectAll: function rejectAll() {
2023
2049
  setShowRejectModal(true);
2024
2050
  setValRejAll(true);
2025
- }
2051
+ },
2052
+ isObservationVisible: isObservationVisible,
2053
+ toggleObservation: toggleObservation,
2054
+ handleClickOutside: handleClickOutside,
2055
+ hideObservation: hideObservation
2026
2056
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
2027
2057
  tabsSections: tabsSections,
2028
2058
  status: retailerStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.96",
3
+ "version": "21.4.98",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -13,6 +13,7 @@ export const ObservationFlag = ({
13
13
  observation,
14
14
  contentObservation,
15
15
  dataProduct,
16
+ isObservationVisible, toggleObservation,handleClickOutside,hideObservation
16
17
  }) => {
17
18
  const PriorityFlags = {
18
19
  ["none"]: without,
@@ -21,7 +22,7 @@ export const ObservationFlag = ({
21
22
  ["high"]: high,
22
23
  };
23
24
 
24
- const [isObservationVisible, setObservationVisible] = useState(false);
25
+ // const [isObservationVisible, setObservationVisible] = useState(false);
25
26
  const [material, setMaterial] = useState(contentObservation || "");
26
27
  const [currentObservation, setCurrentObservation] = useState(observation);
27
28
 
@@ -29,30 +30,17 @@ export const ObservationFlag = ({
29
30
  const [modalData, setModalData] = useState({});
30
31
 
31
32
  const textareaRef = useRef(null);
32
- const toggleObservation = () => {
33
- console.log("VENTANA");
34
- evt.stopPropagation();
35
- setObservationVisible(!isObservationVisible);
36
- };
33
+
37
34
  useEffect(() => {
38
- const handleClickOutside = (event) => {
39
- if (
40
- isObservationVisible &&
41
- !event.target.closest(".Observation") &&
42
- !event.target.closest(".Container")
43
- ) {
44
- setObservationVisible(false);
45
- }
46
- };
47
35
  document.addEventListener("click", handleClickOutside);
48
36
  return () => {
49
37
  document.removeEventListener("click", handleClickOutside);
50
38
  };
51
- }, [isObservationVisible]);
52
-
39
+ }, [isObservationVisible, handleClickOutside]);
40
+
53
41
  useEffect(() => {
54
- setMaterial(contentObservation || ""); // Establecer material después de montar el componente
55
- }, [contentObservation]); // Volver a establecer material cuando contentObservation cambia
42
+ setMaterial(contentObservation || "");
43
+ }, [contentObservation]);
56
44
 
57
45
  useEffect(() => {
58
46
  setCurrentObservation(observation);
@@ -89,7 +77,7 @@ export const ObservationFlag = ({
89
77
  response.data.statusCode === 200 ? succesResponse : errorResponse
90
78
  );
91
79
  setCurrentObservation(material !== "" ? "high" : "low");
92
- setObservationVisible(false);
80
+ hideObservation();
93
81
  return response;
94
82
  } catch (err) {
95
83
  console.log(err);
@@ -13,6 +13,10 @@ export const ProductNameHeader = ({
13
13
  percentRequired,
14
14
  productObservation,
15
15
  dataProduct,
16
+ isObservationVisible,
17
+ toggleObservation,
18
+ handleClickOutside,
19
+ hideObservation
16
20
  }) => {
17
21
  const typeFlag =
18
22
  productObservation !== null && productObservation !== "" ? "high" : "low";
@@ -30,6 +34,10 @@ export const ProductNameHeader = ({
30
34
  observation={typeFlag}
31
35
  contentObservation={productObservation}
32
36
  dataProduct={dataProduct}
37
+ isObservationVisible ={isObservationVisible}
38
+ toggleObservation = {toggleObservation}
39
+ handleClickOutside = {handleClickOutside}
40
+ hideObservation={hideObservation}
33
41
  />
34
42
  <ScreenHeader headerType={"date-header"} text={date} />
35
43
  </Container>
@@ -18,6 +18,10 @@ export const FullProductNameHeader = ({
18
18
  servicesData,
19
19
  showApproveRejectAll,
20
20
  productObservation,
21
+ isObservationVisible,
22
+ toggleObservation,
23
+ handleClickOutside,
24
+ hideObservation
21
25
  }) => {
22
26
  const [retailers, setRetailers] = useState([]);
23
27
 
@@ -56,6 +60,11 @@ export const FullProductNameHeader = ({
56
60
  productObservation={productObservation}
57
61
  date={getTime(headerData?.article?.timestamp || headerData?.timestamp)}
58
62
  dataProduct={headerData}
63
+ isObservationVisible ={isObservationVisible}
64
+ toggleObservation = {toggleObservation}
65
+ handleClickOutside ={handleClickOutside}
66
+ hideObservation={hideObservation}
67
+
59
68
  />
60
69
  <div className="features-bar-container">
61
70
  <FeaturesBar
@@ -8,6 +8,7 @@ export const ContainerModal = styled.div`
8
8
  display: grid;
9
9
  place-items: center;
10
10
  background-color: rgba(0, 0, 0, 0.4);
11
+ z-index: 10100;
11
12
 
12
13
  .contentModal {
13
14
  width: fit-content;
@@ -231,6 +231,32 @@ export const RetailerProductEdition = ({
231
231
  const [fich, setFich] = useState([]);
232
232
  const [imag, setImag] = useState([]);
233
233
 
234
+ const [isObservationVisible, setObservationVisible] = useState(false);
235
+
236
+ const toggleObservation = () => {
237
+ setObservationVisible(!isObservationVisible);
238
+ };
239
+ const handleClickOutside = (event) => {
240
+ if (
241
+ isObservationVisible &&
242
+ !event.target.closest(".Observation") &&
243
+ !event.target.closest(".Container")
244
+ ) {
245
+ setObservationVisible(false);
246
+ }
247
+ };
248
+
249
+ useEffect(() => {
250
+ document.addEventListener("click", handleClickOutside);
251
+ return () => {
252
+ document.removeEventListener("click", handleClickOutside);
253
+ };
254
+ }, [isObservationVisible]);
255
+
256
+ const hideObservation = () => {
257
+ setObservationVisible(false);
258
+ };
259
+
234
260
  useEffect(async () => {
235
261
  const { id_article } = product?.article || {};
236
262
  if (id_article)
@@ -1362,6 +1388,10 @@ export const RetailerProductEdition = ({
1362
1388
  setShowRejectModal(true);
1363
1389
  setValRejAll(true);
1364
1390
  }}
1391
+ isObservationVisible={isObservationVisible}
1392
+ toggleObservation={toggleObservation}
1393
+ handleClickOutside={handleClickOutside}
1394
+ hideObservation={hideObservation}
1365
1395
  />
1366
1396
  <FullTabsMenu
1367
1397
  tabsSections={tabsSections}