contentoh-components-library 21.4.83 → 21.4.85

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 (26) hide show
  1. package/dist/components/atoms/TabSection/styles.js +1 -1
  2. package/dist/components/molecules/ProductNameHeader/index.js +8 -3
  3. package/dist/components/organisms/EditGroup/index.js +0 -11
  4. package/dist/components/organisms/FullProductNameHeader/index.js +3 -1
  5. package/dist/components/organisms/VersionSelector/index.js +101 -169
  6. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +55 -74
  7. package/dist/components/pages/ProviderProductEdition/index.js +88 -66
  8. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +47 -52
  9. package/dist/components/pages/RetailerProductEdition/index.js +101 -177
  10. package/dist/global-files/data.js +11 -26
  11. package/package.json +2 -1
  12. package/src/components/atoms/GeneralButton/styles.js +1 -0
  13. package/src/components/atoms/ObservationFlag/ObservationFlag.stories.js +20 -0
  14. package/src/components/atoms/ObservationFlag/index.js +33 -0
  15. package/src/components/atoms/ObservationFlag/styles.js +3 -0
  16. package/src/components/atoms/TabSection/index.js +1 -1
  17. package/src/components/atoms/TabSection/styles.js +1 -4
  18. package/src/components/molecules/ProductNameHeader/index.js +5 -1
  19. package/src/components/organisms/EditGroup/index.js +0 -8
  20. package/src/components/organisms/FullProductNameHeader/index.js +2 -0
  21. package/src/components/organisms/VersionSelector/index.js +100 -100
  22. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +73 -86
  23. package/src/components/pages/ProviderProductEdition/index.js +38 -23
  24. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +48 -52
  25. package/src/components/pages/RetailerProductEdition/index.js +32 -144
  26. package/src/global-files/data.js +7 -33
@@ -16,64 +16,60 @@ RetailerProductEditionDefault.args = {
16
16
  Imágenes: false,
17
17
  },
18
18
  token:
