contentoh-components-library 21.1.12 → 21.1.13

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.
@@ -16,95 +16,102 @@ RetailerProductEditionDefault.args = {
16
16
  Imágenes: false,
17
17
  },
18
18
  token:
19
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI3MTNhNzQ1Ny1mOTQzLTRiYzktOGViMC04NmI0MWY1YmQ0ZjgiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwiY29nbml0bzp1c2VybmFtZSI6IjcxM2E3NDU3LWY5NDMtNGJjOS04ZWIwLTg2YjQxZjViZDRmOCIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiI4NjQwM2FlZC03Y2I3LTQ4MjgtYmNhOS05NGY1OWRkYjFhMTAiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY1NTY4MDY2MiwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY1NTY4NDI2MiwiaWF0IjoxNjU1NjgwNjYyLCJlbWFpbCI6ImhjYXJyaWxsb0Bjb250ZW50b2guY29tIn0.WL09DLe9etfQEhxSL7D1fdgjF_tO3PxyUraxU3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KzUyMTExMSIsImV4cCI6MTY1NTc1NzcyNSwiaWF0IjoxNjU1NzU0MTI1LCJlbWFpbCI6ImV0Y0Bjb250ZW50b2guY29tIn0.KFEGYLEDArzX7rXRsXo4wCc6nuSxATU6E8aL_XSCJyvYk3F2fn-cslstPX-zEgG1uybmzXfxMvSfnhjMGe1hCdxpHXXrcq4Khm6jlHcnsF62QUdIz5gPqZDoXjegctkCqQtTYhuZEhxhXmHn9Ijj3rSdk2_5-4AKYx89l9p1_G3u1EN8Vs1jH6BuE2v7u1wv45QQ9KB6h7s8DLZF_SfmivlJbQrqKmOzbwlDBpll94rRffKjHXzJtXx0YmKM--zU0E3dzAEdq-UcfEnM7GpC-SV__xMoLK7Rj7yTAq1fTHEfcMnAFBzkSoPjNAUi5xBw9GLCxt55DmZlVfvKyfzx6Q",
20
20
  articleId: 238,
21
21
  category: 846,
22
22
  version: 2,
