contentoh-components-library 21.3.21 → 21.3.23

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 (52) hide show
  1. package/.env.development +1 -2
  2. package/dist/assets/fonts/roboto/Roboto-Black.ttf +0 -0
  3. package/dist/assets/fonts/roboto/Roboto-BlackItalic.ttf +0 -0
  4. package/dist/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  5. package/dist/assets/fonts/roboto/Roboto-BoldItalic.ttf +0 -0
  6. package/dist/assets/fonts/roboto/Roboto-Italic.ttf +0 -0
  7. package/dist/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  8. package/dist/assets/fonts/roboto/Roboto-LightItalic.ttf +0 -0
  9. package/dist/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  10. package/dist/assets/fonts/roboto/Roboto-MediumItalic.ttf +0 -0
  11. package/dist/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  12. package/dist/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  13. package/dist/assets/fonts/roboto/Roboto-ThinItalic.ttf +0 -0
  14. package/dist/components/atoms/GeneralInput/index.js +3 -1
  15. package/dist/components/atoms/GeneralInput/styles.js +1 -1
  16. package/dist/components/molecules/GalleryElement/index.js +12 -3
  17. package/dist/components/molecules/GalleryElement/styles.js +1 -1
  18. package/dist/components/molecules/HeaderTop/index.js +12 -14
  19. package/dist/components/molecules/HeaderTop/styles.js +1 -1
  20. package/dist/components/molecules/TagAndInput/index.js +6 -2
  21. package/dist/components/organisms/Chat/ContentChat/index.js +16 -8
  22. package/dist/components/organisms/Chat/Footer/index.js +2 -2
  23. package/dist/components/organisms/InputGroup/index.js +19 -8
  24. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +38 -46
  25. package/dist/components/pages/RetailerProductEdition/index.js +331 -235
  26. package/dist/components/pages/RetailerProductEdition/utils.js +68 -0
  27. package/package.json +1 -1
  28. package/src/assets/fonts/roboto/Roboto-Black.ttf +0 -0
  29. package/src/assets/fonts/roboto/Roboto-BlackItalic.ttf +0 -0
  30. package/src/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  31. package/src/assets/fonts/roboto/Roboto-BoldItalic.ttf +0 -0
  32. package/src/assets/fonts/roboto/Roboto-Italic.ttf +0 -0
  33. package/src/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  34. package/src/assets/fonts/roboto/Roboto-LightItalic.ttf +0 -0
  35. package/src/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  36. package/src/assets/fonts/roboto/Roboto-MediumItalic.ttf +0 -0
  37. package/src/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  38. package/src/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  39. package/src/assets/fonts/roboto/Roboto-ThinItalic.ttf +0 -0
  40. package/src/components/atoms/GeneralInput/index.js +2 -1
  41. package/src/components/atoms/GeneralInput/styles.js +9 -1
  42. package/src/components/molecules/GalleryElement/index.js +14 -2
  43. package/src/components/molecules/GalleryElement/styles.js +5 -0
  44. package/src/components/molecules/HeaderTop/index.js +9 -18
  45. package/src/components/molecules/HeaderTop/styles.js +19 -0
  46. package/src/components/molecules/TagAndInput/index.js +4 -0
  47. package/src/components/organisms/Chat/ContentChat/index.js +1 -1
  48. package/src/components/organisms/Chat/Footer/index.js +2 -2
  49. package/src/components/organisms/InputGroup/index.js +31 -4
  50. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +38 -47
  51. package/src/components/pages/RetailerProductEdition/index.js +61 -18
  52. package/src/components/pages/RetailerProductEdition/utils.js +34 -0
@@ -32,6 +32,7 @@ import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
32
32
  import errorModal from "../../../assets/images/genericModal/errorModal.svg";
33
33
  import { VersionSelector } from "../../organisms/VersionSelector";
34
34
  import { useCloseModal } from "../../../global-files/customHooks";
35
+ import { getAuditVersion, getInputsData } from "./utils";
35
36
 
