contentoh-components-library 21.0.96 → 21.0.97

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.
@@ -26,43 +26,43 @@ RetailerProductEditionDefault.args = {
26
26
  descriptions: 1,
27
27
  images: 1,
28
28
  },
29
- orderId: 13,
30
- status: "IN_PROGRESS",
31
- datasheet_status: "IN_PROGRESS",
29
+ orderId: 4,
30
+ status: "ASSIGNED",
31
+ datasheet_status: null,
32
32
  prio: "none",
33
- version: 2,
34
- description_status: "IN_PROGRESS",
35
- images_status: "IN_PROGRESS",
33
+ version: 3,
34
+ description_status: null,
35
+ images_status: null,
36
36
  article: {
37
- id_article: 35703,
38
- id_category: "4",
39
- name: "Manzana",
40
- upc: "89898989",
41
- timestamp: "2022-06-15T22:16:56.000Z",
37
+ id_article: 33249,
38
+ id_category: "684",
39
+ name: "Crema dental ",
40
+ upc: "232435",
41
+ timestamp: "2022-06-14T14:52:51.000Z",
42
42
  id_user: 28,
43
43
  status: "NULL",
44
44
  active: 1,
45
45
  company_id: 1,
46
46
  company_name: "COMPANY DEV",
47
47
  country: "México",
48
- id_order: 13,
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: null,
48
+ id_order: 4,
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
+ id_auditor: 37,
56
56
  id_recepcionist: null,
57
- category: "ABARROTES|ABARROTES SECOS|ALIMENTOS DESHIDRATADOS",
58
- missingAttributes: -4,
59
- missingDescriptions: 2,
60
- missingImages: 2,
57
+ category: "SALUD Y BELLEZA|CUIDADO BUCAL|PASTAS DENTALES Y ASEO BUCAL",
58
+ missingAttributes: 13,
59
+ missingDescriptions: 4,
60
+ missingImages: 3,
61
61
  },
62
62
  retailers: [
63
63
  {
64
- id: 3,
65
- name: "Sam´s Club",
64
+ id: 4,
65
+ name: "Walmart Super y Superama",
66
66
  country: "México",
67
67
  id_region: 1,
68
68
  active: 1,
@@ -74,30 +74,44 @@ RetailerProductEditionDefault.args = {
74
74
  id_region: 1,
75
75
  active: 1,
76
76
  },
77
+ {
78
+ id: 1013,
79
+ name: "Cencosud Colombia",
80
+ country: "Colombia",
81
+ id_region: 2,
82
+ active: 1,
83
+ },
84
+ {
85
+ id: 2005,
86
+ name: "ClubCo",
87
+ country: "Costa Rica",
88
+ id_region: 3,
89
+ active: 1,
90
+ },
77
91
  ],
78
92
  country: "México",
79
- upc: "89898989",
93
+ upc: "232435",
80
94
  },
81
95
  location: {
82
96
  product: { articleId: 109485, versionId: 3 },
83
97
  },
84
98
  user: {
85
- id_user: 52,
86
- name: "FACILITADOR TXT PRUEBA",
99
+ id_user: 54,
100
+ name: "ESPECIALISTA TXTS PRUEBA",
87
101
  last_name: "",
88
- email: "azarate@contentoh.com",
102
+ email: "rlegorreta@contentoh.com",
89
103
  position: null,
90
104
  telephone: null,
91
105
  country: null,
92
106
  id_company: 2,
93
- id_cognito: "b2ce5b2a-609c-4e79-9ea9-2f74cff43889",
107
+ id_cognito: "ca1d24ab-e992-4c19-b4e1-2fe6f720c16b",
94
108
  birth_Date: null,
95
109
  about_me: null,
96
110
  zip_code: null,
97
111
  address: null,
98
112
  job: null,
99
113
  id_stripe: null,
100
- id_role: 4,
114
+ id_role: 7,
101
115
  active: 1,
102
116
  is_retailer: 0,
103
117
  membership: {
@@ -111,6 +125,6 @@ RetailerProductEditionDefault.args = {
111
125
  products_limit: "3",
112
126
  type: "PyMES",
113
127
  },
114
- src: "https://content-management-profile.s3.amazonaws.com/id-52/52.png?1655320339846",
128
+ src: "https://content-management-profile.s3.amazonaws.com/id-54/54.png?1655433250522",
115
129
  },
116
130
  };
