contentoh-components-library 21.2.101 → 21.2.103

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 (106) hide show
  1. package/dist/components/atoms/GeneralButton/index.js +6 -2
  2. package/dist/components/atoms/Select/VersionSelect.js +2 -1
  3. package/dist/components/organisms/CreateVersion/RenderChilds.js +11 -11
  4. package/dist/components/organisms/CreateVersion/index.js +30 -89
  5. package/dist/components/organisms/VersionSelector/index.js +28 -2
  6. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +69 -147
  7. package/dist/components/pages/ProviderProductEdition/index.js +0 -20
  8. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +77 -67
  9. package/dist/components/pages/RetailerProductEdition/index.js +3 -22
  10. package/package.json +1 -1
  11. package/src/components/atoms/GeneralButton/index.js +4 -1
  12. package/src/components/atoms/Select/VersionSelect.js +4 -2
  13. package/src/components/organisms/CreateVersion/RenderChilds.js +28 -34
  14. package/src/components/organisms/CreateVersion/index.js +16 -36
  15. package/src/components/organisms/VersionSelector/index.js +18 -3
  16. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +75 -166
  17. package/src/components/pages/ProviderProductEdition/index.js +0 -19
  18. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +79 -67
  19. package/src/components/pages/RetailerProductEdition/index.js +0 -12
  20. package/src/global-files/customHooks.js +2 -2
  21. package/dist/assets/images/chatPopup/Spinner.gif +0 -0
  22. package/dist/assets/images/chatPopup/close.svg +0 -3
  23. package/dist/assets/images/chatPopup/defaultImage.png +0 -0
  24. package/dist/assets/images/chatPopup/defaultProfile.png +0 -0
  25. package/dist/assets/images/chatPopup/doc.svg +0 -1
  26. package/dist/assets/images/chatPopup/document.svg +0 -1
  27. package/dist/assets/images/chatPopup/iconChat.svg +0 -19
  28. package/dist/assets/images/chatPopup/iconPlus.svg +0 -3
  29. package/dist/assets/images/chatPopup/pdf.svg +0 -75
  30. package/dist/assets/images/chatPopup/remove.svg +0 -4
  31. package/dist/assets/images/chatPopup/send.svg +0 -3
  32. package/dist/assets/images/chatPopup/svgIcon.svg +0 -109
  33. package/dist/assets/images/chatPopup/upload_file.svg +0 -3
  34. package/dist/assets/images/chatPopup/xls.svg +0 -53
  35. package/dist/assets/images/customSelect/starIcon.svg +0 -14
  36. package/dist/assets/images/defaultImages/Spinner.gif +0 -0
  37. package/dist/assets/images/defaultImages/notFound.svg +0 -124
  38. package/dist/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +0 -72
  39. package/dist/components/atoms/ButtonFileChooser/index.js +0 -118
  40. package/dist/components/atoms/ButtonFileChooser/styles.js +0 -20
  41. package/dist/components/atoms/ButtonV2/ButtonV2.stories.js +0 -66
  42. package/dist/components/atoms/ButtonV2/index.js +0 -111
  43. package/dist/components/atoms/ButtonV2/styles.js +0 -53
  44. package/dist/components/atoms/ChatPopUp/ChatPopUp.stories.js +0 -28
  45. package/dist/components/atoms/ChatPopUp/index.js +0 -841
  46. package/dist/components/atoms/ChatPopUp/styles.js +0 -27
  47. package/dist/components/atoms/ChatPopUp/utils/handlersChat.js +0 -182
  48. package/dist/components/atoms/CustomIcon/CustomIcon.stories.js +0 -50
  49. package/dist/components/atoms/CustomIcon/index.js +0 -40
  50. package/dist/components/atoms/CustomIcon/styles.js +0 -33
  51. package/dist/components/atoms/IconFile/IconFile.stories.js +0 -48
  52. package/dist/components/atoms/IconFile/index.js +0 -249
  53. package/dist/components/atoms/IconFile/styles.js +0 -23
  54. package/dist/components/atoms/Image/Image.stories.js +0 -73
  55. package/dist/components/atoms/Image/index.js +0 -76
  56. package/dist/components/atoms/Image/styles.js +0 -43
  57. package/dist/components/atoms/ImageLink/ImageLink.stories.js +0 -63
  58. package/dist/components/atoms/ImageLink/index.js +0 -77
  59. package/dist/components/atoms/ImageLink/styles.js +0 -40
  60. package/dist/components/atoms/ImagePreview/ImagePreview.stories.js +0 -70
  61. package/dist/components/atoms/ImagePreview/index.js +0 -222
  62. package/dist/components/atoms/ImagePreview/styles.js +0 -44
  63. package/dist/components/atoms/InputText/InputText.stories.js +0 -60
  64. package/dist/components/atoms/InputText/index.js +0 -66
  65. package/dist/components/atoms/InputText/styles.js +0 -32
  66. package/dist/components/atoms/NotFound/NotFound.stories.js +0 -36
  67. package/dist/components/atoms/NotFound/index.js +0 -75
  68. package/dist/components/atoms/NotFound/styles.js +0 -20
  69. package/dist/components/atoms/SelectItemV2/SelectItemV2.stories.js +0 -45
  70. package/dist/components/atoms/SelectItemV2/index.js +0 -46
  71. package/dist/components/atoms/SelectItemV2/styles.js +0 -23
  72. package/dist/components/atoms/Tooltip/Tooltip.stories.js +0 -66
  73. package/dist/components/atoms/Tooltip/index.js +0 -72
  74. package/dist/components/atoms/Tooltip/styles.js +0 -20
  75. package/dist/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +0 -66
  76. package/dist/components/molecules/ButtonDownloadFile/index.js +0 -179
  77. package/dist/components/molecules/ButtonDownloadFile/styles.js +0 -23
  78. package/dist/components/molecules/ImageTooltip/ImageTooltip.stories.js +0 -72
  79. package/dist/components/molecules/ImageTooltip/index.js +0 -84
  80. package/dist/components/molecules/ImageTooltip/styles.js +0 -33
  81. package/dist/components/molecules/SelectV2/SelectV2.stories.js +0 -119
  82. package/dist/components/molecules/SelectV2/index.js +0 -298
  83. package/dist/components/molecules/SelectV2/styles.js +0 -42
  84. package/dist/components/organisms/Chat/Chat.stories.js +0 -215
  85. package/dist/components/organisms/Chat/ChatLists/ChatLists.stories.js +0 -83
  86. package/dist/components/organisms/Chat/ChatLists/index.js +0 -160
  87. package/dist/components/organisms/Chat/ChatLists/styles.js +0 -29
  88. package/dist/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +0 -176
  89. package/dist/components/organisms/Chat/ContainerItems/index.js +0 -569
  90. package/dist/components/organisms/Chat/ContainerItems/styles.js +0 -20
  91. package/dist/components/organisms/Chat/ContentChat/ContentChat.stories.js +0 -142
  92. package/dist/components/organisms/Chat/ContentChat/index.js +0 -1422
  93. package/dist/components/organisms/Chat/ContentChat/styles.js +0 -20
  94. package/dist/components/organisms/Chat/Footer/Footer.stories.js +0 -43
  95. package/dist/components/organisms/Chat/Footer/index.js +0 -984
  96. package/dist/components/organisms/Chat/Footer/styles.js +0 -32
  97. package/dist/components/organisms/Chat/Header/Header.stories.js +0 -96
  98. package/dist/components/organisms/Chat/Header/index.js +0 -84
  99. package/dist/components/organisms/Chat/Header/styles.js +0 -20
  100. package/dist/components/organisms/Chat/index.js +0 -327
  101. package/dist/components/organisms/Chat/styles.js +0 -29
  102. package/dist/components/organisms/Modal/Modal.stories.js +0 -66
  103. package/dist/components/organisms/Modal/index.js +0 -95
  104. package/dist/components/organisms/Modal/styles.js +0 -20
  105. package/dist/global-files/handle_http.js +0 -383
  106. package/dist/global-files/utils.js +0 -472
