contentoh-components-library 20.0.0 → 21.0.2

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 (35) hide show
  1. package/dist/components/atoms/GeneralInput/index.js +1 -1
  2. package/dist/components/atoms/GenericModal/styles.js +1 -1
  3. package/dist/components/atoms/InputFormatter/index.js +3 -2
  4. package/dist/components/atoms/LabelToInput/index.js +0 -1
  5. package/dist/components/atoms/LabelToInput/style.js +1 -1
  6. package/dist/components/atoms/Loading/index.js +26 -0
  7. package/dist/components/atoms/Loading/styles.js +22 -0
  8. package/dist/components/atoms/ScreenHeader/index.js +1 -1
  9. package/dist/components/atoms/ScreenHeader/styles.js +1 -1
  10. package/dist/components/atoms/StatusTag/index.js +37 -2
  11. package/dist/components/atoms/StatusTag/styles.js +1 -1
  12. package/dist/components/molecules/StatusAsignationInfo/index.js +1 -1
  13. package/dist/components/molecules/TableHeader/index.js +1 -1
  14. package/dist/components/molecules/TableHeader/styles.js +1 -1
  15. package/dist/components/organisms/ImageDataTable/index.js +10 -10
  16. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +11 -1
  17. package/dist/components/pages/RetailerProductEdition/index.js +129 -122
  18. package/package.json +1 -1
  19. package/src/components/atoms/GeneralInput/index.js +2 -2
  20. package/src/components/atoms/GenericModal/styles.js +4 -0
  21. package/src/components/atoms/InputFormatter/index.js +5 -3
  22. package/src/components/atoms/LabelToInput/index.js +0 -1
  23. package/src/components/atoms/LabelToInput/style.js +5 -2
  24. package/src/components/atoms/Loading/index.js +12 -0
  25. package/src/components/atoms/Loading/styles.js +57 -0
  26. package/src/components/atoms/ScreenHeader/index.js +7 -3
  27. package/src/components/atoms/ScreenHeader/styles.js +9 -2
  28. package/src/components/atoms/StatusTag/index.js +30 -2
  29. package/src/components/atoms/StatusTag/styles.js +2 -1
  30. package/src/components/molecules/StatusAsignationInfo/index.js +1 -1
  31. package/src/components/molecules/TableHeader/index.js +1 -1
  32. package/src/components/molecules/TableHeader/styles.js +5 -0
  33. package/src/components/organisms/ImageDataTable/index.js +18 -7
  34. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +11 -1
  35. package/src/components/pages/RetailerProductEdition/index.js +97 -92
@@ -8,12 +8,16 @@ export const ScreenHeader = ({
8
8
  color,
9
9
  headerType,
10
10
  Paragraph,
11
-
12
11
  }) => {
13
12
  return (
14
- <Container fontFamily={fontFamily} color={color} className={headerType} key={`title-${text}`}>
13
+ <Container
14
+ fontFamily={fontFamily}
15
+ color={color}
16
+ className={headerType}
17
+ key={`title-${text}`}
18
+ >
15
19
  {text} {boldText && <span> {boldText}</span>}
16
- {<p>{Paragraph}</p>}
20
+ {Paragraph && <p>{Paragraph}</p>}
17
21
  </Container>
18
22
  );
19
23
  };
@@ -52,6 +52,11 @@ export const Container = styled.h2`
52
52
  font-weight: 400;
53
53
  font-size: 11px;
54
54
  line-height: 18px;
55
+
56
+ &:last-child {
57
+ min-width: 50px;
58
+ text-align: center;
59
+ }
55
60
  }
56
61
 
57
62
  &.gray-table-row {
@@ -63,12 +68,14 @@ export const Container = styled.h2`
63
68
  background-color: ${GlobalColors.s2};
64
69
  padding: 1px 3px;
65
70
  border-radius: 3px;
71
+ min-width: 50px;
72
+ text-align: center;
66
73
  }