23
23
  productSelected: {
24
24
  services: {
25
- datasheets: 0,
26
- descriptions: 0,
25
+ datasheets: 1,
26
+ descriptions: 1,
27
27
  images: 1,
28
28
  },
29
- orderId: 72,
30
- status: "ASSIGNED",
31
- datasheet_status: "NS",
29
+ orderId: 42,
30
+ status: "RECEIVED",
31
+ datasheet_status: null,
32
32
  prio: "none",
33
- version: 14,
34
- description_status: "NS",
35
- images_status: "IN_PROGRESS",
33
+ version: 2,
34
+ description_status: null,
35
+ images_status: null,
36
36
  article: {
37
- id_article: 55109,
38
- id_category: "2999",
39
- name: "Resize Ismael",
40
- upc: "ResizeIsmael",
41
- timestamp: "2022-06-18T03:32:56.000Z",
42
- id_user: 110,
37
+ id_article: 54413,
38
+ id_category: "684",
39
+ name: "Crema dental 120 gr",
40
+ upc: "456463435",
41
+ timestamp: "2022-06-17T16:21:59.000Z",
42
+ id_user: 28,
43
43
  status: "NULL",
44
44
  active: 1,
45
- company_id: 834,
46
- company_name: "THD Resize Proveedor",
47
- country: null,
48
- id_order: 72,
49
- id_datasheet_especialist: 54,
50
- id_datasheet_facilitator: 52,
51
- id_description_especialist: 54,
52
- id_description_facilitator: 52,
53
- id_images_especialist: 55,
54
- id_images_facilitator: 53,
45
+ company_id: 1,
46
+ company_name: "COMPANY DEV",
47
+ country: "México",
48
+ id_order: 42,
49
+ id_datasheet_especialist: null,
50
+ id_datasheet_facilitator: null,
51
+ id_description_especialist: null,
52
+ id_description_facilitator: null,
53
+ id_images_especialist: null,
54
+ id_images_facilitator: null,
55
55
  id_auditor: null,
56
56
  id_recepcionist: null,
57
- category: "RESIZING|RESIZING|RESIZING",
58
- missingAttributes: null,
59
- missingDescriptions: null,
60
- missingImages: null,
57
+ category: "SALUD Y BELLEZA|CUIDADO BUCAL|PASTAS DENTALES Y ASEO BUCAL",
58
+ missingAttributes: 22,
59
+ missingDescriptions: 16,
60
+ missingImages: 4,
61
61
  },
62
62
  retailers: [
63
63
  {
64
- id: 58,
65
- name: "The Home Depot Golden",
64
+ id: 4,
65
+ name: "Walmart Super y Superama",
66
66
  country: "México",
67
67
  id_region: 1,
68
68
  active: 1,
69
69
  },
70
70
  {
71
- id: 59,
72
- name: "The Home Depot Platinum",
71
+ id: 5,
72
+ name: "Chedraui",
73
73
  country: "México",
74
74
  id_region: 1,
75
75
  active: 1,
76
76
  },
77
77
  {
78
- id: 60,
79
- name: "The Home Depot Resizing",
78
+ id: 6,
79
+ name: "HEB",
80
+ country: "México",
81
+ id_region: 1,
82
+ active: 1,
83
+ },
84
+ {
85
+ id: 13,
86
+ name: "Soriana",
80
87
  country: "México",
81
88
  id_region: 1,
82
89
  active: 1,
83
90
  },
84
91
  ],
85
- country: null,
86
- upc: "ResizeIsmael",
92
+ country: "México",
93
+ upc: "456463435",
87
94
  },
88
95
  location: {
89
96
  product: { articleId: 109485, versionId: 3 },
90
97
  },
91
98
  user: {
92
- id_user: 55,
93
- name: "ESPECIALISTA ED PRUEBA",
99
+ id_user: 51,
100
+ name: "ADMIN PRUEBA",
94
101
  last_name: "",
95
- email: "hcarrillo@contentoh.com",
102
+ email: "etc@contentoh.com",
96
103
  position: null,
97
104
  telephone: null,
98
105
  country: null,
99
106
  id_company: 2,
100
- id_cognito: "713a7457-f943-4bc9-8eb0-86b41f5bd4f8",
107
+ id_cognito: "a6c4d3d6-24a4-41d4-ad0f-d087438ab5b6",
101
108
  birth_Date: null,
102
109
  about_me: null,
103
110
  zip_code: null,
104
111
  address: null,
105
112
  job: null,
106
113
  id_stripe: null,
107
- id_role: 8,
114
+ id_role: 1,
108
115
  active: 1,
109
116
  is_retailer: 0,
110
117
  membership: {
@@ -118,6 +125,6 @@ RetailerProductEditionDefault.args = {
118
125
  products_limit: "3",
119
126
  type: "PyMES",
120
127
  },
121
- src: "https://content-management-profile.s3.amazonaws.com/id-55/55.png?1655680663244",
128
+ src: "https://content-management-profile.s3.amazonaws.com/id-51/51.png?1655754126500",
122
129
  },
123
130
  };
@@ -167,24 +167,28 @@ export const RetailerProductEdition = ({
167
167
  }, [checkAll]);
168
168
 