@@ -45,6 +45,11 @@ const reducerImages = (state, action) => {
45
45
  case "changeAttrValue":
46
46
  attrForImgs[action.retailer][action.index].value = action.value;
47
47
  return { ...state, attrForImgs, values };
48
+ case "deleteImage":
49
+ values = values.filter(
50
+ (value) => action.selectedImages.indexOf(value) === -1
51
+ );
52
+ return { ...state, values };
48
53
  default:
49
54
  return state;
50
55
  }
@@ -153,6 +158,8 @@ export const RetailerProductEdition = ({
153
158
  const [retailerStatus, setRetailerStatus] = useState("-");
154
159
  const [statusArray, setStatusArray] = useState([]);
155
160
  const [socketType, setSocketType] = useState(null);
161
+ const [servicesStatus, setServicesStatus] = useState([]);
162
+ const [saving, setSaving] = useState(loading);
156
163
 
157
164
  useEffect(() => {
158
165
  checkAll && setSelectedImages(images.values);
@@ -166,18 +173,15 @@ export const RetailerProductEdition = ({
166
173
  );
167
174
  //Converts the data inside the datasheets object to array
168
175
  setServices(services);
176
+ getServices();
169
177
 
170
178
  //setActiveRetailer(product?.retailers[0]);
171
179
  setImages({
172
180
  action: "init",
173
- init: JSON.parse(sessionStorage.getItem("imagesList")) || services[2],
181
+ init: services[2],
174
182
  });
175
183
  if (services[2]?.values?.length > 0) setActiveImage(0);
176
184
 
177
- setActiveRetailer(
178
- product.retailers ? product.retailers[0] : product.retailersAvailable[0]
179
- );
180
-
181
185
  getPercentage({ data: [product] }).then((res) => setPercentages(res));
182
186
  setLoading(false);
183
187
  };
@@ -234,7 +238,9 @@ export const RetailerProductEdition = ({
234
238
  // getPercentage({ data: [product] }).then((res) =>
235
239
  // setPercentages(res)
236
240
  // );
237
- getServices();
241
+ setActiveRetailer(
242
+ product.retailers ? product.retailers[0] : product.retailersAvailable[0]
243
+ );
238
244
  getComments();
239
245
  setUserGroups(await fetchUsers(token));
240
246
  let arr = [];
@@ -483,6 +489,7 @@ export const RetailerProductEdition = ({
483
489
  });
484
490
  }
485
491
  if (valid && duplicated?.length === 0) {
492
+ setLoading(true);
486
493
  try {
487
494
  data?.articleData?.forEach((e) => {
488
495
  e.uuid = uuidv4();
@@ -524,7 +531,6 @@ export const RetailerProductEdition = ({
524
531
 
525
532
  useEffect(async () => {
526
533
  if (imagesUploaded) {
527
- setLoading(true);
528
534
  dataImages.articleData = dataImages?.articleData.map((e) => {
529
535
  delete e.src;
530
536
  e.imageID = e.image_id;
@@ -836,7 +842,22 @@ export const RetailerProductEdition = ({
836
842
  });
837
843
 
838
844
  objetcTemp["Descripción"] = desInputsRequired;
839
- const requiredImages = services[2]?.inputs?.filter((e) => e.required);
845
+
846
+ const retailersRequested = [];
847
+ services[2]?.retailerMandatories?.forEach((retMan) =>
848
+ retMan.forEach((rm) => retailersRequested.push(rm))
849
+ );
850
+ const requiredImages = services[2]?.inputs?.filter(
851
+ (e) =>
852
+ e.required === 1 &&
853
+ retailersRequested.filter(
854
+ (ret) =>
855
+ ret.id_image === e.id &&
856
+ servicesData.filter((srv) => srv.id_retailer === ret.id_retailer)
857
+ .length > 0
858
+ ).length > 0
859
+ );
860
+
840
861
  let requiredCounter = 0;
841
862
  requiredImages?.forEach(
842
863
  (req) =>
@@ -985,7 +1006,6 @@ export const RetailerProductEdition = ({
985
1006
 
986
1007
  const deleteImages = () => {
987
1008
  setLoading(true);
988
- const imagesTemp = images;
989
1009
  const { values } = images;
990
1010
  const imgsInBack = [];
991
1011
 
@@ -997,12 +1017,10 @@ export const RetailerProductEdition = ({
997
1017
  (value) => selectedImages.indexOf(value) === -1
998
1018
  );
999
1019
 
1000
- imagesTemp.values = imgsLeft;
1001
-
1002
1020
  if (imgsInBack.length > 0) {
1003
1021
  const data = {
1004
1022
  articleId: product.article.id_article,
1005
- deleteImages: selectedImages,
1023
+ deleteImages: imgsInBack,
1006
1024
  };
1007
1025
  try {
1008
1026
  axios.put(
@@ -1016,8 +1034,22 @@ export const RetailerProductEdition = ({
1016
1034
  console.log(err);
1017
1035
  }
1018
1036
  }
1019
- sessionStorage.setItem("imagesList", JSON.stringify(imagesTemp));
1020
- loadData();
1037
+
1038
+ setImages({
1039
+ action: "deleteImage",
1040
+ selectedImages,
1041
+ });
1042
+
1043
+ getRequired([
1044
+ services[0],
1045
+ services[1],
1046
+ { ...services[2], values: imgsLeft },
1047
+ ]);
1048
+
1049
+ setTimeout(() => {
1050
+ setLoading(false);
1051
+ }, 500);
1052
+
1021
1053
  setMessage("");
1022
1054
  setComponentsArray([]);
1023
1055
  };
@@ -1093,6 +1125,10 @@ export const RetailerProductEdition = ({
1093
1125
  services.length > 0 && getRequired(services);
1094
1126
  }, [services, servicesData, activeTab]);
1095
1127
 
1128
+ useEffect(() => {
1129
+ setSaving(loading);
1130
+ }, [loading]);
1131
+
1096
1132
  return (
1097
1133
  <Container headerTop={headerTop}>
1098
1134
  <HeaderTop setHeaderTop={setHeaderTop} />
@@ -1123,6 +1159,7 @@ export const RetailerProductEdition = ({
1123
1159
  headerData={product}
1124
1160
  percent={activePercentage}
1125
1161
  activeRetailer={activeRetailer}
1162
+ servicesData={servicesData}
1126
1163
  setActiveRetailer={setActiveRetailer}
1127
1164
  sendToFacilitator={sendToFacilitator}
1128
1165
  approve={() => {
@@ -1146,17 +1183,21 @@ export const RetailerProductEdition = ({
1146
1183
  assig={assig[activeTab]}
1147
1184
  setAssignation={setAssignation}
1148
1185
  isRetailer={isRetailer}
1149
- showSaveButton={true}
1186
+ showSaveButton={userAssigned()}
1150
1187
  onClickSave={() => {
1151
1188
  switch (activeTab) {
1152
1189
  case "Descripción":
1153
- product?.description_status !== "NS" && saveDescriptions();
1190
+ !saving &&
1191
+ product?.description_status !== "NS" &&
1192
+ saveDescriptions();
1154
1193
  break;
1155
1194
  case "Ficha técnica":
1156
- product?.datasheet_status !== "NS" && saveDatasheets();
1195
+ !saving &&
1196
+ product?.datasheet_status !== "NS" &&
1197
+ saveDatasheets();
1157
1198
  break;
1158
1199
  case "Imágenes":
1159
- product?.images_status !== "NS" && updateImages();
1200
+ !saving && product?.images_status !== "NS" && updateImages();
1160
1201
  break;
1161
1202
 
1162
1203
  default: