contentoh-components-library 21.3.98 → 21.3.99

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.
Files changed (30) hide show
  1. package/dist/components/atoms/RetailerCatalog/index.js +4 -4
  2. package/dist/components/atoms/RetailersList/index.js +3 -1
  3. package/dist/components/atoms/UserCatalog/UserCatalog.stories.js +1 -0
  4. package/dist/components/atoms/UserCatalog/index.js +23 -9
  5. package/dist/components/atoms/UserOption/index.js +49 -2
  6. package/dist/components/atoms/UserOption/styles.js +1 -1
  7. package/dist/components/atoms/UserSelector/index.js +13 -4
  8. package/dist/components/molecules/GridItem/index.js +4 -3
  9. package/dist/components/molecules/GridItem/styles.js +1 -1
  10. package/dist/components/molecules/HeaderItem/styles.js +1 -1
  11. package/dist/components/molecules/RowItem/index.js +1 -1
  12. package/dist/components/organisms/GridProducts/GridProducts.stories.js +7 -3
  13. package/dist/components/organisms/GridProducts/index.js +1 -6
  14. package/dist/components/organisms/GridProducts/utils.js +6 -2
  15. package/package.json +1 -1
  16. package/src/components/atoms/RetailerCatalog/index.js +3 -4
  17. package/src/components/atoms/RetailersList/index.js +2 -2
  18. package/src/components/atoms/UserCatalog/UserCatalog.stories.js +1 -0
  19. package/src/components/atoms/UserCatalog/index.js +21 -2
  20. package/src/components/atoms/UserOption/index.js +40 -1
  21. package/src/components/atoms/UserOption/styles.js +8 -1
  22. package/src/components/atoms/UserSelector/index.js +22 -4
  23. package/src/components/molecules/GridItem/index.js +2 -1
  24. package/src/components/molecules/GridItem/styles.js +1 -1
  25. package/src/components/molecules/HeaderItem/styles.js +2 -0
  26. package/src/components/molecules/RowItem/index.js +1 -1
  27. package/src/components/organisms/GridProducts/GridProducts.stories.js +14 -3
  28. package/src/components/organisms/GridProducts/index.js +1 -4
  29. package/src/components/organisms/GridProducts/utils.js +5 -1
  30. package/src/components/organisms/OrderDetail/utils/Table/utils.js +6 -16
@@ -42,11 +42,10 @@ var RetailerCatalog = function RetailerCatalog(_ref) {
42
42
 
43
43
  (0, _react.useEffect)(function () {
44
44
  setRetLimit(limit);
45
- console.log("limit");
46
45
  }, [retailers]);
47
46
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
48
- id: id,
49
- onClick: function onClick() {
47
+ onClick: function onClick(e) {
48
+ e.stopPropagation();
50
49
  setShowRetailers(true);
51
50
  },
52
51
  children: [retailers.map(function (retailer, i) {
@@ -62,7 +61,8 @@ var RetailerCatalog = function RetailerCatalog(_ref) {
62
61
  })
63
62
  }), showRetailers && /*#__PURE__*/(0, _jsxRuntime.jsx)(_RetailersList.RetailersList, {
64
63
  retailers: retailers,
65
- article: article
64
+ article: article,
65
+ id: id
66
66
  })]
67
67
  });
68
68
  };
@@ -21,7 +21,8 @@ var _jsxRuntime = require("react/jsx-runtime");
21
21
 
22
22
  var RetailersList = function RetailersList(_ref) {
23
23
  var retailers = _ref.retailers,
24
- article = _ref.article;
24
+ article = _ref.article,
25
+ id = _ref.id;
25
26
 
26
27
  var _useState = (0, _react.useState)({}),
27
28
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -32,6 +33,7 @@ var RetailersList = function RetailersList(_ref) {
32
33
  if (article) setServices(article.statusByRetailer);
33
34
  }, [article]);