36
37
  const reducerImages = (state, action) => {
37
38
  let { values, attrForImgs, inputsByRetailer } = state;
@@ -210,6 +211,41 @@ export const RetailerProductEdition = ({
210
211
  const [showVersionSelector, setShowVersionSelector] =
211
212
  useCloseModal("version-selector");
212
213
  const shotThd = [58, 59, 60, 61].includes(activeRetailer.id);
214
+ const [auditableVersion, setAuditableVersion] = useState(null);
215
+ const [auditServices, setAuditServices] = useState([]);
216
+ const [auditDatasheets, setAuditDatasheets] = useState([]);
217
+ const [auditDescriptions, setAuditDescriptions] = useState([]);
218
+ const [auditImages, setAuditImages] = useState([]);
219
+ const [compare, setCompare] = useState(false);
220
+
221
+ useEffect(async () => {
222
+ const { id_article } = product?.article || {};
223
+ if (id_article)
224
+ await getAuditVersion(id_article, setAuditableVersion, token);
225
+ }, []);
226
+
227
+ const loadAuditableData = async () => {
228
+ if (auditableVersion) {
229
+ const auditServices = await getRetailerServices(
230
+ product?.article?.id_article,
231
+ product?.article?.category,
232
+ parseInt(product?.article?.id_category),
233
+ auditableVersion.version
234
+ );
235
+ getInputsData(
236
+ auditServices,
237
+ activeRetailer,
238
+ setAuditDatasheets,
239
+ setAuditDescriptions
240
+ );
241
+ setAuditServices(auditServices);
242
+ setAuditImages(auditServices[2]);
243
+ }
244
+ };
245
+
246
+ useEffect(() => {
247
+ loadAuditableData();
248
+ }, [auditableVersion]);
213
249
 
214
250
  useEffect(() => {
215
251
  checkAll && setSelectedImages(images.values);
@@ -223,6 +259,9 @@ export const RetailerProductEdition = ({
223
259
  parseInt(product?.article?.id_category),
224
260
  version
225
261
  );
262
+ if (auditableVersion) {
263
+ loadAuditableData();
264
+ }
226
265
  //Converts the data inside the datasheets object to array
227
266
  setServices(services);
228
267
  getServices();
@@ -384,21 +423,15 @@ export const RetailerProductEdition = ({
384
423
  }, [percentages]);
385
424
 
386
425
  useEffect(() => {
387
- if (services.length > 0) {
388
- if (services[0][activeRetailer.id]?.data)
389
- services[0][activeRetailer.id].data = Object.values(
390
- services[0][activeRetailer.id].data
391
- );
392
- setActivePercentage(Math.round(activeRetailer?.percentage, 0));
393
-
394
- const datagroups = services[0][activeRetailer?.id];
395
- const inputs = services[0]?.inputs;
396
- const descriptions = services[1]?.filter(
397
- (service) => service?.id === activeRetailer?.id
426
+ getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
427
+ auditableVersion &&
428
+ getInputsData(
429
+ auditServices,
430
+ activeRetailer,
431
+ setAuditDatasheets,
432
+ setAuditDescriptions
398
433
  );
399
- setDatasheets([datagroups, inputs]);
400
- setDescriptions(descriptions);
401
- }
434
+ setActivePercentage(Math.round(activeRetailer?.percentage, 0));
402
435
  activeRetailer?.id &&
403
436
  setImages({ action: "orderImages", retailerId: activeRetailer.id });
404
437
  }, [activeRetailer, services]);
@@ -424,7 +457,7 @@ export const RetailerProductEdition = ({
424
457
  image={image}
425
458
  gridLayout={imageLayout}
426
459
  id={"gallery-element-" + index}
427
- index={index + "-" + image.name}
460
+ index={index + "-" + image.name + "-" + compare}
428
461
  number={index}
429
462
  imageType={imageType}
430
463
  imagePackagingType={imagePackagingType}
@@ -434,12 +467,14 @@ export const RetailerProductEdition = ({
434
467
  changeImage={setImages}
435
468
  selectedImages={selectedImages}
436
469
  setSelectedImages={setSelectedImages}
470
+ auditImages={auditImages}
471
+ compare={compare}
437
472
  />
438
473
  ));
439
474
  };
440
475
 
441
476
  const saveDescriptions = async () => {
442
- const dataClean = updatedDescriptions.filter((f) => f.value !== '');
477
+ const dataClean = updatedDescriptions.filter((f) => f.value !== "");
443
478
  if (dataClean.length > 0) {
444
479
  setLoading(true);
445
480
  const productTemp = product;
@@ -480,7 +515,7 @@ export const RetailerProductEdition = ({
480
515
  };
481
516
 
482
517
  const saveDatasheets = async () => {
483
- const dataClean = updatedDatasheets.filter((f) => f.value !== '');
518
+ const dataClean = updatedDatasheets.filter((f) => f.value !== "");
484
519
  if (dataClean.length > 0) {
485
520
  setLoading(true);
486
521
  const productTemp = product;
@@ -1233,7 +1268,11 @@ export const RetailerProductEdition = ({
1233
1268
 
1234
1269
  return (
1235
1270
  <Container headerTop={headerTop}>
1236
- <HeaderTop setHeaderTop={setHeaderTop} />
1271
+ <HeaderTop
1272
+ setHeaderTop={setHeaderTop}
1273
+ auditableVersion={auditableVersion}
1274
+ setCompare={setCompare}
1275
+ />
1237
1276
  <div className="data-container">
1238
1277
  <div className="image-data-panel">
1239
1278
  <ImagePreviewer
@@ -1409,8 +1448,10 @@ export const RetailerProductEdition = ({
1409
1448
  activeSection={activeTab}
1410
1449
  inputGroup={dataGroup}
1411
1450
  dataInputs={datasheets[1]}
1451
+ auditInputs={auditDatasheets[1]}
1412
1452
  updatedDatasheets={updatedDatasheets}
1413
1453
  setUpdatedDatasheets={setUpdatedDatasheets}
1454
+ compare={compare}
1414
1455
  />
1415
1456
  ))
1416
1457
  ) : (
@@ -1424,11 +1465,13 @@ export const RetailerProductEdition = ({
1424
1465
  <InputGroup
1425
1466
  activeSection={activeTab}
1426
1467
  inputGroup={descriptions[0]}
1468
+ auditInputGroup={auditDescriptions[0]}
1427
1469
  updatedDescriptions={updatedDescriptions}
1428
1470
  setUpdatedDescriptions={setUpdatedDescriptions}
1429
1471
  articleId={product?.article?.id_article}
1430
1472
  version={version}
1431
1473
  dinamicHeight={true}
1474
+ compare={compare}
1432
1475
  />
1433
1476
  ) : (
1434
1477
  <ScreenHeader
@@ -0,0 +1,34 @@
1
+ import axios from "axios";
2
+
3
+ export const getAuditVersion = async (articleId, setState, token) => {
4
+ const auditResponse = await axios.get(
5
+ `${process.env.REACT_APP_GET_AUDIT}?articleId=${articleId}`,
6
+ { headers: { Authorization: token } }
7
+ );
8
+ console.log(auditResponse, "auditResponse");
9
+ if (auditResponse.status === 200) {
10
+ setState(JSON.parse(auditResponse.data.body).data);
11
+ }
12
+ };
13
+
14
+ export const getInputsData = (
15
+ services,
16
+ activeRetailer,
17
+ setDatasheetState,
18
+ setDescriptionState
19
+ ) => {
20
+ if (services.length > 0) {
21
+ if (services[0][activeRetailer.id]?.data)
22
+ services[0][activeRetailer.id].data = Object.values(
23
+ services[0][activeRetailer.id].data
24
+ );
25
+
26
+ const datagroups = services[0][activeRetailer?.id];
27
+ const inputs = services[0]?.inputs;
28
+ const descriptions = services[1]?.filter(
29
+ (service) => service?.id === activeRetailer?.id
30
+ );
31
+ setDatasheetState([datagroups, inputs]);
32
+ setDescriptionState(descriptions);
33
+ }
34
+ };