contentoh-components-library 21.3.4 → 21.3.6

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 (66) hide show
  1. package/.env.development +2 -2
  2. package/.env.production +25 -25
  3. package/dist/assets/fonts/{roboto → Roboto}/LICENSE.txt +0 -0
  4. package/dist/assets/fonts/{roboto → Roboto}/Roboto-Black.ttf +0 -0
  5. package/dist/assets/fonts/{roboto → Roboto}/Roboto-BlackItalic.ttf +0 -0
  6. package/dist/assets/fonts/{roboto → Roboto}/Roboto-Bold.ttf +0 -0
  7. package/dist/assets/fonts/{roboto → Roboto}/Roboto-BoldItalic.ttf +0 -0
  8. package/dist/assets/fonts/{roboto → Roboto}/Roboto-Italic.ttf +0 -0
  9. package/dist/assets/fonts/{roboto → Roboto}/Roboto-Light.ttf +0 -0
  10. package/dist/assets/fonts/{roboto → Roboto}/Roboto-LightItalic.ttf +0 -0
  11. package/dist/assets/fonts/{roboto → Roboto}/Roboto-Medium.ttf +0 -0
  12. package/dist/assets/fonts/{roboto → Roboto}/Roboto-MediumItalic.ttf +0 -0
  13. package/dist/assets/fonts/{roboto → Roboto}/Roboto-Regular.ttf +0 -0
  14. package/dist/assets/fonts/{roboto → Roboto}/Roboto-Thin.ttf +0 -0
  15. package/dist/assets/fonts/{roboto → Roboto}/Roboto-ThinItalic.ttf +0 -0
  16. package/dist/components/atoms/GeneralButton/index.js +6 -2
  17. package/dist/components/atoms/ProgressBar/index.js +36 -6
  18. package/dist/components/atoms/ProgressBar/styles.js +11 -3
  19. package/dist/components/atoms/Select/VersionSelect.js +2 -1
  20. package/dist/components/molecules/ProductNameHeader/index.js +5 -3
  21. package/dist/components/organisms/CreateVersion/RenderChilds.js +11 -11
  22. package/dist/components/organisms/CreateVersion/index.js +30 -89
  23. package/dist/components/organisms/FullProductNameHeader/index.js +1 -0
  24. package/dist/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
  25. package/dist/components/organisms/OrderDetail/index.js +20 -11
  26. package/dist/components/organisms/OrderDetail/styles.js +1 -1
  27. package/dist/components/organisms/OrderDetail/utils/Table/styles.js +1 -1
  28. package/dist/components/organisms/OrderDetail/utils/Table/utils.js +45 -15
  29. package/dist/components/organisms/VersionSelector/index.js +28 -2
  30. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +69 -147
  31. package/dist/components/pages/ProviderProductEdition/index.js +27 -47
  32. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +66 -82
  33. package/dist/components/pages/RetailerProductEdition/index.js +18 -36
  34. package/package.json +4 -4
  35. package/src/assets/fonts/{roboto → Roboto}/LICENSE.txt +0 -0
  36. package/src/assets/fonts/{roboto → Roboto}/Roboto-Black.ttf +0 -0
  37. package/src/assets/fonts/{roboto → Roboto}/Roboto-BlackItalic.ttf +0 -0
  38. package/src/assets/fonts/{roboto → Roboto}/Roboto-Bold.ttf +0 -0
  39. package/src/assets/fonts/{roboto → Roboto}/Roboto-BoldItalic.ttf +0 -0
  40. package/src/assets/fonts/{roboto → Roboto}/Roboto-Italic.ttf +0 -0
  41. package/src/assets/fonts/{roboto → Roboto}/Roboto-Light.ttf +0 -0
  42. package/src/assets/fonts/{roboto → Roboto}/Roboto-LightItalic.ttf +0 -0
  43. package/src/assets/fonts/{roboto → Roboto}/Roboto-Medium.ttf +0 -0
  44. package/src/assets/fonts/{roboto → Roboto}/Roboto-MediumItalic.ttf +0 -0
  45. package/src/assets/fonts/{roboto → Roboto}/Roboto-Regular.ttf +0 -0
  46. package/src/assets/fonts/{roboto → Roboto}/Roboto-Thin.ttf +0 -0
  47. package/src/assets/fonts/{roboto → Roboto}/Roboto-ThinItalic.ttf +0 -0
  48. package/src/components/atoms/GeneralButton/index.js +4 -1
  49. package/src/components/atoms/ProgressBar/index.js +38 -5
  50. package/src/components/atoms/ProgressBar/styles.js +23 -0
  51. package/src/components/atoms/Select/VersionSelect.js +4 -2
  52. package/src/components/molecules/ProductNameHeader/index.js +6 -1
  53. package/src/components/organisms/CreateVersion/RenderChilds.js +28 -34
  54. package/src/components/organisms/CreateVersion/index.js +16 -36
  55. package/src/components/organisms/FullProductNameHeader/index.js +1 -0
  56. package/src/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
  57. package/src/components/organisms/OrderDetail/index.js +19 -12
  58. package/src/components/organisms/OrderDetail/styles.js +1 -0
  59. package/src/components/organisms/OrderDetail/utils/Table/styles.js +26 -0
  60. package/src/components/organisms/OrderDetail/utils/Table/utils.js +30 -15
  61. package/src/components/organisms/VersionSelector/index.js +18 -3
  62. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +75 -166
  63. package/src/components/pages/ProviderProductEdition/index.js +12 -28
  64. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +71 -82
  65. package/src/components/pages/RetailerProductEdition/index.js +14 -24
  66. package/src/global-files/customHooks.js +2 -2