67
- &.header-and-paragraph{
74
+ &.header-and-paragraph {
68
75
  font-family: ${FontFamily.Raleway};
69
76
  font-size: 36px;
70
77
  color: ${GlobalColors.s5};
71
- p{
78
+ p {
72
79
  font-family: ${FontFamily.AvenirNext};
73
80
  font-size: 14px;
74
81
  color: ${GlobalColors.s4};
@@ -1,9 +1,37 @@
1
1
  import { Container } from "./styles";
2
2
 
3
3
  export const StatusTag = ({ statusType, ovalForm }) => {
4
+ const getShortStatus = (status) => {
5
+ switch (status) {
6
+ case "COMPLETED":
7
+ return "C";
8
+ case "RECEPTION":
9
+ return "Pr";
10
+ case "NULL":
11
+ return "-";
12
+ case "RECEIVED":
13
+ return "Rc";
14
+ case "IN_PROGRESS":
15
+ return "P";
16
+ case "ASSIGNED":
17
+ return "As";
18
+ case "APPROVED":
19
+ return "Ap";
20
+ case "VALIDATING":
21
+ return "V";
22
+ case "PAID_OUT":
23
+ return "Po";
24
+ default:
25
+ return status;
26
+ }
27
+ };
4
28
  return (
5
- <Container className={`status-${statusType} ${ovalForm && "oval-form"}`}>
6
- <p>{statusType}</p>
29
+ <Container
30
+ className={`status-${getShortStatus(statusType)} ${
31
+ ovalForm && "oval-form"
32
+ }`}
33
+ >
34
+ <p>{getShortStatus(statusType)}</p>
7
35
  </Container>
8
36
  );
9
37
  };
@@ -2,7 +2,8 @@ import styled from "styled-components";
2
2
  import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
3
 
4
4
  export const Container = styled.div`
5
- width: 30px;
5
+ width: fit-content;
6
+ padding: 0 10px;
6
7
  height: 20px;
7
8
  background-color: ${GlobalColors.s3};
8
9
  border-radius: 3px;
@@ -121,7 +121,7 @@ export const StatusAsignationInfo = ({
121
121
  <p className="no-asignations">Sin personas para asignar</p>
122
122
  )}
123
123
  </div>
124
- {isRetailer === 0 && (
124
+ {isRetailer === 1 && (
125
125
  <div className="default-asignations-list">
126
126
  <AsignationOption
127
127
  asignationType={"provider"}
@@ -14,7 +14,7 @@ export const TableHeader = ({
14
14
  return (
15
15
  <Container>
16
16
  <ScreenHeader
17
- text={activeImage?.name}
17
+ text={activeImage?.name || "-"}
18
18
  color={GlobalColors.s5}
19
19
  headerType={"input-name-header"}
20
20
  />
@@ -7,6 +7,11 @@ export const Container = styled.div`
7
7
  padding-bottom: 5px;
8
8
  border-bottom: 1px solid ${GlobalColors.s2};
9
9
 
10
+ .input-name-header {
11
+ overflow: auto;
12
+ max-width: 40%;
13
+ white-space: nowrap;
14
+ }
10
15
  .status-asignation-info {
11
16
  display: flex;
12
17
  align-items: center;
@@ -31,7 +31,8 @@ export const ImageDataTable = ({
31
31
  <ScreenHeader
32
32
  headerType={"table-row-text gray-table-row"}
33
33
  text={
34
- lists?.inputs?.find((f) => f.id === +activeImage?.image_id)?.name
34
+ lists?.inputs?.find((f) => f.id === +activeImage?.image_id)?.name ||
35
+ "-"
35
36
  }
36
37
  />
37
38
  </Row>
@@ -42,7 +43,7 @@ export const ImageDataTable = ({
42
43
  text={
43
44
  lists?.imagePackagingType?.find(
44
45
  (f) => f.id === +activeImage?.packing_type
45
- )?.name
46
+ )?.name || "-"
46
47
  }
47
48
  />
48
49
  </Row>
@@ -52,26 +53,36 @@ export const ImageDataTable = ({
52
53
  headerType={"table-row-text gray-table-row"}
53
54
  text={
54
55
  lists?.imageType?.find((f) => f.id === +activeImage?.image_type)
55
- ?.name
56
+ ?.name || "-"
56
57
  }
57
58
  />
58
59
  </Row>
59
60
  <Row>
60
61
  <ScreenHeader headerType={"table-row-text"} text="Formato" />
61
- <ScreenHeader headerType={"table-row-text"} text={activeImage?.ext} />
62
+ <ScreenHeader
63
+ headerType={"table-row-text"}
64
+ text={activeImage?.ext || "-"}
65
+ />
62
66
  </Row>
63
67
  <Row>
64
68
  <ScreenHeader headerType={"table-row-text"} text="Tamaño de imagen" />
65
69
  <ScreenHeader
66
70
  headerType={"table-row-text"}
67
- text={`${activeImage?.width}x${activeImage?.height}px`}
71
+ text={
72
+ activeImage?.width && activeImage.height
73
+ ? `${activeImage?.width}x${activeImage?.height}px`
74
+ : "-"
75
+ }
68
76
  />
69
77
  </Row>
70
78
  {retailerSelected &&
71
79
  lists?.attrForImgs &&
72
80
  lists?.attrForImgs[retailerSelected]?.map((attr, index) => (
73
81
  <Row key={"row-" + index}>
74
- <ScreenHeader headerType={"table-row-text"} text={attr?.name} />
82
+ <ScreenHeader
83
+ headerType={"table-row-text"}
84
+ text={attr?.name || "-"}
85
+ />
75
86
  <LabelToInput
76
87
  width="100px"
77
88
  defaultValue={attr?.value}
@@ -80,7 +91,7 @@ export const ImageDataTable = ({
80
91
  action: "changeAttrValue",
81
92
  retailer: retailerSelected,
82
93
  index,
83
- value: e.target.value,
94
+ value: e.target.value || "-",
84
95
  });
85
96
  }}
86
97
  />
@@ -105,7 +105,17 @@ RetailerProductEditionDefault.args = {
105
105
  },
106
106
  ],
107
107
  country: "Colombia",
108
- upc: "7491989462",
108
+ modal: false,
109
+ modalCadenas: false,
110
+ totalCadenas: false,
111
+ modalAsig1: false,
112
+ modalFD: false,
113
+ modalAsig2: false,
114
+ modalAsig3: false,
115
+ modalAsig4: false,
116
+ modalAsig5: false,
117
+ modalFI: false,
118
+ modalQA: false,
109
119
  },
110
120
  user: {
111
121
  id_user: 30,
@@ -27,6 +27,8 @@ import { Button } from "../../atoms/GeneralButton";
27
27
  import { Commentary } from "../../atoms/Commentary";
28
28
  import { GenericModal } from "../../atoms/GenericModal";
29
29
  import { ScreenHeader } from "../../atoms/ScreenHeader";
30
+ import { Loading } from "../../atoms/Loading";
31
+ import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
30
32
 
31
33
  const reducerImages = (state, action) => {
32
34
  let { values, attrForImgs } = state;
@@ -135,6 +137,7 @@ export const RetailerProductEdition = ({
135
137
  const [componentsArray, setComponentsArray] = useState([]);
136
138
  const [checkAll, setCheckAll] = useState(false);
137
139
  const isRetailer = user?.is_retailer;
140
+ const [loading, setLoading] = useState(true);
138
141
  useEffect(() => {
139
142
  checkAll && setSelectedImages(images.values);
140
143
  }, [checkAll]);
@@ -155,6 +158,7 @@ export const RetailerProductEdition = ({
155
158
  });
156
159
  if (services[2]?.values?.length > 0) setActiveImage(0);
157
160
  setProduct(productSelected);
161
+ setLoading(false);
158
162
  };
159
163
 
160
164
  const getServices = async (tab) => {
@@ -294,9 +298,10 @@ export const RetailerProductEdition = ({
294
298
  useEffect(() => {
295
299
  const required = {};
296
300
  if (services.length > 0) {
297
- services[0][activeRetailer.id].data = Object.values(
298
- services[0][activeRetailer.id].data
299
- );
301
+ if (services[0][activeRetailer.id])
302
+ services[0][activeRetailer.id].data = Object.values(
303
+ services[0][activeRetailer.id].data
304
+ );
300
305
  setActivePercentage(Math.round(activeRetailer?.percentage, 0));
301
306
  const datagroups = services[0][activeRetailer?.id];
302
307
  const inputs = services[0]?.inputs;
@@ -307,7 +312,7 @@ export const RetailerProductEdition = ({
307
312
  setDatasheets([datagroups, inputs]);
308
313
  setDescriptions(descriptions);
309
314
  }
310
- }, [activeRetailer]);
315
+ }, [activeRetailer, services]);
311
316
 
312
317
  const thumbs = () => {
313
318
  const imageInputs = images?.inputs?.map((e) => ({
@@ -341,10 +346,13 @@ export const RetailerProductEdition = ({
341
346
  };
342
347
 
343
348
  const saveDescriptions = async () => {
349
+ setLoading(true);
344
350
  const dataObject = {
345
351
  articleId: productSelected?.article?.id_article,
346
352
  articleData: updatedDescriptions,
347
353
  };
354
+ if (productSelected?.orderId)
355
+ dataObject["orderId"] = productSelected?.orderId;
348
356
  try {
349
357
  await axios.put(
350
358
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?description=true&version=${version}`,
@@ -356,16 +364,20 @@ export const RetailerProductEdition = ({
356
364
  }
357
365
  );
358
366
  setMessage("Descripciones guardadas con éxito");
367
+ loadData();
359
368
  } catch (error) {
360
369
  console.log(error);
361
370
  }
362
371
  };
363
372
 
364
373
  const saveDatasheets = async () => {
374
+ setLoading(true);
365
375
  const dataObject = {
366
376
  articleId: productSelected?.article?.id_article,
367
377
  articleData: updatedDatasheets,
368
378
  };
379
+ if (productSelected?.orderId)
380
+ dataObject["orderId"] = productSelected?.orderId;
369
381
  try {
370
382
  await axios.put(
371
383
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?datasheet=true&version=${version}`,
@@ -376,7 +388,8 @@ export const RetailerProductEdition = ({
376
388
  },
377
389
  }
378
390
  );
379
- setMessage("Fichas técnicas guardadas con éxito");
391
+ setMessage("Fichas técnicas guardadas");
392
+ loadData();
380
393
  } catch (error) {
381
394
  console.log(error);
382
395
  }
@@ -404,6 +417,7 @@ export const RetailerProductEdition = ({
404
417
  articleData: imagesList?.filter((e) => !e.id),
405
418
  updateImages: imagesList?.filter((e) => e.id),
406
419
  };
420
+ if (productSelected?.orderId) data["orderId"] = productSelected?.orderId;
407
421
  let valid =
408
422
  data?.articleData?.length === 0
409
423
  ? true
@@ -463,11 +477,13 @@ export const RetailerProductEdition = ({
463
477
 
464
478
  useEffect(async () => {
465
479
  if (imagesUploaded) {
480
+ setLoading(true);
466
481
  dataImages.articleData = dataImages?.articleData.map((e) => {
467
482
  delete e.src;
468
483
  e.imageID = e.image_id;
469
484
  e.packingType = e.packing_type;
470
485
  e.imageType = e.image_type;
486
+ if (productSelected?.orderId) e["orderId"] = productSelected?.orderId;
471
487
  return e;
472
488
  });
473
489
  try {
@@ -481,6 +497,7 @@ export const RetailerProductEdition = ({
481
497
  }
482
498
  );
483
499
  setMessage("Imágenes guardadas con éxito");
500
+ loadData();
484
501
  } catch (error) {
485
502
  console.log(error);
486
503
  }
@@ -713,31 +730,6 @@ export const RetailerProductEdition = ({
713
730
  return productSelected?.article[`id_auditor`] === user.id_user;
714
731
  };
715
732
 
716
- function specialistValid(tab) {
717
- let concept = "";
718
- switch (tab) {
719
- case "Ficha técnica":
720
- concept = "datasheet";
721
- break;
722
- case "Imágenes":
723
- concept = "images";
724
- break;
725
-
726
- default:
727
- concept = "description";
728
- break;
729
- }
730
- return (
731
- product[`${concept}_status`] === "IN_PROGRESS" ||
732
- product[`${concept}_status`] === "RF" ||
733
- product[`${concept}_status`] === "RA"
734
- );
735
- }
736
-
737
- function versionMatch() {
738
- return productSelected?.version === version;
739
- }
740
-
741
733
  const createComment = async (e, body, tab) => {
742
734
  let concept = "";
743
735
  switch (activeTab) {
@@ -915,6 +907,7 @@ export const RetailerProductEdition = ({
915
907
  headers: { Authorization: token },
916
908
  }
917
909
  );
910
+ loadData();
918
911
  } catch (err) {
919
912
  console.log(err);
920
913
  }
@@ -967,7 +960,9 @@ export const RetailerProductEdition = ({
967
960
  imagesStatus={productSelected?.images_status}
968
961
  setAssignation={setAssignation}
969
962
  isRetailer={isRetailer}
970
- onClickSave={() => updateImages()}
963
+ onClickSave={() =>
964
+ product?.services?.images === 1 && updateImages()
965
+ }
971
966
  />
972
967
  </div>
973
968
  <div className="product-information">
@@ -984,16 +979,8 @@ export const RetailerProductEdition = ({
984
979
  <FullTabsMenu
985
980
  tabsSections={tabsSections}
986
981
  status={{
987
- Descripción: servicesData.filter(
988
- (service) =>
989
- service.id_retailer === activeRetailer?.id &&
990
- service.service === "description"
991
- )[0]?.status,
992
- "Ficha técnica": servicesData.filter(
993
- (service) =>
994
- service.id_retailer === activeRetailer?.id &&
995
- service.service === "datasheet"
996
- )[0]?.status,
982
+ Descripción: product?.description_status,
983
+ "Ficha técnica": product?.datasheet_status,
997
984
  Imágenes: product?.images_status,
998
985
  }}
999
986
  activeTab={activeTab}
@@ -1013,7 +1000,7 @@ export const RetailerProductEdition = ({
1013
1000
  saveDatasheets();
1014
1001
  break;
1015
1002
  case "Imágenes":
1016
- updateImages();
1003
+ product?.services?.images === 1 && updateImages();
1017
1004
  break;
1018
1005
 
1019
1006
  default:
@@ -1027,56 +1014,73 @@ export const RetailerProductEdition = ({
1027
1014
  (imageLayout && activeTab === "Imágenes" ? "image-services" : "")
1028
1015
  }
1029
1016
  >
1030
- {!imageLayout && activeTab === "Imágenes" && (
1031
- <GalleryHeader
1032
- setSelectedImages={setSelectedImages}
1033
- checkAll={checkAll}
1034
- setCheckAll={setCheckAll}
1035
- />
1036
- )}
1037
- {activeTab === "Ficha técnica" &&
1038
- (product?.services?.datasheets === 1 ? (
1039
- datasheets[0]?.data?.map((dataGroup, index) => (
1040
- <InputGroup
1041
- key={index + "-" + activeRetailer.name}
1042
- articleId={productSelected.article.id_article}
1043
- version={version}
1044
- activeSection={activeTab}
1045
- inputGroup={dataGroup}
1046
- dataInputs={datasheets[1]}
1047
- updatedDatasheets={updatedDatasheets}
1048
- setUpdatedDatasheets={setUpdatedDatasheets}
1049
- />
1050
- ))
1051
- ) : (
1052
- <p>no tienes este servicio</p>
1053
- ))}
1054
- {activeTab === "Descripción" &&
1055
- (product?.services?.descriptions === 1 ? (
1056
- <InputGroup
1057
- activeSection={activeTab}
1058
- inputGroup={descriptions[0]}
1059
- updatedDescriptions={updatedDescriptions}
1060
- setUpdatedDescriptions={setUpdatedDescriptions}
1061
- articleId={product?.article?.id_article}
1062
- version={version}
1063
- dinamicHeight={true}
1064
- />
1065
- ) : (
1066
- <p>no tienes este servicio</p>
1067
- ))}
1017
+ {loading ? (
1018
+ <Loading />
1019
+ ) : (
1020
+ <>
1021
+ {!imageLayout &&
1022
+ activeTab === "Imágenes" &&
1023
+ product?.services?.images === 1 && (
1024
+ <GalleryHeader
1025
+ setSelectedImages={setSelectedImages}
1026
+ checkAll={checkAll}
1027
+ setCheckAll={setCheckAll}
1028
+ />
1029
+ )}
1030
+ {activeTab === "Ficha técnica" &&
1031
+ (product?.services?.datasheets === 1 ? (
1032
+ datasheets[0]?.data?.map((dataGroup, index) => (
1033
+ <InputGroup
1034
+ key={index + "-" + activeRetailer.name}
1035
+ articleId={productSelected.article.id_article}
1036
+ version={version}
1037
+ activeSection={activeTab}
1038
+ inputGroup={dataGroup}
1039
+ dataInputs={datasheets[1]}
1040
+ updatedDatasheets={updatedDatasheets}
1041
+ setUpdatedDatasheets={setUpdatedDatasheets}
1042
+ />
1043
+ ))
1044
+ ) : (
1045
+ <ScreenHeader
1046
+ text={"No cuentas con este servicio"}
1047
+ headerType={"input-name-header"}
1048
+ />
1049
+ ))}
1050
+ {activeTab === "Descripción" &&
1051
+ (product?.services?.descriptions === 1 ? (
1052
+ <InputGroup
1053
+ activeSection={activeTab}
1054
+ inputGroup={descriptions[0]}
1055
+ updatedDescriptions={updatedDescriptions}
1056
+ setUpdatedDescriptions={setUpdatedDescriptions}
1057
+ articleId={product?.article?.id_article}
1058
+ version={version}
1059
+ dinamicHeight={true}
1060
+ />
1061
+ ) : (
1062
+ <ScreenHeader
1063
+ text={"No cuentas con este servicio"}
1064
+ headerType={"input-name-header"}
1065
+ />
1066
+ ))}
1068
1067
 
1069
- {activeTab === "Imágenes" &&
1070
- (product?.services?.images === 1 ? (
1071
- <section className="container">
1072
- <div {...getRootProps({ className: "dropzone" })}>
1073
- <input {...getInputProps()} />
1074
- <aside>{thumbs()}</aside>
1075
- </div>
1076
- </section>
1077
- ) : (
1078
- <p>no tienes este servicio</p>
1079
- ))}
1068
+ {activeTab === "Imágenes" &&
1069
+ (product?.services?.images === 1 ? (
1070
+ <section className="container">
1071
+ <div {...getRootProps({ className: "dropzone" })}>
1072
+ <input {...getInputProps()} />
1073
+ <aside>{thumbs()}</aside>
1074
+ </div>
1075
+ </section>
1076
+ ) : (
1077
+ <ScreenHeader
1078
+ text={"No cuentas con este servicio"}
1079
+ headerType={"input-name-header"}
1080
+ />
1081
+ ))}
1082
+ </>
1083
+ )}
1080
1084
  </div>
1081
1085
  {(userAssigned(activeTab, "especialist" || "facilitator") ||
1082
1086
  auditorAssigned()) && (
@@ -1147,11 +1151,12 @@ export const RetailerProductEdition = ({
1147
1151
  )}
1148
1152
  {message.length > 0 && (
1149
1153
  <GenericModal
1150
- buttonType={"delete-product"}
1154
+ buttonType={componentsArray.length > 0 && "delete-product"}
1151
1155
  componentsArray={
1152
1156
  componentsArray.length > 0
1153
1157
  ? componentsArray
1154
1158
  : [
1159
+ <img src={succes} alt="success icon" />,
1155
1160
  <ScreenHeader
1156
1161
  key="1"
1157
1162
  headerType={"retailer-name-header"}