contentoh-components-library 21.1.36 → 21.1.39

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 (28) hide show
  1. package/dist/components/atoms/Percent/Percent.stories.js +39 -0
  2. package/dist/components/atoms/Percent/index.js +39 -0
  3. package/dist/components/atoms/Percent/styles.js +20 -0
  4. package/dist/components/atoms/StatusTag/index.js +17 -2
  5. package/dist/components/atoms/StatusTag/styles.js +1 -1
  6. package/dist/components/molecules/TextAndGradient/TextAndGradient.stories.js +31 -0
  7. package/dist/components/molecules/TextAndGradient/index.js +36 -0
  8. package/dist/components/molecules/TextAndGradient/styles.js +18 -0
  9. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  10. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +105 -103
  11. package/dist/components/pages/ProviderProductEdition/index.js +323 -349
  12. package/dist/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +37 -0
  13. package/dist/components/pages/RegistrationLoginFirstStep/index.js +269 -0
  14. package/dist/components/pages/RegistrationLoginFirstStep/styles.js +20 -0
  15. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +38 -83
  16. package/dist/components/pages/RetailerProductEdition/index.js +197 -208
  17. package/dist/global-files/data.js +9 -10
  18. package/dist/index.js +13 -0
  19. package/package.json +1 -1
  20. package/src/components/atoms/StatusTag/index.js +12 -2
  21. package/src/components/atoms/StatusTag/styles.js +11 -11
  22. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  23. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +117 -103
  24. package/src/components/pages/ProviderProductEdition/index.js +171 -165
  25. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +33 -82
  26. package/src/components/pages/RetailerProductEdition/index.js +167 -139
  27. package/src/global-files/data.js +9 -10
  28. package/src/index.js +1 -0
@@ -233,8 +233,11 @@ export const ProviderProductEdition = ({
233
233
  );
234
234
  }
235
235
 
236
- // setActiveRetailer(product?.retailers[0]);
237
- setImages({ action: "init", init: services[2] });
236
+ //setActiveRetailer(product?.retailers[0]);
237
+ setImages({
238
+ action: "init",
239
+ init: services[2],
240
+ });
238
241
  if (services[2]?.values?.length > 0) setActiveImage(0);
239
242
 
240
243
  getPercentage({ data: [product] }).then((res) => setPercentages(res));
