contentoh-components-library 21.0.80 → 21.0.81

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.80",
3
+ "version": "21.0.81",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -12,7 +12,7 @@ export const GalleryElement = ({
12
12
  gridLayout = false,
13
13
  id = "chk-default",
14
14
  label,
15
- index,
15
+ number,
16
16
  imageInputs,
17
17
  imageType,
18
18
  imagePackagingType,
@@ -83,7 +83,7 @@ export const GalleryElement = ({
83
83
  action: "changeImageInfo",
84
84
  attribute: "image_id",
85
85
  value: +e.target.value,
86
- index: index,
86
+ index: number,
87
87
  });
88
88
  }}
89
89
  />
@@ -97,7 +97,7 @@ export const GalleryElement = ({
97
97
  action: "changeImageInfo",
98
98
  attribute: "image_type",
99
99
  value: +e.target.value,
100
- index: index,
100
+ index: number,
101
101
  });
102
102
  }}
103
103
  />
@@ -111,7 +111,7 @@ export const GalleryElement = ({
111
111
  action: "changeImageInfo",
112
112
  attribute: "packing_type",
113
113
  value: +e.target.value,
114
- index: index,
114
+ index: number,
115
115
  });
116
116
  }}
117
117
  />
@@ -40,6 +40,7 @@ export const StatusAsignationInfo = ({
40
40
 
41
41
  return (
42
42
  <Container id={id}>
43
+ {status !== "-" && <StatusTag statusType={status} ovalForm={true} />}
43
44
  {showSaveButton && (
44
45
  <Button
45
46
  buttonType={"circular-button save-button"}
@@ -210,7 +210,7 @@ export const ProviderProductEdition = ({
210
210
  //setActiveRetailer(product?.retailers[0]);
211
211
  setImages({
212
212
  action: "init",
213
- init: services[2],
213
+ init: JSON.parse(sessionStorage.getItem("imagesList")) || services[2],
214
214
  });
215
215
  if (services[2]?.values?.length > 0) setActiveImage(0);
216
216
 
@@ -375,7 +375,8 @@ export const ProviderProductEdition = ({
375
375
  image={image}
376
376
  gridLayout={imageLayout}
377
377
  id={"gallery-element-" + index}
378
- index={index}
378
+ index={index + "-" + image.name}
379
+ number={index}
379
380
  imageType={imageType}
380
381
  imagePackagingType={imagePackagingType}
381
382
  imageInputs={imageInputs}
@@ -548,6 +549,7 @@ export const ProviderProductEdition = ({
548
549
  }
549
550
  );
550
551
  setMessage("Imágenes guardadas con éxito");
552
+ sessionStorage.removeItem("imagesList");
551
553
  loadData();
552
554
  } catch (error) {
553
555
  console.log(error);
@@ -940,23 +942,42 @@ export const ProviderProductEdition = ({
940
942
  };
941
943
 
942
944
  const deleteImages = () => {
943
- const data = {
944
- articleId: product.id_article,
945
- deleteImages: selectedImages,
946
- };
947
- try {
948
- axios.put(
949
- `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
950
- data,
951
- {
952
- headers: { Authorization: token },
953
- }
954
- );
955
- loadData();
956
- } catch (err) {
957
- console.log(err);
945
+ setLoading(true);
946
+ const imagesTemp = images;
947
+ const { values } = images;
948
+ const imgsInBack = [];
949
+
950
+ selectedImages.forEach((selectedImg) => {
951
+ if (selectedImg.id) imgsInBack.push(selectedImg);
952
+ });
953
+
954
+ const imgsLeft = values.filter(
955
+ (value) => selectedImages.indexOf(value) === -1
956
+ );
957
+
958
+ imagesTemp.values = imgsLeft;
959
+
960
+ if (imgsInBack.length > 0) {
961
+ const data = {
962
+ articleId: product.article.id_article,
963
+ deleteImages: selectedImages,
964
+ };
965
+ try {
966
+ axios.put(
967
+ `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
968
+ data,
969
+ {
970
+ headers: { Authorization: token },
971
+ }
972
+ );
973
+ } catch (err) {
974
+ console.log(err);
975
+ }
958
976
  }
977
+ sessionStorage.setItem("imagesList", JSON.stringify(imagesTemp));
978
+ loadData();
959
979
  setMessage("");
980
+ setComponentsArray([]);
960
981
  };
961
982
 
962
983
  const askToDeleteImages = () => {
@@ -979,7 +1000,10 @@ export const ProviderProductEdition = ({
979
1000
  key={"3"}
980
1001
  buttonType="general-button-default"
981
1002
  label={"Aceptar"}
982
- onClick={() => deleteImages()}
1003
+ onClick={() => {
1004
+ setMessage("");
1005
+ deleteImages();
1006
+ }}
983
1007
  />,
984
1008
  ]);
985
1009
  }
@@ -21,50 +21,63 @@ RetailerProductEditionDefault.args = {
21
21
  category: 846,
22
22
  version: 2,
23
23
  productSelected: {
24
- orderId: 132,
25
- id_category: "612",
24
+ services: {
25
+ datasheets: 1,
26
+ descriptions: 1,
27
+ images: 1,
28
+ },
29
+ orderId: 233,
26
30
  status: "IN_PROGRESS",
27
- datasheet_status: "QF",
31
+ datasheet_status: "IN_PROGRESS",
28
32
  prio: "none",
29
33
  version: 2,
30
- description_status: "IN_PROGRESS",
31
- images_status: "IN_PROGRESS",
32
- brand: null,
33
- missing: {
34
- datasheet: 0,
35
- descriptions: 0,
36
- images: 0,
37
- },
34
+ description_status: "QF",
35
+ images_status: "QF",
38
36
  article: {
39
- category: "ROPA, ACCESORIOS, FRAGANCIAS Y JOYERÍA|ACCESORIOS|COLLARES",
37
+ id_article: 190965,
38
+ id_category: "697",
39
+ name: "Shampoo hidratante",
40
+ upc: "6545345",
41
+ timestamp: "2022-06-10T15:05:56.000Z",
42
+ id_user: 28,
43
+ status: "NULL",
44
+ active: 1,
45
+ company_id: 1,
40
46
  company_name: "COMPANY DEV",
41
- id_category: "612",
42
- id_article: 109490,
43
- name: "Collar con dije letra ",
44
- timestamp: "2022-05-05T16:45:49.000Z",
45
- upc: "123434",
47
+ country: "México",
48
+ id_order: 233,
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,
55
+ id_auditor: 30,
56
+ id_recepcionist: null,
57
+ category:
58
+ "SALUD Y BELLEZA|CUIDADO DEL CABELLO|SHAMPOOS Y ACONDICIONADORES",
59
+ missingAttributes: null,
60
+ missingDescriptions: null,
61
+ missingImages: null,
46
62
  },
47
63
  retailers: [
48
64
  {
49
- id: 2,
50
- name: "Walmart Mercancías Generales",
65
+ id: 4,
66
+ name: "Walmart Super y Superama",
67
+ country: "México",
68
+ id_region: 1,
69
+ active: 1,
51
70
  },
52
- ],
53
- services: {
54
- datasheets: 1,
55
- descriptions: 1,
56
- images: 1,
57
- },
58
- checked: false,
59
- retailersAvailable: [
60
71
  {
61
- id: 2,
62
- name: "Walmart Mercancías Generales",
72
+ id: 26,
73
+ name: "Mercado Libre",
74
+ country: "México",
75
+ id_region: 1,
76
+ active: 1,
63
77
  },
64
78
  ],
65
- id_article: 109490,
66
- categoryName: "ROPA, ACCESORIOS, FRAGANCIAS Y JOYERÍA|ACCESORIOS|COLLARES",
67
- version_status: "IN_PROGRESS",
79
+ country: "México",
80
+ upc: "6545345",
68
81
  },
69
82
  location: {
70
83
  product: { articleId: 109485, versionId: 3 },
@@ -167,7 +167,7 @@ export const RetailerProductEdition = ({
167
167
  //setActiveRetailer(product?.retailers[0]);
168
168
  setImages({
169
169
  action: "init",
170
- init: services[2],
170
+ init: JSON.parse(sessionStorage.getItem("imagesList")) || services[2],
171
171
  });
172
172
  if (services[2]?.values?.length > 0) setActiveImage(0);
173
173
 
@@ -181,7 +181,9 @@ export const RetailerProductEdition = ({
181
181
 
182
182
  const getServices = async () => {
183
183
  const servicesResponse = await axios.get(
184
- `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${product?.article?.id_article}&orderId=${product?.article?.id_order}&end=true`
184
+ `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${
185
+ product?.article?.id_article
186
+ }&orderId=${product?.article?.id_order || product.orderId}&end=true`
185
187
  );
186
188
  const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
187
189
  setServicesData(parsedResponse);
@@ -357,7 +359,8 @@ export const RetailerProductEdition = ({
357
359
  image={image}
358
360
  gridLayout={imageLayout}
359
361
  id={"gallery-element-" + index}
360
- index={index}
362
+ index={index + "-" + image.name}
363
+ number={index}
361
364
  imageType={imageType}
362
365
  imagePackagingType={imagePackagingType}
363
366
  imageInputs={imageInputs}
@@ -531,6 +534,7 @@ export const RetailerProductEdition = ({
531
534
  }
532
535
  );
533
536
  setMessage("Imágenes guardadas con éxito");
537
+ sessionStorage.removeItem("imagesList");
534
538
  loadData();
535
539
  } catch (error) {
536
540
  console.log(error);
@@ -983,23 +987,42 @@ export const RetailerProductEdition = ({
983
987
  };
984
988
 
985
989
  const deleteImages = () => {
986
- const data = {
987
- articleId: product.article.id_article,
988
- deleteImages: selectedImages,
989
- };
990
- try {
991
- axios.put(
992
- `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
993
- data,
994
- {
995
- headers: { Authorization: token },
996
- }
997
- );
998
- loadData();
999
- } catch (err) {
1000
- console.log(err);
990
+ setLoading(true);
991
+ const imagesTemp = images;
992
+ const { values } = images;
993
+ const imgsInBack = [];
994
+
995
+ selectedImages.forEach((selectedImg) => {
996
+ if (selectedImg.id) imgsInBack.push(selectedImg);
997
+ });
998
+
999
+ const imgsLeft = values.filter(
1000
+ (value) => selectedImages.indexOf(value) === -1
1001
+ );
1002
+
1003
+ imagesTemp.values = imgsLeft;
1004
+
1005
+ if (imgsInBack.length > 0) {
1006
+ const data = {
1007
+ articleId: product.article.id_article,
1008
+ deleteImages: selectedImages,
1009
+ };
1010
+ try {
1011
+ axios.put(
1012
+ `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
1013
+ data,
1014
+ {
1015
+ headers: { Authorization: token },
1016
+ }
1017
+ );
1018
+ } catch (err) {
1019
+ console.log(err);
1020
+ }
1001
1021
  }
1022
+ sessionStorage.setItem("imagesList", JSON.stringify(imagesTemp));
1023
+ loadData();
1002
1024
  setMessage("");
1025
+ setComponentsArray([]);
1003
1026
  };
1004
1027
 
1005
1028
  const askToDeleteImages = () => {
@@ -1022,7 +1045,10 @@ export const RetailerProductEdition = ({
1022
1045
  key={"3"}
1023
1046
  buttonType="general-button-default"
1024
1047
  label={"Aceptar"}
1025
- onClick={() => deleteImages()}
1048
+ onClick={() => {
1049
+ setMessage("");
1050
+ deleteImages();
1051
+ }}
1026
1052
  />,
1027
1053
  ]);
1028
1054
  }
@@ -1127,13 +1153,13 @@ export const RetailerProductEdition = ({
1127
1153
  onClickSave={() => {
1128
1154
  switch (activeTab) {
1129
1155
  case "Descripción":
1130
- product?.services?.descriptions === 1 && saveDescriptions();
1156
+ product?.description_status !== "NS" && saveDescriptions();
1131
1157
  break;
1132
1158
  case "Ficha técnica":
1133
- product?.services?.datasheets === 1 && saveDatasheets();
1159
+ product?.datasheet_status !== "NS" && saveDatasheets();
1134
1160
  break;
1135
1161
  case "Imágenes":
1136
- product?.services?.images === 1 && updateImages();
1162
+ product?.images_status !== "NS" && updateImages();
1137
1163
  break;
1138
1164
 
1139
1165
  default: