contentoh-components-library 21.3.34 → 21.3.36

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.
@@ -28,7 +28,8 @@ var HeaderTop = function HeaderTop(_ref) {
28
28
  token = _ref.token,
29
29
  auditableVersion = _ref.auditableVersion,
30
30
  setCompare = _ref.setCompare,
31
- isAuditor = _ref.isAuditor;
31
+ isAuditor = _ref.isAuditor,
32
+ activeRetailer = _ref.activeRetailer;
32
33
  var headerTop = (0, _react.useRef)();
33
34
  (0, _react.useEffect)(function () {
34
35
  setHeaderTop && setHeaderTop(headerTop.current.clientHeight);
@@ -47,7 +48,8 @@ var HeaderTop = function HeaderTop(_ref) {
47
48
  id: productSelected.id_article,
48
49
  version: productSelected.version
49
50
  },
50
- size: 18
51
+ size: 18,
52
+ activeRetailer: activeRetailer
51
53
  }), isAuditor && auditableVersion && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Button, {
52
54
  buttonType: "general-white-button circular-button",
53
55
  onClick: function onClick() {
@@ -99,6 +99,12 @@ chatCAD_merchantsProduct.args = {
99
99
  userToken: "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI1ODg0YWUzNC01OWQ2LTQ0NTQtYjk4ZS04MjE1MThiY2MzYTciLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6IjU4ODRhZTM0LTU5ZDYtNDQ1NC1iOThlLTgyMTUxOGJjYzNhNyIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiJhMWYyM2IzZC1mOTk0LTRjNWUtOTk4MC04ZThjYmQxMzcwMzYiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY3NDU3NjMzNywibmFtZSI6IkNhZGVuYSBJc21hZWwiLCJwaG9uZV9udW1iZXIiOiIrNTIzMTExMzY2MzM2IiwiZXhwIjoxNjc0NTc5OTM3LCJpYXQiOjE2NzQ1NzYzMzcsImVtYWlsIjoiY2FkZW5hLmlzbWFlbEBhbGxmcmVlbWFpbC5uZXQifQ.GZIbxwAqZBifyxJQdb-Asbf2X9k4Nmi44TRINg9oGdvz0MknHOUtCiQ2ID7XiqKzgcVvbl9RDDx2GFWZt0Fd2-Sd5NSMxEl3C3ZWqVWQb9ncrMdVcAOHPp76w2eR6IzOwpa5L4GAc_mLACaJtfGdYrSLSxYTpMPQfhxaG2GDdWbOLA-_hNflff0lQD-EvCg8wEirAcZHro2mEeqMFG2GLhh0zfb_H-A8EWMqmMM3kYXVHTza04S1HSYsXhGzBi-7paL_Oh3bcORN95CqeddkReSmThG5wcp0_YScCSFNeUDEvJo2Z9w9TlOrEgUIrSkaY0aLZUpERfOST55P4R9hRw",
100
100
  id: 429,
101
101
  version: 1
102
+ },
103
+ activeRetailer: {
104
+ id: 68,
105
+ name: "The Home Depot Merchants",
106
+ image: "https://content-management-images.s3.amazonaws.com/retailers/68.png",
107
+ percentage: 100
102
108
  }
103
109
  };
104
110
  var chatCAD_merchantsProductProvider = Template.bind({});
@@ -110,6 +116,12 @@ chatCAD_merchantsProductProvider.args = {
110
116
  userToken: "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1h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ZX7vibtUtvnbXPtkPgJV1Wb3RoB-45qi3qa1xIUcHwtdInsdQG1PvL28ryH4-ZupjXYRC9JB2wMDFPF1c6HnUQQupTSHRgTHVj9USNCYblOuCJSj1s2_lUrmFZJBifRGXsYj8rBz6mkkl5wAGU-YCmCFkwuD3Gl5bsevFg_VL2CGEfSwSXMzsB-ud4FMIaMZuQHpF-CefGJaEHYxg",
111
117
  id: 429,
112
118
  version: 1
119
+ },
120
+ activeRetailer: {
121
+ id: 68,
122
+ name: "The Home Depot Merchants",
123
+ image: "https://content-management-images.s3.amazonaws.com/retailers/68.png",
124
+ percentage: 100
113
125
  }
114
126
  };
115
127
  /*
@@ -56,7 +56,8 @@ var ContentChat = function ContentChat(props) {
56
56
  showBtnClose = props.showBtnClose,
57
57
  onClickBtnClose = props.onClickBtnClose,
58
58
  showPopUpChat = props.showPopUpChat,
59
- ticketCompany = props.ticketCompany;
59
+ ticketCompany = props.ticketCompany,
60
+ activeRetailer = props.activeRetailer;
60
61
 
61
62
  var _useState = (0, _react.useState)({}),
62
63
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -177,10 +178,18 @@ var ContentChat = function ContentChat(props) {
177
178
  return function () {
178
179
  if (processUpdateID !== undefined) clearTimeout(processUpdateID);
179
180
  };
180
- }, []); // al cargar el componente
181
+ }, []);
182
+
183
+ var stopUpdate = function stopUpdate() {
184
+ if (processUpdateID !== undefined) {
185
+ clearTimeout(processUpdateID);
186
+ setProcessUpdateID(undefined);
187
+ }
188
+ }; // al cargar el componente
189
+
181
190
 
182
191
  (0, _react.useEffect)(function () {
183
- if (dataChat) {
192
+ if (dataChat && showPopUpChat) {
184
193
  stopUpdate();
185
194
 
186
195
  if (dataChat.code) {
@@ -196,6 +205,10 @@ var ContentChat = function ContentChat(props) {
196
205
 
197
206
  if (chatType === "merchant_product") getInitialMerchantProduct();else if (chatType === "order_product") getInitialOrderProduct();else getInitialTicket();
198
207
  }
208
+
209
+ if (!showPopUpChat) {
210
+ stopUpdate();
211
+ }
199
212
  }, [dataChat, showPopUpChat]); // comenzar temporizador del update de 20s
200
213
 
201
214
  (0, _react.useEffect)(function () {
@@ -1129,6 +1142,7 @@ var ContentChat = function ContentChat(props) {
1129
1142
  var items,
1130
1143
  id,
1131
1144
  version,
1145
+ retailerId,
1132
1146
  paramsBody,
1133
1147
  paramsHeaders,
1134
1148
  response,
@@ -1139,22 +1153,24 @@ var ContentChat = function ContentChat(props) {
1139
1153
  case 0:
1140
1154
  items = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : [];
1141
1155
  id = dataChat.id, version = dataChat.version;
1156
+ retailerId = activeRetailer.id;
1142
1157
  paramsBody = {
1143
1158
  id: id,
1144
1159
  version: version,
1145
- items: items
1160
+ items: items,
1161
+ retailerId: retailerId
1146
1162
  };
1147
1163
  paramsHeaders = {
1148
1164
  Authorization: dataChat.userToken
1149
1165
  };
1150
- _context11.next = 6;
1166
+ _context11.next = 7;
1151
1167
  return (0, _handle_http.fetchPOST)(process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT, paramsBody, paramsHeaders);
1152
1168
 
1153
- case 6:
1169
+ case 7:
1154
1170
  response = _context11.sent;
1155
1171
 
1156
1172
  if (response.body) {
1157
- _context11.next = 9;
1173
+ _context11.next = 10;
1158
1174
  break;
1159
1175
  }
1160
1176
 
@@ -1163,7 +1179,7 @@ var ContentChat = function ContentChat(props) {
1163
1179
  errorDetail: response.errorDetail
1164
1180
  });
1165
1181
 
1166
- case 9:
1182
+ case 10:
1167
1183
  case "end":
1168
1184
  return _context11.stop();
1169
1185
  }
@@ -1193,8 +1209,7 @@ var ContentChat = function ContentChat(props) {
1193
1209
  version: currentArticle.version,
1194
1210
  items: items,
1195
1211
  orderId: dataChat.orderId,
1196
- sentCompanyId: currentUser.companyId,
1197
- receivedCompanyId: activeCompanyId
1212
+ retailerId: activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id
1198
1213
  };
1199
1214
  paramsHeaders = {
1200
1215
  Authorization: dataChat.userToken
@@ -1373,13 +1388,6 @@ var ContentChat = function ContentChat(props) {
1373
1388
  setAllUsers(currentUsers);
1374
1389
  };
1375
1390
 
1376
- var stopUpdate = function stopUpdate() {
1377
- if (processUpdateID !== undefined) {
1378
- clearTimeout(processUpdateID);
1379
- setProcessUpdateID(undefined);
1380
- }
1381
- };
1382
-
1383
1391
  var renderBodyChat = function renderBodyChat() {
1384
1392
  if (isLoading) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {});
1385
1393
 
@@ -216,7 +216,8 @@ var Chat = function Chat(props) {
216
216
  chatContainerType: "fixed",
217
217
  dataChat: data,
218
218
  showBtnClose: false,
219
- ticketCompany: ticketCompany
219
+ ticketCompany: ticketCompany,
220
+ activeRetailer: props.activeRetailer
220
221
  })
221
222
  });
222
223
  } else {
@@ -247,7 +248,8 @@ var Chat = function Chat(props) {
247
248
  ticketCompany: ticketCompany,
248
249
  onClickBtnClose: function onClickBtnClose() {
249
250
  setShowPopUpChat(false);
250
- }
251
+ },
252
+ activeRetailer: props.activeRetailer
251
253
  })
252
254
  })
253
255
  })]
@@ -1751,7 +1751,8 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1751
1751
  setHeaderTop: setHeaderTop,
1752
1752
  withChat: location === null || location === void 0 ? void 0 : (_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.withChat,
1753
1753
  productSelected: productSelected,
1754
- token: token
1754
+ token: token,
1755
+ activeRetailer: activeRetailer
1755
1756
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1756
1757
  className: "data-container",
1757
1758
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.3.34",
3
+ "version": "21.3.36",
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 HeaderTop = ({
13
13
  auditableVersion,
14
14
  setCompare,
15
15
  isAuditor,
16
+ activeRetailer,
16
17
  }) => {
17
18
  const headerTop = useRef();
18
19
 
@@ -34,6 +35,7 @@ export const HeaderTop = ({
34
35
  version: productSelected.version,
35
36
  }}
36
37
  size={18}
38
+ activeRetailer={activeRetailer}
37
39
  />
38
40
  )}
39
41
 
@@ -84,6 +84,13 @@ chatCAD_merchantsProduct.args = {
84
84
  id: 429,
85
85
  version: 1,
86
86
  },
87
+ activeRetailer: {
88
+ id: 68,
89
+ name: "The Home Depot Merchants",
90
+ image:
91
+ "https://content-management-images.s3.amazonaws.com/retailers/68.png",
92
+ percentage: 100,
93
+ },
87
94
  };
88
95
 
89
96
  export const chatCAD_merchantsProductProvider = Template.bind({});
@@ -96,6 +103,13 @@ chatCAD_merchantsProductProvider.args = {
96
103
  id: 429,
97
104
  version: 1,
98
105
  },
106
+ activeRetailer: {
107
+ id: 68,
108
+ name: "The Home Depot Merchants",
109
+ image:
110
+ "https://content-management-images.s3.amazonaws.com/retailers/68.png",
111
+ percentage: 100,
112
+ },
99
113
  };
100
114
 
101
115
  /*
@@ -26,6 +26,7 @@ export const ContentChat = (props) => {
26
26
  onClickBtnClose, // () => {}
27
27
  showPopUpChat, // boolean
28
28
  ticketCompany, // id de la compañía que creó el ticket
29
+ activeRetailer, // object retailer
29
30
  } = props;
30
31
  const [companies, setCompanies] = useState({}); /* {
31
32
  companyId: {
@@ -75,9 +76,17 @@ export const ContentChat = (props) => {
75
76
  if (processUpdateID !== undefined) clearTimeout(processUpdateID);
76
77
  };
77
78
  }, []);
79
+
80
+ const stopUpdate = () => {
81
+ if (processUpdateID !== undefined) {
82
+ clearTimeout(processUpdateID);
83
+ setProcessUpdateID(undefined);
84
+ }
85
+ };
86
+
78
87
  // al cargar el componente
79
88
  useEffect(() => {
80
- if (dataChat) {
89
+ if (dataChat && showPopUpChat) {
81
90
  stopUpdate();
82
91
  if (dataChat.code) {
83
92
  setErrorChat({
@@ -93,6 +102,9 @@ export const ContentChat = (props) => {
93
102
  else if (chatType === "order_product") getInitialOrderProduct();
94
103
  else getInitialTicket();
95
104
  }
105
+ if (!showPopUpChat) {
106
+ stopUpdate();
107
+ }
96
108
  }, [dataChat, showPopUpChat]);
97
109
 
98
110
  // comenzar temporizador del update de 20s
@@ -616,7 +628,8 @@ export const ContentChat = (props) => {
616
628
 
617
629
  const createItemsMerchantProduct = async (items = []) => {
618
630
  const { id, version } = dataChat;
619
- const paramsBody = { id, version, items };
631
+ const { id: retailerId } = activeRetailer;
632
+ const paramsBody = { id, version, items, retailerId };
620
633
  const paramsHeaders = { Authorization: dataChat.userToken };
621
634
  const response = await fetchPOST(
622
635
  process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
@@ -637,8 +650,7 @@ export const ContentChat = (props) => {
637
650
  version: currentArticle.version,
638
651
  items,
639
652
  orderId: dataChat.orderId,
640
- sentCompanyId: currentUser.companyId,
641
- receivedCompanyId: activeCompanyId,
653
+ retailerId: activeRetailer?.id,
642
654
  };
643
655
  const paramsHeaders = { Authorization: dataChat.userToken };
644
656
  const response = await fetchPOST(
@@ -762,13 +774,6 @@ export const ContentChat = (props) => {
762
774
  setAllUsers(currentUsers);
763
775
  };
764
776
 
765
- const stopUpdate = () => {
766
- if (processUpdateID !== undefined) {
767
- clearTimeout(processUpdateID);
768
- setProcessUpdateID(undefined);
769
- }
770
- };
771
-
772
777
  const renderBodyChat = () => {
773
778
  if (isLoading) return <Loading />;
774
779
  if (errorChat.existError) {
@@ -1,5 +1,5 @@
1
1
  import styled from "styled-components";
2
- import { GlobalColors, FontFamily } from "../../../../global-files/variables";
2
+ import { FontFamily } from "../../../../global-files/variables";
3
3
 
4
4
  export const Container = styled.div`
5
5
  width: 100%;
@@ -197,6 +197,7 @@ export const Chat = (props) => {
197
197
  dataChat={data}
198
198
  showBtnClose={false}
199
199
  ticketCompany={ticketCompany}
200
+ activeRetailer={props.activeRetailer}
200
201
  />
201
202
  </ContainerFixed>
202
203
  );
@@ -229,6 +230,7 @@ export const Chat = (props) => {
229
230
  onClickBtnClose={() => {
230
231
  setShowPopUpChat(false);
231
232
  }}
233
+ activeRetailer={props.activeRetailer}
232
234
  />
233
235
  </ContainerPopUp>
234
236
  </Slide>
@@ -1126,6 +1126,7 @@ export const ProviderProductEdition = ({
1126
1126
  withChat={location?.state?.withChat}
1127
1127
  productSelected={productSelected}
1128
1128
  token={token}
1129
+ activeRetailer={activeRetailer}
1129
1130
  />
1130
1131
  <div className="data-container">
1131
1132
  <div className="image-data-panel">