@@ -42,7 +42,7 @@ import Slide1_4 from "../../../assets/images/sliderToolTip/slide4.svg";
42
42
  import Slide1_5 from "../../../assets/images/sliderToolTip/slide5.svg";
43
43
  import { VersionSelector } from "../../organisms/VersionSelector";
44
44
  import { useCloseModal } from "../../../global-files/customHooks";
45
- import { CreateVersion } from "../../organisms/CreateVersion";
45
+ import { number } from "prop-types";
46
46
 
47
47
  const reducerImages = (state, action) => {
48
48
  let { values, attrForImgs, inputsByRetailer } = state;
@@ -114,8 +114,8 @@ const S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
114
114
  const REGION = "us-east-1";
115
115
 
116
116
  AWS.config.update({
117
- accessKeyId: process.env.REACT_APP_KEY_UPLOAD_TO_S3,
118
- secretAccessKey: process.env.REACT_APP_ACCESS_KEY_UPLOAD_TO_S3,
117
+ accessKeyId: process.env.REACT_APP_KUTS3,
118
+ secretAccessKey: process.env.REACT_APP_AKUTS3,
119
119
  });
120
120
 
121
121
  const myBucket = new AWS.S3({
@@ -252,7 +252,6 @@ export const ProviderProductEdition = ({
252
252
  const [retailerStatus, setRetailerStatus] = useState(
253
253
  product.statusByRetailer
254
254
  );
255
- const [showCreateVersion, setShowCreateVersion] = useState(false);
256
255
  const [showVersionSelector, setShowVersionSelector] =
257
256
  useCloseModal("version-selector");
258
257
 
@@ -272,19 +271,10 @@ export const ProviderProductEdition = ({
272
271
  setServices(services);
273
272
  await getServices();
274
273
 
275
- // if (!originProp) {
276
- // setActiveRetailer(
277
- // product?.retailers
278
- // ? product?.retailers[0]
279
- // : product?.retailersAvailable[0]
280
- // );
281
- // }
282
-
283
- // setActiveRetailer(product?.retailers[0]);
284
274
  setImages({ action: "init", init: services[2] });
285
275
  if (services[2]?.values?.length > 0) setActiveImage(0);
286
276
 
287
- getPercentage({ data: [product] }).then((res) => setPercentages(res));
277
+ getPercentage({ data: [product] }).then((res) => setPercentages(res[0]));
288
278
  setLoading(false);
289
279
  };
290
280
 
@@ -374,11 +364,13 @@ export const ProviderProductEdition = ({
374
364
  useEffect(() => {
375
365
  const productTemp = product;
376
366
  const retailers = productTemp?.retailersAvailable || productTemp?.retailers;
377
- retailers?.forEach((retailer) => {
378
- retailer["percentage"] = percentages?.find(
379
- (percent) => retailer?.id === percent?.id_retailer
380
- )?.percentage;
381
- });
367
+ if (Object.keys(percentages?.retailers ?? {})?.length > 0) {
368
+ retailers?.forEach((retailer) => {
369
+ retailer["percentage"] = Number(
370
+ percentages?.retailers[retailer.id].percentageRequired
371
+ );
372
+ });
373
+ }
382
374
 
383
375
  setProduct(productTemp);
384
376
  setActivePercentage(retailers[0]?.percentage);
@@ -481,7 +473,7 @@ export const ProviderProductEdition = ({
481
473
  };
482
474
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
483
475
  try {
484
- await axios.put(
476
+ const res = await axios.put(
485
477
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?datasheet=true&version=${version}`,
486
478
  dataObject,
487
479
  {
@@ -1497,18 +1489,10 @@ export const ProviderProductEdition = ({
1497
1489
  setVersion={setVersion}
1498
1490
  companyName={company.company_name}
1499
1491
  currentVersion={version}
1500
- setShowCreateVersion={setShowCreateVersion}
1501
1492
  setShowVersionSelector={setShowVersionSelector}
1502
1493
  jwt={token}
1503
1494
  />
1504
1495
  )}
1505
- {showCreateVersion && (
1506
- <CreateVersion
1507
- idArticle={product.id_article}
1508
- version={version}
1509
- setShowCreateVersion={setShowCreateVersion}
1510
- />
1511
- )}
1512
1496
  </Container>
1513
1497
  );
1514
1498
  };
@@ -12,108 +12,97 @@ export const RetailerProductEditionDefault = Template.bind({});
12
12
  RetailerProductEditionDefault.args = {
13
13
  tabsSections: {
14
14
  Descripción: true,
15
- "Ficha técnica": false,
16
- Imágenes: false,
15
+ "Ficha técnica": true,
16
+ Imágenes: true,
17
17
  },
18
18
  token:
19
- "eyJraWQiOiJEV3owZnNieXg2MXNFcVduN3RCXC81bVhod3ZNbFZIOTgwUnZcL3RjT0lKdEk9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI4ZDAxMDIxNC01YmZhLTQzYzMtOTZmYi1jNTU2ZGMwNTc3NGIiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfbFN6UVo0WjdSIiwiY29nbml0bzp1c2VybmFtZSI6IjhkMDEwMjE0LTViZmEtNDNjMy05NmZiLWM1NTZkYzA1Nzc0YiIsImF1ZCI6IjUyZDlza2tkY2c4cWpwODhvb2sxdXNlNm1rIiwiZXZlbnRfaWQiOiI2ZWY3Y2UxYy0xYjBjLTRkNGYtYTc3Yy1jMWIwYTk0ZjIwOWEiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY2NzMyMTQ5NCwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY2NzMyNTA5NCwiaWF0IjoxNjY3MzIxNDk0LCJlbWFpbCI6ImthcmFmZTMyMThAbW9tMmtpZC5jb20ifQ.GjBtY-LW5eYzvNfrIJOdb9pDMU_CZlIxRAn1ZszjMfWNU9s8s_j6o4_2x0J7AyiSjgu9TaLRcRpF6FZ5pzwNGs8G5AxnO3r_PIg2mznM44QLnt5PTfdoFx2jJmU53UA8GZU1SFDvDlR1QZR-EtANz2wfNs8RqY_mKTz5WjY7RdGTFVkowTv-Y1Q9T7x_fpv_5o-nB5GzLBQoHwTLQ_vjguSLH17l2BUn0QxLi2WJVs-qWX4ze4QysADVxYOlMkAQql328oqoqdXRbZrntnxYxa5EMpmref1bGbSOFk4qgHax4qa3gD2_h291NLjCZS7IMGDSIhOk9r7irItbojM01Q",
19
+ "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI1ODg0YWUzNC01OWQ2LTQ0NTQtYjk4ZS04MjE1MThiY2MzYTciLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6IjU4ODRhZTM0LTU5ZDYtNDQ1NC1iOThlLTgyMTUxOGJjYzNhNyIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiJmMzY2YTdjYi02YjA0LTRiMzAtOTJmYy1iMzY0MmY3ZjEzNmEiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY3MTc0MzE0OSwibmFtZSI6IkNhZGVuYSBJc21hZWwiLCJwaG9uZV9udW1iZXIiOiIrNTIzMTExMzY2MzM2IiwiZXhwIjoxNjcxNzQ2NzQ5LCJpYXQiOjE2NzE3NDMxNDksImVtYWlsIjoiY2FkZW5hLmlzbWFlbEBhbGxmcmVlbWFpbC5uZXQifQ.J8kTv1sEotxoicaRclaK1r0tjVbwHPDxIzdDfxYo9J4XwBYYfS180__KYYE0Dh1AfUK_K0mrk2_78_rhTNxCQT85W7XS3ZEcxIOUekqoxaKFl8LSVN_eWz3SlsGG0yRflhJGt6d4gBVByXZbdNiyp1rkjgMln6fhwlRUnuGRbG1WKQvdAPli3qfH8mLzgoTz-6HWs1Jf2Ujheavf3ipGMNtj-OSUdQsh04Ov7jehDWdnPNn2s2DAl4eubgjdXrwIiBPCRkbuFeYZZJpzj1wy__a0nCM7bzly5uTZ2aWujgEJvf9bJb-Y4gkS8TxyJaggJ01ZsMki36aEpIt8J1tJag",
20
20
  productSelected: {
21
- services: {
22
- datasheets: 1,
23
- descriptions: 1,
24
- images: 1,
25
- },
26
- orderId: 3321,
27
- status: "PA",
28
- datasheet_status: "AC",
29
- prio: "none",
30
- version: 2,
31
- description_status: "AC",
32
- images_status: "PA",
33
- statusByRetailer: {
34
- 58: {
35
- datasheet: "AC",
36
- description: "AC",
37
- images: "PA",
38
- },
39
- },
21
+ articleStatus: "AA",
22
+ version: 3,
23
+ missing: {},
40
24
  article: {
41
- id_article: 85655,
42
- id_category: "2052",
43
- name: "EXTENSION P/ EXTERIOR 3X10 AWG 10M ROJO",
44
- upc: "165679",
45
- timestamp: "2022-11-01T15:46:51.000Z",
46
- id_user: 1436,
47
- status: null,
48
- active: 1,
49
- company_id: 409,
50
- SKU: null,
51
- Descripcion: null,
52
- Proveedor: null,
53
- id_proveedor: 0,
54
- company_name: "HIGHLINE-WARREN LLC",
55
- country: null,
56
- id_order: 3321,
57
- id_datasheet_especialist: 1248,
58
- id_datasheet_facilitator: null,
59
- id_description_especialist: 1248,
60
- id_description_facilitator: null,
61
- id_images_especialist: null,
62
- id_images_facilitator: null,
63
- id_auditor: null,
64
- id_recepcionist: null,
65
25
  category:
66
- "Eléctrico|Extensiones y Multicontactos|Extensiones y Multicontactos",
67
- missingAttributes: null,
68
- missingDescriptions: null,
69
- missingImages: null,
26
+ "Ventilación y Calefacción|Ventiladores de Techo|Ventiladores de Techo",
27
+ company_name: "GRUPO BRAHMA",
28
+ company_id: 1,
29
+ id_category: "2416",
30
+ id_article: 221,
31
+ name: 'DEMO VENTILADOR DE TECHO TRIBECA 52"',
32
+ upc: "147259",
70
33
  },
34
+ asignations: [],
71
35
  retailers: [
72
36
  {
73
- id: 58,
74
- name: "The Home Depot Golden",
37
+ id: 59,
38
+ name: "The Home Depot Platinum",
39
+ country: "México",
40
+ id_region: 1,
41
+ active: 1,
42
+ },
43
+ ],
44
+ retailersAvailable: [
45
+ {
46
+ id: 59,
47
+ name: "The Home Depot Platinum",
75
48
  country: "México",
76
49
  id_region: 1,
77
50
  active: 1,
78
51
  },
79
52
  ],
80
- country: null,
81
- upc: "165679",
53
+ upc: "147259",
54
+ name: 'DEMO VENTILADOR DE TECHO TRIBECA 52"',
55
+ categoryName:
56
+ "Ventilación y Calefacción|Ventiladores de Techo|Ventiladores de Techo",
57
+ id_category: "2416",
58
+ id_article: 221,
59
+ services: [
60
+ {
61
+ id_article: 221,
62
+ service: "datasheet",
63
+ quantity: 1,
64
+ price: 0,
65
+ id_user: 59,
66
+ datasheet_common: null,
67
+ discount: null,
68
+ },
69
+ ],
82
70
  },
83
71
  location: {
84
- product: { articleId: 109485, versionId: 3 },
72
+ product: { articleId: 221, versionId: 3 },
85
73
  },
86
74
  user: {
87
- id_user: 426,
88
- name: "Especialista Textos",
89
- last_name: " ",
90
- email: "karafe3218@mom2kid.com",
91
- position: "Tester",
92
- telephone: null,
93
- country: null,
94
- id_company: 254,
95
- id_cognito: "8d010214-5bfa-43c3-96fb-c556dc05774b",
75
+ id_user: 59,
76
+ name: "The Home",
77
+ last_name: "Depot",
78
+ email: "cadena.ismael@allfreemail.net",
79
+ position: "Admin",
80
+ telephone: "+523111366336",
81
+ country: "México",
82
+ id_company: 817,
83
+ id_cognito: "5884ae34-59d6-4454-b98e-821518bcc3a7",
96
84
  birth_Date: null,
97
- about_me: null,
98
- zip_code: null,
99
- address: null,
100
- job: null,
101
- id_stripe: null,
102
- id_role: 7,
85
+ about_me: "",
86
+ zip_code: "",
87
+ address: "",
88
+ job: "",
89
+ id_stripe: "",
90
+ id_role: 0,
103
91
  active: 1,
104
- is_retailer: 0,
105
- email_notify: null,
92
+ is_retailer: 1,
93
+ email_notify: 0,
94
+ is_user_tech: null,
106
95
  membership: {
107
- id: 750,
108
- start_date: "2022-01-07T21:32:54.000Z",
109
- end_date: "2023-01-07T21:32:54.000Z",
110
- planID: 6,
111
- plan: "prod_KvGd6YSTJyR3AP",
112
- name: "Plan Small",
113
- user_limit: "10",
114
- products_limit: "1000",
115
- type: "Enterprise",
96
+ id: 47,
97
+ start_date: "2022-05-25T14:31:12.000Z",
98
+ end_date: "2023-05-25T14:31:12.000Z",
99
+ planID: 5,
100
+ plan: "prod_Ktl6B5Ou2gqTB2",
101
+ name: "Plan Pro",
102
+ user_limit: "5",
103
+ products_limit: "500",
104
+ type: "PyMES",
116
105
  },
117
- src: "https://content-management-profile-prod.s3.amazonaws.com/id-426/426.png?1667321494598",
106
+ src: "https://content-management-profile.s3.amazonaws.com/id-59/59.png?1671735033010",
118
107
  },
119
108
  };
@@ -32,7 +32,6 @@ 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 { CreateVersion } from "../../organisms/CreateVersion";
36
35
 
37
36
  const reducerImages = (state, action) => {
38
37
  let { values, attrForImgs, inputsByRetailer } = state;
@@ -108,8 +107,8 @@ const S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
108
107
  const REGION = "us-east-1";
109
108
 
110
109
  AWS.config.update({
111
- accessKeyId: process.env.REACT_APP_KEY_UPLOAD_TO_S3,
112
- secretAccessKey: process.env.REACT_APP_ACCESS_KEY_UPLOAD_TO_S3,
110
+ accessKeyId: process.env.REACT_APP_KUTS3,
111
+ secretAccessKey: process.env.REACT_APP_AKUTS3,
113
112
  });
114
113
 
115
114
  const myBucket = new AWS.S3({
@@ -176,6 +175,7 @@ export const RetailerProductEdition = ({
176
175
  const [percentages, setPercentages] = useState(
177
176
  new Array(product?.retailers?.length).fill({ percentage: 0 })
178
177
  );
178
+ // const [percentages, setPercentages] = useState([{ retailers: {} }]);
179
179
  const [activePercentage, setActivePercentage] = useState(0);
180
180
  const [activeRetailer, setActiveRetailer] = useState({});
181
181
  const [services, setServices] = useState([]);
@@ -206,10 +206,7 @@ export const RetailerProductEdition = ({
206
206
  const [retailerStatus, setRetailerStatus] = useState("-");
207
207
  const [statusArray, setStatusArray] = useState([]);
208
208
  const [socketType, setSocketType] = useState(null);
209
- const [servicesStatus, setServicesStatus] = useState([]);
210
209
  const [saving, setSaving] = useState(loading);
211
- const isAuditor = user.id_role === 6;
212
- const [showCreateVersion, setShowCreateVersion] = useState(false);
213
210
  const [showVersionSelector, setShowVersionSelector] =
214
211
  useCloseModal("version-selector");
215
212
  const shotThd = [58, 59, 60, 61].includes(activeRetailer.id);
@@ -229,12 +226,9 @@ export const RetailerProductEdition = ({
229
226
  //Converts the data inside the datasheets object to array
230
227
  setServices(services);
231
228
  getServices();
232
-
233
- // setActiveRetailer(product?.retailers[0]);
234
229
  setImages({ action: "init", init: services[2] });
235
230
  if (services[2]?.values?.length > 0) setActiveImage(0);
236
-
237
- getPercentage({ data: [product] }).then((res) => setPercentages(res));
231
+ getPercentage({ data: [product] }).then((res) => setPercentages(res[0]));
238
232
  setLoading(false);
239
233
  } catch (error) {
240
234
  console.log(error);
@@ -375,12 +369,16 @@ export const RetailerProductEdition = ({
375
369
  }, [userGroups]);
376
370
 
377
371
  useEffect(() => {
378
- product?.retailers?.forEach((retailer) => {
379
- retailer["percentage"] = percentages?.filter(
380
- (percent) => retailer?.id === percent?.id_retailer
381
- )[0]?.percentage;
382
- });
383
- setActivePercentage(product?.retailers[0]?.percentage);
372
+ const retailers = product?.retailersAvailable || product?.retailers;
373
+ if (Object.keys(percentages?.retailers ?? {})?.length > 0) {
374
+ retailers?.forEach((retailer) => {
375
+ retailer["percentage"] = Number(
376
+ percentages?.retailers[retailer.id].percentageRequired
377
+ );
378
+ });
379
+ }
380
+
381
+ setActivePercentage(retailers[0]?.percentage);
384
382
  }, [percentages]);
385
383
 
386
384
  useEffect(() => {
@@ -1549,18 +1547,10 @@ export const RetailerProductEdition = ({
1549
1547
  setVersion={setVersion}
1550
1548
  companyName={product.article.company_name}
1551
1549
  currentVersion={version}
1552
- setShowCreateVersion={setShowCreateVersion}
1553
1550
  setShowVersionSelector={setShowVersionSelector}
1554
1551
  jwt={token}
1555
1552
  />
1556
1553
  )}
1557
- {showCreateVersion && (
1558
- <CreateVersion
1559
- idArticle={product.article.id_article}
1560
- version={version}
1561
- setShowCreateVersion={setShowCreateVersion}
1562
- />
1563
- )}
1564
1554
  </Container>
1565
1555
  );
1566
1556
  };
@@ -1,5 +1,4 @@
1
- import { useState } from "react";
2
- import { useEffect } from "react";
1
+ import { useState, useEffect } from "react";
3
2
 
4
3
  export const useCloseModal = (id) => {
5
4
  const [showModal, setShowModal] = useState(false);
@@ -11,6 +10,7 @@ export const useCloseModal = (id) => {
11
10
  setShowModal(false);
12
11
  }
13
12
  };
13
+
14
14
  useEffect(() => {
15
15
  if (showModal) {
16
16
  document.addEventListener("click", closeModal, false);