@@ -253,11 +256,10 @@ export const ProviderProductEdition = ({
253
256
  }&end=true`
254
257
  );
255
258
  const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
256
- const retailerResponse = parsedResponse?.map((srv) => srv.id_retailer);
257
259
  let retailers = product.retailers || product.retailersAvailable;
258
- let active = retailers?.find((retailer) =>
259
- retailerResponse.includes(retailer.id)
260
- );
260
+ let active = retailers?.filter((retailer) =>
261
+ parsedResponse?.map((srv) => srv.id_retailer).includes(retailer.id)
262
+ )[0];
261
263
  !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
262
264
  setServicesData(parsedResponse);
263
265
  }
@@ -278,15 +280,15 @@ export const ProviderProductEdition = ({
278
280
  if (revision && currentService === "AP") return true;
279
281
  } else {
280
282
  const { product } = productEdit;
281
- const isRequestWithoutContentoh =
282
- orgn === "RequestWithoutContentoh" &&
283
- (["R", "CA"].includes(currentService) ||
284
- (currentService === "RCA" &&
285
- (!product.id_order || !product.orderId)));
286
- const isRequestWithContentoh =
287
- orgn === "RequestWithContentoh" && currentService === "AA";
288
- const isContentoh = orgn === "Contentoh" && currentService === "AA";
289
- if (isContentoh || isRequestWithoutContentoh || isRequestWithContentoh)
283
+ if (
284
+ orgn === "Contentoh" ||
285
+ (["RECEIVED", "IN_PROGRESS"].includes(currentService) &&
286
+ orgn === "RequestWithoutContentoh") ||
287
+ (currentService === "AA" && orgn === "RequestWithContentoh") ||
288
+ (currentService === "RC" &&
289
+ orgn === "RequestWithoutContentoh" &&
290
+ (!product.id_order || !product.orderId))
291
+ )
290
292
  return true;
291
293
  }
292
294
  }
@@ -303,26 +305,26 @@ export const ProviderProductEdition = ({
303
305
  setInCart(arr.some((e) => e.articleId === product.id_article));
304
306
  };
305
307
 
306
- useEffect(() => {
308
+ useEffect(async () => {
307
309
  sessionStorage.setItem("user", JSON.stringify(user));
308
310
  loadData();
309
311
  getCart();
310
- fetchUsers(token).then((res) => setUserGroups(res));
312
+ setUserGroups(await fetchUsers(token));
311
313
  let arr = [];
312
- // ?? Que sentido tiene verificar los roles de colaborador en la app de proveedor
313
314
  switch (user.id_role) {
314
315
  case 7:
315
316
  case 8:
316
- arr = ["CA", "RC", "RA"];
317
+ arr = ["IN_PROGRESS", "RF", "RA"];
317
318
  break;
318
319
  case 4:
319
320
  case 5:
320
- arr = ["RC", "AC", "AA", "AP", "ACA"];
321
+ arr = ["RF", "AF", "AA", "AP", "AC"];
321
322
  break;
322
323
  case 6:
323
- arr = ["RP", "RCA", "AC"];
324
+ arr = ["RP", "RC", "AF"];
324
325
  break;
325
326
  default:
327
+ arr = [];
326
328
  break;
327
329
  }
328
330
  setStatusArray(arr);
@@ -340,9 +342,9 @@ export const ProviderProductEdition = ({
340
342
  const productTemp = product;
341
343
  const retailers = productTemp?.retailersAvailable || productTemp?.retailers;
342
344
  retailers?.forEach((retailer) => {
343
- retailer["percentage"] = percentages?.find(
345
+ retailer["percentage"] = percentages?.filter(
344
346
  (percent) => retailer?.id === percent?.id_retailer
345
- )?.percentage;
347
+ )[0]?.percentage;
346
348
  });
347
349
 
348
350
  setProduct(productTemp);
@@ -418,7 +420,7 @@ export const ProviderProductEdition = ({
418
420
  };
419
421
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
420
422
  try {
421
- const res = await axios.put(
423
+ await axios.put(
422
424
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?description=true&version=${version}`,
423
425
  dataObject,
424
426
  {
@@ -427,10 +429,8 @@ export const ProviderProductEdition = ({
427
429
  },
428
430
  }
429
431
  );
430
- if (res.data.statusCode === 200) {
431
- setMessage("Descripciones guardadas con éxito");
432
- await loadData();
433
- }
432
+ setMessage("Descripciones guardadas con éxito");
433
+ loadData();
434
434
  } catch (error) {
435
435
  console.log(error);
436
436
  }
@@ -453,10 +453,8 @@ export const ProviderProductEdition = ({
453
453
  },
454
454
  }
455
455
  );
456
- if (res.data.statusCode === 200) {
457
- setMessage("Fichas técnicas guardadas");
458
- await loadData();
459
- }
456
+ setMessage("Fichas técnicas guardadas");
457
+ loadData();
460
458
  } catch (error) {
461
459
  console.log(error);
462
460
  }
@@ -554,7 +552,7 @@ export const ProviderProductEdition = ({
554
552
  return e;
555
553
  });
