contentoh-components-library 21.5.3 → 21.5.5

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 (295) hide show
  1. package/dist/components/organisms/InputGroup/index.js +1 -1
  2. package/dist/components/organisms/Table/styles.js +1 -1
  3. package/dist/components/pages/MultipleEdition/saveData.js +9 -19
  4. package/dist/components/pages/MultipleEdition/styles.js +1 -1
  5. package/dist/components/pages/MultipleEdition/utils.js +86 -153
  6. package/dist/components/pages/ProviderProductEdition/index.js +3 -4
  7. package/package.json +4 -1
  8. package/src/assets/images/Icons/addv2.svg +8 -0
  9. package/src/assets/images/Icons/beenhere.svg +9 -0
  10. package/src/assets/images/Icons/checkv2.svg +8 -0
  11. package/src/assets/images/Icons/close-magenta.svg +9 -0
  12. package/src/assets/images/Icons/close.svg +8 -0
  13. package/src/assets/images/Icons/closeCircle.svg +8 -0
  14. package/src/assets/images/Icons/delete-forever-red.svg +9 -0
  15. package/src/assets/images/Icons/delete-forever-white.svg +10 -0
  16. package/src/assets/images/Icons/edit.svg +8 -0
  17. package/src/assets/images/Icons/fullscreen.svg +3 -0
  18. package/src/assets/images/Icons/infoNR.svg +8 -0
  19. package/src/assets/images/Icons/options.svg +3 -0
  20. package/src/assets/images/Icons/save-white-gray.svg +9 -0
  21. package/src/assets/images/Icons/save-white.svg +9 -0
  22. package/src/assets/images/Icons/save.svg +8 -0
  23. package/src/assets/images/Icons/search.svg +3 -0
  24. package/src/assets/images/Icons/settings.svg +8 -0
  25. package/src/assets/images/Icons/trash.svg +8 -0
  26. package/src/assets/images/Icons/undo.svg +8 -0
  27. package/src/assets/images/Icons/upload-file-white.svg +4 -0
  28. package/src/assets/images/Icons/upload-file.svg +10 -0
  29. package/src/assets/images/Icons/upload_file.svg +10 -0
  30. package/src/assets/images/Icons/warningv2.svg +3 -0
  31. package/src/assets/images/checkBox/checkrosa.svg +3 -0
  32. package/src/assets/images/checkBox/checkverde.svg +3 -0
  33. package/src/assets/images/flagsv2/highPriority.svg +3 -0
  34. package/src/assets/images/flagsv2/lowPriority.svg +3 -0
  35. package/src/assets/images/flagsv2/mediumPriority.svg +3 -0
  36. package/src/assets/images/flagsv2/noPriority.svg +3 -0
  37. package/src/assets/images/generalButton/closeIconWhite.svg +4 -0
  38. package/src/assets/images/generalButton/closeIconv2.svg +4 -0
  39. package/src/assets/images/generalButton/saveIconpink.svg +3 -0
  40. package/src/components/atoms/Avatar/index.js +8 -2
  41. package/src/components/atoms/ButtonV2/ButtonV2.stories.js +1 -0
  42. package/src/components/atoms/ButtonV2/index.js +1 -0
  43. package/src/components/atoms/ButtonV2/styles.js +16 -0
  44. package/src/components/atoms/CharsMissing/Wysiwyg.stories.js +12 -0
  45. package/src/components/atoms/CharsMissing/index.js +60 -0
  46. package/src/components/atoms/CharsMissing/styles.js +44 -0
  47. package/src/components/atoms/CheckBox/CheckBox.stories.js +5 -0
  48. package/src/components/atoms/CheckBox/index.js +5 -1
  49. package/src/components/atoms/CheckBox/styles.js +9 -3
  50. package/src/components/atoms/CustomChip/CustomChip.stories.js +16 -0
  51. package/src/components/atoms/CustomChip/index.js +34 -0
  52. package/src/components/atoms/CustomChip/styles.js +6 -0
  53. package/src/components/atoms/FeatureTagv2/FeatureTagv2.stories.js +16 -0
  54. package/src/components/atoms/FeatureTagv2/index.js +10 -0
  55. package/src/components/atoms/FeatureTagv2/styles.js +56 -0
  56. package/src/components/atoms/GeneralButton/styles.js +46 -0
  57. package/src/components/atoms/GeneralInput/index.js +3 -0
  58. package/src/components/atoms/GeneralInput/styles.js +19 -1
  59. package/src/components/atoms/GeneralInputv2/GeneralInputv2.stories.js +33 -0
  60. package/src/components/atoms/GeneralInputv2/index.js +155 -0
  61. package/src/components/atoms/GeneralInputv2/styles.js +67 -0
  62. package/src/components/atoms/InputFormatter/index.js +2 -1
  63. package/src/components/atoms/InputFormatter/styles.js +9 -4
  64. package/src/components/atoms/InputFormatterv2/Wysiwyg.stories.js +12 -0
  65. package/src/components/atoms/InputFormatterv2/index.js +148 -0
  66. package/src/components/atoms/InputFormatterv2/styles.js +39 -0
  67. package/src/components/atoms/InputImages/InputImages.stories.js +19 -0
  68. package/src/components/atoms/InputImages/index.js +25 -0
  69. package/src/components/atoms/InputImages/styles.js +17 -0
  70. package/src/components/atoms/Multiselect/Multiselect.stories.js +364 -0
  71. package/src/components/atoms/Multiselect/index.js +351 -0
  72. package/src/components/atoms/Multiselect/styles.js +33 -0
  73. package/src/components/atoms/NumberMandatory/NumberMandatory.stories.js +19 -0
  74. package/src/components/atoms/NumberMandatory/index.js +16 -0
  75. package/src/components/atoms/NumberMandatory/styles.js +11 -0
  76. package/src/components/atoms/ObservationFlag/ObservationFlag.stories.js +20 -0
  77. package/src/components/atoms/ObservationFlag/index.js +167 -0
  78. package/src/components/atoms/ObservationFlag/styles.js +104 -0
  79. package/src/components/atoms/PriorityFlagv2/PriorityFlagv2.stories.js +20 -0
  80. package/src/components/atoms/PriorityFlagv2/index.js +20 -0
  81. package/src/components/atoms/PriorityFlagv2/styles.js +6 -0
  82. package/src/components/atoms/ProductImage/index.js +24 -11
  83. package/src/components/atoms/ProductImage/styles.js +7 -0
  84. package/src/components/atoms/ProductImagev2/ProductImagev2.stories.js +28 -0
  85. package/src/components/atoms/ProductImagev2/index.js +16 -0
  86. package/src/components/atoms/ProductImagev2/styles.js +62 -0
  87. package/src/components/atoms/Progress/Progress.stories.js +25 -0
  88. package/src/components/atoms/Progress/index.js +74 -0
  89. package/src/components/atoms/Progress/styles.js +98 -0
  90. package/src/components/atoms/ScreenHeaderv2/ScreenHeaderv2.stories.js +53 -0
  91. package/src/components/atoms/ScreenHeaderv2/index.js +134 -0
  92. package/src/components/atoms/ScreenHeaderv2/styles.js +103 -0
  93. package/src/components/atoms/Selectv2/VersionSelect.js +27 -0
  94. package/src/components/atoms/Selectv2/index.js +35 -0
  95. package/src/components/atoms/Selectv2/style.js +93 -0
  96. package/src/components/atoms/SliderToolTip/styles.js +1 -1
  97. package/src/components/atoms/TabSection/index.js +1 -1
  98. package/src/components/atoms/TabSection/styles.js +0 -3
  99. package/src/components/atoms/TabSectionv2/TabSection.stories.js +25 -0
  100. package/src/components/atoms/TabSectionv2/index.js +9 -0
  101. package/src/components/atoms/TabSectionv2/styles.js +20 -0
  102. package/src/components/atoms/TooltipLight/Tooltip.stories.js +20 -0
  103. package/src/components/atoms/TooltipLight/index.js +46 -0
  104. package/src/components/atoms/TooltipLight/styles.js +65 -0
  105. package/src/components/atoms/WordsMissing/Wysiwyg.stories.js +12 -0
  106. package/src/components/atoms/WordsMissing/index.js +60 -0
  107. package/src/components/atoms/WordsMissing/styles.js +10 -0
  108. package/src/components/molecules/AddGroup/AddGroup.stories.js +15 -0
  109. package/src/components/molecules/AddGroup/index.js +84 -0
  110. package/src/components/molecules/AddGroup/styles.js +141 -0
  111. package/src/components/molecules/AsignationInfo/AsignationInfo.stories.js +17 -0
  112. package/src/components/molecules/AsignationInfo/index.js +108 -0
  113. package/src/components/molecules/AsignationInfo/styles.js +86 -0
  114. package/src/components/molecules/BoxAttribute/index.js +32 -25
  115. package/src/components/molecules/BoxAttribute/styles.js +1 -1
  116. package/src/components/molecules/BoxButtons/index.js +23 -22
  117. package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
  118. package/src/components/molecules/EditionActiveImagev2/EditionActiveImagev2.stories.js +12 -0
  119. package/src/components/molecules/EditionActiveImagev2/index.js +15 -0
  120. package/src/components/molecules/EditionActiveImagev2/styles.js +7 -0
  121. package/src/components/molecules/EditionTabs/EditionTabs.stories.js +12 -0
  122. package/src/components/molecules/EditionTabs/index.js +33 -0
  123. package/src/components/molecules/EditionTabs/styles.js +24 -0
  124. package/src/components/molecules/FeaturesBarv2/FeaturesBarv2.stories.js +20 -0
  125. package/src/components/molecules/FeaturesBarv2/index.js +32 -0
  126. package/src/components/molecules/FeaturesBarv2/styles.js +17 -0
  127. package/src/components/molecules/GalleryElement/index.js +76 -1
  128. package/src/components/molecules/GalleryElementv2/GalleryElementv2.stories.js +30 -0
  129. package/src/components/molecules/GalleryElementv2/index.js +142 -0
  130. package/src/components/molecules/GalleryElementv2/styles.js +119 -0
  131. package/src/components/molecules/GalleryHeader/index.js +1 -0
  132. package/src/components/molecules/GalleryHeaderv2/GalleryHeaderv2.stories.js +10 -0
  133. package/src/components/molecules/GalleryHeaderv2/index.js +25 -0
  134. package/src/components/molecules/GalleryHeaderv2/styles.js +47 -0
  135. package/src/components/molecules/GroupSelect/GroupSelect.stories.js +35 -0
  136. package/src/components/molecules/GroupSelect/SelectItem.js +105 -0
  137. package/src/components/molecules/GroupSelect/index.js +190 -0
  138. package/src/components/molecules/GroupSelect/styles.js +124 -0
  139. package/src/components/molecules/HeaderTop/index.js +52 -6
  140. package/src/components/molecules/HeaderTopv2/HeaderTopv2.stories.js +10 -0
  141. package/src/components/molecules/HeaderTopv2/index.js +100 -0
  142. package/src/components/molecules/HeaderTopv2/styles.js +33 -0
  143. package/src/components/molecules/ImageSelectorv2/ImageSelectorv2.stories.js +46 -0
  144. package/src/components/molecules/ImageSelectorv2/index.js +22 -0
  145. package/src/components/molecules/ImageSelectorv2/styles.js +15 -0
  146. package/src/components/molecules/Phase/Phase.stories.js +107 -0
  147. package/src/components/molecules/Phase/index.js +391 -0
  148. package/src/components/molecules/Phase/styles.js +97 -0
  149. package/src/components/molecules/ProductNameHeader/index.js +19 -1
  150. package/src/components/molecules/ProductNameHeaderv2/ProductNameHeaderv2.stories.js +37 -0
  151. package/src/components/molecules/ProductNameHeaderv2/index.js +12 -0
  152. package/src/components/molecules/ProductNameHeaderv2/styles.js +10 -0
  153. package/src/components/molecules/ProductSkuStatus/ProductSkuStatus.stories.js +37 -0
  154. package/src/components/molecules/ProductSkuStatus/index.js +26 -0
  155. package/src/components/molecules/ProductSkuStatus/styles.js +7 -0
  156. package/src/components/molecules/RetailerSelectorv2/RetailerSelectorv2.stories.js +35 -0
  157. package/src/components/molecules/RetailerSelectorv2/index.js +80 -0
  158. package/src/components/molecules/RetailerSelectorv2/styles.js +21 -0
  159. package/src/components/molecules/ServiceDataValidator/ServiceDataValidator.stories.js +90 -0
  160. package/src/components/molecules/ServiceDataValidator/index.js +49 -0
  161. package/src/components/molecules/ServiceDataValidator/styles.js +36 -0
  162. package/src/components/molecules/SignInLogin/index.js +11 -11
  163. package/src/components/molecules/StatusAsignationInfo/FinancedCompanies.js +501 -63
  164. package/src/components/molecules/StatusAsignationInfo/index.js +1 -1
  165. package/src/components/molecules/StatusRetailer/StatusAsignationInfo.stories.js +17 -0
  166. package/src/components/molecules/StatusRetailer/index.js +55 -0
  167. package/src/components/molecules/StatusRetailer/styles.js +85 -0
  168. package/src/components/molecules/StripeCardSelector/CardSelector.stories.js +1 -2
  169. package/src/components/molecules/TabsMenuv2/TabsMenuv2.stories.js +19 -0
  170. package/src/components/molecules/TabsMenuv2/index.js +112 -0
  171. package/src/components/molecules/TabsMenuv2/styles.js +19 -0
  172. package/src/components/molecules/TagAndInput/index.js +8 -6
  173. package/src/components/molecules/TagAndInputv2/TagAndInputv2.stories.js +24 -0
  174. package/src/components/molecules/TagAndInputv2/index.js +86 -0
  175. package/src/components/molecules/TagAndInputv2/styles.js +35 -0
  176. package/src/components/molecules/Validation/Validation.stories.js +12 -0
  177. package/src/components/molecules/Validation/index.js +77 -0
  178. package/src/components/molecules/Validation/styles.js +19 -0
  179. package/src/components/molecules/VersionItemv2/VersionItemv2.stories.js +14 -0
  180. package/src/components/molecules/VersionItemv2/index.js +59 -0
  181. package/src/components/molecules/VersionItemv2/styles.js +47 -0
  182. package/src/components/organisms/BarButtons/BarButtons.stories.js +13 -0
  183. package/src/components/organisms/BarButtons/index.js +150 -0
  184. package/src/components/organisms/BarButtons/styles.js +54 -0
  185. package/src/components/organisms/Chat/Chat.stories.js +27 -7
  186. package/src/components/organisms/Chat/ContainerItems/index.js +18 -2
  187. package/src/components/organisms/Chat/ContainerItems/styles.js +14 -2
  188. package/src/components/organisms/Chat/ContentChat/index.js +88 -12
  189. package/src/components/organisms/Chat/Footer/index.js +11 -0
  190. package/src/components/organisms/Chat/index.js +46 -4
  191. package/src/components/organisms/Chat/styles.js +4 -0
  192. package/src/components/organisms/Chatv2/ChatLists/ChatLists.stories.js +65 -0
  193. package/src/components/organisms/Chatv2/ChatLists/Rotoplas.jpeg +0 -0
  194. package/src/components/organisms/Chatv2/ChatLists/THD.png +0 -0
  195. package/src/components/organisms/Chatv2/ChatLists/index.js +141 -0
  196. package/src/components/organisms/Chatv2/ChatLists/styles.js +162 -0
  197. package/src/components/organisms/Chatv2/Chatv2.stories.js +184 -0
  198. package/src/components/organisms/Chatv2/ContainerItems/ContainerItems.stories.js +142 -0
  199. package/src/components/organisms/Chatv2/ContainerItems/index.js +538 -0
  200. package/src/components/organisms/Chatv2/ContainerItems/styles.js +360 -0
  201. package/src/components/organisms/Chatv2/ContentChat/ContentChat.stories.js +102 -0
  202. package/src/components/organisms/Chatv2/ContentChat/Rotoplas.jpeg +0 -0
  203. package/src/components/organisms/Chatv2/ContentChat/THD.png +0 -0
  204. package/src/components/organisms/Chatv2/ContentChat/index.js +1016 -0
  205. package/src/components/organisms/Chatv2/ContentChat/styles.js +44 -0
  206. package/src/components/organisms/Chatv2/Footer/Footer.stories.js +22 -0
  207. package/src/components/organisms/Chatv2/Footer/index.js +668 -0
  208. package/src/components/organisms/Chatv2/Footer/styles.js +290 -0
  209. package/src/components/organisms/Chatv2/Header/Header.stories.js +66 -0
  210. package/src/components/organisms/Chatv2/Header/index.js +93 -0
  211. package/src/components/organisms/Chatv2/Header/styles.js +49 -0
  212. package/src/components/organisms/Chatv2/index.js +281 -0
  213. package/src/components/organisms/Chatv2/styles.js +85 -0
  214. package/src/components/organisms/CompleteServices/CompleteServices.stories.js +91 -0
  215. package/src/components/organisms/CompleteServices/index.js +82 -0
  216. package/src/components/organisms/CompleteServices/styles.js +35 -0
  217. package/src/components/organisms/DashboardMetric/index.js +6 -3
  218. package/src/components/organisms/DragAndDropPhases/DragAndDropPhases.stories.js +13 -0
  219. package/src/components/organisms/DragAndDropPhases/index.js +336 -0
  220. package/src/components/organisms/DragAndDropPhases/styles.js +107 -0
  221. package/src/components/organisms/DragPrueba/DragPrueba.stories.js +12 -0
  222. package/src/components/organisms/DragPrueba/index.js +57 -0
  223. package/src/components/organisms/DragPrueba/styles.js +8 -0
  224. package/src/components/organisms/EditGroup/EditGroup.stories.js +20 -0
  225. package/src/components/organisms/EditGroup/index.js +321 -0
  226. package/src/components/organisms/EditGroup/styles.js +207 -0
  227. package/src/components/organisms/FullProductNameHeader/index.js +13 -1
  228. package/src/components/organisms/FullProductNamev2/FullProductNamev2.stories.js +28 -0
  229. package/src/components/organisms/FullProductNamev2/index.js +101 -0
  230. package/src/components/organisms/FullProductNamev2/styles.js +49 -0
  231. package/src/components/organisms/FullTabsMenuv2/FullTabsMenuv2.stories.js +22 -0
  232. package/src/components/organisms/FullTabsMenuv2/index.js +142 -0
  233. package/src/components/organisms/FullTabsMenuv2/styles.js +47 -0
  234. package/src/components/organisms/GridProducts/GridProducts.stories.js +682 -107
  235. package/src/components/organisms/ImageDataTablev2/ImageDataTablev2.stories.js +24 -0
  236. package/src/components/organisms/ImageDataTablev2/index.js +124 -0
  237. package/src/components/organisms/ImageDataTablev2/styles.js +18 -0
  238. package/src/components/organisms/ImagePreviewerv2/ImagePreviewerv2.stories.js +38 -0
  239. package/src/components/organisms/ImagePreviewerv2/index.js +22 -0
  240. package/src/components/organisms/ImagePreviewerv2/styles.js +7 -0
  241. package/src/components/organisms/ImageUploader/ImageUploader.stories.js +15 -0
  242. package/src/components/organisms/ImageUploader/index.js +62 -0
  243. package/src/components/organisms/ImageUploader/styles.js +29 -0
  244. package/src/components/organisms/ImageVisor/ImageVisor.stories.js +15 -0
  245. package/src/components/organisms/ImageVisor/index.js +143 -0
  246. package/src/components/organisms/ImageVisor/styles.js +106 -0
  247. package/src/components/organisms/InputGroup/index.js +292 -144
  248. package/src/components/organisms/InputGroup/styles.js +31 -0
  249. package/src/components/organisms/InputGroupv2/InputGroupv2.stories.js +31 -0
  250. package/src/components/organisms/InputGroupv2/index.js +296 -0
  251. package/src/components/organisms/InputGroupv2/styles.js +90 -0
  252. package/src/components/organisms/MandatoryBar/MandatoryBar.stories.js +18 -0
  253. package/src/components/organisms/MandatoryBar/index.js +31 -0
  254. package/src/components/organisms/MandatoryBar/styles.js +12 -0
  255. package/src/components/organisms/Modal/Modal.stories.js +2 -1
  256. package/src/components/organisms/Modal/index.js +9 -2
  257. package/src/components/organisms/Modal/styles.js +8 -1
  258. package/src/components/organisms/OrderDetail/utils/Table/utils.js +6 -16
  259. package/src/components/organisms/ProductImageModalv2/ProductImageModalv2.stories.js +90 -0
  260. package/src/components/organisms/ProductImageModalv2/index.js +105 -0
  261. package/src/components/organisms/ProductImageModalv2/styles.js +71 -0
  262. package/src/components/organisms/RenameImagesBar/RenameImagesBar.stories.js +18 -0
  263. package/src/components/organisms/RenameImagesBar/index.js +30 -0
  264. package/src/components/organisms/RenameImagesBar/styles.js +12 -0
  265. package/src/components/organisms/Table/Table.stories.js +609 -0
  266. package/src/components/organisms/Table/index.js +84 -0
  267. package/src/components/organisms/Table/styles.js +114 -0
  268. package/src/components/organisms/VersionSelectorv2/VersionSelectorv2.stories.js +15 -0
  269. package/src/components/organisms/VersionSelectorv2/index.js +105 -0
  270. package/src/components/organisms/VersionSelectorv2/styles.js +45 -0
  271. package/src/components/pages/Dashboard/Dashboard.stories.js +33 -38
  272. package/src/components/pages/Dashboard/index.js +36 -7
  273. package/src/components/pages/MultipleEdition/MultipleEdition.stories.js +17 -0
  274. package/src/components/pages/MultipleEdition/components/ImageUploader.js +62 -0
  275. package/src/components/pages/MultipleEdition/components/ImageUploaderStyles.js +29 -0
  276. package/src/components/pages/MultipleEdition/components/ImageVisor.js +143 -0
  277. package/src/components/pages/MultipleEdition/components/styles.js +106 -0
  278. package/src/components/pages/MultipleEdition/index.js +248 -0
  279. package/src/components/pages/MultipleEdition/saveData.js +92 -0
  280. package/src/components/pages/MultipleEdition/styles.js +201 -0
  281. package/src/components/pages/MultipleEdition/utils.js +1073 -0
  282. package/src/components/pages/ProductEditionv2/ProductEditionv2.stories.js +213 -0
  283. package/src/components/pages/ProductEditionv2/index.js +1758 -0
  284. package/src/components/pages/ProductEditionv2/styles.js +154 -0
  285. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +56 -60
  286. package/src/components/pages/ProviderProductEdition/index.js +149 -133
  287. package/src/components/pages/ProviderProductEdition/styles.js +5 -1
  288. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +4 -0
  289. package/src/components/pages/RetailerProductEdition/generateThumnail.js +21 -0
  290. package/src/components/pages/RetailerProductEdition/index.js +293 -300
  291. package/src/components/pages/RetailerProductEdition/styles.js +4 -0
  292. package/src/components/pages/RetailerProductEdition/utils.js +37 -0
  293. package/src/global-files/data.js +6 -10
  294. package/src/global-files/variables.js +6 -0
  295. package/src/index.js +12 -0
