contentoh-components-library 21.4.82 → 21.4.83

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/molecules/ProductNameHeader/index.js +3 -8
  2. package/dist/components/organisms/EditGroup/index.js +0 -3
  3. package/dist/components/organisms/FullProductNameHeader/index.js +1 -3
  4. package/dist/components/organisms/VersionSelector/index.js +169 -101
  5. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +38 -34
  6. package/dist/components/pages/ProviderProductEdition/index.js +53 -71
  7. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +52 -47
  8. package/dist/components/pages/RetailerProductEdition/index.js +177 -101
  9. package/dist/global-files/data.js +26 -11
  10. package/package.json +1 -2
  11. package/src/components/atoms/GeneralButton/styles.js +0 -1
  12. package/src/components/atoms/TabSection/index.js +1 -1
  13. package/src/components/molecules/ProductNameHeader/index.js +1 -5
  14. package/src/components/organisms/EditGroup/index.js +1 -3
  15. package/src/components/organisms/FullProductNameHeader/index.js +0 -2
  16. package/src/components/organisms/VersionSelector/index.js +100 -100
  17. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +29 -39
  18. package/src/components/pages/ProviderProductEdition/index.js +21 -34
  19. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +52 -48
  20. package/src/components/pages/RetailerProductEdition/index.js +144 -32
  21. package/src/global-files/data.js +33 -7
  22. package/src/components/atoms/ObservationFlag/ObservationFlag.stories.js +0 -20
  23. package/src/components/atoms/ObservationFlag/index.js +0 -33
  24. package/src/components/atoms/ObservationFlag/styles.js +0 -3
@@ -224,7 +224,6 @@ 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();
228
227
  const [valRejAll, setValRejAll] = useState(false);
229
228
 
230
229
  const [desc, setDesc] = useState([]);
@@ -284,20 +283,7 @@ export const RetailerProductEdition = ({
284
283
  getServices();
285
284
  setImages({ action: "init", init: services[2] });
286
285
  if (services[2]?.values?.length > 0) setActiveImage(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
- });
286
+ getPercentage({ data: [product] }).then((res) => setPercentages(res[0]));
301
287
  setLoading(false);
302
288
  } catch (error) {
303
289
  console.log(error);
@@ -453,7 +439,7 @@ export const RetailerProductEdition = ({
453
439
  }, [percentages]);
454
440
 
455
441
  useEffect(() => {
456
- //getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
442
+ getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
457
443
  auditableVersion && loadAuditableData();
458
444
  setActivePercentage(Math.round(activeRetailer?.percentage, 0));
459
445
  activeRetailer?.id &&
@@ -834,6 +820,84 @@ export const RetailerProductEdition = ({
834
820
  }
835
821
  };
836
822
 
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
+ // };
837
901
  const sendToFacilitator = async (result) => {
838
902
  setLoading(true);
839
903
  try {
@@ -1223,6 +1287,70 @@ export const RetailerProductEdition = ({
1223
1287
  setSaving(loading);
1224
1288
  }, [loading]);
1225
1289
 
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
+
1226
1354
  const validateAll = async (result) => {
1227
1355
  try {
1228
1356
  setLoading(true);
@@ -1282,21 +1410,6 @@ export const RetailerProductEdition = ({
1282
1410
  }
1283
1411
  };
1284
1412
 
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
- }, []);
1300
1413
  return (
1301
1414
  <Container headerTop={headerTop}>
1302
1415
  <HeaderTop
@@ -1339,7 +1452,6 @@ export const RetailerProductEdition = ({
1339
1452
  <div className="product-information">
1340
1453
  <FullProductNameHeader
1341
1454
  headerData={product}
1342
- productObservation= {observation}
1343
1455
  percent={activePercentage}
1344
1456
  activeRetailer={activeRetailer}
1345
1457
  servicesData={servicesData}
@@ -88,17 +88,43 @@ export const getImage = (imageGeneral, width = 250, height = 250) => {
88
88
 
89
89
  export const getPercentage = async (params = {}) => {
90
90
  const func = async () => {
91
- const headers = {
92
- Authorization:
93
- params?.headers?.Authorization ?? sessionStorage.getItem("jwt"),
94
- };
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
+
95
115
  return await axios
96
116
  .post(
97
117
  process.env.REACT_APP_VALID_EXPORT_ENDPOINT,
98
- { data: params.data },
99
- { headers }
118
+ { data: dataToSend },
119
+ {
120
+ headers: {
121
+ Authorization: sessionStorage.getItem("jwt"),
122
+ },
123
+ }
100
124
  )
101
- .then((response) => [response.data])
125
+ .then((response) => {
126
+ return [response.data];
127
+ })
102
128
  .catch((err) => console.log(err, "Errror"));
103
129
  };
104
130
 
@@ -1,20 +0,0 @@
1
- import { ObservationFlag } from "./index";
2
-
3
- export default {
4
- title: "Components/atoms/ObservationFlag",
5
- component: ObservationFlag,
6
- argTypes: {
7
- observation: {
8
- options: ["no priority", "low", "medium", "high"],
9
- control: { type: "select" },
10
- },
11
- },
12
- };
13
-
14
- const Template = (args) => <ObservationFlag {...args} />;
15
-
16
- export const PriorityFlagDefault = Template.bind({});
17
-
18
- PriorityFlagDefault.args = {
19
- observation: "no observation",
20
- };
@@ -1,33 +0,0 @@
1
- import { Container } from "./styles";
2
- import { Tooltip } from "../Tooltip";
3
- import without from "../../../assets/images/flags/noPriority.svg";
4
- import high from "../../../assets/images/flags/highPriority.svg";
5
- import medium from "../../../assets/images/flags/mediumPriority.svg";
6
- import low from "../../../assets/images/flags/lowPriority.svg";
7
-
8
- export const ObservationFlag = ({ observation,contentObservation }) => {
9
- const PriorityFlags = {
10
- ["none"]: without,
11
- ["low"]: low,
12
- ["medium"]: medium,
13
- ["high"]: high,
14
- };
15
- return (
16
- <Tooltip
17
- componentTooltip={
18
- <>
19
- <p>
20
- <b>Observaciones del producto</b>
21
- </p>
22
- <p>{contentObservation} </p>
23
- </>
24
- }
25
- children={
26
- <Container>
27
- <img src={PriorityFlags[observation]} alt={observation} />
28
- </Container>
29
- }
30
- classNameTooltip={"container-tooltip"}
31
- />
32
- );
33
- };
@@ -1,3 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- export const Container = styled.div``;