556
554
  try {
557
- const res = await axios.put(
555
+ await axios.put(
558
556
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
559
557
  dataImages,
560
558
  {
@@ -563,11 +561,9 @@ export const ProviderProductEdition = ({
563
561
  },
564
562
  }
565
563
  );
566
- if (res.data.statusCode === 200) {
567
- setMessage("Imágenes guardadas con éxito");
568
- sessionStorage.removeItem("imagesList");
569
- await loadData();
570
- }
564
+ setMessage("Imágenes guardadas con éxito");
565
+ sessionStorage.removeItem("imagesList");
566
+ loadData();
571
567
  } catch (error) {
572
568
  console.log(error);
573
569
  }
@@ -669,12 +665,12 @@ export const ProviderProductEdition = ({
669
665
  },
670
666
  ],
671
667
  concept: concept,
672
- userId: assignationId,
668
+ [`${assignationType}Id`]: assignationId,
673
669
  };
674
- await axios({
670
+ axios({
675
671
  method: "post",
676
672
  url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
677
- data,
673
+ data: data,
678
674
  headers: {
679
675
  Authorization: token,
680
676
  },
@@ -692,7 +688,7 @@ export const ProviderProductEdition = ({
692
688
  serv = serv.filter((f) => f.id_retailer === activeRetailer.id);
693
689
  }
694
690
  const statusArray =
695
- user.is_retailer === 1 ? ["ACA", "RCA"] : ["AP", "RP", "ACA"];
691
+ user.is_retailer === 1 ? ["AC", "RC"] : ["AP", "RP", "AC"];
696
692
  return (
697
693
  serv.length > 0 && serv.every((item) => statusArray.includes(item.status))
698
694
  );
@@ -795,7 +791,7 @@ export const ProviderProductEdition = ({
795
791
  const { datasheet_status, description_status, images_status } = product;
796
792
  const completionStates =
797
793
  user.is_retailer === 1
798
- ? ["ACA", "Evaluated", "NS"]
794
+ ? ["AC", "Evaluated", "NS"]
799
795
  : ["AP", "Evaluated", "NS"];
800
796
  const dsEvaluated = completionStates.includes(datasheet_status);
801
797
  const descsEvaluated = completionStates.includes(description_status);
@@ -808,53 +804,54 @@ export const ProviderProductEdition = ({
808
804
 
809
805
  const sendEvaluation = async (result) => {
810
806
  setLoading(true);
811
- const concept = getConcept(activeTab);
812
- const productTemp = product;
813
- const articleId = productTemp.id_article;
814
- const orderId = productTemp.id_order ?? productTemp.orderId;
815
- const evalStatus =
816
- product[`${getConcept(activeTab)}_status`] || product?.version_status;
817
- let data = { articleId, orderId, concept, evalStatus };
807
+ let data = {};
818
808
  const retailerId = activeRetailer?.id;
819
- let res;
820
- try {
821
- if (result) {
822
- data.result = result;
823
- data.retailerId = retailerId;
824
- res = await axios.put(
825
- `${process.env.REACT_APP_EVALUATION_ENDPOINT}`,
826
- data,
827
- {
828
- headers: {
829
- Authorization: token,
830
- },
831
- }
832
- );
833
- } else {
834
- res = await axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
835
- headers: {
836
- Authorization: token,
837
- },
838
- });
839
- }
840
- if (res.data.statusCode === 200) {
841
- productTemp[`${concept}_status`] = "Evaluated";
842
- setProduct(productTemp);
843
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
844
- const newProductEdit = {
845
- ArticleId: articleId,
809
+ if (result) {
810
+ data = {
811
+ articleId: product.id_article,
812
+ orderId: product.id_order ?? product.orderId,
813
+ concept: getConcept(activeTab),
814
+ result: result,
815
+ retailerId,
816
+ };
817
+ await axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
818
+ headers: {
819
+ Authorization: token,
820
+ },
821
+ });
822
+ } else {
823
+ const productTemp = product;
824
+ const concept = getConcept(activeTab);
825
+ productTemp[`${concept}_status`] = "Evaluated";
826
+ data = {
827
+ articleId: product.id_article,
828
+ orderId: product.id_order ?? product.orderId,
829
+ concept,
830
+ };
831
+ axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
832
+ headers: {
833
+ Authorization: token,
834
+ },
835
+ });
836
+ setProduct(productTemp);
837
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
838
+ setProductEdit({
839
+ ArticleId: productTemp.id_article,
840
+ idCategory: productTemp.article.id_category,
841
+ product: productTemp,
842
+ });
843
+ sessionStorage.setItem(
844
+ "productEdit",
845
+ JSON.stringify({
846
+ ArticleId: productTemp.id_article,
846
847
  idCategory: productTemp.article.id_category,
847
848
  product: productTemp,
848
- };
849
- setProductEdit(newProductEdit);
850
- sessionStorage.setItem("productEdit", JSON.stringify(newProductEdit));
851
- setOrigin((prev) => ({ ...prev, [concept]: "Evaluated" }));
852
- await loadData();
853
- showSurvey && showSurvey(confirmStatusComplete());
854
- }
855
- } catch (err) {
856
- console.log(err);
849
+ })
850
+ );
851
+ setOrigin((prev) => ({ ...prev, [concept]: "Evaluated" }));
857
852
  }
853
+ loadData();
854
+ showSurvey && showSurvey(confirmStatusComplete());
858
855
  };
859
856
 
860
857
  const validateAll = async (result) => {
@@ -900,13 +897,13 @@ export const ProviderProductEdition = ({
900
897
 
901
898
  await Promise.all(sendAll);
902
899
  const productTemp = product;
903
- productTemp.article_status = `${result}CA`;
900
+ productTemp.article_status = `${result}C`;
904
901
  productTemp.datasheet_status =
905
- productTemp.datasheet_status === "NA" ? "NA" : `${result}CA`;
902
+ productTemp.datasheet_status === "NA" ? "NA" : `${result}C`;
906
903
  productTemp.description_status =
907
- productTemp.description_status === "NA" ? "NA" : `${result}CA`;
904
+ productTemp.description_status === "NA" ? "NA" : `${result}C`;
908
905
  productTemp.images_status =
909
- productTemp.images_status === "NA" ? "NA" : `${result}CA`;
906
+ productTemp.images_status === "NA" ? "NA" : `${result}C`;
910
907
  setProduct(productTemp);
911
908
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
912
909
  setProductEdit({
@@ -923,7 +920,7 @@ export const ProviderProductEdition = ({
923
920
  })
924
921
  );
925
922
 
926
- await loadData();
923
+ loadData();
927
924
  } catch (error) {
928
925
  console.log(error);
929
926
  }
@@ -944,7 +941,7 @@ export const ProviderProductEdition = ({
944
941
  },
945
942
  });
946
943
  const prod = productEdit;
947
- const statusComplete = user.is_retailer ? `${result}CA` : `${result}P`;
944
+ const statusComplete = user.is_retailer ? `${result}C` : `${result}P`;
948
945
  prod.product.datasheet_status = statusComplete;
949
946
  prod.product.description_status = statusComplete;
950
947
  prod.product.images_status = statusComplete;
@@ -953,22 +950,24 @@ export const ProviderProductEdition = ({
953
950
  sessionStorage.setItem("productEdit", JSON.stringify(prod));
954
951
  setProduct(prod);
955
952
  setShowGenericModal && setShowGenericModal(false);
956
- await loadData();
953
+ loadData();
957
954
  };
958
955
 
959
956
  const getSectionStatus = () => {
960
957
  const concept = getConcept(activeTab);
961
- return ["AA", "AP", "R", "CA", "RCA"].includes(
958
+ return ["AA", "AP", "RECEIVED", "IN_PROGRESS", "RC"].includes(
962
959
  productEdit.product[`${concept}_status`]
963
960
  );
964
961
  };
965
962
 
966
963
  const enableActions = (versionStatus) => {
967
964
  try {
968
- if (user.is_retailer) return false;
965
+ const userIsRetailer = user.is_retailer;
966
+
967
+ if (userIsRetailer) return false;
969
968
 
970
969
  if (versionStatus) {
971
- return ["AP", "ACA", "RCA", null].includes(versionStatus);
970
+ return ["AP", "AC", "RC", null].includes(versionStatus);
972
971
  }
973
972
  return true;
974
973
  } catch (err) {
@@ -1058,21 +1057,23 @@ export const ProviderProductEdition = ({
1058
1057
  },
1059
1058
  }));
1060
1059
  setShowGenericModal(true);
1061
- } else if (user.is_retailer) {
1062
- if (product.id_order || product.orderId) {
1063
- validateAll("A");
1060
+ } else {
1061
+ if (user.is_retailer) {
1062
+ if (product.id_order || product.orderId) {
1063
+ validateAll("A");
1064
+ } else {
1065
+ setDataGenericModal((prev) => ({
1066
+ ...prev,
1067
+ button2: {
1068
+ name: "Continuar",
1069
+ action: () => evaluationToRetailer("A"),
1070
+ },
1071
+ }));
1072
+ setShowGenericModal(true);
1073
+ }
1064
1074
  } else {
1065
- setDataGenericModal((prev) => ({
1066
- ...prev,
1067
- button2: {
1068
- name: "Continuar",
1069
- action: () => evaluationToRetailer("A"),
1070
- },
1071
- }));
1072
- setShowGenericModal(true);
1075
+ validateAll("A");
1073
1076
  }
1074
- } else {
1075
- validateAll("A");
1076
1077
  }
1077
1078
  }}
1078
1079
  rejectAll={() => {
@@ -1082,23 +1083,25 @@ export const ProviderProductEdition = ({
1082
1083
  (!product.id_order || !product.orderId)
1083
1084
  ) {
1084
1085
  return;
1085
- } else if (user.is_retailer) {
1086
- if (product.id_order || product.orderId) {
1086
+ } else {
1087
+ if (user.is_retailer) {
1088
+ if (product.id_order || product.orderId) {
1089
+ validateAll("R");
1090
+ setModalViewError(true);
1091
+ } else {
1092
+ setDataGenericModal((prev) => ({
1093
+ ...prev,
1094
+ button2: {
1095
+ name: "Continuar",
1096
+ action: () => evaluationToRetailer("R"),
1097
+ },
1098
+ }));
1099
+ setShowGenericModal(true);
1100
+ }
1101
+ } else {
1087
1102
  validateAll("R");
1088
1103
  setModalViewError(true);
1089
- } else {
1090
- setDataGenericModal((prev) => ({
1091
- ...prev,
1092
- button2: {
1093
- name: "Continuar",
1094
- action: () => evaluationToRetailer("R"),
1095
- },
1096
- }));
1097
- setShowGenericModal(true);
1098
1104
  }
1099
- } else {
1100
- validateAll("R");
1101
- setModalViewError(true);
1102
1105
  }
1103
1106
  }}
1104
1107
  approve={() => {
@@ -1115,21 +1118,23 @@ export const ProviderProductEdition = ({
1115
1118
  },
1116
1119
  }));
1117
1120
  setShowGenericModal(true);
1118
- } else if (user.is_retailer) {
1119
- if (product.id_order || product.orderId) {
1120
- sendEvaluation("A");
1121
+ } else {
1122
+ if (user.is_retailer) {
1123
+ if (product.id_order || product.orderId) {
1124
+ sendEvaluation("A");
1125
+ } else {
1126
+ setDataGenericModal((prev) => ({
1127
+ ...prev,
1128
+ button2: {
1129
+ name: "Continuar",
1130
+ action: () => evaluationToRetailer("A"),
1131
+ },
1132
+ }));
1133
+ setShowGenericModal(true);
1134
+ }
1121
1135
  } else {
1122
- setDataGenericModal((prev) => ({
1123
- ...prev,
1124
- button2: {
1125
- name: "Continuar",
1126
- action: () => evaluationToRetailer("A"),
1127
- },
1128
- }));
1129
- setShowGenericModal(true);
1136
+ sendEvaluation("A");
1130
1137
  }
1131
- } else {
1132
- sendEvaluation("A");
1133
1138
  }
1134
1139
  }}
1135
1140
  reject={() => {
@@ -1139,23 +1144,25 @@ export const ProviderProductEdition = ({
1139
1144
  (!product.id_order || !product.orderId)
1140
1145
  ) {
1141
1146
  return;
1142
- } else if (user.is_retailer) {
1143
- if (product.id_order || product.orderId) {
1147
+ } else {
1148
+ if (user.is_retailer) {
1149
+ if (product.id_order || product.orderId) {
1150
+ sendEvaluation("R");
1151
+ setModalViewError(true);
1152
+ } else {
1153
+ setDataGenericModal((prev) => ({
1154
+ ...prev,
1155
+ button2: {
1156
+ name: "Continuar",
1157
+ action: () => evaluationToRetailer("R"),
1158
+ },
1159
+ }));
1160
+ setShowGenericModal(true);
1161
+ }
1162
+ } else {
1144
1163
  sendEvaluation("R");
1145
1164
  setModalViewError(true);
1146
- } else {
1147
- setDataGenericModal((prev) => ({
1148
- ...prev,
1149
- button2: {
1150
- name: "Continuar",
1151
- action: () => evaluationToRetailer("R"),
1152
- },
1153
- }));
1154
- setShowGenericModal(true);
1155
1165
  }
1156
- } else {
1157
- sendEvaluation("R");
1158
- setModalViewError(true);
1159
1166
  }
1160
1167
  }}
1161
1168
  />
@@ -1306,21 +1313,20 @@ export const ProviderProductEdition = ({
1306
1313
  />
1307
1314
  </div>
1308
1315
  )}
1309
- {/* <Button
1310
- buttonType={
1311
- evaluationComplete(activeTab) &&
1312
- (productEdit.product.id_order ||
1313
- productEdit.product.orderId)
1314
- ? "general-green-button"
1315
- : "general-button-disabled"
1316
- }
1317
- label={"Enviar evaluación"}
1318
- onClick={() => {
1319
- //setModalSent(true);
1320
- sendEvaluation();
1321
- setMessage(`¡Evaluación de ${activeTab} completada!`);
1322
- }}
1323
- /> */}
1316
+ <Button
1317
+ buttonType={
1318
+ evaluationComplete(activeTab) &&
1319
+ (productEdit.product.id_order || productEdit.product.orderId)
1320
+ ? "general-green-button"
1321
+ : "general-button-disabled"
1322
+ }
1323
+ label={"Enviar evaluación"}
1324
+ onClick={() => {
1325
+ //setModalSent(true);
1326
+ sendEvaluation();
1327
+ setMessage(`¡Evaluación de ${activeTab} completada!`);
1328
+ }}
1329
+ />
1324
1330
  </div>
1325
1331
  ) : revision ? null : (
1326
1332
  <div className="required-inputs-message">