contentoh-components-library 21.1.62 → 21.1.63

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 (24) hide show
  1. package/dist/components/atoms/InputFormatter/index.js +3 -3
  2. package/dist/components/atoms/ProductPercentCard/Percent.stories.js +1 -1
  3. package/dist/components/atoms/ProductPercentCard/styles.js +1 -1
  4. package/dist/components/molecules/AssignedWork/AssignedWork.stories.js +1 -1
  5. package/dist/components/molecules/AssignedWork/styles.js +1 -1
  6. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  7. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +93 -109
  8. package/dist/components/pages/ProviderProductEdition/index.js +430 -429
  9. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +42 -30
  10. package/dist/components/pages/RetailerProductEdition/index.js +217 -200
  11. package/dist/global-files/data.js +8 -8
  12. package/package.json +1 -1
  13. package/src/components/atoms/InputFormatter/index.js +3 -6
  14. package/src/components/atoms/ProductPercentCard/Percent.stories.js +11 -12
  15. package/src/components/atoms/ProductPercentCard/styles.js +9 -9
  16. package/src/components/molecules/AssignedWork/AssignedWork.stories.js +8 -8
  17. package/src/components/molecules/AssignedWork/styles.js +9 -10
  18. package/src/components/organisms/FullProductNameHeader/index.js +2 -2
  19. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +95 -114
  20. package/src/components/pages/ProviderProductEdition/index.js +232 -248
  21. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +44 -30
  22. package/src/components/pages/RetailerProductEdition/index.js +149 -173
  23. package/src/global-files/data.js +8 -8
  24. package/src/components/atoms/ProgressBar/styles.js +0 -69
@@ -16,49 +16,49 @@ RetailerProductEditionDefault.args = {
16
16
  Imágenes: false,
17
17
  },
18
18
  token:
19
- "eyJraWQiOiJEV3owZnNieXg2MXNFcVduN3RCXC81bVhod3ZNbFZIOTgwUnZcL3RjT0lKdEk9IiwiYWxnI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kTGq6G373LrZ6vrsquZeUiaOnVQdOT-ucSI1oJRGRq6CqLSQOb7fo1Q",
20
20
  productSelected: {
21
21
  services: {
22
- datasheets: 1,
23
- descriptions: 1,
22
+ datasheets: 0,
23
+ descriptions: 0,
24
24
  images: 1,
25
25
  },
26
- orderId: 2012,
27
- status: "QF",
28
- datasheet_status: "QF",
26
+ orderId: 1973,
27
+ status: "R",
28
+ datasheet_status: "NS",
29
29
  prio: "none",
30
30
  version: 2,
31
- description_status: "QF",
32
- images_status: "AF",
31
+ description_status: "NS",
32
+ images_status: null,
33
33
  article: {
34
- id_article: 76958,
35
- id_category: "2627",
36
- name: "COLGANTE MAGIC NAVIDAD",
37
- upc: "163963",
38
- timestamp: "2022-07-07T17:01:17.000Z",
39
- id_user: 1195,
34
+ id_article: 48873,
35
+ id_category: "2095",
36
+ name: '710 DISCO CORTE METAL 4 1/2"',
37
+ upc: "436882",
38
+ timestamp: "2022-06-18T12:16:21.000Z",
39
+ id_user: 1239,
40
40
  status: "NULL",
41
41
  active: 1,
42
- company_id: 657,
42
+ company_id: 308,
43
43
  SKU: null,
44
44
  Descripcion: null,
45
45
  Proveedor: null,
46
46
  id_proveedor: 0,
47
- company_name: "",
47
+ company_name: "The Home Depot",
48
48
  country: null,
49
- id_order: 2012,
50
- id_datasheet_especialist: 1248,
51
- id_datasheet_facilitator: 1252,
52
- id_description_especialist: 334,
53
- id_description_facilitator: 1252,
54
- id_images_especialist: 1251,
55
- id_images_facilitator: 1286,
56
- id_auditor: 1254,
49
+ id_order: 1973,
50
+ id_datasheet_especialist: null,
51
+ id_datasheet_facilitator: null,
52
+ id_description_especialist: null,
53
+ id_description_facilitator: null,
54
+ id_images_especialist: null,
55
+ id_images_facilitator: null,
56
+ id_auditor: null,
57
57
  id_recepcionist: null,
58
- category: "Navidad|Esferas y Colgantes|Colgantes",
59
- missingAttributes: 3,
60
- missingDescriptions: 0,
61
- missingImages: 0,
58
+ category: "Herramientas|Accesorios para Herramientas Eléctricas|Discos",
59
+ missingAttributes: null,
60
+ missingDescriptions: null,
61
+ missingImages: null,
62
62
  },
63
63
  retailers: [
64
64
  {
@@ -68,9 +68,23 @@ RetailerProductEditionDefault.args = {
68
68
  id_region: 1,
69
69
  active: 1,
70
70
  },
71
+ {
72
+ id: 59,
73
+ name: "The Home Depot Platinum",
74
+ country: "México",
75
+ id_region: 1,
76
+ active: 1,
77
+ },
78
+ {
79
+ id: 61,
80
+ name: "Home Depot TAB",
81
+ country: "México",
82
+ id_region: 1,
83
+ active: 1,
84
+ },
71
85
  ],
72
86
  country: null,
73
- upc: "163963",
87
+ upc: "436882",
74
88
  },
75
89
  location: {
76
90
  product: { articleId: 109485, versionId: 3 },
@@ -106,6 +120,6 @@ RetailerProductEditionDefault.args = {
106
120
  products_limit: "1000",
107
121
  type: "Enterprise",
108
122
  },
109
- src: "https://content-management-profile-prod.s3.amazonaws.com/id-460/460.png?1658943295529",
123
+ src: "https://content-management-profile-prod.s3.amazonaws.com/id-460/460.png?1658444769519",
110
124
  },
111
125
  };