19
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M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dQk6DGDnvFzXFsaEbaxAPjTfYc491sHCpOjf4W98quBuzDZCRtdCsr9u3A0AnX8Lh1Jquvn83nrHN2ZeefpLyKc-xGGp50Oy6EnJgSK4PcAAV631nwYV9DfVaLb3SIWDrJIIuBjFjBBCXBcnGJBieErlnF-4gumHzsro_QqF-s7aq_3EJChAhfslFvczNSyDc-LXJVkpDuZW3TaYKlHwhoFxz1aMuYRFQ8xy5Pz8FDNKQ",
20
20
  productSelected: {
21
- services: {
22
- datasheets: 1,
23
- descriptions: 1,
24
- images: 1,
25
- },
26
- orderId: 15275,
27
- status: "AC",
28
- datasheet_status: "AC",
21
+ orderId: 15190,
22
+ status: "RA",
23
+ datasheet_status: "NS",
29
24
  prio: "none",
30
25
  version: 3,
31
- description_status: "AC",
32
- images_status: "AC",
33
- statusByRetailer: {
34
- 34: {
35
- datasheet: "AC",
36
- description: "AC",
37
- images: "AC",
38
- },
26
+ description_status: "NS",
27
+ images_status: "RA",
28
+ brand: null,
29
+ retailerOrder: 0,
30
+ missing: {
31
+ datasheet: null,
32
+ descriptions: null,
33
+ images: null,
34
+ },
35
+ services: {
36
+ datasheets: 0,
37
+ descriptions: 0,
38
+ images: 1,
39
39
  },
40
40
  article: {
41
- id_article: 39485,
42
- id_category: "11",
43
- name: "Mix de nueces",
44
- upc: "7543453453",
45
- timestamp: "2023-07-14T21:02:54.000Z",
46
- id_user: 28,
47
- status: "NULL",
48
- active: 1,
49
- company_id: 1,
41
+ category:
42
+ "Abarrotes Básicos|Abarrotes Básicos y Procesados|Abarrotes Básicos y Procesados",
50
43
  company_name: "GRUPO BRAHMA",
51
44
  country: "México",
52
- id_order: 15275,
53
- id_datasheet_especialist: 54,
54
- id_datasheet_facilitator: 52,
55
- id_description_especialist: 54,
56
- id_description_facilitator: 52,
45
+ id_category: "4004",
46
+ id_datasheet_especialist: null,
47
+ id_datasheet_facilitator: null,
48
+ id_description_especialist: null,
49
+ id_description_facilitator: null,
57
50
  id_images_especialist: 55,
58
51
  id_images_facilitator: 53,
52
+ id_order: 15190,
53
+ id_article: 39364,
59
54
  id_auditor: 37,
60
- id_recepcionist: null,
61
- category: "Abarrotes|Abarrotes Secos|Frutos Secos",
62
- missingAttributes: 0,
63
- missingDescriptions: 0,
64
- missingImages: 0,
55
+ name: "test 2 img ba",
56
+ timestamp: "2023-05-05T02:56:16.000Z",
57
+ upc: "4353242",
65
58
  },
66
59
  retailers: [
67
60
  {
68
- id: 34,
69
- name: "San Pablo",
61
+ id: 70,
62
+ name: "Bodega Aurrera",
70
63
  },
71
64
  ],
72
- country: "México",
73
- upc: "7543453453",
65
+ statusByRetailer: {
66
+ 70: {
67
+ images: "RA/AC",
68
+ },
69
+ },
74
70
  },
75
71
  location: {
76
- product: { articleId: 354, versionId: 3 },
72
+ product: { articleId: 39364, versionId: 3 },
77
73
  state: {
78
74
  withChat: true,
79
75
  chatType: "product_status",
@@ -87,7 +83,7 @@ RetailerProductEditionDefault.args = {
87
83
  position: "Auditor",
88
84
  telephone: "",
89
85
  country: "México",
90
- id_company: 2,
86
+ id_company: 254,
91
87
  id_cognito: "9a213128-6482-4c16-a4b6-6e64f225b1bd",
92
88
  birth_Date: null,
93
89
  about_me: "",
@@ -101,16 +97,16 @@ RetailerProductEditionDefault.args = {
101
97
  email_notify: 1,
102
98
  is_user_tech: null,
103
99
  membership: {
104
- id: 2,
105
- start_date: "2021-11-05T02:35:12.000Z",
106
- end_date: "2022-11-05T02:34:49.000Z",
107
- planID: 1,
108
- plan: "prod_KtkvuFFLpOdP6e",
109
- name: "Plan Free",
110
- user_limit: "1",
111
- products_limit: "3",
112
- type: "PyMES",
100
+ id: 137,
101
+ start_date: "2023-10-04T15:46:14.000Z",
102
+ end_date: "2024-10-04T08:46:09.000Z",
103
+ planID: 8,
104
+ plan: "prod_KtlhECVSFG2iro",
105
+ name: "Plan Pro",
106
+ user_limit: "50",
107
+ products_limit: "5000",
108
+ type: "Enterprise",
113
109
  },
114
- src: "https://content-management-profile.s3.amazonaws.com/id-37/37.png?1692750648813",
110
+ src: "https://content-management-profile.s3.amazonaws.com/id-37/37.png?1701902088068",
115
111
  },
116
112
  };
@@ -224,6 +224,7 @@ export const RetailerProductEdition = ({
224
224
  const [auditDescriptions, setAuditDescriptions] = useState([]);
225
225
  const [auditImages, setAuditImages] = useState([]);
226
226
  const [compare, setCompare] = useState(false);
227
+ const [observation,setObservation] = useState();
227
228
  const [valRejAll, setValRejAll] = useState(false);
228
229
 
229
230
  const [desc, setDesc] = useState([]);
@@ -283,7 +284,20 @@ export const RetailerProductEdition = ({
283
284
  getServices();
284
285
  setImages({ action: "init", init: services[2] });
285
286
  if (services[2]?.values?.length > 0) setActiveImage(0);
286
- getPercentage({ data: [product] }).then((res) => setPercentages(res[0]));
287
+ const data = [
288
+ {
289
+ id_article: product.article.id_article,
290
+ id_category: product.article.id_category,
291
+ version: product.version,
292
+ id_retailer_array: (
293
+ product.retailersAvailable ?? product.retailers
294
+ ).map(({ id }) => id),
295
+ },
296
+ ];
297
+ const headers = { Authorization: token };
298
+ getPercentage({ data, headers }).then((res) => {
299
+ setPercentages(res[0]);
300
+ });
287
301
  setLoading(false);
288
302
  } catch (error) {
289
303
  console.log(error);
@@ -439,7 +453,7 @@ export const RetailerProductEdition = ({
439
453
  }, [percentages]);
440
454
 
441
455
  useEffect(() => {
442
- getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
456
+ //getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
443
457
  auditableVersion && loadAuditableData();
444
458
  setActivePercentage(Math.round(activeRetailer?.percentage, 0));
445
459
  activeRetailer?.id &&
@@ -820,84 +834,6 @@ export const RetailerProductEdition = ({
820
834
  }
821
835
  };
822
836
 
823
- // const sendToFacilitator = async (result) => {
824
- // setLoading(true);
825
- // try {
826
- // let concept = getConcept(activeTab);
827
-
828
- // const productTemp = { ...product };
829
- // const evalStatus = retailerStatus;
830
- // const articleId = product.article.id_article;
831
- // const orderId = product.orderId;
832
-
833
- // // const body = {
834
- // // orderArticleRetailers: [
835
- // // { orderId, articleId, retailersIds: [activeRetailer.id] },
836
- // // ],
837
- // // isAproved: false,
838
- // // service: concept,
839
- // // };
840
-
841
- // const body = {
842
- // articleId: product.article.id_article,
843
- // orderId: product.orderId,
844
- // concept: concept,
845
- // result: result,
846
- // evalStatus: evalStatus,
847
- // retailerId: activeRetailer.id,
848
- // };
849
-
850
- // let res;
851
- // let message;
852
- // if (result) {
853
- // body.isAproved = result === "A";
854
- // res = await axios.put(
855
- // `${process.env.REACT_APP_EVALUATION_ENDPOINT}`,
856
- // body,
857
- // {
858
- // headers: {
859
- // Authorization: token,
860
- // },
861
- // }
862
- // );
863
- // console.log(JSON.parse(res.data.body), "res");
864
- // getServices();
865
- // } else {
866
- // const specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
867
-
868
- // if (specialistDone) {
869
- // message = `${activeTab} enviada a facilitador`;
870
- // getSectionIcon();
871
- // } else if (["IE", "AC", "RP", "RCA"].includes(evalStatus)) {
872
- // message = "Evaluación enviada";
873
- // getSectionIcon();
874
- // }
875
- // res = await axios.put(
876
- // `${process.env.REACT_APP_EVALUATION_ENDPOINT}`,
877
- // body,
878
- // {
879
- // headers: {
880
- // Authorization: token,
881
- // },
882
- // }
883
- // );
884
- // }
885
- // if (res.data.statusCode === 200) {
886
- // const response = JSON.parse(res.data.body)?.successfulData;
887
- // const statusObject =
888
- // response[`${orderId}-${articleId}-${activeRetailer.id}`];
889
- // productTemp.status = statusObject["generalStatus"];
890
- // productTemp[`${concept}_status`] = statusObject[`${concept}Status`];
891
- // await loadData();
892
- // if (message) setMessage(message);
893
- // sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
894
- // setProduct(productTemp);
895
- // }
896
- // } catch (error) {
897
- // console.log(error);
898
- // }
899
- // setLoading(false);
900
- // };
901
837
  const sendToFacilitator = async (result) => {
902
838
  setLoading(true);
903
839
  try {
@@ -1287,70 +1223,6 @@ export const RetailerProductEdition = ({
1287
1223
  setSaving(loading);
1288
1224
  }, [loading]);
1289
1225
 
1290
- // const validateAll = async (result) => {
1291
- // try {
1292
- // setLoading(true);
1293
- // const evaluationArray = [];
1294
- // let conceptArray = ["description", "datasheet", "images"];
1295
- // switch (user.id_role) {
1296
- // case 4:
1297
- // conceptArray = ["description", "datasheet"];
1298
- // break;
1299
- // case 5:
1300
- // conceptArray = ["images"];
1301
- // break;
1302
-
1303
- // default:
1304
- // conceptArray = ["description", "datasheet", "images"];
1305
- // break;
1306
- // }
1307
-
1308
- // const isAproved = result === "A";
1309
- // const retailersIds = [];
1310
- // servicesData?.forEach((ret) => {
1311
- // if (!retailersIds.includes(ret.id_retailer))
1312
- // retailersIds.push(ret.id_retailer);
1313
- // });
1314
- // const body = {
1315
- // orderArticleRetailers: [
1316
- // {
1317
- // orderId: product.id_order ?? product.orderId,
1318
- // articleId: product.article.id_article,
1319
- // retailersIds,
1320
- // },
1321
- // ],
1322
- // isAproved,
1323
- // };
1324
- // conceptArray.forEach((concept) => {
1325
- // body.service = concept;
1326
- // evaluationArray.push(
1327
- // axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, body, {
1328
- // headers: {
1329
- // Authorization: token,
1330
- // },
1331
- // })
1332
- // );
1333
- // });
1334
-
1335
- // await Promise.all(evaluationArray);
1336
-
1337
- // const productTemp = product;
1338
- // productTemp.status = `${result}A`;
1339
- // productTemp.datasheet_status =
1340
- // productTemp.datasheet_status === "NA" ? "NA" : `${result}A`;
1341
- // productTemp.description_status =
1342
- // productTemp.description_status === "NA" ? "NA" : `${result}A`;
1343
- // productTemp.images_status =
1344
- // productTemp.images_status === "NA" ? "NA" : `${result}A`;
1345
- // sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1346
- // setProduct(productTemp);
1347
-
1348
- // await loadData();
1349
- // } catch (error) {
1350
- // console.log(error);
1351
- // }
1352
- // };
1353
-
1354
1226
  const validateAll = async (result) => {
1355
1227
  try {
1356
1228
  setLoading(true);
@@ -1410,6 +1282,21 @@ export const RetailerProductEdition = ({
1410
1282
  }
1411
1283
  };
1412
1284
 
1285
+ const getObservation = async () => {
1286
+ const response = await axios.get(
1287
+ `${process.env.REACT_APP_READ_OBSERVATION}?articleId=${product.article.id_article}&orderId=${product?.orderId}`,
1288
+ {
1289
+ headers: {
1290
+ Authorization: sessionStorage.getItem("jwt"),
1291
+ },
1292
+ }
1293
+ );
1294
+ const parseData = JSON.parse(response.data.body).data[0];
1295
+ setObservation( parseData.observations);
1296
+ };
1297
+ useEffect(() => {
1298
+ getObservation();
1299
+ }, []);
1413
1300
  return (
1414
1301
  <Container headerTop={headerTop}>
1415
1302
  <HeaderTop
@@ -1452,6 +1339,7 @@ export const RetailerProductEdition = ({
1452
1339
  <div className="product-information">
1453
1340
  <FullProductNameHeader
1454
1341
  headerData={product}
1342
+ productObservation= {observation}
1455
1343
  percent={activePercentage}
1456
1344
  activeRetailer={activeRetailer}
1457
1345
  servicesData={servicesData}
@@ -88,43 +88,17 @@ export const getImage = (imageGeneral, width = 250, height = 250) => {
88
88
 
89
89
  export const getPercentage = async (params = {}) => {
90
90
  const func = async () => {
91
- const dataToSend = [];
92
- const arrayRetailers = [];
93
- let retailers =
94
- params.data[0].retailers || params.data[0].retailersAvailable;
95
- params.data.forEach((product, i) => {
96
- dataToSend.push(
97
- product.article
98
- ? {
99
- id_article: product.article.id_article,
100
- id_category: product.article.id_category,
101
- version: product.version,
102
- }
103
- : {
104
- id_article: product.id_article,
105
- id_category: product.id_category,
106
- version: product.version,
107
- }
108
- );
109
- retailers.forEach((retailer) => {
110
- arrayRetailers.push(retailer.id);
111
- });
112
- dataToSend[i].id_retailer_array = arrayRetailers;
113
- });
114
-
91
+ const headers = {
92
+ Authorization:
93
+ params?.headers?.Authorization ?? sessionStorage.getItem("jwt"),
94
+ };
115
95
  return await axios
116
96
  .post(
117
97
  process.env.REACT_APP_VALID_EXPORT_ENDPOINT,
118
- { data: dataToSend },
119
- {
120
- headers: {
121
- Authorization: sessionStorage.getItem("jwt"),
122
- },
123
- }
98
+ { data: params.data },
99
+ { headers }
124
100
  )
125
- .then((response) => {
126
- return [response.data];
127
- })
101
+ .then((response) => [response.data])
128
102
  .catch((err) => console.log(err, "Errror"));
129
103
  };
130
104