@@ -0,0 +1,1073 @@
1
+ import axios from "axios";
2
+ import { ImageVisor } from "../../organisms/ImageVisor";
3
+ import { ButtonV2 } from "../../atoms/ButtonV2";
4
+ import { deleteImage, saveData} from "./saveData";
5
+ import { Container, Input, InputBase, TextField } from "@mui/material";
6
+ import { ValidationPanel } from "../../atoms/ValidationPanel";
7
+ import { TagAndInput } from "../../molecules/TagAndInput";
8
+ import acceptIcon from "../../../assets/images/generalButton/acceptIcon.svg";
9
+ import rejectIcon from "../../../assets/images/generalButton/rejectIcon.svg";
10
+ import infoIcon from "../../../assets/images/Icons/info.svg";
11
+ import saveWhite from "../../../assets/images/Icons/save-white.svg";
12
+ import saveWhiteGray from "../../../assets/images/Icons/save-white-gray.svg";
13
+ import { DockSharp } from "@mui/icons-material";
14
+ import React, { useState } from 'react';
15
+ import nullIcon from "../../../assets/images/generalButton/nullIcon.svg";
16
+ import { Tooltip } from "../../atoms/Tooltip";
17
+
18
+ // variables
19
+ export const optionsSelect = [
20
+ {
21
+ label: "item 1",
22
+ value: 1,
23
+ },
24
+ {
25
+ label: "item 2",
26
+ value: 2,
27
+ },
28
+ {
29
+ label: "item 3",
30
+ value: 3,
31
+ },
32
+ {
33
+ label: "item 4",
34
+ value: 4,
35
+ },
36
+ ];
37
+
38
+ export const columnsBase = [
39
+ {
40
+ Header: "UPC",
41
+ accessor: "upc",
42
+ width: "100px",
43
+ fixedToLeft: 0,
44
+ style: {
45
+ textAlign: "left",
46
+ },
47
+ },
48
+ {
49
+ Header: "Nombre",
50
+ accessor: "name",
51
+ width: "100px",
52
+ fixedToLeft: 100,
53
+ },
54
+ {
55
+ Header: "Categoría",
56
+ accessor: "category",
57
+ width: "100px",
58
+ fixedToLeft: 200,
59
+ },
60
+ {
61
+ Header: "Est.",
62
+ accessor: "status",
63
+ width: "30px",
64
+ fixedToLeft: 300,
65
+ },
66
+ {
67
+ Header: "Ver.",
68
+ accessor: "version",
69
+ width: "30px",
70
+ fixedToLeft: 330,
71
+ style: {
72
+ borderRight: "1px solid #f0f0f0",
73
+ },
74
+ },
75
+ ];
76
+
77
+ // data
78
+ async function getData(service, articles, versions, token) {
79
+ const encodedArticles = encodeURIComponent(articles.join(","));
80
+ const encodedVersion = encodeURIComponent(versions.join(","));
81
+ const params = `?articles=${encodedArticles}&versions=${encodedVersion}`;
82
+ const res = await axios.get(
83
+ `${process.env.REACT_APP_BASE_MULTIPLE_EDITION_ENDPOINT}/${service}${params}`,
84
+ {
85
+ headers: {
86
+ Authorization: token,
87
+ },
88
+ }
89
+ );
90
+ return JSON.parse(res.data.body);
91
+ }
92
+
93
+ // functions
94
+ export function dataReducer(state, action) {
95
+ if (action.type === "init") {
96
+ return action.payload;
97
+ }
98
+ if (action.type === "updateImage") {
99
+ const { articleId, imageId ,token } = action.payload;
100
+ const newImageData = state.images.data.slice();
101
+ const articleIndex = newImageData.findIndex((f) => f.id === articleId);
102
+ const id = newImageData[articleIndex]?.images[imageId]?.value?.id;
103
+ newImageData[articleIndex].images[imageId].value = {
104
+ ...action.payload,
105
+ id,
106
+ };
107
+ const data = newImageData;
108
+ saveData({section:"images", data: {data}, token: token});
109
+ return {
110
+ ...state,
111
+ images: {
112
+ ...state.images,
113
+ data: newImageData,
114
+ },
115
+ };
116
+ }
117
+ if (action.type === "deleteImage") {
118
+ const { articleId, imageId, token } = action.payload;
119
+ const newImageData = state.images.data.slice();
120
+ const articleIndex = newImageData.findIndex((f) => f.id === articleId);
121
+ const id = newImageData[articleIndex]?.images[imageId]?.value?.id;
122
+ delete newImageData[articleIndex]?.images[imageId]?.value;
123
+ const data = {
124
+ articleId,
125
+ deleteImages: [
126
+ {
127
+ id,
128
+ },
129
+ ],
130
+ };
131
+ deleteImage(data, newImageData[articleIndex].version, token);
132
+ return {
133
+ ...state,
134
+ images: {
135
+ ...state.images,
136
+ data: newImageData,
137
+ },
138
+ };
139
+ }
140
+ return state;
141
+ }
142
+
143
+ export async function initData(setDataServices, articles, versions, token) {
144
+ const [description, datasheet, images] = await Promise.all([
145
+ getData("description", articles, versions, token),
146
+ getData("datasheet", articles, versions, token),
147
+ getData("images", articles, versions, token),
148
+ ]);
149
+ const { data: dataDescription, attributes: rulesDescription } = description;
150
+ const { data: dataDatasheet, attributes: rulesDatasheet } = datasheet;
151
+ const { data: dataImage, typesShot: rulesImage } = images;
152
+ const payload = {
153
+ description: {
154
+ data: Object.values(dataDescription),
155
+ rules: rulesDescription,
156
+ },
157
+ datasheet: {
158
+ data: Object.values(dataDatasheet),
159
+ rules: rulesDatasheet,
160
+ },
161
+ images: {
162
+ data: Object.values(dataImage),
163
+ rules: rulesImage.reduce(
164
+ (prev, curr) =>
165
+ (prev = {
166
+ ...prev,
167
+ [curr.id]: curr.name,
168
+ }),
169
+ {}
170
+ ),
171
+ },
172
+ };
173
+ setDataServices({
174
+ type: "init",
175
+ payload,
176
+ });
177
+ }
178
+
179
+ export function setDataColumns(
180
+ section,
181
+ dataService,
182
+ token,
183
+ setModalFromTable,
184
+ setDataServices,
185
+ setModal,
186
+ setShowValidationPanel,
187
+ setAttributeSelected,
188
+ setShowRejectModal,
189
+ setAttributesReviewed,
190
+ setMessage,
191
+ showValidationPanel,
192
+ attributeSelected,
193
+ attributesReviewed,
194
+ descriptionsReviewed,
195
+ imagesReviewed
196
+ ) {
197
+ const { data, rules } = dataService;
198
+ const columns = [...columnsBase];
199
+ const values = [];
200
+
201
+ const styleRetailer = {
202
+ borderRight: "1px solid #f0f0f0",
203
+ borderLeft: "1px solid #f0f0f0",
204
+ };
205
+ const styleSaveButtonCol = {
206
+ borderRight: "1px solid #f0f0f0",
207
+ //borderLeft: "1px solid #f0f0f0",
208
+ };
209
+ const styleData = {
210
+ textAlign: "center",
211
+ display: "flex",
212
+ justifyContent: "center",
213
+ };
214
+
215
+ const styleApprovalAttributes = {
216
+ textAlign: "center",
217
+ display: "flex",
218
+ justifyContent: "center",
219
+ border: "1px solid #ECDD1D",
220
+ background: "#ECDD1D"
221
+ };
222
+
223
+ const retailersAdded = {
224
+ id: [],
225
+ attr: [],
226
+ };
227
+ data.forEach((item) => {
228
+ const currentData = {};
229
+ ["upc", "name", "accessor", "category", "status", "version"].forEach(
230
+ (key) => {
231
+ currentData[key] = <p className="content"> {item[key]} </p>;
232
+ }
233
+ );
234
+ if (item.status)
235
+ currentData["status"] = (
236
+ <StatusTag statusType={item.status} ovalForm={true} />
237
+ );
238
+ if (section === "images") {
239
+ const { images } = item;
240
+ item.retailer.forEach((ret) => {
241
+ if (!retailersAdded.id.includes(ret.id)) {
242
+ retailersAdded.id.push(ret.id);
243
+ columns.push({
244
+ Header: "Cadena",
245
+ accessor: `retailer${ret.id}`,
246
+ width: "100px"
247
+ });
248
+ columns.push({
249
+ Header: "",
250
+ accessor: `retailer${ret.id}-save`,
251
+ width: "60px",
252
+ style: styleSaveButtonCol,
253
+ });
254
+ }
255
+ currentData[`retailer${ret.id}`] = <p> {ret.name} </p>;
256
+ ret.images.forEach((imgId) => {
257
+ if (!retailersAdded.attr.includes(`img${imgId}`)) {
258
+ retailersAdded.attr.push(`img${imgId}`);
259
+ columns.push({
260
+ Header: rules[imgId],
261
+ accessor: `img${imgId}`,
262
+ width: "170px",
263
+ style: styleData,
264
+ });
265
+ }
266
+ });
267
+ var saveAvailable=true;
268
+ /**var saveAvailable = imagesReviewed
269
+ .filter((e) => e.articleId === item.id)
270
+ .every((e) => e.isReviewed === true);
271
+ if (
272
+ imagesReviewed.filter((e) => e.articleId === item.id).length == 0
273
+ ) {
274
+ saveAvailable = false;
275
+ }**/
276
+ currentData[`retailer${ret.id}-save`] = (
277
+ <button
278
+ onClick={() => {
279
+ var articlesImagesUpdateBody = [];
280
+ var articleImages = imagesReviewed.filter(
281
+ (e) => e.articleId === item.id && e.versionId === item.version
282
+ );
283
+ articleImages.forEach((articleImage) => {
284
+ articlesImagesUpdateBody.push({
285
+ articleId: articleImage.articleId,
286
+ versionId: articleImage.versionId,
287
+ attributeId: articleImage.imageId,
288
+ value: articleImage.srcdb,
289
+ isApproved: articleImage.isApproved,
290
+ comment: articleImage.comment,
291
+ });
292
+ });
293
+ updateArticleData(
294
+ item.version,
295
+ item.id,
296
+ articlesImagesUpdateBody,
297
+ token,
298
+ setMessage,
299
+ section
300
+ );
301
+ }}
302
+ className="validation-option"
303
+ disabled={!saveAvailable}
304
+ >
305
+ {saveAvailable && <img src={saveWhite} alt="guardar" />}{" "}
306
+ {!saveAvailable && <img src={saveWhiteGray} alt="guardar" />}{" "}
307
+ </button>
308
+ );
309
+
310
+ Object.values(images).forEach(({ value, isApproved, imageId, comment}) => {
311
+ const props = {
312
+ name: rules[imageId],
313
+ value: value,
314
+ setModalFromTable,
315
+ articleId: item.id,
316
+ setDataServices,
317
+ imageId,
318
+ setModal,
319
+ token,
320
+ };
321
+ if (
322
+ !imagesReviewed.find(
323
+ (e) =>
324
+ e.articleId == item.id &&
325
+ e.imageId == imageId &&
326
+ e.versionId == item.version
327
+ )
328
+ )
329
+ imagesReviewed.push({
330
+ articleId: item.id,
331
+ imageId: imageId,
332
+ versionId: item.version,
333
+ isApproved: isApproved? isApproved: false,
334
+ isReviewed: isApproved!=null? true: false,
335
+ comment: "",
336
+ srcdb: value? value.src: ""
337
+ });
338
+ var index = imagesReviewed.findIndex(
339
+ (e) =>
340
+ e.articleId === item.id &&
341
+ e.imageId=== imageId &&
342
+ e.versionId === item.version
343
+ );
344
+ currentData[`img${imageId}`] =
345
+ <>
346
+ {/**<button
347
+ onClick={() => {
348
+ setShowValidationPanel(true);
349
+ setAttributeSelected({
350
+ articleId: item.id,
351
+ attributeId: imageId,
352
+ versionId: item.version,
353
+ });
354
+ }}
355
+ className="validation-button"
356
+ >
357
+ {imagesReviewed[index].isReviewed &&
358
+ imagesReviewed[index].isApproved && (
359
+ <img
360
+ id={
361
+ "button_" +
362
+ item.id +
363
+ "_" +
364
+ imageId +
365
+ "_" +
366
+ item.version
367
+ }
368
+ src={acceptIcon}
369
+ alt="accept button"
370
+ />
371
+ )}{" "}
372
+ {imagesReviewed[index].isReviewed &&
373
+ !imagesReviewed[index].isApproved && (
374
+ <img
375
+ id={
376
+ "button_" +
377
+ item.id +
378
+ "_" +
379
+ imageId +
380
+ "_" +
381
+ item.version
382
+ }
383
+ src={rejectIcon}
384
+ alt="reject button"
385
+ />
386
+ )}{" "}
387
+ {
388
+ !imagesReviewed[index].isReviewed && (
389
+ <img
390
+ id={
391
+ "button_" +
392
+ item.id +
393
+ "_" +
394
+ imageId +
395
+ "_" +
396
+ item.version
397
+ }
398
+ src={rejectIcon}
399
+ alt="reject button"
400
+ />
401
+ )}
402
+ </button>{" "}
403
+ {showValidationPanel &&
404
+ attributeSelected.articleId === item.id &&
405
+ attributeSelected.attributeId === imageId &&
406
+ attributeSelected.versionId === item.version && (
407
+ <div className="buttons-container" style={{left: "70px"}}>
408
+ <button
409
+ onClick={() => {
410
+ imagesReviewed[index].isApproved = true;
411
+ imagesReviewed[index].isReviewed = true;
412
+ //document.getElementById(item.id+'_'+des.attributeId+'_'+item.version).style.borderColor="#71DE56";
413
+ setShowValidationPanel(false);
414
+ }}
415
+ className="validation-option"
416
+ >
417
+ <img src={acceptIcon} alt="accept button" />
418
+ <p> Validar </p>{" "}
419
+ </button>{" "}
420
+ <button
421
+ onClick={() => {
422
+ setShowValidationPanel(false);
423
+ setShowRejectModal(true);
424
+ }}
425
+ className="validation-option"
426
+ >
427
+ <img src={rejectIcon} alt="reject button" />
428
+ <p> Rechazar </p>{" "}
429
+ </button>{" "}
430
+ </div>
431
+ )}{" "**/}
432
+ {comment && <div class="tooltip">
433
+ <ImageVisor {...props}/>
434
+ <span class="tooltiptext"><p><b>Comentarios del rechazo</b></p><p>{des.comment}</p></span>
435
+ </div>}
436
+ {!comment && <div>
437
+ <ImageVisor {...props} />
438
+ </div>}
439
+ </>;
440
+ });
441
+ });
442
+ }
443
+ if (section === "datasheet") {
444
+ item.retailer.forEach((ret) => {
445
+ if (!retailersAdded.id.includes(ret.id)) {
446
+ retailersAdded.id.push(ret.id);
447
+ columns.push({
448
+ Header: "Cadena",
449
+ accessor: `retailer${ret.id}`,
450
+ width: "100px",
451
+ });
452
+ columns.push({
453
+ Header: "",
454
+ accessor: `retailer${ret.id}-save`,
455
+ width: "60px",
456
+ style: styleSaveButtonCol,
457
+ });
458
+ }
459
+ currentData[`retailer${ret.id}`] = <p> {ret.name} </p>;
460
+ var saveAvailable = attributesReviewed
461
+ .filter((e) => e.articleId === item.id)
462
+ .every((e) => e.isReviewed === true);
463
+ if (
464
+ attributesReviewed.filter((e) => e.articleId === item.id).length == 0
465
+ ) {
466
+ saveAvailable = false;
467
+ }
468
+ currentData[`retailer${ret.id}-save`] = (
469
+ <button
470
+ onClick={() => {
471
+ var articlesAtributesUpdateBody = [];
472
+ var articleAttributes = attributesReviewed.filter(
473
+ (e) => e.articleId === item.id && e.versionId === item.version
474
+ );
475
+ var value;
476
+ articleAttributes.forEach((articleAttribute) => {
477
+ if(articleAttribute.attributeId==6700 || articleAttribute.attributeId==6701){
478
+ value= document.getElementById(
479
+ articleAttribute.articleId +
480
+ "_" +
481
+ articleAttribute.attributeId +
482
+ "_" +
483
+ articleAttribute.versionId
484
+ ).checked;
485
+ }
486
+ else{
487
+ value = document.getElementById(
488
+ articleAttribute.articleId +
489
+ "_" +
490
+ articleAttribute.attributeId +
491
+ "_" +
492
+ articleAttribute.versionId
493
+ ).value;
494
+ }
495
+ articlesAtributesUpdateBody.push({
496
+ articleId: articleAttribute.articleId,
497
+ versionId: articleAttribute.versionId,
498
+ attributeId: articleAttribute.attributeId,
499
+ value: value!=undefined ? value : "",
500
+ isApproved: articleAttribute.isApproved,
501
+ comment: articleAttribute.comment,
502
+ });
503
+ });
504
+ updateArticleData(
505
+ item.version,
506
+ item.id,
507
+ articlesAtributesUpdateBody,
508
+ token,
509
+ setMessage,
510
+ section
511
+ );
512
+ }}
513
+ className="validation-option"
514
+ disabled={!saveAvailable}
515
+ >
516
+ {saveAvailable && <img src={saveWhite} alt="guardar" />}{" "}
517
+ {!saveAvailable && <img src={saveWhiteGray} alt="guardar" />}{" "}
518
+ </button>
519
+ );
520
+ ret.attributes.forEach((attributeId) => {
521
+ if (!retailersAdded.attr.includes(`${attributeId + "-" + ret.id}`)) {
522
+ retailersAdded.attr.push(`${attributeId + "-" + ret.id}`);
523
+ columns.push({
524
+ Header: rules[attributeId].name,
525
+ accessor: `${attributeId + "-" + ret.id}`,
526
+ width: "200px",
527
+ style: (attributeId==6700 || attributeId==6701) ? styleApprovalAttributes : styleData,
528
+ description: rules[attributeId].description,
529
+ });
530
+ }
531
+ });
532
+
533
+ const handleChangeOptions = (attributeId, newValue) => {
534
+ const updatedAttributes = Object.values(item.attributes).map((attr) => {
535
+ if (attr.attributeId === attributeId) {
536
+ return { ...attr, value: newValue };
537
+ }
538
+ return attr;
539
+ });
540
+ const updatedAttributesObject = {};
541
+ updatedAttributes.forEach((attr) => {
542
+ updatedAttributesObject[attr.attributeId] = attr;
543
+ });
544
+ return updatedAttributesObject;
545
+ };
546
+
547
+
548
+
549
+ const inputTypeValue = (type) => {
550
+ switch (type) {
551
+ case "Booleano":
552
+ return "checkbox";
553
+ case "Numérico":
554
+ return "number";
555
+ default:
556
+ return "text";
557
+ }
558
+ };
559
+ Object.values(item.attributes).forEach((des) => {
560
+ const props = {
561
+ inputId:
562
+ item.id +
563
+ "_" +
564
+ rules[des.attributeId].attributeId +
565
+ "_" +
566
+ item.version,
567
+ name:
568
+ item.id +
569
+ "-" +
570
+ rules[des.attributeId].attributeId +
571
+ "-" +
572
+ item.version,
573
+ value: des.value,
574
+ inputType:inputTypeValue(des.type),
575
+ };
576
+ let inputComponent;
577
+ if (des.option_list.length>0) {
578
+ inputComponent = (
579
+ <select
580
+ id={
581
+ item.id +
582
+ "_" +
583
+ rules[des.attributeId].attributeId +
584
+ "_" +
585
+ item.version
586
+ }
587
+ name={
588
+ item.id +
589
+ "-" +
590
+ rules[des.attributeId].attributeId +
591
+ "-" +
592
+ item.version
593
+ }
594
+ className="select-edition-multiple"
595
+ defaultValue={des.value}
596
+ onChange={(e) =>{
597
+ handleChangeOptions(des.attributeId, e.target.value)}
598
+ }
599
+ >
600
+ <option value="" selected disabled>Selecciona una opción</option>
601
+ {des.option_list.map((option, index) => (
602
+ <option key={index} value={option}>
603
+ {option}
604
+ </option>
605
+ ))}
606
+ </select>
607
+ );
608
+
609
+ } else {
610
+ inputComponent = <TagAndInput {...props} />;
611
+ }
612
+
613
+ if (
614
+ !attributesReviewed.find(
615
+ (e) =>
616
+ e.articleId == item.id &&
617
+ e.attributeId == des.attributeId &&
618
+ e.versionId == item.version
619
+ )
620
+ )
621
+ attributesReviewed.push({
622
+ articleId: item.id,
623
+ attributeId: des.attributeId,
624
+ versionId: item.version,
625
+ isApproved: des.isApproved ? des.isApproved : false,
626
+ isReviewed: des.isApproved != null ? true : false,
627
+ comment: "",
628
+ });
629
+ var index = attributesReviewed.findIndex(
630
+ (e) =>
631
+ e.articleId === item.id &&
632
+ e.attributeId === des.attributeId &&
633
+ e.versionId === item.version
634
+ );
635
+ currentData[`${des.attributeId + "-" + ret.id}`] = (
636
+ <>
637
+ <button
638
+ onClick={() => {
639
+ setShowValidationPanel(true);
640
+ setAttributeSelected({
641
+ articleId: item.id,
642
+ attributeId: des.attributeId,
643
+ versionId: item.version,
644
+ });
645
+ }}
646
+ className="validation-button"
647
+ >
648
+ {attributesReviewed[index].isReviewed &&
649
+ attributesReviewed[index].isApproved && (
650
+ <img
651
+ id={
652
+ "button_" +
653
+ item.id +
654
+ "_" +
655
+ des.attributeId +
656
+ "_" +
657
+ item.version
658
+ }
659
+ src={acceptIcon}
660
+ alt="accept button"
661
+ />
662
+ )}
663
+ {attributesReviewed[index].isReviewed &&
664
+ !attributesReviewed[index].isApproved && (
665
+ /**<Tooltip position="topCenter" componentTooltip={<span>Debes aprobar o rechazar para continuar</span>}>**/
666
+ <div>
667
+ <img
668
+ id={
669
+ "button_" +
670
+ item.id +
671
+ "_" +
672
+ des.attributeId +
673
+ "_" +
674
+ item.version
675
+ }
676
+ src={rejectIcon}
677
+ alt="reject icon"
678
+ />
679
+ </div>
680
+ /*</Tooltip>*/
681
+ )}
682
+ {typeof des.isApproved === "undefined" &&
683
+ !attributesReviewed[index].isReviewed && (
684
+ <Tooltip position="topCenter" componentTooltip={<span>Debes aprobar o rechazar para continuar</span>}>
685
+ <div>
686
+ <img
687
+ id={
688
+ "button_" +
689
+ item.id +
690
+ "_" +
691
+ des.attributeId +
692
+ "_" +
693
+ item.version
694
+ }
695
+ src={nullIcon}
696
+ alt="null button"
697
+ />
698
+ </div>
699
+ </Tooltip>
700
+
701
+ )}
702
+ </button>
703
+ {showValidationPanel &&
704
+ attributeSelected.articleId === item.id &&
705
+ attributeSelected.attributeId === des.attributeId &&
706
+ attributeSelected.versionId === item.version && (
707
+ <div className="buttons-container" style={{left: "35px"}}>
708
+ <button
709
+ onClick={() => {
710
+ attributesReviewed[index].isApproved = true;
711
+ attributesReviewed[index].isReviewed = true;
712
+ //document.getElementById(item.id+'_'+des.attributeId+'_'+item.version).style.borderColor="#71DE56";
713
+ setShowValidationPanel(false);
714
+ }}
715
+ className="validation-option"
716
+ >
717
+ <img src={acceptIcon} alt="accept button" />
718
+ <p> Validar </p>{" "}
719
+ </button>{" "}
720
+ <button
721
+ onClick={() => {
722
+ setShowValidationPanel(false);
723
+ setShowRejectModal(true);
724
+ }}
725
+ className="validation-option"
726
+ >
727
+ <img src={rejectIcon} alt="reject button" />
728
+ <p> Rechazar </p>{" "}
729
+ </button>{" "}
730
+ </div>
731
+ )}{" "}
732
+ {des.comment && <div class="tooltip">
733
+ {inputComponent}
734
+ <span class="tooltiptext"><p><b>Comentarios del rechazo</b></p><p>{des.comment}</p></span>
735
+ </div>}
736
+ {!des.comment && <div>
737
+ {inputComponent}
738
+ </div>}
739
+ </>
740
+ );
741
+ });
742
+ });
743
+ }
744
+ if (section === "description") {
745
+ item.retailer.forEach((ret) => {
746
+ if (!retailersAdded.id.includes(ret.id)) {
747
+ retailersAdded.id.push(ret.id);
748
+ columns.push({
749
+ Header: "Cadena",
750
+ accessor: `retailer${ret.id}`,
751
+ width: "100px"
752
+ });
753
+ columns.push({
754
+ Header: "",
755
+ accessor: `retailer${ret.id}-save`,
756
+ width: "60px",
757
+ style: styleSaveButtonCol,
758
+ });
759
+ }
760
+ var saveAvailable=true;
761
+ /**var saveAvailable = descriptionsReviewed
762
+ .filter((e) => e.articleId === item.id)
763
+ .every((e) => e.isReviewed === true);
764
+ if (
765
+ descriptionsReviewed.filter((e) => e.articleId === item.id).length == 0
766
+ ) {
767
+ saveAvailable = false;
768
+ }**/
769
+ currentData[`retailer${ret.id}`] = <p> {ret.name} </p>;
770
+ ret.descriptions.forEach((descriptionId) => {
771
+ if (!retailersAdded.attr.includes(`${descriptionId}`)) {
772
+ retailersAdded.attr.push(`${descriptionId}`);
773
+ columns.push({
774
+ Header: rules[ret.id][descriptionId].name,
775
+ accessor: `${descriptionId}`,
776
+ width: "250px",
777
+ style: styleData,
778
+ description:rules[ret.id][descriptionId].description
779
+ });
780
+ }
781
+ });
782
+
783
+ currentData[`retailer${ret.id}-save`] = (
784
+ <button
785
+ onClick={() => {
786
+ var articlesDescriptionsUpdateBody = [];
787
+ var articleDescriptions = descriptionsReviewed.filter(
788
+ (e) => e.articleId === item.id && e.versionId === item.version
789
+ );
790
+ articleDescriptions.forEach((articleDescription) => {
791
+ const value = document.getElementById(
792
+ articleDescription.articleId +
793
+ "_" +
794
+ articleDescription.attributeId +
795
+ "_" +
796
+ articleDescription.versionId
797
+ ).value;
798
+ articlesDescriptionsUpdateBody.push({
799
+ articleId: articleDescription.articleId,
800
+ versionId: articleDescription.versionId,
801
+ attributeId: articleDescription.attributeId,
802
+ value: value ? value : "",
803
+ isApproved: articleDescription.isApproved,
804
+ comment: articleDescription.comment,
805
+ });
806
+ });
807
+ updateArticleData(
808
+ item.version,
809
+ item.id,
810
+ articlesDescriptionsUpdateBody,
811
+ token,
812
+ setMessage,
813
+ section
814
+ );
815
+ }}
816
+ className="validation-option"
817
+ disabled={!saveAvailable}
818
+ >
819
+ {saveAvailable && <img src={saveWhite} alt="guardar" />}{" "}
820
+ {!saveAvailable && <img src={saveWhiteGray} alt="guardar" />}{" "}
821
+ </button>
822
+ );
823
+ Object.values(item.descriptions).forEach((des) => {
824
+ const props = {
825
+ name: rules[des.attributeId],
826
+ id: item.id + "_" + des.attributeId + "_" + item.version,
827
+ cols: 30,
828
+ rows: 2,
829
+ defaultValue: des.value
830
+ };
831
+ if (
832
+ !descriptionsReviewed.find(
833
+ (e) =>
834
+ e.articleId == item.id &&
835
+ e.attributeId == des.attributeId &&
836
+ e.versionId == item.version
837
+ )
838
+ )
839
+ descriptionsReviewed.push({
840
+ articleId: item.id,
841
+ attributeId: des.attributeId,
842
+ versionId: item.version,
843
+ isApproved: des.isApproved ? des.isApproved : false,
844
+ isReviewed: des.isApproved != null ? true : false,
845
+ comment: "",
846
+ });
847
+ var index = descriptionsReviewed.findIndex(
848
+ (e) =>
849
+ e.articleId === item.id &&
850
+ e.attributeId === des.attributeId &&
851
+ e.versionId === item.version
852
+ );
853
+ currentData[`${des.attributeId}`] = (
854
+ <>
855
+ {/**<button
856
+ onClick={() => {
857
+ setShowValidationPanel(true);
858
+ setAttributeSelected({
859
+ articleId: item.id,
860
+ attributeId: des.attributeId,
861
+ versionId: item.version,
862
+ });
863
+ }}
864
+ className="validation-button"
865
+ >
866
+ {descriptionsReviewed[index].isReviewed &&
867
+ descriptionsReviewed[index].isApproved && (
868
+ <img
869
+ id={
870
+ "button_" +
871
+ item.id +
872
+ "_" +
873
+ des.attributeId +
874
+ "_" +
875
+ item.version
876
+ }
877
+ src={acceptIcon}
878
+ alt="accept button"
879
+ />
880
+ )}{" "}
881
+ {descriptionsReviewed[index].isReviewed &&
882
+ !descriptionsReviewed[index].isApproved && (
883
+ <img
884
+ id={
885
+ "button_" +
886
+ item.id +
887
+ "_" +
888
+ des.attributeId +
889
+ "_" +
890
+ item.version
891
+ }
892
+ src={rejectIcon}
893
+ alt="reject button"
894
+ />
895
+ )}{" "}
896
+ {typeof des.isApproved === "undefined" &&
897
+ !descriptionsReviewed[index].isReviewed && (
898
+ <img
899
+ id={
900
+ "button_" +
901
+ item.id +
902
+ "_" +
903
+ des.attributeId +
904
+ "_" +
905
+ item.version
906
+ }
907
+ src={rejectIcon}
908
+ alt="reject button"
909
+ />
910
+ )}
911
+ </button>{" "}
912
+ {showValidationPanel &&
913
+ attributeSelected.articleId === item.id &&
914
+ attributeSelected.attributeId === des.attributeId &&
915
+ attributeSelected.versionId === item.version && (
916
+ <div className="buttons-container" style={{left: "35px"}}>
917
+ <button
918
+ onClick={() => {
919
+ descriptionsReviewed[index].isApproved = true;
920
+ descriptionsReviewed[index].isReviewed = true;
921
+ setShowValidationPanel(false);
922
+ }}
923
+ className="validation-option"
924
+ >
925
+ <img src={acceptIcon} alt="accept button" />
926
+ <p> Validar </p>{" "}
927
+ </button>{" "}
928
+ <button
929
+ onClick={() => {
930
+ setShowValidationPanel(false);
931
+ setShowRejectModal(true);
932
+ }}
933
+ className="validation-option"
934
+ >
935
+ <img src={rejectIcon} alt="reject button" />
936
+ <p> Rechazar </p>{" "}
937
+ </button>{" "}
938
+ </div>
939
+ )}{" "}**/}
940
+ {des.comment && <div class="tooltip">
941
+ <textarea {...props}></textarea>
942
+ <span class="tooltiptext"><p><b>Comentarios del rechazo</b></p><p>{des.comment}</p></span>
943
+ </div>}
944
+ {!des.comment && <div>
945
+ <textarea {...props}></textarea>
946
+ </div>}
947
+ </>
948
+ );
949
+ });
950
+ });
951
+ }
952
+ values.push(currentData);
953
+ });
954
+ return [columns, values];
955
+ }
956
+
957
+ export function modalReducer(state, action) {
958
+ if (action.type === "close") {
959
+ return {
960
+ show: false,
961
+ };
962
+ }
963
+ const { setModal, setDataServices } = action?.functions;
964
+ const buttons = [
965
+ <ButtonV2
966
+ key="btn-Cancelar"
967
+ type="white"
968
+ label="Cancelar"
969
+ onClick={() =>
970
+ setModal({
971
+ type: "close",
972
+ })
973
+ }
974
+ />,
975
+ ];
976
+ if (action.type === "saved successfully") {
977
+ buttons[0] = (
978
+ <ButtonV2
979
+ key="btn-Aceptar"
980
+ type="pink"
981
+ label="Aceptar"
982
+ onClick={async () =>
983
+ setModal({
984
+ type: "close",
985
+ })
986
+ }
987
+ />
988
+ );
989
+ return {
990
+ show: true,
991
+ title: "Servicio guardado con éxito",
992
+ message: `El servicio de ${action.payload?.service} se ha guardado con éxito.`,
993
+ icon: "success",
994
+ buttons,
995
+ };
996
+ }
997
+ if (action.type === "delete") {
998
+ buttons.push(
999
+ <ButtonV2
1000
+ key="btn-Aceptar"
1001
+ type="pink"
1002
+ label="Aceptar"
1003
+ onClick={async () => {
1004
+ setDataServices({
1005
+ type: "deleteImage",
1006
+ payload: action.payload,
1007
+ });
1008
+ setModal({
1009
+ type: "close",
1010
+ });
1011
+ }}
1012
+ />
1013
+ );
1014
+ return {
1015
+ show: true,
1016
+ title: "Eliminar imagen",
1017
+ message: "¿Está seguro de eliminar la imagen seleccionada?",
1018
+ icon: "warning",
1019
+ buttons,
1020
+ };
1021
+ }
1022
+ return state;
1023
+ }
1024
+
1025
+ async function updateArticleData(
1026
+ version,
1027
+ articleId,
1028
+ attributes,
1029
+ token,
1030
+ setMessage,
1031
+ section
1032
+ ) {
1033
+ var body={} ;
1034
+ var params=""
1035
+ if(section!="images"){
1036
+ body = {
1037
+ articleId: articleId,
1038
+ articleData: attributes,
1039
+ };
1040
+ params = `?${section}=true&version=${version}`;
1041
+ }
1042
+ else{
1043
+ body = {
1044
+ articleId: articleId,
1045
+ onboardingImagesData: attributes,
1046
+ };
1047
+ params = `?image=true&version=${version}`;
1048
+
1049
+ }
1050
+ try {
1051
+ const res = await axios.put(
1052
+ `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}` + params,
1053
+ body,
1054
+ {
1055
+ headers: {
1056
+ Authorization: token,
1057
+ },
1058
+ }
1059
+ );
1060
+ if (res.data.statusCode === 200 && section=="description") {
1061
+ setMessage("Descripciones de los productos guardados con éxito");
1062
+ }
1063
+ if (res.data.statusCode === 200 && section=="datasheet") {
1064
+ setMessage("Atributos de los productos guardados con éxito");
1065
+ }
1066
+ if (res.data.statusCode === 200 && section=="images") {
1067
+ setMessage("Imágenes de los productos guardados con éxito");
1068
+ }
1069
+ } catch (error) {
1070
+ console.log(error);
1071
+ }
1072
+ }
1073
+