contentoh-components-library 21.3.46 → 21.3.48

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 (26) hide show
  1. package/.env.development +0 -2
  2. package/dist/components/molecules/HeaderTop/index.js +11 -68
  3. package/dist/components/organisms/Chat/Chat.stories.js +1 -21
  4. package/dist/components/organisms/Chat/ContainerItems/index.js +1 -1
  5. package/dist/components/organisms/Chat/ContentChat/index.js +191 -343
  6. package/dist/components/organisms/Chat/Footer/index.js +39 -48
  7. package/dist/components/organisms/Chat/index.js +3 -48
  8. package/dist/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
  9. package/dist/components/organisms/OrderDetail/utils/Table/styles.js +1 -1
  10. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +1 -2
  11. package/dist/components/pages/ProviderProductEdition/index.js +1 -2
  12. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +2 -6
  13. package/dist/components/pages/RetailerProductEdition/index.js +2 -4
  14. package/package.json +1 -1
  15. package/src/components/molecules/HeaderTop/index.js +6 -52
  16. package/src/components/organisms/Chat/Chat.stories.js +0 -21
  17. package/src/components/organisms/Chat/ContainerItems/index.js +1 -4
  18. package/src/components/organisms/Chat/ContentChat/index.js +6 -81
  19. package/src/components/organisms/Chat/Footer/index.js +0 -11
  20. package/src/components/organisms/Chat/index.js +3 -47
  21. package/src/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
  22. package/src/components/organisms/OrderDetail/utils/Table/styles.js +2 -3
  23. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +0 -1
  24. package/src/components/pages/ProviderProductEdition/index.js +0 -1
  25. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +1 -5
  26. package/src/components/pages/RetailerProductEdition/index.js +0 -2
@@ -100,7 +100,6 @@ export const ContentChat = (props) => {
100
100
  }
101
101
  if (chatType === "merchant_product") getInitialMerchantProduct();
102
102
  else if (chatType === "order_product") getInitialOrderProduct();
103
- else if (chatType === "product_status") getInitialProductStatus();
104
103
  else getInitialTicket();
105
104
  }