@@ -29,7 +29,6 @@ import { GenericModal } from "../../atoms/GenericModal";
29
29
  import { ScreenHeader } from "../../atoms/ScreenHeader";
30
30
  import { Loading } from "../../atoms/Loading";
31
31
  import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
32
- import { getNewStatus } from "../../../global-files/data";
33
32
  import errorModal from "../../../assets/images/genericModal/errorModal.svg";
34
33
 
35
34
  const reducerImages = (state, action) => {
@@ -182,11 +181,8 @@ export const RetailerProductEdition = ({
182
181
  setServices(services);
183
182
  getServices();
184
183
 
185
- //setActiveRetailer(product?.retailers[0]);
186
- setImages({
187
- action: "init",
188
- init: services[2],
189
- });
184
+ // setActiveRetailer(product?.retailers[0]);
185
+ setImages({ action: "init", init: services[2] });
190
186
  if (services[2]?.values?.length > 0) setActiveImage(0);
191
187
 
192
188
  getPercentage({ data: [product] }).then((res) => setPercentages(res));
@@ -204,24 +200,22 @@ export const RetailerProductEdition = ({
204
200
  );
205
201
  const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
206
202
 
207
- let retailers = product.retailers || product.retailersAvailable;
208
- let active = retailers?.filter((retailer) =>
209
- parsedResponse?.map((srv) => srv.id_retailer).includes(retailer.id)
210
- )[0];
203
+ const retailers = product.retailers || product.retailersAvailable;
204
+ const retailerResponse = parsedResponse?.map((srv) => srv.id_retailer);
205
+ const active = retailers?.find((retailer) =>
206
+ retailerResponse.includes(retailer.id)
207
+ );
211
208
  !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
212
209
  setServicesData(parsedResponse);
213
210
  };
214
211
 
215
212
  const translateConcept = (concept) => {
216
- let translation = "";
217
- if (concept === "datasheet") {
218
- translation = "Ficha técnica";
219
- } else if (concept === "description") {
220
- translation = "Descripción";
221
- } else if (concept === "images") {
222
- translation = "Imágenes";
223
- }
224
- return translation;
213
+ const translation = {
214
+ datasheet: "Ficha técnica",
215
+ description: "Descripción",
216
+ images: "Imágenes",
217
+ };
218
+ return translation[concept];
225
219
  };
226
220
 
227
221
  const getComments = async (tab = "Descripción") => {
@@ -257,14 +251,14 @@ export const RetailerProductEdition = ({
257
251
  switch (user.id_role) {
258
252
  case 7:
259
253
  case 8:
260
- arr = ["IN_PROGRESS", "RF", "RA"];
254
+ arr = ["CA", "RC", "RA"];
261
255
  break;
262
256
  case 4:
263
257
  case 5:
264
- arr = ["RF", "AF", "AA", "AP", "AC"];
258
+ arr = ["RC", "AC", "AA", "AP", "ACA"];
265
259
  break;
266
260
  case 6:
267
- arr = ["RP", "RC", "AF", "RA"];
261
+ arr = ["RP", "RCA", "AC", "RA"];
268
262
  break;
269
263
  default:
270
264
  arr = [];
@@ -390,13 +384,14 @@ export const RetailerProductEdition = ({
390
384
  const saveDescriptions = async () => {
391
385
  setLoading(true);
392
386
  const productTemp = product;
387
+ const articleId = product?.article?.id_article;
393
388
  const dataObject = {
394
- articleId: product?.article?.id_article,
389
+ articleId,
395
390
  articleData: updatedDescriptions,
396
391
  };
397
392
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
398
393
  try {
399
- await axios.put(
394
+ const res = await axios.put(
400
395
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?description=true&version=${version}`,
401
396
  dataObject,
402
397
  {
@@ -405,14 +400,16 @@ export const RetailerProductEdition = ({
405
400
  },
406
401
  }
407
402
  );
408
- if (productTemp.status === "ASSIGNED") {
409
- productTemp.status = "IN_PROGRESS";
403
+ if (res.data.statusCode === 200) {
404
+ const { newStatus, newArticleStatus } = JSON.parse(res.data.body);
405
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
406
+ if (newStatus) productTemp.description_status = newStatus;
410
407
  setProduct(productTemp);
411
408
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
412
- }
413
409
 
414
- setMessage("Descripciones guardadas con éxito");
415
- loadData();
410
+ setMessage("Descripciones guardadas con éxito");
411
+ await loadData();
412
+ }
416
413
  } catch (error) {
417
414
  console.log(error);
418
415
  }
@@ -421,13 +418,14 @@ export const RetailerProductEdition = ({
421
418
  const saveDatasheets = async () => {
422
419
  setLoading(true);
423
420
  const productTemp = product;
421
+ const articleId = product?.article?.id_article;
424
422
  const dataObject = {
425
- articleId: product?.article?.id_article,
423
+ articleId,
426
424
  articleData: updatedDatasheets,
427
425
  };
428
426
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
429
427
  try {
430
- await axios.put(
428
+ const res = await axios.put(
431
429
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?datasheet=true&version=${version}`,
432
430
  dataObject,
433
431
  {
@@ -436,13 +434,16 @@ export const RetailerProductEdition = ({
436
434
  },
437
435
  }
438
436
  );
439
- setMessage("Fichas técnicas guardadas");
440
- if (productTemp.status === "ASSIGNED") {
441
- productTemp.status = "IN_PROGRESS";
437
+ if (res.data.statusCode === 200) {
438
+ const { newStatus, newArticleStatus } = JSON.parse(res.data.body);
439
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
440
+ if (newStatus) productTemp.datasheet_status = newStatus;
442
441
  setProduct(productTemp);
443
442
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
443
+
444
+ setMessage("Fichas técnicas guardadas");
445
+ await loadData();
444
446
  }
445
- loadData();
446
447
  } catch (error) {
447
448
  console.log(error);
448
449
  }
@@ -525,15 +526,6 @@ export const RetailerProductEdition = ({
525
526
  } else {
526
527
  setImagesUploaded(true);
527
528
  }
528
- let productTemp = product;
529
- if (productTemp.status === "ASSIGNED") {
530
- productTemp.status = "IN_PROGRESS";
531
- setProduct(productTemp);
532
- sessionStorage.setItem(
533
- "productSelected",
534
- JSON.stringify(productTemp)
535
- );
536
- }
537
529
  } catch (err) {
538
530
  console.log(err);
539
531
  // setMainLoading(false);
@@ -558,7 +550,7 @@ export const RetailerProductEdition = ({
558
550
  return e;
559
551
  });
560
552
  try {
561
- await axios.put(
553
+ const res = await axios.put(
562
554
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
563
555
  dataImages,
564
556
  {
@@ -567,9 +559,21 @@ export const RetailerProductEdition = ({
567
559
  },
568
560
  }
569
561
  );
570
- setMessage("Imágenes guardadas con éxito");
571
- sessionStorage.removeItem("imagesList");
572
- loadData();
562
+ if (res.data.statusCode === 200) {
563
+ let productTemp = product;
564
+ const { newStatus, newArticleStatus } = JSON.parse(res.data.body);
565
+ if (newArticleStatus)
566
+ productTemp.status = newArticleStatus[articleId];
567
+ if (newStatus) productTemp.images_status = newStatus;
568
+ setProduct(productTemp);
569
+ sessionStorage.setItem(
570
+ "productSelected",
571
+ JSON.stringify(productTemp)
572
+ );
573
+ setMessage("Imágenes guardadas con éxito");
574
+ sessionStorage.removeItem("imagesList");
575
+ await loadData();
576
+ }
573
577
  } catch (error) {
574
578
  console.log(error);
575
579
  }
@@ -578,24 +582,23 @@ export const RetailerProductEdition = ({
578
582
 
579
583
  const evaluationFinished = (userId, tab, statusArray) => {
580
584
  const srv = servicesData.filter((serv) => serv.service === getConcept(tab));
581
- const [srvActive] = srv.filter(
582
- (serv) => serv.id_retailer === activeRetailer?.id
585
+ const srvActive = srv
586
+ .find((serv) => serv.id_retailer === activeRetailer?.id)
587
+ ?.status?.replace(/.*\//, "");
588
+ const currStatus = product[`${getConcept(tab)}_status`]?.replace(
589
+ /.*\//,
590
+ ""
583
591
  );
584
- const unvalidated =
585
- product[`${getConcept(tab)}_status`] === "QF" ||
586
- product[`${getConcept(tab)}_status`] === "IN_PROGRESS";
592
+ const unvalidated = ["IE", "CA"].includes(currStatus);
587
593
 
588
- const auditorUnvalidated = !["RA", "AA", "AC", "AP"].includes(
589
- product[`${getConcept(tab)}_status`]
590
- );
594
+ const auditorUnvalidated = !["RA", "AA", "ACA", "AP"].includes(currStatus);
591
595
 
592
596
  switch (userId) {
593
597
  case 7:
594
598
  case 8:
595
599
  return (
596
- (["RA", "RF"].includes(product?.status) && //"IN_PROGRESS", "RF", "RA"
597
- statusArray.includes(srvActive?.status)) ||
598
- (statusArray.includes(product.status) &&
600
+ statusArray.includes(srvActive) &&
601
+ (["RA", "RC"].includes(product?.status) ||
599
602
  srv.filter((serv) => statusArray.includes(serv.status)).length ===
600
603
  srv.length)
601
604
  );
@@ -603,14 +606,16 @@ export const RetailerProductEdition = ({
603
606
  case 5:
604
607
  return (
605
608
  unvalidated &&
606
- ["IN_PROGRESS", "QF"].includes(product.status) && //"RF", "AF", "AA", "AP", "AC
609
+ ["CA", "IE"].includes(product.status) && // "RC", "AC", "AA", "AP", "ACA"
607
610
  srv.filter((serv) => statusArray.includes(serv.status)).length ===
608
611
  srv.length
609
612
  );
610
613
  case 6:
611
614
  return (
612
- statusArray.includes(product.status) && //RP, RC, AF, RA true
613
- srv.every((serv) => ["RA", "AA", "AP", "AC"].includes(serv.status)) &&
615
+ statusArray.includes(product.status) && // RP, RCA, AC, RA true
616
+ srv.every((serv) =>
617
+ ["RA", "AA", "AP", "ACA"].includes(serv.status)
618
+ ) &&
614
619
  auditorUnvalidated
615
620
  );
616
621
  default:
@@ -632,20 +637,20 @@ export const RetailerProductEdition = ({
632
637
  const approveRejectButtons = (action) => {
633
638
  let concept = getConcept(action || activeTab);
634
639
 
635
- const [retailerStatus] = servicesData.filter(
636
- (srv) => srv.id_retailer === activeRetailer?.id && srv.service === concept
637
- );
638
-
639
- return (
640
- (retailerStatus?.status === "QF" &&
641
- (user.id_role === 1 || user.id_role === 4 || user.id_role === 5)) ||
642
- (retailerStatus?.status === "AF" && //sessionStorage product
643
- (user.id_role === 1 || user.id_role === 6)) ||
644
- (retailerStatus?.status === "RP" &&
645
- (user.id_role === 1 || user.id_role === 6)) ||
646
- (retailerStatus?.status === "RC" &&
647
- (user.id_role === 1 || user.id_role === 6))
648
- );
640
+ const retailerStatus = servicesData
641
+ .find(
642
+ (srv) =>
643
+ srv.id_retailer === activeRetailer?.id && srv.service === concept
644
+ )
645
+ ?.status?.replace(/.*\//, "");
646
+
647
+ //sessionStorage product
648
+ const adminFacilitatorCanEvaluate =
649
+ retailerStatus === "IE" && [1, 4, 5].includes(user.id_role);
650
+ const adminAuditorCanEvaluate =
651
+ ["AC", "RP", "RCA"].includes(retailerStatus) &&
652
+ [1, 6].includes(user.id_role);
653
+ return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
649
654
  };
650
655
 
651
656
  const getSectionIcon = () => {
@@ -669,92 +674,57 @@ export const RetailerProductEdition = ({
669
674
  try {
670
675
  let concept = getConcept(activeTab);
671
676
 
672
- let productTemp = { ...product };
673
- let evalStatus = product[`${concept}_status`];
674
-
675
- let data = {};
677
+ const productTemp = { ...product };
678
+ const evalStatus = retailerStatus;
679
+ const articleId = product.article.id_article;
680
+ const orderId = product.orderId;
681
+
682
+ let data = {
683
+ articleId,
684
+ orderId,
685
+ concept,
686
+ evalStatus,
687
+ retailerId: activeRetailer.id,
688
+ };
689
+ let res;
690
+ let message;
676
691
  if (result) {
677
- data = {
678
- articleId: product.article.id_article,
679
- orderId: product.orderId,
680
- concept: concept,
681
- result: result,
682
- evalStatus: evalStatus,
683
- retailerId: activeRetailer.id,
684
- };
685
-
686
- await axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
687
- headers: {
688
- Authorization: token,
689
- },
690
- });
692
+ data.result = result;
693
+ res = await axios.put(
694
+ `${process.env.REACT_APP_EVALUATION_ENDPOINT}`,
695
+ data,
696
+ {
697
+ headers: {
698
+ Authorization: token,
699
+ },
700
+ }
701
+ );
691
702
  getServices();
692
703
  } else {
693
- const specialistDone =
694
- evalStatus === "RF" ||
695
- evalStatus === "RA" ||
696
- evalStatus === "IN_PROGRESS";
704
+ const specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
697
705
 
698
706
  if (specialistDone) {
699
- setMessage(`${activeTab} enviada a facilitador`);
707
+ message = `${activeTab} enviada a facilitador`;
700
708
  getSectionIcon();
701
- } else if (evalStatus === "QF") {
702
- setMessage("Evaluación enviada");
703
- getSectionIcon();
704
- } else if (evalStatus === "AF") {
705
- setMessage("Evaluación enviada");
706
- getSectionIcon();
707
- } else if (evalStatus === "RP") {
708
- setMessage("Evaluación enviada");
709
- getSectionIcon();
710
- } else if (evalStatus === "RC") {
711
- setMessage("Evaluación enviada");
709
+ } else if (["IE", "AC", "RP", "RCA"].includes(evalStatus)) {
710
+ message = "Evaluación enviada";
712
711
  getSectionIcon();
713
712
  }
714
- let statusArr = [];
715
- servicesData.forEach((srv) => {
716
- srv.service === concept && statusArr.push(srv.status);
717
- });
718
-
719
- productTemp[`${concept}_status`] = getNewStatus(statusArr);
720
-
721
- let newStatus = getNewStatus([
722
- productTemp.datasheet_status,
723
- productTemp.description_status,
724
- productTemp.images_status,
725
- ]);
726
-
727
- productTemp.status = newStatus;
728
-
729
- data = {
730
- articleId: product.article.id_article,
731
- orderId: product.orderId,
732
- concept: concept,
733
- evalStatus: evalStatus,
734
- retailerId: activeRetailer.id,
735
- };
736
-
737
- switch (user.id_role) {
738
- case 7:
739
- case 8:
740
- data.especialist = true;
741
- break;
742
- case 4:
743
- case 5:
744
- data.facilitator = true;
745
- break;
746
- default:
747
- break;
748
- }
749
- await axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
713
+ res = await axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
750
714
  headers: {
751
715
  Authorization: token,
752
716
  },
753
717
  });
754
718
  }
755
- loadData();
756
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
757
- setProduct(productTemp);
719
+ if (res.data.statusCode === 200) {
720
+ const { newStatus, newOrderStatus } = JSON.parse(res.data.body);
721
+ if (newOrderStatus) productTemp.status = newOrderStatus[orderId];
722
+ productTemp[`${concept}_status`] = newStatus;
723
+ await loadData();
724
+ if (message) setMessage(message);
725
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
726
+ setProduct(productTemp);
727
+ }
758
728
  } catch (error) {
759
729
  console.log(error);
760
730
  }
@@ -852,21 +822,23 @@ export const RetailerProductEdition = ({
852
822
 
853
823
  objetcTemp["Ficha técnica"] = dsInputsRequired.length;
854
824
 
825
+ const regex = /(<\/?p>)|(<\/?strong>)|(<br>)/gm;
855
826
  descriptionsServicesArray.forEach((description) => {
856
827
  const [requested] = servicesData.filter(
857
828
  (srv) =>
858
829
  srv.id_retailer === description.id &&
859
830
  srv.service === getConcept(activeTab)
860
831
  );
861
- requested &&
862
- description.inputs.forEach(
863
- (input) =>
832
+ if (requested) {
833
+ description.inputs.forEach((input) => {
834
+ if (
864
835
  input.required &&
865
- (!input.value ||
866
- input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") ===
867
- "") &&
868
- desInputsRequired++
869
- );
836
+ (!input.value || input.value?.replace(regex, "") === "")
837
+ ) {
838
+ desInputsRequired++;
839
+ }
840
+ });
841
+ }
870
842
  });
871
843
 
872
844
  objetcTemp["Descripción"] = desInputsRequired;
@@ -940,12 +912,12 @@ export const RetailerProductEdition = ({
940
912
  },
941
913
  ],
942
914
  concept: concept,
943
- [`${assignationType}Id`]: assignationId,
915
+ userId: assignationId,
944
916
  };
945
- axios({
917
+ await axios({
946
918
  method: "post",
947
919
  url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
948
- data: data,
920
+ data,
949
921
  headers: {
950
922
  Authorization: token,
951
923
  },
@@ -1134,7 +1106,7 @@ export const RetailerProductEdition = ({
1134
1106
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1135
1107
  setProduct(productTemp);
1136
1108
 
1137
- loadData();
1109
+ await loadData();
1138
1110
  } catch (error) {
1139
1111
  console.log(error);
1140
1112
  }
@@ -1212,7 +1184,7 @@ export const RetailerProductEdition = ({
1212
1184
  showApproveRejectAll={
1213
1185
  isAuditor &&
1214
1186
  servicesData.every((serv) =>
1215
- ["RA", "AA", "AP", "AC", "AF"].includes(serv.status)
1187
+ ["RA", "AA", "AP", "ACA", "AC"].includes(serv.status)
1216
1188
  ) &&
1217
1189
  approveRejectButtons() &&
1218
1190
  (auditorAssigned() || userAssigned())
@@ -1255,7 +1227,6 @@ export const RetailerProductEdition = ({
1255
1227
  }}
1256
1228
  />
1257
1229
  <FullTabsMenu
1258
- canAssign={![7, 8].includes(user.id_role)}
1259
1230
  tabsSections={tabsSections}
1260
1231
  status={retailerStatus}
1261
1232
  activeTab={activeTab}
@@ -1406,16 +1377,21 @@ export const RetailerProductEdition = ({
1406
1377
  />
1407
1378
  </div>
1408
1379
  )}
1409
- <Button
1410
- buttonType={
1411
- evaluationFinished(user.id_role, activeTab, statusArray) &&
1412
- requiredNull[activeTab] === 0
1413
- ? "general-green-button"
1414
- : "general-button-disabled"
1415
- }
1416
- label={"Enviar evaluación"}
1417
- onClick={() => sendToFacilitator()}
1418
- />
1380
+ {[7, 8].includes(user.id_role) && (
1381
+ <Button
1382
+ buttonType={
1383
+ evaluationFinished(
1384
+ user.id_role,
1385
+ activeTab,
1386
+ statusArray
1387
+ ) && requiredNull[activeTab] === 0
1388
+ ? "general-green-button"
1389
+ : "general-button-disabled"
1390
+ }
1391
+ label={"Enviar evaluación"}
1392
+ onClick={() => sendToFacilitator()}
1393
+ />
1394
+ )}
1419
1395
  </div>
1420
1396
  )}
1421
1397
  </div>
@@ -195,18 +195,18 @@ export const fetchUsers = async (auth) => {
195
195
  export const getNewStatus = (statusArray) => {
196
196
  let lookupString = "";
197
197
  statusArray.forEach((element) => (lookupString += element + "/"));
198
- if (lookupString.includes("RF")) return "RF";
198
+ if (lookupString.includes("RCA")) return "RCA";
199
+ if (lookupString.includes("RC")) return "RC";
199
200
  if (lookupString.includes("RA")) return "RA";
200
201
  if (lookupString.includes("RP")) return "RP";
201
- if (lookupString.includes("RC")) return "RC";
202
- if (lookupString.includes("UNASSIGNED")) return "IN_PROGRESS";
203
- if (lookupString.includes("IN_PROGRESS")) return "IN_PROGRESS";
204
- if (lookupString.includes("QF")) return "QF";
205
- if (lookupString.includes("AF")) return "AF";
202
+ if (lookupString.includes("ACA")) return "ACA";
203
+ if (lookupString.includes("PA")) return "PA";
204
+ if (lookupString.includes("CA")) return "CA";
205
+ if (lookupString.includes("IE")) return "IE";
206
+ if (lookupString.includes("AC")) return "AC";
206
207
  if (lookupString.includes("AA")) return "AA";
207
208
  if (lookupString.includes("AP")) return "AP";
208
- if (lookupString.includes("AC")) return "AC";
209
- if (lookupString.includes("RECEIVED")) return "RECEIVED";
209
+ if (lookupString.includes("R")) return "R";
210
210
  if (lookupString.includes("NA")) return "NA";
211
211
  return new Error("Status not found");
212
212
  };