169
169
  const loadData = async () => {
170
- const services = await getRetailerServices(
171
- product?.article?.id_article,
172
- parseInt(product?.article?.id_category),
173
- product?.version
174
- );
175
- //Converts the data inside the datasheets object to array
176
- setServices(services);
177
- getServices();
178
-
179
- //setActiveRetailer(product?.retailers[0]);
180
- setImages({
181
- action: "init",
182
- init: services[2],
183
- });
184
- if (services[2]?.values?.length > 0) setActiveImage(0);
170
+ try {
171
+ const services = await getRetailerServices(
172
+ product?.article?.id_article,
173
+ parseInt(product?.article?.id_category),
174
+ product?.version
175
+ );
176
+ //Converts the data inside the datasheets object to array
177
+ setServices(services);
178
+ getServices();
179
+
180
+ //setActiveRetailer(product?.retailers[0]);
181
+ setImages({
182
+ action: "init",
183
+ init: services[2],
184
+ });
185
+ if (services[2]?.values?.length > 0) setActiveImage(0);
185
186
 
186
- getPercentage({ data: [product] }).then((res) => setPercentages(res));
187
- setLoading(false);
187
+ getPercentage({ data: [product] }).then((res) => setPercentages(res));
188
+ setLoading(false);
189
+ } catch (error) {
190
+ console.log(error);
191
+ }
188
192
  };
189
193
 