106
105
  if (!showPopUpChat) {
@@ -127,8 +126,6 @@ export const ContentChat = (props) => {
127
126
  } else if (chatType === "order_product") {
128
127
  if (companies) getUpdateLatestOrderProduct(true);
129
128
  else getInitialOrderProduct();
130
- } else if (chatType === "product_status") {
131
- getInitialProductStatus();
132
129
  } else {
133
130
  if (singleChat.items) getUpdateLatestTicket(true);
134
131
  else getInitialTicket();
@@ -138,47 +135,6 @@ export const ContentChat = (props) => {
138
135
  /*=======================================================================
139
136
  PETICION GET INICIAL SEGUN EL TIPO DE CHAT
140
137
  ======================================================================= */
141
- const getInitialProductStatus = async () => {
142
- const paramsQuery = {
143
- articleData: {
144
- articleId: JSON.stringify(dataChat.id),
145
- version: JSON.stringify(dataChat.version),
146
- retailerId: JSON.stringify(dataChat.retailerId),
147
- status: dataChat.status,
148
- },
149
- };
150
- const paramsHeaders = { Authorization: dataChat.userToken };
151
- const response = await fetchGET(
152
- process.env.REACT_APP_READ_MESSAGES,
153
- paramsQuery,
154
- paramsHeaders
155
- );
156
- if (!response.body) {
157
- setErrorChat({
158
- existError: true,
159
- code: 400,
160
- message: response.message,
161
- errorDetail: response.errorDetail,
162
- });
163
- setIsLoading(false);
164
- return;
165
- }
166
- // success
167
- setStartUpdate((prev) => prev + 1);
168
- setCurrentUser({
169
- id: response.body.data.currentUserId,
170
- companyId: response.body.data.currentCompanyId,
171
- });
172
- setLastUpdateDate(response.body.data.lastUpdateDate);
173
- setAllUsers(response.body.users);
174
- setSingleChat({
175
- items: response.body.items,
176
- enabledLoadMore: response.body.items.length === 50,
177
- });
178
- setErrorChat({ existError: false });
179
- setIsLoading(false);
180
- };
181
-
182
138
  const getInitialMerchantProduct = async () => {
183
139
  const paramsQuery = {
184
140
  getType: "initial",
@@ -653,14 +609,12 @@ export const ContentChat = (props) => {
653
609
  // enviar items a la BD
654
610
  if (chatType === "merchant_product") {
655
611
  errorCreate = await createItemsMerchantProduct(items);
656
- } else if (chatType === "product_status") {
657
- errorCreate = await createItemsProductStatus(items);
658
612
  } else if (chatType === "order_product") {
659
613
  errorCreate = await createItemsOrderProduct(items);
660
614
  } else errorCreate = await createItemsTicket(items);
661
615
 
662
616
  // actualizar chat para que aparezcan los items enviados
663
- if (["merchant_product", "product_status"].includes(chatType)) {
617
+ if (chatType === "merchant_product") {
664
618
  await getUpdateLatestMerchantProduct();
665
619
  } else if (chatType === "order_product") {
666
620
  await getUpdateLatestOrderProduct();
@@ -673,10 +627,9 @@ export const ContentChat = (props) => {
673
627
  };
674
628
 
675
629
  const createItemsMerchantProduct = async (items = []) => {
676
- const { id, version, orderId } = dataChat;
630
+ const { id, version } = dataChat;
677
631
  const { id: retailerId } = activeRetailer;
678
632
  const paramsBody = { id, version, items, retailerId };
679
- if (chatType === "product_status") paramsBody["orderId"] = orderId;
680
633
  const paramsHeaders = { Authorization: dataChat.userToken };
681
634
  const response = await fetchPOST(
682
635
  process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
@@ -690,23 +643,6 @@ export const ContentChat = (props) => {
690
643
  };
691
644
  }
692
645
  };
693
- const createItemsProductStatus = async (items = []) => {
694
- const { id, version, orderId, status } = dataChat;
695
- const { id: retailerId } = activeRetailer;
696
- const paramsBody = { id, version, items, retailerId, orderId, status };
697
- const paramsHeaders = { Authorization: dataChat.userToken };
698
- const response = await fetchPOST(
699
- process.env.REACT_APP_CREATE_MESSAGES,
700
- paramsBody,
701
- paramsHeaders
702
- );
703
- if (!response.body) {
704
- return {
705
- message: response.message,
706
- errorDetail: response.errorDetail,
707
- };
708
- }
709
- };
710
646
 
711
647
  const createItemsOrderProduct = async (items = []) => {
712
648
  const paramsBody = {
@@ -754,11 +690,7 @@ export const ContentChat = (props) => {
754
690
  SECCION DE FUNCIONES
755
691
  ======================================================================= */
756
692
  const isSingleChat = () => {
757
- if (
758
- chatType === "merchant_product" ||
759
- chatType === "ticket" ||
760
- chatType === "product_status"
761
- ) {
693
+ if (chatType === "merchant_product" || chatType === "ticket") {
762
694
  return true;
763
695
  }
764
696
  if (companies && Object.keys(companies).length < 2) return true;
@@ -869,7 +801,7 @@ export const ContentChat = (props) => {
869
801
  // mostrar chat?
870
802
  let items;
871
803
  let enabledLoadMore;
872
- if (["merchant_product", "ticket", "product_status"].includes(chatType)) {
804
+ if (["merchant_product", "ticket"].includes(chatType)) {
873
805
  items = singleChat.items;
874
806
  enabledLoadMore = singleChat.enabledLoadMore;
875
807
  }
@@ -911,9 +843,7 @@ export const ContentChat = (props) => {
911
843
  activeCompanyId={activeCompanyId}
912
844
  ticketCompany={ticketCompany}
913
845
  currentUser={
914
- ["merchant_product", "order_product", "product_status"].includes(
915
- chatType
916
- )
846
+ ["merchant_product", "order_product"].includes(chatType)
917
847
  ? currentUser
918
848
  : dataChat.currentUser
919
849
  }
@@ -952,12 +882,6 @@ export const ContentChat = (props) => {
952
882
  ? { id: dataChat.id, version: currentArticle.version }
953
883
  : chatType === "ticket"
954
884
  ? { id: dataChat.id }
955
- : chatType === "product_status"
956
- ? {
957
- id: dataChat.id,
958
- version: dataChat.version,
959
- retailerId: dataChat.retailerId,
960
- }
961
885
  : undefined
962
886
  }
963
887
  chatCompany={getChatCompany()}
@@ -1000,6 +924,7 @@ export const ContentChat = (props) => {
1000
924
  }}
1001
925
  />
1002
926
  )}
927
+
1003
928
  {/* body */}
1004
929
  {renderBodyChat()}
1005
930
  </Container>
@@ -169,17 +169,6 @@ export const Footer = (props) => {
169
169
  errorMessage = "El ID del ticket no es valido";
170
170
  }
171
171
  break;
172
- case "product_status":
173
- if (
174
- isValidNaturalNumber(dataChat?.id) &&
175
- isValidNaturalNumber(dataChat?.version) &&
176
- isValidNaturalNumber(dataChat?.retailerId)
177
- ) {
178
- fileKey += `productStatus/${dataChat.id}-${dataChat?.version}-${dataChat?.retailerId}/`;
179
- } else {
180
- errorMessage = "El ID del ticket no es valido";
181
- }
182
- break;
183
172
 
184
173
  default:
185
174
  errorMessage =
@@ -24,7 +24,7 @@ export const Chat = (props) => {
24
24
  const [showPopUpChat, setShowPopUpChat] = useState(false);
25
25
  const [data, setData] = useState();
26
26
 
27
- const { ticketCompany, retailerId } = chatData || {};
27
+ const { ticketCompany } = chatData || {};
28
28
 
29
29
  useEffect(() => {
30
30
  switch (chatType) {
@@ -37,9 +37,6 @@ export const Chat = (props) => {
37
37
  case "ticket":
38
38
  validateChatTicket();
39
39
  break;
40
- case "product_status":
41
- validateProductStatus();
42
- break;
43
40
  default:
44
41
  setData({
45
42
  code: 404,
@@ -49,45 +46,6 @@ export const Chat = (props) => {
49
46
  }
50
47
  }, [chatType]);
51
48
 
52
- const validateProductStatus = () => {
53
- const {
54
- userToken, // string
55
- id, // number
56
- version,
57
- retailerId, // number
58
- status,
59
- orderId,
60
- } = chatData;
61
-
62
- if (!isValidGeneral(userToken, id)) return;
63
-
64
- // validar el ID de la cadena asociada al producto en la OT
65
- if (!isValidNaturalNumber(retailerId)) {
66
- setDataError("La cadena relacionada al producto no es válida");
67
- return;
68
- }
69
-
70
- // validar el ID de la version asociada al producto en la OT
71
- if (!isValidNaturalNumber(version)) {
72
- setDataError("La versión del producto no es válida");
73
- return;
74
- }
75
-
76
- if (orderId && !isValidNaturalNumber(orderId)) {
77
- setDataError("La orden del producto no es válida");
78
- return;
79
- }
80
-
81
- setData({
82
- userToken,
83
- id,
84
- version,
85
- retailerId,
86
- orderId,
87
- status,
88
- });
89
- };
90
-
91
49
  const isValidGeneral = (userToken, id) => {
92
50
  // validar token del user
93
51
  if (isStringEmpty(userToken)) {
@@ -111,8 +69,6 @@ export const Chat = (props) => {
111
69
  retailerId, // number
112
70
  } = chatData;
113
71
 
114
- console.log(chatData, "chatData");
115
-
116
72
  if (!isValidGeneral(userToken, id)) return;
117
73
 
118
74
  // validar el ID de la OT en donde se encuentra el producto
@@ -241,7 +197,7 @@ export const Chat = (props) => {
241
197
  dataChat={data}
242
198
  showBtnClose={false}
243
199
  ticketCompany={ticketCompany}
244
- activeRetailer={props.activeRetailer || { id: retailerId }}
200
+ activeRetailer={props.activeRetailer}
245
201
  />
246
202
  </ContainerFixed>
247
203
  );
@@ -274,7 +230,7 @@ export const Chat = (props) => {
274
230
  onClickBtnClose={() => {
275
231
  setShowPopUpChat(false);
276
232
  }}
277
- activeRetailer={props.activeRetailer || { id: retailerId }}
233
+ activeRetailer={props.activeRetailer}
278
234
  />
279
235
  </ContainerPopUp>
280
236
  </Slide>
@@ -69,7 +69,7 @@ OrderDetailDefault.args = {
69
69
  company_name: "GRUPO BRAHMA",
70
70
  date: "2022-11-12T00:00:00.000Z",
71
71
  type: "En oficina",
72
- id_order: 5,
72
+ id_order: 15202,
73
73
  status: "PA",
74
74
  total: 731.2639770507812,
75
75
  timestamp: "2022-11-12T22:48:23.000Z",
@@ -33,10 +33,9 @@ export const Column = styled.div`
33
33
  .center {
34
34
  margin: auto;
35
35
  }
36
- &:nth-child(2) {
36
+ &:nth-child(-n + 2) {
37
37
  overflow: hidden;
38
38
  }
39
-
40
39
  .tooltip {
41
40
  position: relative;
42
41
  display: inline-block;
@@ -49,7 +48,7 @@ export const Column = styled.div`
49
48
  text-align: center;
50
49
  padding: 5px 0;
51
50
  border-radius: 3px;
52
-
51
+
53
52
  position: absolute;
54
53
  z-index: 1;
55
54
  top: -8px;
@@ -138,7 +138,6 @@ ProviderProductEditionDefault.args = {
138
138
  hash: "",
139
139
  state: {
140
140
  withChat: true,
141
- chatType: "product_status",
142
141
  },
143
142
  key: "24vwut",
144
143
  },
@@ -1294,7 +1294,6 @@ export const ProviderProductEdition = ({
1294
1294
  <HeaderTop
1295
1295
  setHeaderTop={setHeaderTop}
1296
1296
  withChat={location?.state?.withChat}
1297
- chatType={location?.state?.chatType}
1298
1297
  productSelected={productSelected}
1299
1298
  token={token}
1300
1299
  activeRetailer={activeRetailer}
@@ -74,11 +74,7 @@ RetailerProductEditionDefault.args = {
74
74
  }
75
75
  },
76
76
  location: {
77
- product: { articleId: 354, versionId: 3 },
78
- state: {
79
- withChat: true,
80
- chatType: "product_status",
81
- },
77
+ product: { articleId: 39290, versionId: 7 },
82
78
  },
83
79
  user: {
84
80
  "id_user": 51,
@@ -1271,10 +1271,8 @@ export const RetailerProductEdition = ({
1271
1271
  setCompare={setCompare}
1272
1272
  isAuditor={[1, 6].includes(user.id_role)}
1273
1273
  withChat={location?.state?.withChat}
1274
- chatType={location?.state?.chatType}
1275
1274
  productSelected={productSelected}
1276
1275
  token={token}
1277
- activeRetailer={activeRetailer}
1278
1276
  />
1279
1277
  <div className="data-container">
1280
1278
  <div className="image-data-panel">