34
35
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Container, {
36
+ id: id,
35
37
  children: retailers.map(function (retailer, i) {
36
38
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RetailerOption.RetailerOption, {
37
39
  retailer: retailer,
@@ -26,6 +26,7 @@ var Template = function Template(args) {
26
26
  var UserCatalogDefault = Template.bind({});
27
27
  exports.UserCatalogDefault = UserCatalogDefault;
28
28
  UserCatalogDefault.args = {
29
+ product: "product",
29
30
  datasheet: 54,
30
31
  description: 54,
31
32
  images: 55,
@@ -17,10 +17,10 @@ var _data = require("../../../global-files/data");
17
17
 
18
18
  var _UserOption = require("../UserOption");
19
19
 
20
- var _react = require("react");
21
-
22
20
  var _customHooks = require("../../../global-files/customHooks");
23
21
 
22
+ var _react = require("react");
23
+
24
24
  var _jsxRuntime = require("react/jsx-runtime");
25
25
 
26
26
  var UserCatalog = function UserCatalog(_ref) {
@@ -35,7 +35,9 @@ var UserCatalog = function UserCatalog(_ref) {
35
35
  _ref$imagesSpecialist = _ref.imagesSpecialists,
36
36
  imagesSpecialists = _ref$imagesSpecialist === void 0 ? [] : _ref$imagesSpecialist,
37
37
  _ref$id = _ref.id,
38
- id = _ref$id === void 0 ? "list-modal" : _ref$id;
38
+ id = _ref$id === void 0 ? "list-modal" : _ref$id,
39
+ onAssign = _ref.onAssign,
40
+ product = _ref.product;
39
41
 
40
42
  var _useCloseModal = (0, _customHooks.useCloseModal)(id),
41
43
  _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
@@ -43,10 +45,10 @@ var UserCatalog = function UserCatalog(_ref) {
43
45
  setShowList = _useCloseModal2[1];
44
46
 
45
47
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
48
+ id: id,
46
49
  onClick: function onClick() {
47
- return setShowList(true);
50
+ setShowList(true);
48
51
  },
49
- id: id,
50
52
  children: [datasheet && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.Avatar, {
51
53
  image: (0, _data.getProfilePicture)(datasheet, 26, 26),
52
54
  altText: "datasheet specialist",
@@ -66,21 +68,33 @@ var UserCatalog = function UserCatalog(_ref) {
66
68
  }), showList && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
67
69
  className: "users-assigned-list",
68
70
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_UserOption.UserOption, {
71
+ onAssign: onAssign,
72
+ product: product,
69
73
  userId: datasheet,
70
74
  usersArray: textSpecialists,
71
- id: id + "-" + datasheet
75
+ id: id + "-" + datasheet,
76
+ index: "datasheet"
72
77
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_UserOption.UserOption, {
78
+ onAssign: onAssign,
79
+ product: product,
73
80
  userId: description,
74
81
  usersArray: textSpecialists,
75
- id: id + "-" + description
82
+ id: id + "-" + description,
83
+ index: "description"
76
84
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_UserOption.UserOption, {
85
+ onAssign: onAssign,
86
+ product: product,
77
87
  userId: images,
78
88
  usersArray: imagesSpecialists,
79
- id: id + "-" + images
89
+ id: id + "-" + images,
90
+ index: "image"
80
91
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_UserOption.UserOption, {
92
+ onAssign: onAssign,
93
+ product: product,
81
94
  userId: auditor,
82
95
  usersArray: auditors,
83
- id: id + "-" + auditor
96
+ id: id + "-" + auditor,
97
+ index: "auditor"
84
98
  })]
85
99
  })]
86
100
  });
@@ -29,7 +29,9 @@ var UserOption = function UserOption(_ref) {
29
29
  var userId = _ref.userId,
30
30
  index = _ref.index,
31
31
  usersArray = _ref.usersArray,
32
- id = _ref.id;
32
+ id = _ref.id,
33
+ onAssign = _ref.onAssign,
34
+ product = _ref.product;
33
35
 
34
36
  var _useState = (0, _react.useState)({}),
35
37
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -41,6 +43,21 @@ var UserOption = function UserOption(_ref) {
41
43
  showSelector = _useCloseModal2[0],
42
44
  setShowSelector = _useCloseModal2[1];
43
45
 
46
+ var _useState3 = (0, _react.useState)(""),
47
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
48
+ assignationTarget = _useState4[0],
49
+ setAssignationTarget = _useState4[1];
50
+
51
+ var _useState5 = (0, _react.useState)(""),
52
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
53
+ concept = _useState6[0],
54
+ setConcept = _useState6[1];
55
+
56
+ var _useState7 = (0, _react.useState)(""),
57
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
58
+ target = _useState8[0],
59
+ setTarget = _useState8[1];
60
+
44
61
  var icons = _utils.servicesCodeIcon;
45
62
  (0, _react.useEffect)(function () {
46
63
  if (usersArray) {
@@ -51,6 +68,31 @@ var UserOption = function UserOption(_ref) {
51
68
  });
52
69
  }
53
70
  }, [userId, usersArray]);
71
+ (0, _react.useEffect)(function () {
72
+ switch (index) {
73
+ case "datasheet":
74
+ case "description":
75
+ setAssignationTarget("id_".concat(index, "_specialist"));
76
+ setConcept(index);
77
+ setTarget("specialist");
78
+ break;
79
+
80
+ case "image":
81
+ setAssignationTarget("id_".concat(index, "s_specialist"));
82
+ setConcept(index + "s");
83
+ setTarget("specialist");
84
+ break;
85
+
86
+ case "auditor":
87
+ setAssignationTarget("id_".concat(index));
88
+ setConcept(index);
89
+ setTarget(index);
90
+ break;
91
+
92
+ default:
93
+ break;
94
+ }
95
+ }, [index]);
54
96
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
55
97
  onClick: function onClick() {
56
98
  return setShowSelector(true);
@@ -72,7 +114,12 @@ var UserOption = function UserOption(_ref) {
72
114
  searchLabel: "Buscar Usuario",
73
115
  index: index,
74
116
  usersArray: usersArray,
75
- position: "absolute"
117
+ position: "absolute",
118
+ onAssign: onAssign,
119
+ product: product,
120
+ assignationTarget: assignationTarget,
121
+ target: target,
122
+ concept: concept
76
123
  })]
77
124
  });
78
125
  };
@@ -15,6 +15,6 @@ var _variables = require("../../../global-files/variables");
15
15
 
16
16
  var _templateObject;
17
17
 
18
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n border: 1px solid #f0f0f0;\n border-radius: 5px;\n color: #262626;\n font-size: 12px;\n font-family: ", ";\n display: flex;\n align-items: center;\n padding: 5px 10px;\n justify-content: space-between;\n cursor: pointer;\n position: relative;\n background-color: white;\n width: 217px;\n\n .image-and-name {\n display: flex;\n align-items: center;\n\n div + p {\n margin-left: 10px;\n }\n }\n\n .icon-container {\n position: relative;\n span {\n color: #808080;\n cursor: pointer;\n\n & + span {\n display: none;\n position: absolute;\n right: 120%;\n top: 50%;\n transform: translateY(-50%);\n white-space: nowrap;\n }\n\n &:hover {\n & + span {\n display: block;\n }\n }\n }\n }\n\n & + * {\n margin-top: 5px;\n }\n"])), _variables.FontFamily.Lato);
18
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n border: 1px solid #f0f0f0;\n border-radius: 5px;\n color: #262626;\n font-size: 12px;\n font-family: ", ";\n display: flex;\n align-items: center;\n padding: 5px 10px;\n justify-content: space-between;\n cursor: pointer;\n position: relative;\n background-color: white;\n\n .image-and-name {\n display: flex;\n align-items: center;\n\n div + p {\n margin-left: 10px;\n white-space: nowrap;\n }\n\n & + * {\n margin-left: 10px;\n }\n }\n\n .icon-container {\n position: relative;\n span {\n color: #808080;\n cursor: pointer;\n\n & + span {\n display: none;\n position: absolute;\n right: 120%;\n top: 50%;\n transform: translateY(-50%);\n white-space: nowrap;\n border: 1px solid #f0f0f0;\n padding: 5px;\n background-color: white;\n }\n\n &:hover {\n & + span {\n display: block;\n }\n }\n }\n }\n\n & + * {\n margin-top: 5px;\n }\n"])), _variables.FontFamily.Lato);
19
19
 
20
20
  exports.Container = Container;
@@ -21,14 +21,20 @@ var _data = require("../../../global-files/data");
21
21
 
22
22
  var _react = require("react");
23
23
 
24
+ var _customHooks = require("../../../global-files/customHooks");
25
+
24
26
  var _jsxRuntime = require("react/jsx-runtime");
25
27
 
26
28
  var UserSelector = function UserSelector(_ref) {
27
29
  var searchLabel = _ref.searchLabel,
28
- index = _ref.index,
29
30
  usersArray = _ref.usersArray,
30
- onClick = _ref.onClick,
31
- position = _ref.position;
31
+ position = _ref.position,
32
+ id = _ref.id,
33
+ onAssign = _ref.onAssign,
34
+ product = _ref.product,
35
+ assignationTarget = _ref.assignationTarget,
36
+ target = _ref.target,
37
+ concept = _ref.concept;
32
38
 
33
39
  var _useState = (0, _react.useState)([]),
34
40
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -53,6 +59,7 @@ var UserSelector = function UserSelector(_ref) {
53
59
 
54
60
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
55
61
  position: position,
62
+ id: id,
56
63
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
57
64
  className: "search-cotainer",
58
65
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
@@ -70,7 +77,9 @@ var UserSelector = function UserSelector(_ref) {
70
77
  children: userFiltered.length ? userFiltered.map(function (user) {
71
78
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
72
79
  className: "user-item",
73
- onClick: onClick,
80
+ onClick: function onClick(e) {
81
+ return onAssign && onAssign(product, user.id_user, assignationTarget, target, concept);
82
+ },
74
83
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.Avatar, {
75
84
  image: (0, _data.getProfilePicture)(user.id_user, 26, 26),
76
85
  altText: "profile image",
@@ -33,7 +33,8 @@ var GridItem = function GridItem(_ref) {
33
33
  isMerchans = _ref.isMerchans,
34
34
  chkOnChange = _ref.chkOnChange,
35
35
  onGridClick = _ref.onGridClick,
36
- chkChecked = _ref.chkChecked;
36
+ chkChecked = _ref.chkChecked,
37
+ index = _ref.index;
37
38
  var _gridElement$images = gridElement.images,
38
39
  images = _gridElement$images === void 0 ? [] : _gridElement$images,
39
40
  _gridElement$info = gridElement.info,
@@ -43,8 +44,8 @@ var GridItem = function GridItem(_ref) {
43
44
  _gridElement$catalogs = gridElement.catalogs,
44
45
  catalogs = _gridElement$catalogs === void 0 ? {} : _gridElement$catalogs;
45
46
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
46
- onClick: function onClick() {
47
- return onGridClick && onGridClick(product);
47
+ onClick: function onClick(e) {
48
+ return onGridClick && onGridClick(e, product, index);
48
49
  },
49
50
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
50
51
  className: "chk-container",
@@ -15,6 +15,6 @@ var _variables = require("../../../global-files/variables");
15
15
 
16
16
  var _templateObject;
17
17
 
18
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 175px;\n border: 1px solid #f0f0f0;\n position: relative;\n\n .chk-container {\n position: absolute;\n top: 5px;\n left: 5px;\n z-index: 10;\n height: 16px;\n }\n\n .data-body {\n padding: 10px;\n border-bottom: 1px solid #f0f0f0;\n\n h3,\n p {\n color: #262626;\n font-family: ", ";\n font-size: 12px;\n line-height: 16px;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\n & + p {\n margin-top: 5px;\n }\n }\n p {\n font-size: 10px;\n line-height: 12px;\n color: #808080;\n }\n }\n\n .status-slider {\n display: flex;\n padding: 5px 10px;\n overflow: auto;\n border-bottom: 1px solid #f0f0f0;\n flex-wrap: nowrap;\n\n .status-element {\n display: flex;\n }\n\n * + * {\n margin-left: 10px;\n }\n }\n\n .cart-and-raiting,\n .retailers-and-user {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 5px 10px;\n .star-button {\n button {\n padding: 3px;\n color: transparent;\n -webkit-text-stroke: 1px #808080;\n }\n }\n }\n\n .retailers-and-user {\n padding: 0;\n > * {\n flex: 1 0 50%;\n display: flex;\n padding: 5px;\n height: 36px;\n }\n .retailers-container {\n border-right: 1px solid #f0f0f0;\n }\n }\n"])), _variables.FontFamily.Lato);
18
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 175px;\n border: 1px solid #f0f0f0;\n position: relative;\n\n .chk-container {\n position: absolute;\n top: 5px;\n left: 5px;\n z-index: 5;\n height: 16px;\n }\n\n .data-body {\n padding: 10px;\n border-bottom: 1px solid #f0f0f0;\n\n h3,\n p {\n color: #262626;\n font-family: ", ";\n font-size: 12px;\n line-height: 16px;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\n & + p {\n margin-top: 5px;\n }\n }\n p {\n font-size: 10px;\n line-height: 12px;\n color: #808080;\n }\n }\n\n .status-slider {\n display: flex;\n padding: 5px 10px;\n overflow: auto;\n border-bottom: 1px solid #f0f0f0;\n flex-wrap: nowrap;\n\n .status-element {\n display: flex;\n }\n\n * + * {\n margin-left: 10px;\n }\n }\n\n .cart-and-raiting,\n .retailers-and-user {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 5px 10px;\n .star-button {\n button {\n padding: 3px;\n color: transparent;\n -webkit-text-stroke: 1px #808080;\n }\n }\n }\n\n .retailers-and-user {\n padding: 0;\n > * {\n flex: 1 0 50%;\n display: flex;\n padding: 5px;\n height: 36px;\n }\n .retailers-container {\n border-right: 1px solid #f0f0f0;\n }\n }\n"])), _variables.FontFamily.Lato);
19
19
 
20
20
  exports.Container = Container;
@@ -15,7 +15,7 @@ var _variables = require("../../../global-files/variables");
15
15
 
16
16
  var _templateObject, _templateObject2;
17
17
 
18
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background-color: #f0f0f0;\n display: flex;\n\n .chk-global-container {\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 30px;\n }\n"])));
18
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background-color: #f0f0f0;\n display: flex;\n width: 100%;\n min-width: fit-content;\n\n .chk-global-container {\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 30px;\n }\n"])));
19
19
 
20
20
  exports.Container = Container;
21
21
 
@@ -28,7 +28,7 @@ var RowItem = function RowItem(_ref) {
28
28
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
29
29
  className: "row-container",
30
30
  onClick: function onClick(e) {
31
- return onGridClick && onGridClick(product);
31
+ return onGridClick && onGridClick(e, product, i);
32
32
  },
33
33
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
34
34
  className: "chk-container",
@@ -5008,11 +5008,15 @@ var setSelected = function setSelected(arr) {
5008
5008
  selected = arr;
5009
5009
  };
5010
5010
 
5011
+ var onAssign = function onAssign(productData, assigneeID, assignationTarget, concept, target) {
5012
+ console.log(productData, assigneeID, assignationTarget, concept, target);
5013
+ };
5014
+
5011
5015
  GridProductsDefault.args = {
5012
5016
  gridView: false,
5013
5017
  selected: selected,
5014
5018
  setSelected: setSelected,
5015
- products: (0, _utils.getProductsToTable)(products, textSpecialists, imagesSpecialists, auditors, images),
5019
+ products: (0, _utils.getProductsToTable)(products, textSpecialists, imagesSpecialists, auditors, images, onAssign),
5016
5020
  images: images,
5017
5021
  auditors: auditors,
5018
5022
  textSpecialists: textSpecialists,
@@ -5077,8 +5081,8 @@ GridProductsDefault.args = {
5077
5081
  });
5078
5082
  return (productSelected === null || productSelected === void 0 ? void 0 : productSelected.length) > 0;
5079
5083
  },
5080
- onGridClick: function onGridClick(e) {
5081
- console.log(e);
5084
+ onGridClick: function onGridClick(e, product, i) {
5085
+ if (!e.target.closest("[id^=users]")) console.log(product, i);
5082
5086
  },
5083
5087
  chkCheckedAll: function chkCheckedAll() {
5084
5088
  return selected.length === products.length;
@@ -11,14 +11,8 @@ var _GridItem = require("../../molecules/GridItem");
11
11
 
12
12
  var _HeaderItem = require("../../molecules/HeaderItem");
13
13
 
14
- var _utils = require("./utils");
15
-
16
- var _react = require("react");
17
-
18
14
  var _RowItem = require("../../molecules/RowItem");
19
15
 
20
- var _CheckBox = require("../../atoms/CheckBox");
21
-
22
16
  var _jsxRuntime = require("react/jsx-runtime");
23
17
 
24
18
  var GridProducts = function GridProducts(_ref) {
@@ -42,6 +36,7 @@ var GridProducts = function GridProducts(_ref) {
42
36
  id = _ref2.id;
43
37
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridItem.GridItem, {
44
38
  id: id,
39
+ index: i,
45
40
  product: product,
46
41
  gridElement: gridElement,
47
42
  chkOnChange: chkOnChange,
@@ -17,6 +17,7 @@ var getProductsToTable = function getProductsToTable() {
17
17
  var imagesSpecialists = arguments.length > 2 ? arguments[2] : undefined;
18
18
  var auditors = arguments.length > 3 ? arguments[3] : undefined;
19
19
  var images = arguments.length > 4 ? arguments[4] : undefined;
20
+ var onAssign = arguments.length > 5 ? arguments[5] : undefined;
20
21
  var productsTableArray = [];
21
22
  products.forEach(function (product) {
22
23
  var article = product.article,
@@ -72,7 +73,8 @@ var getProductsToTable = function getProductsToTable() {
72
73
  textSpecialists: textSpecialists,
73
74
  imagesSpecialists: imagesSpecialists,
74
75
  auditors: auditors,
75
- id: "users-" + id
76
+ id: "users-" + id,
77
+ product: product
76
78
  }),
77
79
  flex: 1,
78
80
  minWidth: 100
@@ -123,7 +125,9 @@ var getProductsToTable = function getProductsToTable() {
123
125
  textSpecialists: textSpecialists,
124
126
  imagesSpecialists: imagesSpecialists,
125
127
  auditors: auditors,
126
- id: "users-" + id
128
+ id: "users-" + id,
129
+ onAssign: onAssign,
130
+ product: product
127
131
  })
128
132
  }
129
133
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.3.98",
3
+ "version": "21.3.99",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -16,13 +16,12 @@ export const RetailerCatalog = ({
16
16
 
17
17
  useEffect(() => {
18
18
  setRetLimit(limit);
19
- console.log("limit");
20
19
  }, [retailers]);
21
20
 
22
21
  return (
23
22
  <Container
24
- id={id}
25
- onClick={() => {
23
+ onClick={(e) => {
24
+ e.stopPropagation();
26
25
  setShowRetailers(true);
27
26
  }}
28
27
  >
@@ -43,7 +42,7 @@ export const RetailerCatalog = ({
43
42
  </div>
44
43
  )}
45
44
  {showRetailers && (
46
- <RetailersList retailers={retailers} article={article} />
45
+ <RetailersList retailers={retailers} article={article} id={id} />
47
46
  )}
48
47
  </Container>
49
48
  );
@@ -3,7 +3,7 @@ import { RetailerOption } from "../RetailerOption";
3
3
  import { useState, useEffect } from "react";
4
4
  import axios from "axios";
5
5
 
6
- export const RetailersList = ({ retailers, article }) => {
6
+ export const RetailersList = ({ retailers, article, id }) => {
7
7
  const [services, setServices] = useState({});
8
8
 
9
9
  useEffect(() => {
@@ -11,7 +11,7 @@ export const RetailersList = ({ retailers, article }) => {
11
11
  }, [article]);
12
12
 
13
13
  return (
14
- <Container>
14
+ <Container id={id}>
15
15
  {retailers.map((retailer, i) => (
16
16
  <RetailerOption key={i} retailer={retailer} services={services} />
17
17
  ))}
@@ -8,6 +8,7 @@ export default {
8
8
  const Template = (args) => <UserCatalog {...args} />;
9
9
  export const UserCatalogDefault = Template.bind({});
10
10
  UserCatalogDefault.args = {
11
+ product: "product",
11
12
  datasheet: 54,
12
13
  description: 54,
13
14
  images: 55,
@@ -2,8 +2,8 @@ import { Container } from "./styles";
2
2
  import { Avatar } from "../Avatar";
3
3
  import { getProfilePicture } from "../../../global-files/data";
4
4
  import { UserOption } from "../UserOption";
5
- import { useState } from "react";
6
5
  import { useCloseModal } from "../../../global-files/customHooks";
6
+ import { useState } from "react";
7
7
  import { useEffect } from "react";
8
8
 
9
9
  export const UserCatalog = ({
@@ -15,11 +15,18 @@ export const UserCatalog = ({
15
15
  textSpecialists = [],
16
16
  imagesSpecialists = [],
17
17
  id = "list-modal",
18
+ onAssign,
19
+ product,
18
20
  }) => {
19
21
  const [showList, setShowList] = useCloseModal(id);
20
22
 
21
23
  return (
22
- <Container onClick={() => setShowList(true)} id={id}>
24
+ <Container
25
+ id={id}
26
+ onClick={() => {
27
+ setShowList(true);
28
+ }}
29
+ >
23
30
  {datasheet && (
24
31
  <Avatar
25
32
  image={getProfilePicture(datasheet, 26, 26)}
@@ -51,24 +58,36 @@ export const UserCatalog = ({
51
58
  {showList && (
52
59
  <div className="users-assigned-list">
53
60
  <UserOption
61
+ onAssign={onAssign}
62
+ product={product}
54
63
  userId={datasheet}
55
64
  usersArray={textSpecialists}
56
65
  id={id + "-" + datasheet}
66
+ index={"datasheet"}
57
67
  />
58
68
  <UserOption
69
+ onAssign={onAssign}
70
+ product={product}
59
71
  userId={description}
60
72
  usersArray={textSpecialists}
61
73
  id={id + "-" + description}
74
+ index={"description"}
62
75
  />
63
76
  <UserOption
77
+ onAssign={onAssign}
78
+ product={product}
64
79
  userId={images}
65
80
  usersArray={imagesSpecialists}
66
81
  id={id + "-" + images}
82
+ index={"image"}
67
83
  />
68
84
  <UserOption
85
+ onAssign={onAssign}
86
+ product={product}
69
87
  userId={auditor}
70
88
  usersArray={auditors}
71
89
  id={id + "-" + auditor}
90
+ index={"auditor"}
72
91
  />
73
92
  </div>
74
93
  )}
@@ -7,9 +7,20 @@ import { servicesCodeIcon } from "../../organisms/OrderDetail/utils/Table/utils"
7
7
  import { UserSelector } from "../UserSelector";
8
8
  import { useCloseModal } from "../../../global-files/customHooks";
9
9
 
10
- export const UserOption = ({ userId, index, usersArray, id }) => {
10
+ export const UserOption = ({
11
+ userId,
12
+ index,
13
+ usersArray,
14
+ id,
15
+ onAssign,
16
+ product,
17
+ }) => {
11
18
  const [userAssigned, setUserAssigned] = useState({});
12
19
  const [showSelector, setShowSelector] = useCloseModal(id);
20
+ const [assignationTarget, setAssignationTarget] = useState("");
21
+ const [concept, setConcept] = useState("");
22
+ const [target, setTarget] = useState("");
23
+
13
24
  const icons = servicesCodeIcon;
14
25
 
15
26
  useEffect(() => {
@@ -22,6 +33,29 @@ export const UserOption = ({ userId, index, usersArray, id }) => {
22
33
  }
23
34
  }, [userId, usersArray]);
24
35
 
36
+ useEffect(() => {
37
+ switch (index) {
38
+ case "datasheet":
39
+ case "description":
40
+ setAssignationTarget(`id_${index}_specialist`);
41
+ setConcept(index);
42
+ setTarget("specialist");
43
+ break;
44
+ case "image":
45
+ setAssignationTarget(`id_${index}s_specialist`);
46
+ setConcept(index + "s");
47
+ setTarget("specialist");
48
+ break;
49
+ case "auditor":
50
+ setAssignationTarget(`id_${index}`);
51
+ setConcept(index);
52
+ setTarget(index);
53
+ break;
54
+ default:
55
+ break;
56
+ }
57
+ }, [index]);
58
+
25
59
  return (
26
60
  <Container onClick={() => setShowSelector(true)}>
27
61
  <div className="image-and-name">
@@ -42,6 +76,11 @@ export const UserOption = ({ userId, index, usersArray, id }) => {
42
76
  index={index}
43
77
  usersArray={usersArray}
44
78
  position="absolute"
79
+ onAssign={onAssign}
80
+ product={product}
81
+ assignationTarget={assignationTarget}
82
+ target={target}
83
+ concept={concept}
45
84
  />
46
85
  )}
47
86
  </Container>
@@ -14,7 +14,6 @@ export const Container = styled.div`
14
14
  cursor: pointer;
15
15
  position: relative;
16
16
  background-color: white;
17
- width: 217px;
18
17
 
19
18
  .image-and-name {
20
19
  display: flex;
@@ -22,6 +21,11 @@ export const Container = styled.div`
22
21
 
23
22
  div + p {
24
23
  margin-left: 10px;
24
+ white-space: nowrap;
25
+ }
26
+
27
+ & + * {
28
+ margin-left: 10px;
25
29
  }
26
30
  }
27
31
 
@@ -38,6 +42,9 @@ export const Container = styled.div`
38
42
  top: 50%;
39
43
  transform: translateY(-50%);
40
44
  white-space: nowrap;
45
+ border: 1px solid #f0f0f0;
46
+ padding: 5px;
47
+ background-color: white;
41
48
  }
42
49
 
43
50
  &:hover {
@@ -5,13 +5,18 @@ import { Avatar } from "../Avatar";
5
5
  import { getProfilePicture } from "../../../global-files/data";
6
6
  import { useState } from "react";
7
7
  import { useEffect } from "react";
8
+ import { useCloseModal } from "../../../global-files/customHooks";
8
9
 
9
10
  export const UserSelector = ({
10
11
  searchLabel,
11
- index,
12
12
  usersArray,
13
- onClick,
14
13
  position,
14
+ id,
15
+ onAssign,
16
+ product,
17
+ assignationTarget,
18
+ target,
19
+ concept,
15
20
  }) => {
16
21
  const [text, setText] = useState([]);
17
22
  const [userFiltered, setUsersFiltered] = useState([]);
@@ -33,7 +38,7 @@ export const UserSelector = ({
33
38
  };
34
39
 
35
40
  return (
36
- <Container position={position}>
41
+ <Container position={position} id={id}>
37
42
  <div className="search-cotainer">
38
43
  <Icon icon={faSearch} />
39
44
  <input
@@ -48,7 +53,20 @@ export const UserSelector = ({
48
53
  <div className="selector-container">
49
54
  {userFiltered.length ? (
50
55
  userFiltered.map((user) => (
51
- <div key={user.id_user} className="user-item" onClick={onClick}>
56
+ <div
57
+ key={user.id_user}
58
+ className="user-item"
59
+ onClick={(e) =>
60
+ onAssign &&
61
+ onAssign(
62
+ product,
63
+ user.id_user,
64
+ assignationTarget,
65
+ target,
66
+ concept
67
+ )
68
+ }
69
+ >
52
70
  <Avatar
53
71
  image={getProfilePicture(user.id_user, 26, 26)}
54
72
  altText={"profile image"}
@@ -16,11 +16,12 @@ export const GridItem = ({
16
16
  chkOnChange,
17
17
  onGridClick,
18
18
  chkChecked,
19
+ index,
19
20
  }) => {
20
21
  const { images = [], info = [], status = [], catalogs = {} } = gridElement;
21
22
 
22
23
  return (
23
- <Container onClick={() => onGridClick && onGridClick(product)}>
24
+ <Container onClick={(e) => onGridClick && onGridClick(e, product, index)}>
24
25
  <div className="chk-container" onClick={(e) => e.stopPropagation()}>
25
26
  <CheckBox
26
27
  id={id}
@@ -10,7 +10,7 @@ export const Container = styled.div`
10
10
  position: absolute;
11
11
  top: 5px;
12
12
  left: 5px;
13
- z-index: 10;
13
+ z-index: 5;
14
14
  height: 16px;
15
15
  }
16
16
 
@@ -4,6 +4,8 @@ import { FontFamily } from "../../../global-files/variables";
4
4
  export const Container = styled.div`
5
5
  background-color: #f0f0f0;
6
6
  display: flex;
7
+ width: 100%;
8
+ min-width: fit-content;
7
9
 
8
10
  .chk-global-container {
9
11
  display: flex;
@@ -14,7 +14,7 @@ export const RowItem = ({
14
14
  <div
15
15
  className="row-container"
16
16
  key={article?.id_article + "-" + article?.id_order}
17
- onClick={(e) => onGridClick && onGridClick(product)}
17
+ onClick={(e) => onGridClick && onGridClick(e, product, i)}
18
18
  >
19
19
  <div
20
20
  className="chk-container"
@@ -5409,6 +5409,16 @@ const setSelected = (arr) => {
5409
5409
  selected = arr;
5410
5410
  };
5411
5411
 
5412
+ const onAssign = (
5413
+ productData,
5414
+ assigneeID,
5415
+ assignationTarget,
5416
+ concept,
5417
+ target
5418
+ ) => {
5419
+ console.log(productData, assigneeID, assignationTarget, concept, target);
5420
+ };
5421
+
5412
5422
  GridProductsDefault.args = {
5413
5423
  gridView: false,
5414
5424
  selected,
@@ -5418,7 +5428,8 @@ GridProductsDefault.args = {
5418
5428
  textSpecialists,
5419
5429
  imagesSpecialists,
5420
5430
  auditors,
5421
- images
5431
+ images,
5432
+ onAssign
5422
5433
  ),
5423
5434
  images,
5424
5435
  auditors,
@@ -5460,8 +5471,8 @@ GridProductsDefault.args = {
5460
5471
  );
5461
5472
  return productSelected?.length > 0;
5462
5473
  },
5463
- onGridClick: (e) => {
5464
- console.log(e);
5474
+ onGridClick: (e, product, i) => {
5475
+ if (!e.target.closest("[id^=users]")) console.log(product, i);
5465
5476
  },
5466
5477
  chkCheckedAll: () => {
5467
5478
  return selected.length === products.length;
@@ -1,11 +1,7 @@
1
1
  import { Container } from "./styles";
2
2
  import { GridItem } from "../../molecules/GridItem";
3
3
  import { HeaderItem } from "../../molecules/HeaderItem";
4
- import { getProductsToTable } from "./utils";
5
- import { useEffect } from "react";
6
- import { useState } from "react";
7
4
  import { RowItem } from "../../molecules/RowItem";
8
- import { CheckBox } from "../../atoms/CheckBox";
9
5
 
10
6
  export const GridProducts = ({
11
7
  products = [],
@@ -25,6 +21,7 @@ export const GridProducts = ({
25
21
  <GridItem
26
22
  key={i}
27
23
  id={id}
24
+ index={i}
28
25
  product={product}
29
26
  gridElement={gridElement}
30
27
  chkOnChange={chkOnChange}
@@ -6,7 +6,8 @@ export const getProductsToTable = (
6
6
  textSpecialists,
7
7
  imagesSpecialists,
8
8
  auditors,
9
- images
9
+ images,
10
+ onAssign
10
11
  ) => {
11
12
  const productsTableArray = [];
12
13
 
@@ -45,6 +46,7 @@ export const getProductsToTable = (
45
46
  imagesSpecialists={imagesSpecialists}
46
47
  auditors={auditors}
47
48
  id={"users-" + id}
49
+ product={product}
48
50
  />
49
51
  ),
50
52
  flex: 1,
@@ -87,6 +89,8 @@ export const getProductsToTable = (
87
89
  imagesSpecialists={imagesSpecialists}
88
90
  auditors={auditors}
89
91
  id={"users-" + id}
92
+ onAssign={onAssign}
93
+ product={product}
90
94
  />
91
95
  ),
92
96
  },
@@ -1,41 +1,31 @@
1
1
  export const servicesCodeIcon = {
2
2
  datasheet: (
3
3
  <div key="datasheet" className="tooltip">
4
- <span className="material-icons small">
5
- &#xf8ee;
6
- </span>
4
+ <span className="material-icons small">&#xf8ee;</span>
7
5
  <span className="tooltiptext">Ficha Técnica</span>
8
6
  </div>
9
7
  ),
10
8
  description: (
11
9
  <div key="description" className="tooltip">
12
- <span className="material-icons small">
13
- &#xe873;
14
- </span>
10
+ <span className="material-icons small">&#xe873;</span>
15
11
  <span className="tooltiptext">Descripción</span>
16
12
  </div>
17
13
  ),
18
14
  image: (
19
15
  <div key="image" className="tooltip">
20
- <span className="material-icons small">
21
- &#xe3f4;
22
- </span>
16
+ <span className="material-icons small">&#xe3f4;</span>
23
17
  <span className="tooltiptext">Imagen</span>
24
18
  </div>
25
19
  ),
26
20
  translate: (
27
21
  <div key="translate" className="tooltip">
28
- <span className="material-icons small">
29
- &#xe8e2;
30
- </span>
22
+ <span className="material-icons small">&#xe8e2;</span>
31
23
  <span className="tooltiptext">Traducción</span>
32
24
  </div>
33
25
  ),
34
26
  build: (
35
- <div key="build" className="tooltip">
36
- <span className="material-icons small">
37
- &#xe1bd;
38
- </span>
27
+ <div key="build" className="tooltip">
28
+ <span className="material-icons small">&#xe1bd;</span>
39
29
  <span className="tooltiptext">Construcción</span>
40
30
  </div>
41
31
  ),