190
194
  const getServices = async () => {
@@ -194,6 +198,12 @@ export const RetailerProductEdition = ({
194
198
  }&orderId=${product?.article?.id_order || product.orderId}&end=true`
195
199
  );
196
200
  const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
201
+
202
+ let retailers = product.retailers || product.retailersAvailable;
203
+ let active = retailers?.filter((retailer) =>
204
+ parsedResponse?.map((srv) => srv.id_retailer).includes(retailer.id)
205
+ )[0];
206
+ !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
197
207
  setServicesData(parsedResponse);
198
208
  };
199
209
 
@@ -236,16 +246,6 @@ export const RetailerProductEdition = ({
236
246
 
237
247
  useEffect(async () => {
238
248
  loadData();
239
- // getPercentage({ data: [product] }).then((res) =>
240
- // setPercentages(res)
241
- // );
242
- setActiveRetailer((current) =>
243
- current.id
244
- ? current
245
- : product.retailers
246
- ? product.retailers[0]
247
- : product.retailersAvailable[0]
248
- );
249
249
  getComments();
250
250
  setUserGroups(await fetchUsers(token));
251
251
  let arr = [];
@@ -353,7 +353,7 @@ export const RetailerProductEdition = ({
353
353
  }, [activeRetailer, services]);
354
354
 
355
355
  const thumbs = () => {
356
- const imageInputs = socketType.slice();
356
+ const imageInputs = socketType?.slice();
357
357
  const imageType = images?.imageType?.map((e) => ({
358
358
  value: e?.id,
359
359
  name: e?.name,
@@ -777,7 +777,8 @@ export const RetailerProductEdition = ({
777
777
  }
778
778
 
779
779
  return (
780
- product.article[`id_${concept}_${rol}`] === user.id_user && validUser
780
+ user.id_role === 1 ||
781
+ (product.article[`id_${concept}_${rol}`] === user.id_user && validUser)
781
782
  );
782
783
  };
783
784
 
@@ -817,75 +818,81 @@ export const RetailerProductEdition = ({
817
818
  };
818
819
 
819
820
  const getRequired = (services) => {
820
- const objetcTemp = {};
821
- const datasheetServicesArray = Object.values(services[0]);
822
- const dsInputs = datasheetServicesArray.pop();
823
- const descriptionsServicesArray = services[1];
824
-
825
- let dsInputsRequired = [];
826
- let desInputsRequired = 0;
827
- datasheetServicesArray.forEach((datasheet) => {
828
- const [requested] = servicesData.filter(
829
- (srv) =>
830
- srv.id_retailer === datasheet.retailer.id &&
831
- srv.service === getConcept(activeTab)
832
- );
833
- requested &&
834
- Object.values(datasheet?.data).forEach((dataGroup) =>
835
- dsInputsRequired.push(
836
- ...dataGroup.inputs.filter(
837
- (input) =>
838
- dsInputs[input].required &&
839
- (dsInputs[input].value === undefined || !dsInputs[input].value)
840
- )
841
- )
821
+ try {
822
+ const objetcTemp = {};
823
+ const datasheetServicesArray = Object.values(services[0]);
824
+ const dsInputs = datasheetServicesArray.pop();
825
+ const descriptionsServicesArray = services[1];
826
+
827
+ let dsInputsRequired = [];
828
+ let desInputsRequired = 0;
829
+ datasheetServicesArray?.forEach((datasheet) => {
830
+ const [requested] = servicesData?.filter(
831
+ (srv) =>
832
+ srv.id_retailer === datasheet.retailer.id &&
833
+ srv.service === getConcept(activeTab)
842
834
  );
843
- });
835
+ requested &&
836
+ datasheet?.data &&
837
+ Object.values(datasheet?.data).forEach((dataGroup) =>
838
+ dsInputsRequired.push(
839
+ ...dataGroup.inputs.filter(
840
+ (input) =>
841
+ dsInputs[input].required &&
842
+ (dsInputs[input].value === undefined ||
843
+ !dsInputs[input].value)
844
+ )
845
+ )
846
+ );
847
+ });
844
848
 
845
- objetcTemp["Ficha técnica"] = dsInputsRequired.length;
849
+ objetcTemp["Ficha técnica"] = dsInputsRequired.length;
846
850
 
847
- descriptionsServicesArray.forEach((description) => {
848
- const [requested] = servicesData.filter(
849
- (srv) =>
850
- srv.id_retailer === description.id &&
851
- srv.service === getConcept(activeTab)
852
- );
853
- requested &&
854
- description.inputs.forEach(
855
- (input) =>
856
- input.required &&
857
- (!input.value ||
858
- input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") ===
859
- "") &&
860
- desInputsRequired++
851
+ descriptionsServicesArray.forEach((description) => {
852
+ const [requested] = servicesData.filter(
853
+ (srv) =>
854
+ srv.id_retailer === description.id &&
855
+ srv.service === getConcept(activeTab)
861
856
  );
862
- });
857
+ requested &&
858
+ description.inputs.forEach(
859
+ (input) =>
860
+ input.required &&
861
+ (!input.value ||
862
+ input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") ===
863
+ "") &&
864
+ desInputsRequired++
865
+ );
866
+ });
863
867
 
864
- objetcTemp["Descripción"] = desInputsRequired;
868
+ objetcTemp["Descripción"] = desInputsRequired;
865
869
 
866
- const retailersRequested = [];
867
- services[2]?.retailerMandatories?.forEach((retMan) =>
868
- retMan.forEach((rm) => retailersRequested.push(rm))
869
- );
870
- const requiredImages = services[2]?.inputs?.filter(
871
- (e) =>
872
- e.required === 1 &&
873
- retailersRequested.filter(
874
- (ret) =>
875
- ret.id_image === e.id &&
876
- servicesData.filter((srv) => srv.id_retailer === ret.id_retailer)
877
- .length > 0
878
- ).length > 0
879
- );
870
+ const retailersRequested = [];
871
+ services[2]?.retailerMandatories?.forEach((retMan) =>
872
+ retMan.forEach((rm) => retailersRequested.push(rm))
873
+ );
874
+ const requiredImages = services[2]?.inputs?.filter(
875
+ (e) =>
876
+ e.required === 1 &&
877
+ retailersRequested.filter(
878
+ (ret) =>
879
+ ret.id_image === e.id &&
880
+ servicesData.filter((srv) => srv.id_retailer === ret.id_retailer)
881
+ .length > 0
882
+ ).length > 0
883
+ );
880
884
 
881
- let requiredCounter = 0;
882
- requiredImages?.forEach(
883
- (req) =>
884
- services[2].values.filter((img) => img.image_id === req.id).length ===
885
- 0 && requiredCounter++
886
- );
887
- objetcTemp["Imágenes"] = requiredCounter;
888
- setRequiredNull(objetcTemp);
885
+ let requiredCounter = 0;
886
+ requiredImages?.forEach(
887
+ (req) =>
888
+ services[2].values.filter((img) => img.image_id === req.id).length ===
889
+ 0 && requiredCounter++
890
+ );
891
+ objetcTemp["Imágenes"] = requiredCounter;
892
+ setRequiredNull(objetcTemp);
893
+ } catch (error) {
894
+ console.log(error);
895
+ }
889
896
  };
890
897
 
891
898
  useEffect(() => {
@@ -943,76 +950,6 @@ export const RetailerProductEdition = ({
943
950
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
944
951
  };
945
952
 
946
- const evaluationComplete = () => {
947
- let concept = "";
948
- switch (activeTab) {
949
- case "Ficha técnica":
950
- concept = "datasheet";
951
- break;
952
- case "Imágenes":
953
- concept = "images";
954
- break;
955
- case "Descripción":
956
- concept = "description";
957
- break;
958
- }
959
-
960
- let serv = servicesData.filter((item) => item.service === concept);
961
- let approved = "";
962
- let rejected = "";
963
- if (
964
- product.status === "IN_PROGRESS" ||
965
- product.status === "QF" ||
966
- product.status === "RF"
967
- ) {
968
- approved = "AF";
969
- rejected = "RF";
970
- if (product.status === "IN_PROGRESS" || product.status === "QF") {
971
- return (
972
- serv.filter(
973
- (item) =>
974
- item.status === approved ||
975
- item.status === rejected ||
976
- item.status === "AA" ||
977
- item.status === "IN_PROGRESS" ||
978
- item.status === "AP"
979
- ).length === serv.length
980
- );
981
- }
982
- } else if (
983
- product.status === "AF" ||
984
- product.status === "RA" ||
985
- product.status === "RP"
986
- ) {
987
- approved = "AA";
988
- rejected = "RA";
989
-
990
- if (product.status === "RP" || product.status === "AF") {
991
- return (
992
- serv.filter(
993
- (item) =>
994
- item.status === approved ||
995
- item.status === rejected ||
996
- item.status === "AP"
997
- ).length === serv.length
998
- );
999
- }
1000
- } else if (product.status === "RC") {
1001
- approved = "AP";
1002
- rejected = "RA";
1003
- return (
1004
- serv.filter(
1005
- (item) => item.status === approved || item.status === rejected
1006
- ).length === serv.length
1007
- );
1008
- }
1009
- return (
1010
- serv.filter(
1011
- (item) => item.status === approved || item.status === rejected
1012
- ).length === serv.length
1013
- );
1014
- };
1015
-
1016
953
  const downloadImages = () => {
1017
954
  selectedImages.forEach((e) => {
1018
955
  if (e.id) {
@@ -1103,26 +1040,6 @@ export const RetailerProductEdition = ({
1103
1040
  }
1104
1041
  };
1105
1042
 
1106
- const specialistValid = (tab) => {
1107
- let concept = "";
1108
- switch (tab) {
1109
- case "Ficha técnica":
1110
- concept = "datasheet";
1111
- break;
1112
- case "Imágenes":
1113
- concept = "images";
1114
- break;
1115
- case "Descripción":
1116
- concept = "description";
1117
- break;
1118
- }
1119
- return (
1120
- product[`${concept}_status`] === "IN_PROGRESS" ||
1121
- product[`${concept}_status`] === "RF" ||
1122
- product[`${concept}_status`] === "RA"
1123
- );
1124
- };
1125
-
1126
1043
  const getRetailerStatus = (servicesData, tab) => {
1127
1044
  const arr = servicesData?.slice();
1128
1045
  let concept = getConcept(tab);
@@ -1172,6 +1089,7 @@ export const RetailerProductEdition = ({
1172
1089
  onClickSave={() =>
1173
1090
  product?.services?.images === 1 && updateImages()
1174
1091
  }
1092
+ showSaveButton={userAssigned()}
1175
1093
  />
1176
1094
  </div>
1177
1095
  <div className="product-information">