contentoh-components-library 21.0.7 → 21.0.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.0.7",
3
+ "version": "21.0.8",
4
4
  "dependencies": {
5
5
  "@babel/runtime": "^7.17.2",
6
6
  "@storybook/addon-postcss": "^2.0.0",
@@ -26,7 +26,7 @@ export const FullTabsMenu = ({
26
26
  setActiveTab={setActiveTab}
27
27
  />
28
28
  <StatusAsignationInfo
29
- status={status[activeTab]}
29
+ status={status()}
30
30
  activeTab={activeTab}
31
31
  setImageLayout={setImageLayout}
32
32
  imagesSection={imagesSection}
@@ -44,7 +44,7 @@ RetailerProductEditionDefault.args = {
44
44
  Imágenes: false,
45
45
  },
46
46
  token:
47
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJjOTRhNzMwNS05MzY1LTQ2ZmYtYTQyMy00YjRiYzNiOGIxODAiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjp0cnVlLCJjb2duaXRvOnVzZXJuYW1lIjoiYzk0YTczMDUtOTM2NS00NmZmLWE0MjMtNGI0YmMzYjhiMTgwIiwiY29nbml0bzpyb2xlcyI6WyJhcm46YXdzOmlhbTo6ODk4NjcwMjMyODA3OnJvbGVcL2NvbnRlbnRvaC1kZXYtdXMtZWFzdC0xLWxhbWJkYVJvbGUiXSwiYXVkIj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ZWE5LTJmNzRjZmY0Mzg4OSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiJkMGQ0NDUxYS01ODg1LTQ0ZTctYjZhNi0xODdkY2NjNDI4MTgiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY1MTIyMDI2NiwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY1MTIyMzg2NiwiaWF0IjoxNjUxMjIwMjY2LCJlbWFpbCI6ImF6YXJhdGVAY29udGVudG9oLmNvbSJ9.lhlgp4NoHgFu4LrpIWiGCTD08MIHo-mLQ17SNx1rAmyHP5YosGp9LKJXEgNcpAIaVfFiy4Zd-YGTf2QExMcP9kAYksoKHI1G6jSg87yh3Pg3V3aGE6X6JkuOOflz2M8jZgyYMRvbkJfG7oi6uj_nZ-tCjq7VMnmZyfWL4LjTvF5E0EqzVC93fcPViwW5ozqr51VvGhIoXGHiG01i4CPbsorp0jJjlU795cq4ETNw6i0d61Wz9pLDUttYmt5RCEMrbCp3ctSymtxHuz3eJTXzsF330KAmGL2SG4hJ8l-kdyoYRSlkGy3PTy4tYdFVrcubpHL3LOFzJWMrmLn98J3MoA",
48
48
  articleId: 238,
49
49
  category: 846,
50
50
  version: 2,
@@ -54,75 +54,75 @@ RetailerProductEditionDefault.args = {
54
54
  descriptions: 1,
55
55
  images: 1,
56
56
  },
57
- orderId: 123,
57
+ orderId: 125,
58
58
  status: "IN_PROGRESS",
59
- datasheet_status: "IN_PROGRESS",
59
+ datasheet_status: "QF",
60
60
  prio: "none",
61
61
  version: 2,
62
- description_status: "IN_PROGRESS",
63
- images_status: null,
62
+ description_status: "QF",
63
+ images_status: "IN_PROGRESS",
64
64
  article: {
65
- id_article: 109481,
66
- id_category: "9",
67
- name: "Barrita de nuez",
68
- upc: "168489",
69
- timestamp: "2022-04-27T15:06:59.000Z",
65
+ id_article: 109483,
66
+ id_category: "2046",
67
+ name: "Celular",
68
+ upc: "31313131",
69
+ timestamp: "2022-04-28T21:42:27.000Z",
70
70
  id_user: 28,
71
71
  status: "NULL",
72
72
  active: 1,
73
73
  company_id: 1,
74
74
  company_name: "COMPANY DEV",
75
75
  country: "Colombia",
76
- id_order: 123,
76
+ id_order: 125,
77
77
  id_datasheet_especialist: 54,
78
78
  id_datasheet_facilitator: 52,
79
79
  id_description_especialist: 54,
80
80
  id_description_facilitator: 52,
81
- id_images_especialist: null,
82
- id_images_facilitator: null,
81
+ id_images_especialist: 55,
82
+ id_images_facilitator: 53,
83
83
  id_auditor: 30,
84
84
  id_recepcionist: null,
85
- category: "ABARROTES|ABARROTES SECOS|CEREALES Y BARRAS",
85
+ category: "ELÉCTRICO|ELECTRÓNICA|ANTENAS Y ACCESORIOS",
86
86
  missingAttributes: null,
87
87
  missingDescriptions: null,
88
88
  missingImages: null,
89
89
  },
90
90
  retailers: [
91
91
  {
92
- id: 4,
93
- name: "Walmart Super y Superama",
92
+ id: 58,
93
+ name: "The Home Depot",
94
94
  country: "México",
95
95
  id_region: 1,
96
96
  active: 1,
97
97
  },
98
98
  {
99
- id: 6,
100
- name: "HEB",
99
+ id: 59,
100
+ name: "Home Depot Platinum",
101
101
  country: "México",
102
102
  id_region: 1,
103
103
  active: 1,
104
104
  },
105
105
  ],
106
106
  country: "Colombia",
107
- upc: "168489",
107
+ upc: "31313131",
108
108
  },
109
109
  user: {
110
- id_user: 30,
111
- name: "Admin",
112
- last_name: "Ulises",
113
- email: "salmeron.5@hotmail.com",
114
- position: "Admin",
110
+ id_user: 52,
111
+ name: "FACILITADOR TXT PRUEBA",
112
+ last_name: "",
113
+ email: "azarate@contentoh.com",
114
+ position: null,
115
115
  telephone: null,
116
- country: "México",
116
+ country: null,
117
117
  id_company: 2,
118
- id_cognito: "c94a7305-9365-46ff-a423-4b4bc3b8b180",
118
+ id_cognito: "b2ce5b2a-609c-4e79-9ea9-2f74cff43889",
119
119
  birth_Date: null,
120
120
  about_me: null,
121
121
  zip_code: null,
122
122
  address: null,
123
123
  job: null,
124
124
  id_stripe: null,
125
- id_role: 6,
125
+ id_role: 4,
126
126
  active: 1,
127
127
  is_retailer: 0,
128
128
  membership: {
@@ -136,6 +136,6 @@ RetailerProductEditionDefault.args = {
136
136
  products_limit: "3",
137
137
  type: "PyMES",
138
138
  },
139
- src: "https://content-management-profile.s3.amazonaws.com/id-30/30.png?1649896700986",
139
+ src: "https://content-management-profile.s3.amazonaws.com/id-52/52.png?1651207506986",
140
140
  },
141
141
  };
@@ -126,7 +126,11 @@ export const RetailerProductEdition = ({
126
126
  const [services, setServices] = useState([]);
127
127
  const [servicesData, setServicesData] = useState([]);
128
128
  const [message, setMessage] = useState("");
129
- const [product, setProduct] = useState({});
129
+ const [product, setProduct] = useState(
130
+ JSON.parse(sessionStorage.getItem("productSelected"))
131
+ ? JSON.parse(sessionStorage.getItem("productSelected"))
132
+ : productSelected
133
+ );
130
134
  const [icon, setIcon] = useState(null);
131
135
  const [version, setVersion] = useState(productSelected?.version);
132
136
  const [comments, setComments] = useState({});
@@ -164,7 +168,7 @@ export const RetailerProductEdition = ({
164
168
  init: services[2],
165
169
  });
166
170
  if (services[2]?.values?.length > 0) setActiveImage(0);
167
- setProduct(productSelected);
171
+
168
172
  getPercentage({ data: [productSelected] }).then((res) =>
169
173
  setPercentages(res)
170
174
  );
@@ -186,7 +190,7 @@ export const RetailerProductEdition = ({
186
190
  }
187
191
  const selected = productSelected;
188
192
  const servicesResponse = await axios.get(
189
- `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${selected?.article?.id_article}&orderId=${selected?.article?.id_order}&end=true`
193
+ `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${product?.article?.id_article}&orderId=${product?.article?.id_order}&end=true`
190
194
  );
191
195
  const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
192
196
  setServicesData(parsedResponse);
@@ -530,11 +534,13 @@ export const RetailerProductEdition = ({
530
534
  }
531
535
  concept = action ? action : concept;
532
536
  return (
533
- (productSelected[`${concept}_status`] === "QF" &&
537
+ (product[`${concept}_status`] === "QF" &&
534
538
  (user.id_role === 1 || user.id_role === 4 || user.id_role === 5)) ||
535
- (productSelected[`${concept}_status`] === "AF" &&
539
+ (product[`${concept}_status`] === "AF" && //sessionStorage productSelected
536
540
  (user.id_role === 1 || user.id_role === 6)) ||
537
- (productSelected[`${concept}_status`] === "RP" &&
541
+ (product[`${concept}_status`] === "RP" &&
542
+ (user.id_role === 1 || user.id_role === 6)) ||
543
+ (product[`${concept}_status`] === "RC" &&
538
544
  (user.id_role === 1 || user.id_role === 6))
539
545
  );
540
546
  };
@@ -557,7 +563,7 @@ export const RetailerProductEdition = ({
557
563
 
558
564
  const updateCompaniesList = (status, result, retailerId, concept) => {
559
565
  let serv = servicesData.slice();
560
- let item = serv?.find(
566
+ let item = serv.find(
561
567
  (item) => item.id_retailer === retailerId && item.service === concept
562
568
  );
563
569
  let index = serv.indexOf(item);
@@ -631,12 +637,9 @@ export const RetailerProductEdition = ({
631
637
  case "Imágenes":
632
638
  concept = "images";
633
639
  break;
634
- default:
635
- break;
636
640
  }
637
- let evalStatus = "";
638
- let productTemp = productSelected;
639
- evalStatus = productSelected[`${concept}_status`];
641
+ let productTemp = { ...product };
642
+ let evalStatus = product[`${concept}_status`];
640
643
  const specialistDone =
641
644
  evalStatus === "RF" ||
642
645
  evalStatus === "RA" ||
@@ -646,46 +649,51 @@ export const RetailerProductEdition = ({
646
649
  setMessage(`${activeTab} enviada a facilitador`);
647
650
  getSectionIcon();
648
651
  productTemp[`${concept}_status`] = "QF";
649
- evalStatus = "QF";
650
652
  } else if (evalStatus === "QF") {
651
653
  setMessage("Evaluación enviada");
652
654
  getSectionIcon();
653
655
  productTemp[`${concept}_status`] = "AF";
654
- evalStatus = "AF";
655
656
  } else if (evalStatus === "AF") {
656
657
  setMessage("Evaluación enviada");
657
658
  getSectionIcon();
658
659
  productTemp[`${concept}_status`] = "AA";
659
- evalStatus = "AA";
660
660
  } else if (evalStatus === "RP") {
661
661
  setMessage("Evaluación enviada");
662
662
  getSectionIcon();
663
663
  productTemp[`${concept}_status`] = "AA";
664
- evalStatus = "AA";
664
+ } else if (evalStatus === "RC") {
665
+ setMessage("Evaluación enviada");
666
+ getSectionIcon();
667
+ productTemp[`${concept}_status`] = "AP";
665
668
  }
669
+
666
670
  let data = {};
667
671
  if (result) {
668
672
  updateCompaniesList(evalStatus, result, activeRetailer.id, concept);
669
673
  data = {
670
- articleId: productSelected.article.id_article,
671
- orderId: productSelected.orderId,
674
+ articleId: product.article.id_article,
675
+ orderId: product.orderId,
672
676
  concept: concept,
673
677
  result: result,
674
678
  evalStatus: evalStatus,
675
679
  retailerId: activeRetailer.id,
676
680
  };
677
- await axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
678
- headers: {
679
- Authorization: token,
680
- },
681
- });
681
+ try {
682
+ await axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
683
+ headers: {
684
+ Authorization: token,
685
+ },
686
+ });
687
+ } catch (error) {
688
+ console.log(error);
689
+ }
682
690
  } else {
683
691
  if (specialistDone) {
684
- updateCompaniesList(evalStatus, result, activeRetailer.id);
692
+ updateCompaniesList(evalStatus, result, activeRetailer.id, concept);
685
693
  }
686
694
  data = {
687
- articleId: productSelected.article.id_article,
688
- orderId: productSelected.orderId,
695
+ articleId: product.article.id_article,
696
+ orderId: product.orderId,
689
697
  concept: concept,
690
698
  evalStatus: evalStatus,
691
699
  retailerId: activeRetailer.id,
@@ -704,11 +712,14 @@ export const RetailerProductEdition = ({
704
712
  break;
705
713
  }
706
714
 
715
+ console.log(data);
716
+
707
717
  axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
708
718
  headers: {
709
719
  Authorization: token,
710
720
  },
711
721
  });
722
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
712
723
  setProduct(productTemp);
713
724
  //setModalSent(true);
714
725
  }
@@ -730,9 +741,21 @@ export const RetailerProductEdition = ({
730
741
  }
731
742
 
732
743
  const allowedRoles = [1, 4, 5, 6, 7, 8];
733
-
734
744
  const validUser = allowedRoles.indexOf(user?.id_role) !== -1;
735
745
 
746
+ if (!rol) {
747
+ switch (user.id_role) {
748
+ case 4:
749
+ case 5:
750
+ rol = "facilitator";
751
+ break;
752
+ case 7:
753
+ case 8:
754
+ rol = "especialist";
755
+ break;
756
+ }
757
+ }
758
+
736
759
  return (
737
760
  productSelected.article[`id_${concept}_${rol}`] === user.id_user &&
738
761
  validUser
@@ -872,20 +895,20 @@ export const RetailerProductEdition = ({
872
895
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
873
896
  };
874
897
 
875
- const evaluationComplete = (tab) => {
898
+ const evaluationComplete = () => {
876
899
  let concept = "";
877
- switch (tab) {
900
+ switch (activeTab) {
878
901
  case "Ficha técnica":
879
902
  concept = "datasheet";
880
903
  break;
881
904
  case "Imágenes":
882
905
  concept = "images";
883
906
  break;
884
-
885
- default:
907
+ case "Descripción":
886
908
  concept = "description";
887
909
  break;
888
910
  }
911
+
889
912
  let serv = servicesData.filter((item) => item.service === concept);
890
913
  let approved = "";
891
914
  let rejected = "";
@@ -998,9 +1021,25 @@ export const RetailerProductEdition = ({
998
1021
  }
999
1022
  };
1000
1023
 
1001
- useEffect(() => {
1002
- console.log(requiredNull[activeTab], evaluationComplete(activeTab));
1003
- }, [activeTab]);
1024
+ const specialistValid = (tab) => {
1025
+ let concept = "";
1026
+ switch (tab) {
1027
+ case "Ficha técnica":
1028
+ concept = "datasheet";
1029
+ break;
1030
+ case "Imágenes":
1031
+ concept = "images";
1032
+ break;
1033
+ case "Descripción":
1034
+ concept = "description";
1035
+ break;
1036
+ }
1037
+ return (
1038
+ product[`${concept}_status`] === "IN_PROGRESS" ||
1039
+ product[`${concept}_status`] === "RF" ||
1040
+ product[`${concept}_status`] === "RA"
1041
+ );
1042
+ };
1004
1043
 
1005
1044
  return (
1006
1045
  <Container headerTop={headerTop}>
@@ -1036,15 +1075,38 @@ export const RetailerProductEdition = ({
1036
1075
  approveRejectButtons={approveRejectButtons}
1037
1076
  sendToFacilitator={sendToFacilitator}
1038
1077
  auditorAssigned={auditorAssigned}
1039
- userAssigned={() => userAssigned(activeTab, "facilitator")}
1078
+ userAssigned={() => userAssigned(activeTab)}
1040
1079
  />
1041
1080
  <FullTabsMenu
1042
1081
  tabsSections={tabsSections}
1043
- status={{
1044
- Descripción: product?.description_status,
1045
- "Ficha técnica": product?.datasheet_status,
1046
- Imágenes: product?.images_status,
1047
- }}
1082
+ status={
1083
+ // {
1084
+ // Descripción: product?.description_status,
1085
+ // "Ficha técnica": product?.datasheet_status,
1086
+ // Imágenes: product?.images_status,
1087
+ // }
1088
+ () => {
1089
+ let concept = "";
1090
+ switch (activeTab) {
1091
+ case "Ficha técnica":
1092
+ concept = "datasheet";
1093
+ break;
1094
+ case "Imágenes":
1095
+ concept = "images";
1096
+ break;
1097
+ case "Descripción":
1098
+ concept = "description";
1099
+ break;
1100
+ }
1101
+ let retailerService = {};
1102
+ [retailerService] = servicesData.filter(
1103
+ (service) =>
1104
+ service.id_retailer === activeRetailer.id &&
1105
+ service.service === concept
1106
+ );
1107
+ return retailerService?.status;
1108
+ }
1109
+ }
1048
1110
  activeTab={activeTab}
1049
1111
  setActiveTab={setActiveTab}
1050
1112
  setImageLayout={setImageLayout}
@@ -1144,8 +1206,7 @@ export const RetailerProductEdition = ({
1144
1206
  </>
1145
1207
  )}
1146
1208
  </div>
1147
- {(userAssigned(activeTab, "especialist" || "facilitator") ||
1148
- auditorAssigned()) && (
1209
+ {(userAssigned(activeTab) || auditorAssigned()) && (
1149
1210
  <div className="commentary-box">
1150
1211
  {!comment ? (
1151
1212
  <div className="commentary">
@@ -1190,9 +1251,9 @@ export const RetailerProductEdition = ({
1190
1251
  )}
1191
1252
  <Button
1192
1253
  buttonType={
1193
- approveRejectButtons() ||
1194
- requiredNull[activeTab] === 0 ||
1195
- evaluationComplete(activeTab)
1254
+ evaluationComplete() &&
1255
+ requiredNull[activeTab] === 0 &&
1256
+ approveRejectButtons()
1196
1257
  ? "general-green-button"
1197
1258
  : "general-button-disabled"
1198
1259
  }