@@ -31,66 +31,75 @@ RetailerProductEditionDefault.args = {
31
31
  "Ficha técnica": false,
32
32
  Imágenes: false
33
33
  },
34
- token: "eyJraWQiOiJEV3owZnNieXg2MXNFcVduN3RCXC81bVhod3ZNbFZIOTgwUnZcL3RjT0lKdEk9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI4ZDAxMDIxNC01YmZhLTQzYzMtOTZmYi1jNTU2ZGMwNTc3NGIiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfbFN6UVo0WjdSIiwiY29nbml0bzp1c2VybmFtZSI6IjhkMDEwMjE0LTViZmEtNDNjMy05NmZiLWM1NTZkYzA1Nzc0YiIsImF1ZCI6IjUyZDlza2tkY2c4cWpwODhvb2sxdXNlNm1rIiwiZXZlbnRfaWQiOiI2ZWY3Y2UxYy0xYjBjLTRkNGYtYTc3Yy1jMWIwYTk0ZjIwOWEiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY2NzMyMTQ5NCwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY2NzMyNTA5NCwiaWF0IjoxNjY3MzIxNDk0LCJlbWFpbCI6ImthcmFmZTMyMThAbW9tMmtpZC5jb20ifQ.GjBtY-LW5eYzvNfrIJOdb9pDMU_CZlIxRAn1ZszjMfWNU9s8s_j6o4_2x0J7AyiSjgu9TaLRcRpF6FZ5pzwNGs8G5AxnO3r_PIg2mznM44QLnt5PTfdoFx2jJmU53UA8GZU1SFDvDlR1QZR-EtANz2wfNs8RqY_mKTz5WjY7RdGTFVkowTv-Y1Q9T7x_fpv_5o-nB5GzLBQoHwTLQ_vjguSLH17l2BUn0QxLi2WJVs-qWX4ze4QysADVxYOlMkAQql328oqoqdXRbZrntnxYxa5EMpmref1bGbSOFk4qgHax4qa3gD2_h291NLjCZS7IMGDSIhOk9r7irItbojM01Q",
34
+ token: "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJhNmM0ZDNkNi0yNGE0LTQxZDQtYWQwZi1kMDg3NDM4YWI1YjYiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwiY29nbml0bzp1c2VybmFtZSI6ImE2YzRkM2Q2LTI0YTQtNDFkNC1hZDBmLWQwODc0MzhhYjViNiIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiI0MmE2OWE4My02OGY0LTRmZjktOGU4Zi1jYzgxODQ5MDU5NGYiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY2OTkyODUxMSwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY2OTkzMjExMSwiaWF0IjoxNjY5OTI4NTExLCJlbWFpbCI6ImV0Y0Bjb250ZW50b2guY29tIn0.Mv1hFVjkF2y__7XP0bXzU2Yq8YMc0go9OgB7all5F4HvfK62I0l9rNRqddlaLjDSCmjvyYI-M8WFwHtdlOL1-liazZr8hhu7_9SciapRzkuuHlWwu0g3EEK54NuHR3-YYRax85hKyN9YoV1MY_fTzT9WUVXWoqf4UPj2SH79g_A0l0lm18ODzzdhXFSpubuI8-Ml7MbXUh8klzl7T55S16sj8zPONpesrA01WsG1PWGqfRZI2g37edj_en2_fIcfi49tQjbSjnQOVOPnkO5TPiyoMtZdS53Rx75iSI8-fP-Z7kD-5TI_KK6vK35PHoG1B-N3EzDUjXek4MowNswnGA",
35
35
  productSelected: {
36
36
  services: {
37
37
  datasheets: 1,
38
38
  descriptions: 1,
39
39
  images: 1
40
40
  },
41
- orderId: 3321,
41
+ orderId: 123,
42
42
  status: "PA",
43
- datasheet_status: "AC",
43
+ datasheet_status: "PA",
44
44
  prio: "none",
45
- version: 2,
46
- description_status: "AC",
45
+ version: 3,
46
+ description_status: "PA",
47
47
  images_status: "PA",
48
48
  statusByRetailer: {
49
- 58: {
50
- datasheet: "AC",
51
- description: "AC",
49
+ 4: {
50
+ datasheet: "PA",
51
+ description: "PA",
52
+ images: "PA"
53
+ },
54
+ 5: {
55
+ datasheet: "PA",
56
+ description: "PA",
57
+ images: "PA"
58
+ },
59
+ 6: {
60
+ datasheet: "PA",
61
+ description: "PA",
52
62
  images: "PA"
53
63
  }
54
64
  },
55
65
  article: {
56
- id_article: 85655,
57
- id_category: "2052",
58
- name: "EXTENSION P/ EXTERIOR 3X10 AWG 10M ROJO",
59
- upc: "165679",
60
- timestamp: "2022-11-01T15:46:51.000Z",
61
- id_user: 1436,
62
- status: null,
66
+ id_article: 127,
67
+ id_category: "700",
68
+ name: "prueba prod flujo",
69
+ upc: "34234353324",
70
+ timestamp: "2022-11-23T23:12:30.000Z",
71
+ id_user: 28,
72
+ status: "NULL",
63
73
  active: 1,
64
- company_id: 409,
65
- SKU: null,
66
- Descripcion: null,
67
- Proveedor: null,
68
- id_proveedor: 0,
69
- company_name: "HIGHLINE-WARREN LLC",
70
- country: null,
71
- id_order: 3321,
72
- id_datasheet_especialist: 1248,
73
- id_datasheet_facilitator: null,
74
- id_description_especialist: 1248,
75
- id_description_facilitator: null,
76
- id_images_especialist: null,
77
- id_images_facilitator: null,
78
- id_auditor: null,
74
+ company_id: 1,
75
+ company_name: "GRUPO BRAHMA",
76
+ country: "México",
77
+ id_order: 123,
78
+ id_datasheet_especialist: 54,
79
+ id_datasheet_facilitator: 52,
80
+ id_description_especialist: 54,
81
+ id_description_facilitator: 52,
82
+ id_images_especialist: 55,
83
+ id_images_facilitator: 53,
84
+ id_auditor: 37,
79
85
  id_recepcionist: null,
80
- category: "Eléctrico|Extensiones y Multicontactos|Extensiones y Multicontactos",
81
- missingAttributes: null,
82
- missingDescriptions: null,
83
- missingImages: null
86
+ category: "Salud y Belleza|Cuidado Facial|Cremas, Mascarillas y Tratamientos",
87
+ missingAttributes: 0,
88
+ missingDescriptions: 0,
89
+ missingImages: 0
84
90
  },
85
91
  retailers: [{
86
- id: 58,
87
- name: "The Home Depot Golden",
88
- country: "México",
89
- id_region: 1,
90
- active: 1
92
+ id: 4,
93
+ name: "Walmart Super y Superama"
94
+ }, {
95
+ id: 5,
96
+ name: "Chedraui"
97
+ }, {
98
+ id: 6,
99
+ name: "HEB"
91
100
  }],
92
- country: null,
93
- upc: "165679"
101
+ country: "México",
102
+ upc: "34234353324"
94
103
  },
95
104
  location: {
96
105
  product: {
@@ -99,36 +108,37 @@ RetailerProductEditionDefault.args = {
99
108
  }
100
109
  },
101
110
  user: {
102
- id_user: 426,
103
- name: "Especialista Textos",
104
- last_name: " ",
105
- email: "karafe3218@mom2kid.com",
106
- position: "Tester",
107
- telephone: null,
108
- country: null,
109
- id_company: 254,
110
- id_cognito: "8d010214-5bfa-43c3-96fb-c556dc05774b",
111
+ id_user: 51,
112
+ name: "ADMIN PRUEBA",
113
+ last_name: "",
114
+ email: "etc@contentoh.com",
115
+ position: "",
116
+ telephone: "",
117
+ country: "",
118
+ id_company: 2,
119
+ id_cognito: "a6c4d3d6-24a4-41d4-ad0f-d087438ab5b6",
111
120
  birth_Date: null,
112
- about_me: null,
113
- zip_code: null,
114
- address: null,
115
- job: null,
116
- id_stripe: null,
117
- id_role: 7,
121
+ about_me: "",
122
+ zip_code: "",
123
+ address: "",
124
+ job: "",
125
+ id_stripe: "",
126
+ id_role: 1,
118
127
  active: 1,
119
128
  is_retailer: 0,
120
- email_notify: null,
129
+ email_notify: 1,
130
+ is_user_tech: null,
121
131
  membership: {
122
- id: 750,
123
- start_date: "2022-01-07T21:32:54.000Z",
124
- end_date: "2023-01-07T21:32:54.000Z",
125
- planID: 6,
126
- plan: "prod_KvGd6YSTJyR3AP",
127
- name: "Plan Small",
128
- user_limit: "10",
129
- products_limit: "1000",
130
- type: "Enterprise"
132
+ id: 2,
133
+ start_date: "2021-11-05T02:35:12.000Z",
134
+ end_date: "2022-11-05T02:34:49.000Z",
135
+ planID: 1,
136
+ plan: "prod_KtkvuFFLpOdP6e",
137
+ name: "Plan Free",
138
+ user_limit: "1",
139
+ products_limit: "3",
140
+ type: "PyMES"
131
141
  },
132
- src: "https://content-management-profile-prod.s3.amazonaws.com/id-426/426.png?1667321494598"
142
+ src: "https://content-management-profile.s3.amazonaws.com/id-51/51.png?1669928511679"
133
143
  }
134
144
  };
@@ -77,8 +77,6 @@ var _VersionSelector = require("../../organisms/VersionSelector");
77
77
 
78
78
  var _customHooks = require("../../../global-files/customHooks");
79
79
 
80
- var _CreateVersion = require("../../organisms/CreateVersion");
81
-
82
80
  var _jsxRuntime = require("react/jsx-runtime");
83
81
 
84
82
  var reducerImages = function reducerImages(state, action) {
@@ -433,22 +431,10 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
433
431
  socketType = _useState66[0],
434
432
  setSocketType = _useState66[1];
435
433
 
436
- var _useState67 = (0, _react.useState)([]),
434
+ var _useState67 = (0, _react.useState)(loading),
437
435
  _useState68 = (0, _slicedToArray2.default)(_useState67, 2),
438
- servicesStatus = _useState68[0],
439
- setServicesStatus = _useState68[1];
440
-
441
- var _useState69 = (0, _react.useState)(loading),
442
- _useState70 = (0, _slicedToArray2.default)(_useState69, 2),
443
- saving = _useState70[0],
444
- setSaving = _useState70[1];
445
-
446
- var isAuditor = user.id_role === 6;
447
-
448
- var _useState71 = (0, _react.useState)(false),
449
- _useState72 = (0, _slicedToArray2.default)(_useState71, 2),
450
- showCreateVersion = _useState72[0],
451
- setShowCreateVersion = _useState72[1];
436
+ saving = _useState68[0],
437
+ setSaving = _useState68[1];
452
438
 
453
439
  var _useCloseModal = (0, _customHooks.useCloseModal)("version-selector"),
454
440
  _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
@@ -2053,13 +2039,8 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
2053
2039
  setVersion: setVersion,
2054
2040
  companyName: product.article.company_name,
2055
2041
  currentVersion: version,
2056
- setShowCreateVersion: setShowCreateVersion,
2057
2042
  setShowVersionSelector: setShowVersionSelector,
2058
2043
  jwt: token
2059
- }), showCreateVersion && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CreateVersion.CreateVersion, {
2060
- idArticle: product.article.id_article,
2061
- version: version,
2062
- setShowCreateVersion: setShowCreateVersion
2063
2044
  })]
