contentoh-components-library 21.3.22 → 21.3.24

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 (48) hide show
  1. package/.env.development +1 -0
  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/InputGroup/index.js +19 -8
  22. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +38 -46
  23. package/dist/components/pages/RetailerProductEdition/index.js +333 -235
  24. package/dist/components/pages/RetailerProductEdition/utils.js +67 -0
  25. package/package.json +1 -1
  26. package/src/assets/fonts/roboto/Roboto-Black.ttf +0 -0
  27. package/src/assets/fonts/roboto/Roboto-BlackItalic.ttf +0 -0
  28. package/src/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  29. package/src/assets/fonts/roboto/Roboto-BoldItalic.ttf +0 -0
  30. package/src/assets/fonts/roboto/Roboto-Italic.ttf +0 -0
  31. package/src/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  32. package/src/assets/fonts/roboto/Roboto-LightItalic.ttf +0 -0
  33. package/src/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  34. package/src/assets/fonts/roboto/Roboto-MediumItalic.ttf +0 -0
  35. package/src/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  36. package/src/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  37. package/src/assets/fonts/roboto/Roboto-ThinItalic.ttf +0 -0
  38. package/src/components/atoms/GeneralInput/index.js +2 -1
  39. package/src/components/atoms/GeneralInput/styles.js +9 -1
  40. package/src/components/molecules/GalleryElement/index.js +14 -2
  41. package/src/components/molecules/GalleryElement/styles.js +5 -0
  42. package/src/components/molecules/HeaderTop/index.js +9 -18
  43. package/src/components/molecules/HeaderTop/styles.js +19 -0
  44. package/src/components/molecules/TagAndInput/index.js +4 -0
  45. package/src/components/organisms/InputGroup/index.js +31 -4
  46. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +38 -47
  47. package/src/components/pages/RetailerProductEdition/index.js +58 -19
  48. 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,43 @@ 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
+ if (auditableVersion) {
248
+ loadAuditableData();
249
+ }
250
+ }, [auditableVersion]);
213
251
 
214
252
  useEffect(() => {
215
253
  checkAll && setSelectedImages(images.values);
@@ -223,6 +261,9 @@ export const RetailerProductEdition = ({
223
261
  parseInt(product?.article?.id_category),
224
262
  version
225
263
  );
264
+ if (auditableVersion) {
265
+ loadAuditableData();
266
+ }
226
267
  //Converts the data inside the datasheets object to array
227
268
  setServices(services);
228
269
  getServices();
@@ -384,21 +425,9 @@ export const RetailerProductEdition = ({
384
425
  }, [percentages]);
385
426
 
386
427
  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
398
- );
399
- setDatasheets([datagroups, inputs]);
400
- setDescriptions(descriptions);
401
- }
428
+ getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
429
+ auditableVersion && loadAuditableData();
430
+ setActivePercentage(Math.round(activeRetailer?.percentage, 0));
402
431
  activeRetailer?.id &&
403
432
  setImages({ action: "orderImages", retailerId: activeRetailer.id });
404
433
  }, [activeRetailer, services]);
@@ -424,7 +453,7 @@ export const RetailerProductEdition = ({
424
453
  image={image}
425
454
  gridLayout={imageLayout}
426
455
  id={"gallery-element-" + index}
427
- index={index + "-" + image.name}
456
+ index={index + "-" + image.name + "-" + compare}
428
457
  number={index}
429
458
  imageType={imageType}
430
459
  imagePackagingType={imagePackagingType}
@@ -434,12 +463,14 @@ export const RetailerProductEdition = ({
434
463
  changeImage={setImages}
435
464
  selectedImages={selectedImages}
436
465
  setSelectedImages={setSelectedImages}
466
+ auditImages={auditImages}
467
+ compare={compare}
437
468
  />
438
469
  ));
439
470
  };
440
471
 
441
472
  const saveDescriptions = async () => {
442
- const dataClean = updatedDescriptions.filter((f) => f.value !== '');
473
+ const dataClean = updatedDescriptions.filter((f) => f.value !== "");
443
474
  if (dataClean.length > 0) {
444
475
  setLoading(true);
445
476
  const productTemp = product;
@@ -480,7 +511,7 @@ export const RetailerProductEdition = ({
480
511
  };
481
512
 
482
513
  const saveDatasheets = async () => {
483
- const dataClean = updatedDatasheets.filter((f) => f.value !== '');
514
+ const dataClean = updatedDatasheets.filter((f) => f.value !== "");
484
515
  if (dataClean.length > 0) {
485
516
  setLoading(true);
486
517
  const productTemp = product;
@@ -1233,7 +1264,11 @@ export const RetailerProductEdition = ({
1233
1264
 
1234
1265
  return (
1235
1266
  <Container headerTop={headerTop}>
1236
- <HeaderTop setHeaderTop={setHeaderTop} />
1267
+ <HeaderTop
1268
+ setHeaderTop={setHeaderTop}
1269
+ auditableVersion={auditableVersion}
1270
+ setCompare={setCompare}
1271
+ />
1237
1272
  <div className="data-container">
1238
1273
  <div className="image-data-panel">
1239
1274
  <ImagePreviewer
@@ -1409,8 +1444,10 @@ export const RetailerProductEdition = ({
1409
1444
  activeSection={activeTab}
1410
1445
  inputGroup={dataGroup}
1411
1446
  dataInputs={datasheets[1]}
1447
+ auditInputs={auditDatasheets[1]}
1412
1448
  updatedDatasheets={updatedDatasheets}
1413
1449
  setUpdatedDatasheets={setUpdatedDatasheets}
1450
+ compare={compare}
1414
1451
  />
1415
1452
  ))
1416
1453
  ) : (
@@ -1424,11 +1461,13 @@ export const RetailerProductEdition = ({
1424
1461
  <InputGroup
1425
1462
  activeSection={activeTab}
1426
1463
  inputGroup={descriptions[0]}
1464
+ auditInputGroup={auditDescriptions[0]}
1427
1465
  updatedDescriptions={updatedDescriptions}
1428
1466
  setUpdatedDescriptions={setUpdatedDescriptions}
1429
1467
  articleId={product?.article?.id_article}
1430
1468
  version={version}
1431
1469
  dinamicHeight={true}
1470
+ compare={compare}
1432
1471
  />
1433
1472
  ) : (
1434
1473
  <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
+
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
+ };