2064
2045
  });
2065
2046
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.2.101",
3
+ "version": "21.2.103",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -15,7 +15,10 @@ export const Button = ({
15
15
  id={id}
16
16
  className={buttonType}
17
17
  buttonFont={buttonFont}
18
- onClick={onClick}
18
+ onClick={(e) => {
19
+ e.stopPropagation();
20
+ onClick(e);
21
+ }}
19
22
  key={`button-${buttonType}`}
20
23
  disabled={buttonType === "general-button-disabled"}
21
24
  >
@@ -13,11 +13,13 @@ export const VersionSelect = ({
13
13
  <select
14
14
  id={id}
15
15
  name={id}
16
- value={`Version ${selectedVersions[id]}`}
16
+ value={selectedVersions[id]}
17
17
  onChange={onChange}
18
18
  >
19
19
  {versions.map((item, index) => (
20
- <option key={`${id}-${index}`}>Version {item.version}</option>
20
+ <option key={`${id}-${index}`} value={item.version}>
21
+ Version {item.version}
22
+ </option>
21
23
  ))}
22
24
  </select>
23
25
  </VrsnSelect>
@@ -21,27 +21,25 @@ export const Children = (
21
21
  <img src={createVersionImg} alt="create version icon" />
22
22
  <ScreenHeader
23
23
  fontFamily={FontFamily.Raleway_500}
24
- headerType={"product-name-header"}
24
+ headerType="product-name-header"
25
25
  color={GlobalColors.white}
26
- text={"Crea una nueva versión"}
26
+ text="Crea una nueva versión"
27
27
  />
28
28
  <ScreenHeader
29
29
  fontFamily={FontFamily.Raleway}
30
- headerType={"retailer-name-header"}
30
+ headerType="retailer-name-header"
31
31
  color={GlobalColors.white}
32
- text={
33
- "Puedes elegir el contenido de versiones anteriores o crear una versión desde cero"
34
- }
32
+ text="Puedes elegir el contenido de versiones anteriores o crear una versión desde cero"
35
33
  />
36
34
  <div className="buttons-container">
37
35
  <Button
38
- label={"Versión desde cero"}
39
- buttonType={"general-transparent-button"}
36
+ label="Versión desde cero"
37
+ buttonType="general-transparent-button"
40
38
  onClick={() => setStep("empty-version")}
41
39
  />
42
40
  <Button
43
- label={"Versión personalizada"}
44
- buttonType={"general-default-button"}
41
+ label="Versión personalizada"
42
+ buttonType="general-default-button"
45
43
  onClick={() => setStep("create-version")}
46
44
  />
47
45
  </div>
@@ -53,27 +51,25 @@ export const Children = (
53
51
  <img src={genericModalWarning} alt="warning icon" />
54
52
  <ScreenHeader
55
53
  fontFamily={FontFamily.Raleway_500}
56
- headerType={"product-name-header"}
54
+ headerType="product-name-header"
57
55
  color={GlobalColors.white}
58
- text={
59
- "Si creas una versión desde cero perderas la información actual"
60
- }
56
+ text="Si creas una versión desde cero perderas la información actual"
61
57
  />
62
58
  <ScreenHeader
63
59
  fontFamily={FontFamily.Raleway}
64
- headerType={"retailer-name-header"}
60
+ headerType="retailer-name-header"
65
61
  color={GlobalColors.white}
66
- text={"¿Deseas Continuar?"}
62
+ text="¿Deseas Continuar?"
67
63
  />
68
64
  <div className="buttons-container">
69
65
  <Button
70
- label={"Atrás"}
71
- buttonType={"general-transparent-button"}
66
+ label="Atrás"
67
+ buttonType="general-transparent-button"
72
68
  onClick={() => setStep("version-options")}
73
69
  />
74
70
  <Button
75
- label={"Continuar"}
76
- buttonType={"general-default-button"}
71
+ label="Continuar"
72
+ buttonType="general-default-button"
77
73
  onClick={() => createVersion(true)}
78
74
  />
79
75
  </div>
@@ -84,18 +80,16 @@ export const Children = (
84
80
  <CreateVersion>
85
81
  <ScreenHeader
86
82
  fontFamily={FontFamily.Raleway_500}
87
- headerType={"retailer-name-header"}
83
+ headerType="retailer-name-header"
88
84
  color={GlobalColors.white}
89
- text={
90
- "Elige el contenido que deseas utilizar de versiones anteriores"
91
- }
85
+ text="Elige el contenido que deseas utilizar de versiones anteriores"
92
86
  />
93
87
  <div className="version-selector">
94
88
  <div className="selector">
95
89
  <VersionSelect
96
90
  versions={versions}
97
- label={"Ficha técnica"}
98
- id={"datasheet"}
91
+ label="Ficha técnica"
92
+ id="datasheet"
99
93
  selectedVersions={selectedVersions}
100
94
  onChange={(e) => onChange(e)}
101
95
  />
@@ -103,8 +97,8 @@ export const Children = (
103
97
  <div className="selector">
104
98
  <VersionSelect
105
99
  versions={versions}
106
- label={"Descripción"}
107
- id={"description"}
100
+ label="Descripción"
101
+ id="description"
108
102
  selectedVersions={selectedVersions}
109
103
  onChange={(e) => onChange(e)}
110
104
  />
@@ -112,8 +106,8 @@ export const Children = (
112
106
  <div className="selector">
113
107
  <VersionSelect
114
108
  versions={versions}
115
- label={"Imágenes"}
116
- id={"image"}
109
+ label="Imágenes"
110
+ id="image"
117
111
  selectedVersions={selectedVersions}
118
112
  onChange={(e) => onChange(e)}
119
113
  />
@@ -121,13 +115,13 @@ export const Children = (
121
115
  </div>
122
116
  <div className="buttons-container">
123
117
  <Button
124
- label={"Atrás"}
125
- buttonType={"general-transparent-button"}
118
+ label="Atrás"
119
+ buttonType="general-transparent-button"
126
120
  onClick={() => setStep("version-options")}
127
121
  />
128
122
  <Button
129
- label={"Continuar"}
130
- buttonType={"general-default-button"}
123
+ label="Continuar"
124
+ buttonType="general-default-button"
131
125
  onClick={() => createVersion()}
132
126
  />
133
127
  </div>
@@ -5,48 +5,32 @@ import { useEffect, useState } from "react";
5
5
  import { Children } from "./RenderChilds";
6
6
  import axios from "axios";
7
7
 
8
- export const CreateVersion = ({ idArticle, version, setShowCreateVersion }) => {
8
+ export const CreateVersion = ({
9
+ articleId,
10
+ version,
11
+ setShowCreateVersion,
12
+ versionsList,
13
+ realoadVersion,
14
+ jwt,
15
+ }) => {
9
16
  const [step, setStep] = useState("version-options");
10
- const [versions, setVersions] = useState([]);
11
17
  const [selectedVersions, setSelectedVersions] = useState({
12
18
  datasheet: version,
13
19
  description: version,
14
20
  image: version,
15
21
  });
16
22
 
17
- const getVersions = async () => {
18
- try {
19
- const response = await axios({
20
- method: "get",
21
- url: `${process.env.REACT_APP_VERSIONS_ENDPOINT}?articleId=${idArticle}&provider=true`,
22
- headers: {
23
- Authorization: sessionStorage.getItem("jwt"),
24
- },
25
- });
26
- setVersions(JSON.parse(response.data.body).data);
27
- } catch (error) {
28
- console.log(error);
29
- }
30
- };
31
-
32
23
  const createVersion = async (isEmpty) => {
33
24
  try {
34
- let data = {
35
- articleId: idArticle,
36
- isEmpty,
37
- };
25
+ let data = { articleId, isEmpty };
38
26
 
39
- isEmpty && (data["version"] = selectedVersions);
27
+ if (!isEmpty) data["version"] = selectedVersions;
40
28
 
41
- await axios({
42
- method: "post",
43
- url: process.env.REACT_APP_VERSIONS_ENDPOINT,
44
- data: data,
45
- headers: {
46
- Authorization: sessionStorage.getItem("jwt"),
47
- },
29
+ await axios.post(process.env.REACT_APP_VERSIONS_ENDPOINT, data, {
30
+ headers: { Authorization: jwt },
48
31
  });
49
32
  setShowCreateVersion(false);
33
+ realoadVersion && realoadVersion();
50
34
  } catch (error) {
51
35
  console.log(error);
52
36
  }
@@ -55,17 +39,13 @@ export const CreateVersion = ({ idArticle, version, setShowCreateVersion }) => {
55
39
  const onChange = (e) => {
56
40
  setSelectedVersions({
57
41
  ...selectedVersions,
58
- [e.target.name]: parseInt(e.target.value.slice(-1)),
42
+ [e.target.name]: parseInt(e.target.value),
59
43
  });
60
44
  };
61
45
 
62
- useEffect(async () => {
63
- await getVersions();
64
- }, []);
65
-
66
46
  return (
67
47
  <Container>
68
- <div className="modal-container">
48
+ <div id="create-version" className="modal-container">
69
49
  <div className="button-container">
70
50
  <Button
71
51
  image={closeIcon}
@@ -77,7 +57,7 @@ export const CreateVersion = ({ idArticle, version, setShowCreateVersion }) => {
77
57
  {Children(
78
58
  step,
79
59
  setStep,
80
- versions,
60
+ versionsList,
81
61
  selectedVersions,
82
62
  onChange,
83
63
  createVersion
@@ -8,7 +8,8 @@ import closeIcon from "../../../assets/images/versionSelector/closeVersionSelect
8
8
  import { GlobalColors } from "contentoh-components-library/dist/global-files/variables";
9
9
  import { FontFamily } from "../../../global-files/variables";
10
10
  import { VersionItem } from "../../molecules/VersionItem";
11
- import { version } from "react";
11
+ import { CreateVersion } from "../../organisms/CreateVersion";
12
+ import { useCloseModal } from "../../../global-files/customHooks";
12
13
 
13
14
  export const VersionSelector = ({
14
15
  modalId,
@@ -16,11 +17,13 @@ export const VersionSelector = ({
16
17
  setVersion,
17
18
  companyName,
18
19
  currentVersion,
19
- setShowCreateVersion,
20
20
  setShowVersionSelector,
21
21
  jwt,
22
22
  }) => {
23
23
  const [versions, setVersions] = useState([]);
24
+ const [showCreateVersion, setShowCreateVersion] =
25
+ useCloseModal("create-version");
26
+ const [reload, setReload] = useState(false);
24
27
 
25
28
  const loadProductVersions = async (articleId) => {
26
29
  try {
@@ -41,13 +44,15 @@ export const VersionSelector = ({
41
44
  };
42
45
 
43
46
  useEffect(() => {
47
+ const ac = new AbortController();
44
48
  loadProductVersions(articleId);
45
49
 
46
50
  return () => {
47
51
  setVersions([]);
48
52
  setShowCreateVersion(false);
53
+ return () => ac.abort(); // Abort both fetches on unmount
49
54
  };
50
- }, []);
55
+ }, [reload]);
51
56
 
52
57
  return (
53
58
  <Container id={modalId}>
@@ -86,6 +91,16 @@ export const VersionSelector = ({
86
91
  />
87
92
  ))}
88
93
  </div>
94
+ {showCreateVersion && (
95
+ <CreateVersion
96
+ articleId={articleId}
97
+ version={currentVersion}
98
+ versionsList={versions}
99
+ setShowCreateVersion={setShowCreateVersion}
100
+ realoadVersion={() => setReload(!reload)}
101
+ jwt={jwt}
102
+ />
103
+ )}
89
104
  </Container>
90
105
  );
91
106
  };