contentoh-components-library 12.0.0 → 12.1.17

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 (288) hide show
  1. package/.env.development +8 -2
  2. package/.env.production +8 -2
  3. package/CHANGELOG.md +39 -0
  4. package/dist/assets/images/carouselImagesLogin/login2.svg +117 -0
  5. package/dist/assets/images/carouselImagesLogin/login3.svg +147 -0
  6. package/dist/assets/images/carouselImagesLogin/loginImage.svg +301 -0
  7. package/dist/assets/images/editField/showPassword.png +0 -0
  8. package/dist/assets/images/generalButton/downloadIcon.svg +3 -0
  9. package/dist/assets/images/genericModal/closeWhite.svg +3 -0
  10. package/dist/assets/images/genericModal/errorModal.svg +3 -0
  11. package/dist/assets/images/genericModal/yellowAlert.svg +12 -0
  12. package/dist/assets/images/sliderToolTip/infoIcon.svg +4 -0
  13. package/dist/assets/images/sliderToolTip/slide1.svg +5 -0
  14. package/dist/assets/images/sliderToolTip/slide2.svg +9 -0
  15. package/dist/assets/images/sliderToolTip/slide3.svg +9 -0
  16. package/dist/assets/images/sliderToolTip/slide4.svg +9 -0
  17. package/dist/assets/images/sliderToolTip/slide5.svg +40 -0
  18. package/dist/assets/images/verticalSideMenuMainPage/closeMenu.svg +4 -0
  19. package/dist/assets/images/verticalSideMenuMainPage/iconFAQS.svg +12 -0
  20. package/dist/assets/images/verticalSideMenuMainPage/iconGroup.svg +3 -0
  21. package/dist/assets/images/verticalSideMenuMainPage/iconLogo.svg +12 -0
  22. package/dist/assets/images/verticalSideMenuMainPage/iconLogoContentoh.svg +15 -0
  23. package/dist/assets/images/verticalSideMenuMainPage/iconProduct.svg +3 -0
  24. package/dist/assets/images/verticalSideMenuMainPage/iconSpeedometer.svg +12 -0
  25. package/dist/assets/images/verticalSideMenuMainPage/iconTask.svg +10 -0
  26. package/dist/assets/images/verticalSideMenuMainPage/openMenu.svg +4 -0
  27. package/dist/components/atoms/AsignationOption/index.js +24 -2
  28. package/dist/components/atoms/AsignationOption/styles.js +1 -1
  29. package/dist/components/atoms/CharCounter/CharCounter.stories.js +31 -0
  30. package/dist/components/atoms/CharCounter/index.js +22 -0
  31. package/dist/components/atoms/CharCounter/styles.js +20 -0
  32. package/dist/components/atoms/CheckBox/index.js +4 -2
  33. package/dist/components/atoms/DropDownButton/styles.js +1 -1
  34. package/dist/components/atoms/GeneralButton/styles.js +4 -2
  35. package/dist/components/atoms/GeneralInput/index.js +121 -65
  36. package/dist/components/atoms/GeneralInput/styles.js +8 -2
  37. package/dist/components/atoms/GenericModal/index.js +4 -2
  38. package/dist/components/atoms/GenericModal/styles.js +1 -1
  39. package/dist/components/atoms/GradientPanel/styles.js +2 -2
  40. package/dist/components/atoms/Input/index.js +1 -1
  41. package/dist/components/atoms/Input/style.js +4 -4
  42. package/dist/components/atoms/InputFormatter/Wysiwyg.stories.js +30 -0
  43. package/dist/components/atoms/InputFormatter/index.js +187 -0
  44. package/dist/components/atoms/InputFormatter/styles.js +33 -0
  45. package/dist/components/atoms/LabelToInput/index.js +0 -1
  46. package/dist/components/atoms/LabelToInput/style.js +3 -3
  47. package/dist/components/atoms/Loading/Loading.stories.js +28 -0
  48. package/dist/components/atoms/Loading/index.js +27 -0
  49. package/dist/components/atoms/Loading/styles.js +22 -0
  50. package/dist/components/atoms/LogoImage/index.js +1 -0
  51. package/dist/components/atoms/ProductPercentCard/Percent.stories.js +41 -0
  52. package/dist/components/atoms/ProductPercentCard/index.js +45 -0
  53. package/dist/components/atoms/ProductPercentCard/styles.js +20 -0
  54. package/dist/components/atoms/ProgressBar/styles.js +1 -1
  55. package/dist/components/atoms/ScreenHeader/index.js +1 -1
  56. package/dist/components/atoms/ScreenHeader/styles.js +1 -1
  57. package/dist/components/atoms/Select/index.js +4 -2
  58. package/dist/components/atoms/Select/style.js +1 -1
  59. package/dist/components/atoms/SliderToolTip/SliderToolTip.stories.js +47 -0
  60. package/dist/components/atoms/SliderToolTip/index.js +200 -0
  61. package/dist/components/atoms/SliderToolTip/styles.js +24 -0
  62. package/dist/components/atoms/StatusTag/index.js +37 -2
  63. package/dist/components/atoms/StatusTag/styles.js +1 -1
  64. package/dist/components/atoms/ValidationPanel/index.js +4 -3
  65. package/dist/components/atoms/VerticalSideMenuMainPage/VerticalSideMenuMainPage.stories.js +28 -0
  66. package/dist/components/atoms/VerticalSideMenuMainPage/index.js +98 -0
  67. package/dist/components/atoms/VerticalSideMenuMainPage/styles.js +24 -0
  68. package/dist/components/molecules/AvatarAndValidation/index.js +9 -12
  69. package/dist/components/molecules/CarouselImagesLogin/CarouselImagesLogin.stories.js +37 -0
  70. package/dist/components/molecules/CarouselImagesLogin/index.js +92 -0
  71. package/dist/components/molecules/CarouselImagesLogin/styles.js +21 -0
  72. package/dist/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +28 -0
  73. package/dist/components/molecules/EmailResetPasswordLogin/index.js +153 -0
  74. package/dist/components/molecules/EmailResetPasswordLogin/styles.js +20 -0
  75. package/dist/components/molecules/GalleryElement/index.js +32 -7
  76. package/dist/components/molecules/GalleryHeader/index.js +19 -2
  77. package/dist/components/molecules/LoginPasswordStrength/LoginPasswordStrength.stories.js +28 -0
  78. package/dist/components/molecules/LoginPasswordStrength/index.js +126 -0
  79. package/dist/components/molecules/LoginPasswordStrength/styles.js +78 -0
  80. package/dist/components/molecules/LogoLoading/Loading.stories.js +28 -0
  81. package/dist/components/molecules/LogoLoading/index.js +22 -0
  82. package/dist/components/molecules/LogoLoading/styles.js +18 -0
  83. package/dist/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +28 -0
  84. package/dist/components/molecules/RegistrationFirstStep/index.js +308 -0
  85. package/dist/components/molecules/RegistrationFirstStep/styles.js +20 -0
  86. package/dist/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +28 -0
  87. package/dist/components/molecules/RegistrationSecondStep/index.js +172 -0
  88. package/dist/components/molecules/RegistrationSecondStep/styles.js +20 -0
  89. package/dist/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +28 -0
  90. package/dist/components/molecules/RegistrationThirdStep/index.js +155 -0
  91. package/dist/components/molecules/RegistrationThirdStep/styles.js +20 -0
  92. package/dist/components/molecules/RetailerSelector/index.js +11 -3
  93. package/dist/components/molecules/RetailerSelector/styles.js +1 -1
  94. package/dist/components/molecules/SignInLogin/SignInLogin.stories.js +28 -0
  95. package/dist/components/molecules/SignInLogin/index.js +315 -0
  96. package/dist/components/molecules/SignInLogin/styles.js +20 -0
  97. package/dist/components/molecules/StatusAsignationInfo/index.js +19 -33
  98. package/dist/components/molecules/TableHeader/index.js +7 -3
  99. package/dist/components/molecules/TableHeader/styles.js +1 -1
  100. package/dist/components/molecules/TagAndInput/index.js +23 -5
  101. package/dist/components/molecules/TagAndInput/styles.js +10 -2
  102. package/dist/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +28 -0
  103. package/dist/components/molecules/VerificationCodeResetPasswordLogin/index.js +211 -0
  104. package/dist/components/molecules/VerificationCodeResetPasswordLogin/styles.js +20 -0
  105. package/dist/components/molecules/VerificationCodeResetPasswordLogin/utils.js +69 -0
  106. package/dist/components/organisms/ChangePassword/ChangePassword.stories.js +28 -0
  107. package/dist/components/organisms/ChangePassword/index.js +124 -0
  108. package/dist/components/organisms/ChangePassword/styles.js +18 -0
  109. package/dist/components/organisms/FullProductNameHeader/index.js +40 -15
  110. package/dist/components/organisms/FullTabsMenu/index.js +11 -11
  111. package/dist/components/organisms/GlobalModal/index.js +73 -0
  112. package/dist/components/organisms/GlobalModal/styles.js +66 -0
  113. package/dist/components/organisms/ImageDataTable/index.js +19 -13
  114. package/dist/components/organisms/InputGroup/index.js +17 -12
  115. package/dist/components/organisms/InputGroup/styles.js +1 -1
  116. package/dist/components/organisms/ProductImageModal/index.js +3 -6
  117. package/dist/components/organisms/ProductImageModal/styles.js +1 -1
  118. package/dist/components/pages/ChangePasswordLogin/ChangePasswordLogin.stories.js +38 -0
  119. package/dist/components/pages/ChangePasswordLogin/index.js +108 -0
  120. package/dist/components/pages/ChangePasswordLogin/styles.js +18 -0
  121. package/dist/components/pages/EmailResetPassword/EmailResetPassword.stories.js +37 -0
  122. package/dist/components/pages/EmailResetPassword/index.js +130 -0
  123. package/dist/components/pages/EmailResetPassword/styles.js +20 -0
  124. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +175 -0
  125. package/dist/components/pages/ProviderProductEdition/index.js +1800 -0
  126. package/dist/components/pages/ProviderProductEdition/styles.js +23 -0
  127. package/dist/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +37 -0
  128. package/dist/components/pages/RegistrationLoginFirstStep/index.js +269 -0
  129. package/dist/components/pages/RegistrationLoginFirstStep/styles.js +20 -0
  130. package/dist/components/pages/RegistrationLoginSecondStep/RegistrationLoginSecondStep.stories.js +38 -0
  131. package/dist/components/pages/RegistrationLoginSecondStep/index.js +176 -0
  132. package/dist/components/pages/RegistrationLoginSecondStep/styles.js +20 -0
  133. package/dist/components/pages/RegistrationLoginThirdStep/RegistrationLoginThirdStep.stories.js +37 -0
  134. package/dist/components/pages/RegistrationLoginThirdStep/index.js +178 -0
  135. package/dist/components/pages/RegistrationLoginThirdStep/styles.js +20 -0
  136. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +34 -75
  137. package/dist/components/pages/RetailerProductEdition/index.js +937 -641
  138. package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
  139. package/dist/components/pages/VerificationCodeResetPassword/VerificationCodeResetPassword.stories.js +37 -0
  140. package/dist/components/pages/VerificationCodeResetPassword/index.js +121 -0
  141. package/dist/components/pages/VerificationCodeResetPassword/styles.js +20 -0
  142. package/dist/components/pages/VerificationCodeResetPassword/utils.js +69 -0
  143. package/dist/global-files/data.js +36 -12
  144. package/dist/index.js +316 -100
  145. package/package.json +21 -8
  146. package/src/assets/images/carouselImagesLogin/login2.svg +117 -0
  147. package/src/assets/images/carouselImagesLogin/login3.svg +147 -0
  148. package/src/assets/images/carouselImagesLogin/loginImage.svg +301 -0
  149. package/src/assets/images/editField/showPassword.png +0 -0
  150. package/src/assets/images/generalButton/downloadIcon.svg +3 -0
  151. package/src/assets/images/genericModal/closeWhite.svg +3 -0
  152. package/src/assets/images/genericModal/errorModal.svg +3 -0
  153. package/src/assets/images/genericModal/yellowAlert.svg +12 -0
  154. package/src/assets/images/sliderToolTip/infoIcon.svg +4 -0
  155. package/src/assets/images/sliderToolTip/slide1.svg +5 -0
  156. package/src/assets/images/sliderToolTip/slide2.svg +9 -0
  157. package/src/assets/images/sliderToolTip/slide3.svg +9 -0
  158. package/src/assets/images/sliderToolTip/slide4.svg +9 -0
  159. package/src/assets/images/sliderToolTip/slide5.svg +40 -0
  160. package/src/assets/images/verticalSideMenuMainPage/closeMenu.svg +4 -0
  161. package/src/assets/images/verticalSideMenuMainPage/iconFAQS.svg +12 -0
  162. package/src/assets/images/verticalSideMenuMainPage/iconGroup.svg +3 -0
  163. package/src/assets/images/verticalSideMenuMainPage/iconLogo.svg +12 -0
  164. package/src/assets/images/verticalSideMenuMainPage/iconLogoContentoh.svg +15 -0
  165. package/src/assets/images/verticalSideMenuMainPage/iconProduct.svg +3 -0
  166. package/src/assets/images/verticalSideMenuMainPage/iconSpeedometer.svg +12 -0
  167. package/src/assets/images/verticalSideMenuMainPage/iconTask.svg +10 -0
  168. package/src/assets/images/verticalSideMenuMainPage/openMenu.svg +4 -0
  169. package/src/components/atoms/AsignationOption/index.js +17 -0
  170. package/src/components/atoms/AsignationOption/styles.js +13 -1
  171. package/src/components/atoms/CharCounter/CharCounter.stories.js +11 -0
  172. package/src/components/atoms/CharCounter/index.js +13 -0
  173. package/src/components/atoms/CharCounter/styles.js +10 -0
  174. package/src/components/atoms/CheckBox/index.js +8 -2
  175. package/src/components/atoms/DropDownButton/styles.js +6 -0
  176. package/src/components/atoms/GeneralButton/styles.js +14 -0
  177. package/src/components/atoms/GeneralInput/index.js +109 -68
  178. package/src/components/atoms/GeneralInput/styles.js +34 -0
  179. package/src/components/atoms/GenericModal/index.js +2 -2
  180. package/src/components/atoms/GenericModal/styles.js +11 -3
  181. package/src/components/atoms/GradientPanel/styles.js +8 -1
  182. package/src/components/atoms/Input/index.js +2 -1
  183. package/src/components/atoms/Input/style.js +9 -5
  184. package/src/components/atoms/InputFormatter/Wysiwyg.stories.js +12 -0
  185. package/src/components/atoms/InputFormatter/index.js +146 -0
  186. package/src/components/atoms/InputFormatter/styles.js +41 -0
  187. package/src/components/atoms/LabelToInput/index.js +0 -1
  188. package/src/components/atoms/LabelToInput/style.js +15 -4
  189. package/src/components/atoms/Loading/Loading.stories.js +10 -0
  190. package/src/components/atoms/Loading/index.js +13 -0
  191. package/src/components/atoms/Loading/styles.js +57 -0
  192. package/src/components/atoms/LogoImage/index.js +1 -1
  193. package/src/components/atoms/ProductPercentCard/Percent.stories.js +41 -0
  194. package/src/components/atoms/ProductPercentCard/index.js +23 -0
  195. package/src/components/atoms/{Percent → ProductPercentCard}/styles.js +11 -7
  196. package/src/components/atoms/ProgressBar/styles.js +2 -1
  197. package/src/components/atoms/ScreenHeader/index.js +7 -3
  198. package/src/components/atoms/ScreenHeader/styles.js +14 -2
  199. package/src/components/atoms/Select/index.js +3 -1
  200. package/src/components/atoms/Select/style.js +1 -2
  201. package/src/components/atoms/SliderToolTip/SliderToolTip.stories.js +23 -0
  202. package/src/components/atoms/SliderToolTip/index.js +182 -0
  203. package/src/components/atoms/SliderToolTip/styles.js +168 -0
  204. package/src/components/atoms/StatusTag/index.js +30 -2
  205. package/src/components/atoms/StatusTag/styles.js +9 -4
  206. package/src/components/atoms/ValidationPanel/index.js +4 -3
  207. package/src/components/atoms/VerticalSideMenuMainPage/VerticalSideMenuMainPage.stories.js +12 -0
  208. package/src/components/atoms/VerticalSideMenuMainPage/index.js +54 -0
  209. package/src/components/atoms/VerticalSideMenuMainPage/styles.js +45 -0
  210. package/src/components/molecules/AvatarAndValidation/index.js +14 -15
  211. package/src/components/molecules/CarouselImagesLogin/CarouselImagesLogin.stories.js +17 -0
  212. package/src/components/molecules/CarouselImagesLogin/index.js +65 -0
  213. package/src/components/molecules/CarouselImagesLogin/styles.js +60 -0
  214. package/src/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +11 -0
  215. package/src/components/molecules/EmailResetPasswordLogin/index.js +85 -0
  216. package/src/components/molecules/EmailResetPasswordLogin/styles.js +23 -0
  217. package/src/components/molecules/GalleryElement/index.js +26 -6
  218. package/src/components/molecules/GalleryHeader/index.js +8 -2
  219. package/src/components/molecules/LoginPasswordStrength/LoginPasswordStrength.stories.js +8 -0
  220. package/src/components/molecules/LoginPasswordStrength/index.js +84 -0
  221. package/src/components/molecules/LoginPasswordStrength/styles.js +91 -0
  222. package/src/components/molecules/LogoLoading/Loading.stories.js +10 -0
  223. package/src/components/molecules/LogoLoading/index.js +12 -0
  224. package/src/components/molecules/LogoLoading/styles.js +16 -0
  225. package/src/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +11 -0
  226. package/src/components/molecules/RegistrationFirstStep/index.js +227 -0
  227. package/src/components/molecules/RegistrationFirstStep/styles.js +87 -0
  228. package/src/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +11 -0
  229. package/src/components/molecules/RegistrationSecondStep/index.js +135 -0
  230. package/src/components/molecules/RegistrationSecondStep/styles.js +64 -0
  231. package/src/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +11 -0
  232. package/src/components/molecules/RegistrationThirdStep/index.js +130 -0
  233. package/src/components/molecules/RegistrationThirdStep/styles.js +44 -0
  234. package/src/components/molecules/RetailerSelector/index.js +7 -1
  235. package/src/components/molecules/RetailerSelector/styles.js +3 -0
  236. package/src/components/molecules/SignInLogin/SignInLogin.stories.js +11 -0
  237. package/src/components/molecules/SignInLogin/index.js +226 -0
  238. package/src/components/molecules/SignInLogin/styles.js +120 -0
  239. package/src/components/molecules/StatusAsignationInfo/index.js +23 -30
  240. package/src/components/molecules/TableHeader/index.js +5 -1
  241. package/src/components/molecules/TableHeader/styles.js +8 -0
  242. package/src/components/molecules/TagAndInput/index.js +19 -1
  243. package/src/components/molecules/TagAndInput/styles.js +28 -0
  244. package/src/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +11 -0
  245. package/src/components/molecules/VerificationCodeResetPasswordLogin/index.js +171 -0
  246. package/src/components/molecules/VerificationCodeResetPasswordLogin/styles.js +54 -0
  247. package/src/components/molecules/VerificationCodeResetPasswordLogin/utils.js +54 -0
  248. package/src/components/organisms/ChangePassword/ChangePassword.stories.js +11 -0
  249. package/src/components/organisms/ChangePassword/index.js +77 -0
  250. package/src/components/organisms/ChangePassword/styles.js +13 -0
  251. package/src/components/organisms/FullProductNameHeader/index.js +47 -16
  252. package/src/components/organisms/FullTabsMenu/index.js +9 -9
  253. package/src/components/organisms/GlobalModal/index.js +68 -0
  254. package/src/components/organisms/GlobalModal/styles.js +113 -0
  255. package/src/components/organisms/ImageDataTable/index.js +25 -8
  256. package/src/components/organisms/InputGroup/index.js +28 -8
  257. package/src/components/organisms/InputGroup/styles.js +2 -2
  258. package/src/components/organisms/ProductImageModal/index.js +8 -5
  259. package/src/components/organisms/ProductImageModal/styles.js +3 -0
  260. package/src/components/pages/ChangePasswordLogin/ChangePasswordLogin.stories.js +18 -0
  261. package/src/components/pages/ChangePasswordLogin/index.js +77 -0
  262. package/src/components/pages/ChangePasswordLogin/styles.js +20 -0
  263. package/src/components/pages/EmailResetPassword/EmailResetPassword.stories.js +17 -0
  264. package/src/components/pages/EmailResetPassword/index.js +77 -0
  265. package/src/components/pages/EmailResetPassword/styles.js +27 -0
  266. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +172 -0
  267. package/src/components/pages/ProviderProductEdition/index.js +1275 -0
  268. package/src/components/pages/ProviderProductEdition/styles.js +118 -0
  269. package/src/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +17 -0
  270. package/src/components/pages/RegistrationLoginFirstStep/index.js +160 -0
  271. package/src/components/pages/RegistrationLoginFirstStep/styles.js +85 -0
  272. package/src/components/pages/RegistrationLoginSecondStep/RegistrationLoginSecondStep.stories.js +18 -0
  273. package/src/components/pages/RegistrationLoginSecondStep/index.js +111 -0
  274. package/src/components/pages/RegistrationLoginSecondStep/styles.js +64 -0
  275. package/src/components/pages/RegistrationLoginThirdStep/RegistrationLoginThirdStep.stories.js +17 -0
  276. package/src/components/pages/RegistrationLoginThirdStep/index.js +106 -0
  277. package/src/components/pages/RegistrationLoginThirdStep/styles.js +48 -0
  278. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +31 -66
  279. package/src/components/pages/RetailerProductEdition/index.js +790 -448
  280. package/src/components/pages/RetailerProductEdition/styles.js +13 -3
  281. package/src/components/pages/VerificationCodeResetPassword/VerificationCodeResetPassword.stories.js +17 -0
  282. package/src/components/pages/VerificationCodeResetPassword/index.js +92 -0
  283. package/src/components/pages/VerificationCodeResetPassword/styles.js +54 -0
  284. package/src/components/pages/VerificationCodeResetPassword/utils.js +56 -0
  285. package/src/global-files/data.js +27 -6
  286. package/src/index.js +23 -8
  287. package/src/components/atoms/Percent/Percent.stories.js +0 -38
  288. package/src/components/atoms/Percent/index.js +0 -15
@@ -37,6 +37,8 @@ var _react = require("react");
37
37
 
38
38
  var _GalleryElement = require("../../molecules/GalleryElement");
39
39
 
40
+ var _fileSaver = require("file-saver");
41
+
40
42
  var _data2 = require("../../../global-files/data");
41
43
 
42
44
  var _GalleryHeader = require("../../molecules/GalleryHeader");
@@ -63,6 +65,16 @@ var _GeneralButton = require("../../atoms/GeneralButton");
63
65
 
64
66
  var _Commentary = require("../../atoms/Commentary");
65
67
 
68
+ var _GenericModal = require("../../atoms/GenericModal");
69
+
70
+ var _ScreenHeader = require("../../atoms/ScreenHeader");
71
+
72
+ var _Loading = require("../../atoms/Loading");
73
+
74
+ var _genericModalCheck = _interopRequireDefault(require("../../../assets/images/genericModal/genericModalCheck.svg"));
75
+
76
+ var _errorModal = _interopRequireDefault(require("../../../assets/images/genericModal/errorModal.svg"));
77
+
66
78
  var _jsxRuntime = require("react/jsx-runtime");
67
79
 
68
80
  var reducerImages = function reducerImages(state, action) {
@@ -86,12 +98,22 @@ var reducerImages = function reducerImages(state, action) {
86
98
  });
87
99
 
88
100
  case "changeAttrValue":
89
- attrForImgs[action.retailer][action.index].value = action.value;
101
+ action.retailersId.forEach(function (ret) {
102
+ attrForImgs[ret][action.index].name === action.name && (attrForImgs[ret][action.index].value = action.value);
103
+ });
90
104
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
91
105
  attrForImgs: attrForImgs,
92
106
  values: values
93
107
  });
94
108
 
109
+ case "deleteImage":
110
+ values = values.filter(function (value) {
111
+ return action.selectedImages.indexOf(value) === -1;
112
+ });
113
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
114
+ values: values
115
+ });
116
+
95
117
  default:
96
118
  return state;
97
119
  }
@@ -113,15 +135,15 @@ var myBucket = new _awsSdk.default.S3({
113
135
  });
114
136
 
115
137
  var RetailerProductEdition = function RetailerProductEdition(_ref) {
116
- var _servicesData$filter$, _servicesData$filter$2, _product$services, _datasheets$, _datasheets$$data, _product$services2, _product$services3;
138
+ var _product$retailers, _product$services2, _datasheets$, _datasheets$$data, _product$article13;
117
139
 
118
- var productData = _ref.productData,
119
- tabsSections = _ref.tabsSections,
120
- articleId = _ref.articleId,
140
+ var tabsSections = _ref.tabsSections,
121
141
  _ref$productSelected = _ref.productSelected,
122
142
  productSelected = _ref$productSelected === void 0 ? {} : _ref$productSelected,
123
143
  _ref$user = _ref.user,
124
144
  user = _ref$user === void 0 ? {} : _ref$user,
145
+ _ref$location = _ref.location,
146
+ location = _ref$location === void 0 ? {} : _ref$location,
125
147
  token = _ref.token;
126
148
 
127
149
  var _useState = (0, _react.useState)("Descripción"),
@@ -134,7 +156,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
134
156
  activeImage = _useState4[0],
135
157
  setActiveImage = _useState4[1];
136
158
 
137
- var _useState5 = (0, _react.useState)(true),
159
+ var _useState5 = (0, _react.useState)(false),
138
160
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
139
161
  imageLayout = _useState6[0],
140
162
  setImageLayout = _useState6[1];
@@ -164,12 +186,6 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
164
186
  showModal = _useState14[0],
165
187
  setShowModal = _useState14[1];
166
188
 
167
- var _useState15 = (0, _react.useState)(54),
168
- _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
169
- retailerSelected = _useState16[0],
170
- setRetailerSelected = _useState16[1]; // revisar después como trabajar esto de mejor forma
171
-
172
-
173
189
  var _useDropzone = (0, _reactDropzone.useDropzone)({
174
190
  accept: "image/*",
175
191
  noKeyboard: true,
@@ -181,42 +197,26 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
181
197
  var reader = new FileReader();
182
198
  reader.fileName = file.name;
183
199
 
184
- reader.onload = /*#__PURE__*/function () {
185
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(e) {
186
- var ext, img, width, height, newImg;
187
- return _regenerator.default.wrap(function _callee$(_context) {
188
- while (1) {
189
- switch (_context.prev = _context.next) {
190
- case 0:
191
- ext = e.srcElement.fileName.split(".");
192
- img = new Image();
193
- img.src = e.target.result;
194
- width = img.width;
195
- height = img.height;
196
- newImg = {
197
- action: "addImg",
198
- img: {
199
- src: e.target.result,
200
- name: e.target.fileName,
201
- ext: ext[ext.length - 1],
202
- width: width,
203
- height: width
204
- }
205
- };
206
- setImages(newImg);
207
-
208
- case 7:
209
- case "end":
210
- return _context.stop();
211
- }
200
+ reader.onload = function (e) {
201
+ var ext = e.srcElement.fileName.split(".");
202
+ var img = new Image();
203
+ img.src = e.target.result;
204
+ setTimeout(function () {
205
+ var width = img.width;
206
+ var height = img.height;
207
+ var newImg = {
208
+ action: "addImg",
209
+ img: {
210
+ src: e.target.result,
211
+ name: e.target.fileName,
212
+ ext: ext[ext.length - 1],
213
+ width: width,
214
+ height: height
212
215
  }
213
- }, _callee);
214
- }));
215
-
216
- return function (_x) {
217
- return _ref2.apply(this, arguments);
218
- };
219
- }();
216
+ };
217
+ setImages(newImg);
218
+ }, 500);
219
+ };
220
220
 
221
221
  reader.onerror = function (error) {
222
222
  console.log("dropzoneError: ", error);
@@ -230,186 +230,242 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
230
230
  getRootProps = _useDropzone.getRootProps,
231
231
  getInputProps = _useDropzone.getInputProps;
232
232
 
233
+ var _useState15 = (0, _react.useState)([]),
234
+ _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
235
+ updatedDatasheets = _useState16[0],
236
+ setUpdatedDatasheets = _useState16[1];
237
+
233
238
  var _useState17 = (0, _react.useState)([]),
234
239
  _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
235
- updatedDatasheets = _useState18[0],
236
- setUpdatedDatasheets = _useState18[1];
240
+ updatedDescriptions = _useState18[0],
241
+ setUpdatedDescriptions = _useState18[1];
237
242
 
238
- var _useState19 = (0, _react.useState)([]),
243
+ var _useState19 = (0, _react.useState)(false),
239
244
  _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
240
- updatedDescriptions = _useState20[0],
241
- setUpdatedDescriptions = _useState20[1];
245
+ imagesUploaded = _useState20[0],
246
+ setImagesUploaded = _useState20[1];
242
247
 
243
- var _useState21 = (0, _react.useState)(false),
248
+ var _useState21 = (0, _react.useState)(),
244
249
  _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
245
- imagesUploaded = _useState22[0],
246
- setImagesUploaded = _useState22[1];
247
-
248
- var _useState23 = (0, _react.useState)(),
249
- _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
250
- dataImages = _useState24[0],
251
- setDataImages = _useState24[1];
250
+ dataImages = _useState22[0],
251
+ setDataImages = _useState22[1];
252
252
 
253
- var _useState25 = (0, _react.useState)(new Array(productSelected.retailers.length).fill({
253
+ var _useState23 = (0, _react.useState)(new Array(product === null || product === void 0 ? void 0 : (_product$retailers = product.retailers) === null || _product$retailers === void 0 ? void 0 : _product$retailers.length).fill({
254
254
  percentage: 0
255
255
  })),
256
+ _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
257
+ percentages = _useState24[0],
258
+ setPercentages = _useState24[1];
259
+
260
+ var _useState25 = (0, _react.useState)(0),
256
261
  _useState26 = (0, _slicedToArray2.default)(_useState25, 2),
257
- percentages = _useState26[0],
258
- setPercentages = _useState26[1];
262
+ activePercentage = _useState26[0],
263
+ setActivePercentage = _useState26[1];
259
264
 
260
- var _useState27 = (0, _react.useState)(0),
265
+ var _useState27 = (0, _react.useState)({}),
261
266
  _useState28 = (0, _slicedToArray2.default)(_useState27, 2),
262
- activePercentage = _useState28[0],
263
- setActivePercentage = _useState28[1];
267
+ activeRetailer = _useState28[0],
268
+ setActiveRetailer = _useState28[1];
264
269
 
265
- var _useState29 = (0, _react.useState)({}),
270
+ var _useState29 = (0, _react.useState)([]),
266
271
  _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
267
- activeRetailer = _useState30[0],
268
- setActiveRetailer = _useState30[1];
272
+ services = _useState30[0],
273
+ setServices = _useState30[1];
269
274
 
270
275
  var _useState31 = (0, _react.useState)([]),
271
276
  _useState32 = (0, _slicedToArray2.default)(_useState31, 2),
272
- services = _useState32[0],
273
- setServices = _useState32[1];
277
+ servicesData = _useState32[0],
278
+ setServicesData = _useState32[1];
274
279
 
275
- var _useState33 = (0, _react.useState)([]),
280
+ var _useState33 = (0, _react.useState)(""),
276
281
  _useState34 = (0, _slicedToArray2.default)(_useState33, 2),
277
- servicesData = _useState34[0],
278
- setServicesData = _useState34[1];
282
+ message = _useState34[0],
283
+ setMessage = _useState34[1];
279
284
 
280
- var _useState35 = (0, _react.useState)(""),
285
+ var _useState35 = (0, _react.useState)(JSON.parse(sessionStorage.getItem("productSelected")) ? JSON.parse(sessionStorage.getItem("productSelected")) : productSelected),
281
286
  _useState36 = (0, _slicedToArray2.default)(_useState35, 2),
282
- message = _useState36[0],
283
- setMessage = _useState36[1];
287
+ product = _useState36[0],
288
+ setProduct = _useState36[1];
284
289
 
285
- var _useState37 = (0, _react.useState)({}),
290
+ var _useState37 = (0, _react.useState)(null),
286
291
  _useState38 = (0, _slicedToArray2.default)(_useState37, 2),
287
- product = _useState38[0],
288
- setProduct = _useState38[1];
292
+ icon = _useState38[0],
293
+ setIcon = _useState38[1];
289
294
 
290
- var _useState39 = (0, _react.useState)(null),
295
+ var _useState39 = (0, _react.useState)(product === null || product === void 0 ? void 0 : product.version),
291
296
  _useState40 = (0, _slicedToArray2.default)(_useState39, 2),
292
- icon = _useState40[0],
293
- setIcon = _useState40[1];
297
+ version = _useState40[0],
298
+ setVersion = _useState40[1];
294
299
 
295
- var _useState41 = (0, _react.useState)(productSelected === null || productSelected === void 0 ? void 0 : productSelected.version),
300
+ var _useState41 = (0, _react.useState)({}),
296
301
  _useState42 = (0, _slicedToArray2.default)(_useState41, 2),
297
- version = _useState42[0],
298
- setVersion = _useState42[1];
302
+ comments = _useState42[0],
303
+ setComments = _useState42[1];
299
304
 
300
- var _useState43 = (0, _react.useState)({}),
305
+ var _useState43 = (0, _react.useState)(""),
301
306
  _useState44 = (0, _slicedToArray2.default)(_useState43, 2),
302
- comments = _useState44[0],
303
- setComments = _useState44[1];
307
+ comment = _useState44[0],
308
+ setComment = _useState44[1];
304
309
 
305
- var _useState45 = (0, _react.useState)(""),
310
+ var _useState45 = (0, _react.useState)({
311
+ "Ficha técnica": 0,
312
+ Descripción: 0,
313
+ Imágenes: 0
314
+ }),
306
315
  _useState46 = (0, _slicedToArray2.default)(_useState45, 2),
307
- comment = _useState46[0],
308
- setComment = _useState46[1];
316
+ requiredNull = _useState46[0],
317
+ setRequiredNull = _useState46[1];
309
318
 
310
- var _useState47 = (0, _react.useState)(0),
319
+ var _useState47 = (0, _react.useState)(false),
311
320
  _useState48 = (0, _slicedToArray2.default)(_useState47, 2),
312
- requiredNull = _useState48[0],
313
- setRequiredNull = _useState48[1];
321
+ crossComment = _useState48[0],
322
+ setCrossComment = _useState48[1];
314
323
 
315
- var _useState49 = (0, _react.useState)(false),
324
+ var _useState49 = (0, _react.useState)([]),
316
325
  _useState50 = (0, _slicedToArray2.default)(_useState49, 2),
317
- crossComment = _useState50[0],
318
- setCrossComment = _useState50[1];
326
+ userGroups = _useState50[0],
327
+ setUserGroups = _useState50[1];
319
328
 
320
- var _useState51 = (0, _react.useState)([]),
329
+ var _useState51 = (0, _react.useState)({}),
321
330
  _useState52 = (0, _slicedToArray2.default)(_useState51, 2),
322
- userGroups = _useState52[0],
323
- setUserGroups = _useState52[1];
331
+ assig = _useState52[0],
332
+ setAssig = _useState52[1];
324
333
 
325
- var _useState53 = (0, _react.useState)({}),
334
+ var _useState53 = (0, _react.useState)([]),
326
335
  _useState54 = (0, _slicedToArray2.default)(_useState53, 2),
327
- assig = _useState54[0],
328
- setAssig = _useState54[1];
336
+ selectedImages = _useState54[0],
337
+ setSelectedImages = _useState54[1];
338
+
339
+ var _useState55 = (0, _react.useState)([]),
340
+ _useState56 = (0, _slicedToArray2.default)(_useState55, 2),
341
+ componentsArray = _useState56[0],
342
+ setComponentsArray = _useState56[1];
343
+
344
+ var _useState57 = (0, _react.useState)(false),
345
+ _useState58 = (0, _slicedToArray2.default)(_useState57, 2),
346
+ checkAll = _useState58[0],
347
+ setCheckAll = _useState58[1];
329
348
 
330
349
  var isRetailer = user === null || user === void 0 ? void 0 : user.is_retailer;
331
350
 
351
+ var _useState59 = (0, _react.useState)(true),
352
+ _useState60 = (0, _slicedToArray2.default)(_useState59, 2),
353
+ loading = _useState60[0],
354
+ setLoading = _useState60[1];
355
+
356
+ var _useState61 = (0, _react.useState)("-"),
357
+ _useState62 = (0, _slicedToArray2.default)(_useState61, 2),
358
+ retailerStatus = _useState62[0],
359
+ setRetailerStatus = _useState62[1];
360
+
361
+ var _useState63 = (0, _react.useState)([]),
362
+ _useState64 = (0, _slicedToArray2.default)(_useState63, 2),
363
+ statusArray = _useState64[0],
364
+ setStatusArray = _useState64[1];
365
+
366
+ var _useState65 = (0, _react.useState)(null),
367
+ _useState66 = (0, _slicedToArray2.default)(_useState65, 2),
368
+ socketType = _useState66[0],
369
+ setSocketType = _useState66[1];
370
+
371
+ var _useState67 = (0, _react.useState)([]),
372
+ _useState68 = (0, _slicedToArray2.default)(_useState67, 2),
373
+ servicesStatus = _useState68[0],
374
+ setServicesStatus = _useState68[1];
375
+
376
+ var _useState69 = (0, _react.useState)(loading),
377
+ _useState70 = (0, _slicedToArray2.default)(_useState69, 2),
378
+ saving = _useState70[0],
379
+ setSaving = _useState70[1];
380
+
381
+ (0, _react.useEffect)(function () {
382
+ checkAll && setSelectedImages(images.values);
383
+ }, [checkAll]);
384
+
332
385
  var loadData = /*#__PURE__*/function () {
333
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
334
- var _services$, _services$$values;
386
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
387
+ var _product$article, _product$article2, _services$, _services$$values, _services;
335
388
 
336
- var services;
337
- return _regenerator.default.wrap(function _callee2$(_context2) {
389
+ return _regenerator.default.wrap(function _callee$(_context) {
338
390
  while (1) {
339
- switch (_context2.prev = _context2.next) {
391
+ switch (_context.prev = _context.next) {
340
392
  case 0:
341
- _context2.next = 2;
342
- return (0, _data2.getRetailerServices)(productSelected.article.id_article, parseInt(productSelected.article.id_category), productSelected.version);
393
+ _context.prev = 0;
394
+ _context.next = 3;
395
+ return (0, _data2.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article = product.article) === null || _product$article === void 0 ? void 0 : _product$article.id_article, parseInt(product === null || product === void 0 ? void 0 : (_product$article2 = product.article) === null || _product$article2 === void 0 ? void 0 : _product$article2.id_category), product === null || product === void 0 ? void 0 : product.version);
343
396
 
344
- case 2:
345
- services = _context2.sent;
397
+ case 3:
398
+ _services = _context.sent;
346
399
  //Converts the data inside the datasheets object to array
347
- setServices(services);
348
- setActiveRetailer(productSelected === null || productSelected === void 0 ? void 0 : productSelected.retailers[0]);
400
+ setServices(_services);
401
+ getServices(); //setActiveRetailer(product?.retailers[0]);
402
+
349
403
  setImages({
350
404
  action: "init",
351
- init: services[2]
405
+ init: _services[2]
406
+ });
407
+ if (((_services$ = _services[2]) === null || _services$ === void 0 ? void 0 : (_services$$values = _services$.values) === null || _services$$values === void 0 ? void 0 : _services$$values.length) > 0) setActiveImage(0);
408
+ (0, _data2.getPercentage)({
409
+ data: [product]
410
+ }).then(function (res) {
411
+ return setPercentages(res);
352
412
  });
353
- if (((_services$ = services[2]) === null || _services$ === void 0 ? void 0 : (_services$$values = _services$.values) === null || _services$$values === void 0 ? void 0 : _services$$values.length) > 0) setActiveImage(0);
354
- setProduct(productSelected);
413
+ setLoading(false);
414
+ _context.next = 15;
415
+ break;
355
416
 
356
- case 8:
417
+ case 12:
418
+ _context.prev = 12;
419
+ _context.t0 = _context["catch"](0);
420
+ console.log(_context.t0);
421
+
422
+ case 15:
357
423
  case "end":
358
- return _context2.stop();
424
+ return _context.stop();
359
425
  }
360
426
  }
361
- }, _callee2);
427
+ }, _callee, null, [[0, 12]]);
362
428
  }));
363
429
 
364
430
  return function loadData() {
365
- return _ref3.apply(this, arguments);
431
+ return _ref2.apply(this, arguments);
366
432
  };
367
433
  }();
368
434
 
369
435
  var getServices = /*#__PURE__*/function () {
370
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(tab) {
371
- var serviceActive, selected, servicesResponse, parsedResponse;
372
- return _regenerator.default.wrap(function _callee3$(_context3) {
436
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
437
+ var _product$article3, _product$article4, _servicesResponse$dat;
438
+
439
+ var servicesResponse, parsedResponse, retailers, active;
440
+ return _regenerator.default.wrap(function _callee2$(_context2) {
373
441
  while (1) {
374
- switch (_context3.prev = _context3.next) {
442
+ switch (_context2.prev = _context2.next) {
375
443
  case 0:
376
- serviceActive = "";
377
- _context3.t0 = tab;
378
- _context3.next = _context3.t0 === "Ficha técnica" ? 4 : _context3.t0 === "Imágenes" ? 6 : 8;
379
- break;
380
-
381
- case 4:
382
- serviceActive = "datasheet";
383
- return _context3.abrupt("break", 10);
384
-
385
- case 6:
386
- serviceActive = "images";
387
- return _context3.abrupt("break", 10);
388
-
389
- case 8:
390
- serviceActive = "description";
391
- return _context3.abrupt("break", 10);
392
-
393
- case 10:
394
- selected = productSelected;
395
- _context3.next = 13;
396
- return _axios.default.get("".concat(process.env.REACT_APP_SERVICES_ENDPOINT, "?articleId=").concat(selected.article.id_article, "&orderId=").concat(selected.article.id_order, "&end=true"));
444
+ _context2.next = 2;
445
+ return _axios.default.get("".concat(process.env.REACT_APP_SERVICES_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_article, "&orderId=").concat((product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_order) || product.orderId, "&end=true"));
397
446
 
398
- case 13:
399
- servicesResponse = _context3.sent;
400
- parsedResponse = JSON.parse(servicesResponse.data.body).data;
447
+ case 2:
448
+ servicesResponse = _context2.sent;
449
+ parsedResponse = JSON.parse(servicesResponse === null || servicesResponse === void 0 ? void 0 : (_servicesResponse$dat = servicesResponse.data) === null || _servicesResponse$dat === void 0 ? void 0 : _servicesResponse$dat.body).data;
450
+ retailers = product.retailers || product.retailersAvailable;
451
+ active = retailers === null || retailers === void 0 ? void 0 : retailers.filter(function (retailer) {
452
+ return parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
453
+ return srv.id_retailer;
454
+ }).includes(retailer.id);
455
+ })[0];
456
+ !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
401
457
  setServicesData(parsedResponse);
402
458
 
403
- case 16:
459
+ case 8:
404
460
  case "end":
405
- return _context3.stop();
461
+ return _context2.stop();
406
462
  }
407
463
  }
408
- }, _callee3);
464
+ }, _callee2);
409
465
  }));
410
466
 
411
- return function getServices(_x2) {
412
- return _ref4.apply(this, arguments);
467
+ return function getServices() {
468
+ return _ref3.apply(this, arguments);
413
469
  };
414
470
  }();
415
471
 
@@ -428,73 +484,91 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
428
484
  };
429
485
 
430
486
  var getComments = /*#__PURE__*/function () {
431
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
432
- var _productSelected$arti, _productSelected$arti2, _productSelected$arti3;
487
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
488
+ var _product$article5, _product$article6, _product$article7;
433
489
 
434
490
  var tab,
435
491
  commentsResponse,
436
492
  comments,
437
- _args4 = arguments;
438
- return _regenerator.default.wrap(function _callee4$(_context4) {
493
+ _args3 = arguments;
494
+ return _regenerator.default.wrap(function _callee3$(_context3) {
439
495
  while (1) {
440
- switch (_context4.prev = _context4.next) {
496
+ switch (_context3.prev = _context3.next) {
441
497
  case 0:
442
- tab = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : "Descripción";
443
- _context4.next = 3;
444
- return Promise.all([_axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(productSelected === null || productSelected === void 0 ? void 0 : (_productSelected$arti = productSelected.article) === null || _productSelected$arti === void 0 ? void 0 : _productSelected$arti.id_article, "&concept=description&orderIdColab=").concat(productSelected === null || productSelected === void 0 ? void 0 : productSelected.orderId, "&version=").concat(version)), _axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(productSelected === null || productSelected === void 0 ? void 0 : (_productSelected$arti2 = productSelected.article) === null || _productSelected$arti2 === void 0 ? void 0 : _productSelected$arti2.id_article, "&concept=datasheet&orderIdColab=").concat(productSelected === null || productSelected === void 0 ? void 0 : productSelected.orderId, "&version=").concat(version)), _axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(productSelected === null || productSelected === void 0 ? void 0 : (_productSelected$arti3 = productSelected.article) === null || _productSelected$arti3 === void 0 ? void 0 : _productSelected$arti3.id_article, "&concept=images&orderIdColab=").concat(productSelected === null || productSelected === void 0 ? void 0 : productSelected.orderId, "&version=").concat(version))]);
498
+ tab = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : "Descripción";
499
+ _context3.next = 3;
500
+ return Promise.all([_axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article5 = product.article) === null || _product$article5 === void 0 ? void 0 : _product$article5.id_article, "&concept=description&orderIdColab=").concat(product === null || product === void 0 ? void 0 : product.orderId, "&version=").concat(version)), _axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article6 = product.article) === null || _product$article6 === void 0 ? void 0 : _product$article6.id_article, "&concept=datasheet&orderIdColab=").concat(product === null || product === void 0 ? void 0 : product.orderId, "&version=").concat(version)), _axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article7 = product.article) === null || _product$article7 === void 0 ? void 0 : _product$article7.id_article, "&concept=images&orderIdColab=").concat(product === null || product === void 0 ? void 0 : product.orderId, "&version=").concat(version))]);
445
501
 
446
502
  case 3:
447
- commentsResponse = _context4.sent;
503
+ commentsResponse = _context3.sent;
448
504
  comments = {};
449
505
  commentsResponse.forEach(function (comment) {
450
- var _JSON$parse$data$;
506
+ var _comment$data, _JSON$parse, _JSON$parse$data$, _comment$data2, _comment$data3;
451
507
 
452
- return JSON.parse(comment.data.body).data[0] && (comments[translateConcept((_JSON$parse$data$ = JSON.parse(comment.data.body).data[0]) === null || _JSON$parse$data$ === void 0 ? void 0 : _JSON$parse$data$.concept)] = JSON.parse(comment.data.body).data[0]);
508
+ return JSON.parse(comment === null || comment === void 0 ? void 0 : (_comment$data = comment.data) === null || _comment$data === void 0 ? void 0 : _comment$data.body).data[0] && (comments[translateConcept((_JSON$parse = JSON.parse(comment === null || comment === void 0 ? void 0 : (_comment$data2 = comment.data) === null || _comment$data2 === void 0 ? void 0 : _comment$data2.body)) === null || _JSON$parse === void 0 ? void 0 : (_JSON$parse$data$ = _JSON$parse.data[0]) === null || _JSON$parse$data$ === void 0 ? void 0 : _JSON$parse$data$.concept)] = JSON.parse(comment === null || comment === void 0 ? void 0 : (_comment$data3 = comment.data) === null || _comment$data3 === void 0 ? void 0 : _comment$data3.body).data[0]);
453
509
  });
454
510
  setComment(comments[tab]);
455
511
  setComments(comments);
456
512
 
457
513
  case 8:
458
514
  case "end":
459
- return _context4.stop();
515
+ return _context3.stop();
460
516
  }
461
517
  }
462
- }, _callee4);
518
+ }, _callee3);
463
519
  }));
464
520
 
465
521
  return function getComments() {
466
- return _ref5.apply(this, arguments);
522
+ return _ref4.apply(this, arguments);
467
523
  };
468
524
  }();
469
525
 
470
- (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
471
- return _regenerator.default.wrap(function _callee5$(_context5) {
526
+ (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
527
+ var arr;
528
+ return _regenerator.default.wrap(function _callee4$(_context4) {
472
529
  while (1) {
473
- switch (_context5.prev = _context5.next) {
530
+ switch (_context4.prev = _context4.next) {
474
531
  case 0:
475
532
  loadData();
476
- (0, _data2.getPercentage)({
477
- data: [productSelected]
478
- }).then(function (res) {
479
- return setPercentages(res);
480
- });
481
- getServices();
482
533
  getComments();
483
- _context5.t0 = setUserGroups;
484
- _context5.next = 7;
534
+ _context4.t0 = setUserGroups;
535
+ _context4.next = 5;
485
536
  return (0, _data2.fetchUsers)(token);
486
537
 
487
- case 7:
488
- _context5.t1 = _context5.sent;
489
- (0, _context5.t0)(_context5.t1);
538
+ case 5:
539
+ _context4.t1 = _context4.sent;
540
+ (0, _context4.t0)(_context4.t1);
541
+ arr = [];
542
+ _context4.t2 = user.id_role;
543
+ _context4.next = _context4.t2 === 7 ? 11 : _context4.t2 === 8 ? 11 : _context4.t2 === 4 ? 13 : _context4.t2 === 5 ? 13 : _context4.t2 === 6 ? 15 : 17;
544
+ break;
545
+
546
+ case 11:
547
+ arr = ["IN_PROGRESS", "RF", "RA"];
548
+ return _context4.abrupt("break", 19);
490
549
 
491
- case 9:
550
+ case 13:
551
+ arr = ["RF", "AF", "AA", "AP", "AC"];
552
+ return _context4.abrupt("break", 19);
553
+
554
+ case 15:
555
+ arr = ["RP", "RC", "AF", "RA"];
556
+ return _context4.abrupt("break", 19);
557
+
558
+ case 17:
559
+ arr = [];
560
+ return _context4.abrupt("break", 19);
561
+
562
+ case 19:
563
+ setStatusArray(arr);
564
+
565
+ case 20:
492
566
  case "end":
493
- return _context5.stop();
567
+ return _context4.stop();
494
568
  }
495
569
  }
496
- }, _callee5);
497
- })), []);
570
+ }, _callee4);
571
+ })), [product]);
498
572
 
499
573
  var loadAssignations = function loadAssignations(currentProduct) {
500
574
  var _currentProduct$artic, _currentProduct$artic2, _currentProduct$artic3, _currentProduct$artic4, _currentProduct$artic5, _currentProduct$artic6;
@@ -543,197 +617,246 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
543
617
  };
544
618
 
545
619
  (0, _react.useEffect)(function () {
546
- loadAssignations(productSelected);
620
+ loadAssignations(product);
547
621
  }, [userGroups]);
548
622
  (0, _react.useEffect)(function () {
549
- var _productSelected$reta;
623
+ var _product$retailers2, _product$retailers$;
550
624
 
551
- productSelected.retailers.forEach(function (retailer) {
625
+ product === null || product === void 0 ? void 0 : (_product$retailers2 = product.retailers) === null || _product$retailers2 === void 0 ? void 0 : _product$retailers2.forEach(function (retailer) {
552
626
  var _percentages$filter$;
553
627
 
554
- retailer["percentage"] = (_percentages$filter$ = percentages.filter(function (percent) {
555
- return retailer.id === percent.id_retailer;
628
+ retailer["percentage"] = percentages === null || percentages === void 0 ? void 0 : (_percentages$filter$ = percentages.filter(function (percent) {
629
+ return (retailer === null || retailer === void 0 ? void 0 : retailer.id) === (percent === null || percent === void 0 ? void 0 : percent.id_retailer);
556
630
  })[0]) === null || _percentages$filter$ === void 0 ? void 0 : _percentages$filter$.percentage;
557
631
  });
558
- setActivePercentage(productSelected === null || productSelected === void 0 ? void 0 : (_productSelected$reta = productSelected.retailers[0]) === null || _productSelected$reta === void 0 ? void 0 : _productSelected$reta.percentage);
632
+ setActivePercentage(product === null || product === void 0 ? void 0 : (_product$retailers$ = product.retailers[0]) === null || _product$retailers$ === void 0 ? void 0 : _product$retailers$.percentage);
559
633
  }, [percentages]);
560
634
  (0, _react.useEffect)(function () {
561
635
  if (services.length > 0) {
562
- services[0][activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id].data = Object.values(services[0][activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id].data);
563
- setActivePercentage(Math.round(activeRetailer.percentage, 0));
564
- setDatasheets([services[0][activeRetailer.id], services[0].inputs]);
565
- setDescriptions(services[1].filter(function (service) {
566
- return service.id === activeRetailer.id;
567
- }));
636
+ var _services$0$activeRet, _services$2, _services$3;
637
+
638
+ if ((_services$0$activeRet = services[0][activeRetailer.id]) !== null && _services$0$activeRet !== void 0 && _services$0$activeRet.data) services[0][activeRetailer.id].data = Object.values(services[0][activeRetailer.id].data);
639
+ setActivePercentage(Math.round(activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.percentage, 0));
640
+ var datagroups = services[0][activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id];
641
+ var inputs = (_services$2 = services[0]) === null || _services$2 === void 0 ? void 0 : _services$2.inputs;
642
+
643
+ var _descriptions = (_services$3 = services[1]) === null || _services$3 === void 0 ? void 0 : _services$3.filter(function (service) {
644
+ return (service === null || service === void 0 ? void 0 : service.id) === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
645
+ });
646
+
647
+ setDatasheets([datagroups, inputs]);
648
+ setDescriptions(_descriptions);
568
649
  }
569
- }, [activeRetailer]);
650
+ }, [activeRetailer, services]);
570
651
 
571
652
  var thumbs = function thumbs() {
572
- var _images$values;
653
+ var _images$imageType, _images$imagePackagin, _images$values;
573
654
 
574
- var imageInputs = images.inputs.map(function (e) {
575
- return {
576
- value: e.id,
577
- name: e.name
578
- };
579
- });
580
- var imageType = images.imageType.map(function (e) {
655
+ var imageInputs = socketType === null || socketType === void 0 ? void 0 : socketType.slice();
656
+ var imageType = images === null || images === void 0 ? void 0 : (_images$imageType = images.imageType) === null || _images$imageType === void 0 ? void 0 : _images$imageType.map(function (e) {
581
657
  return {
582
- value: e.id,
583
- name: e.name
658
+ value: e === null || e === void 0 ? void 0 : e.id,
659
+ name: e === null || e === void 0 ? void 0 : e.name
584
660
  };
585
661
  });
586
- var imagePackagingType = images.imagePackagingType.map(function (e) {
662
+ var imagePackagingType = images === null || images === void 0 ? void 0 : (_images$imagePackagin = images.imagePackagingType) === null || _images$imagePackagin === void 0 ? void 0 : _images$imagePackagin.map(function (e) {
587
663
  return {
588
- value: e.id,
589
- name: e.name
664
+ value: e === null || e === void 0 ? void 0 : e.id,
665
+ name: e === null || e === void 0 ? void 0 : e.name
590
666
  };
591
667
  });
592
668
  return images === null || images === void 0 ? void 0 : (_images$values = images.values) === null || _images$values === void 0 ? void 0 : _images$values.map(function (image, index) {
593
669
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryElement.GalleryElement, {
670
+ setCheckAll: setCheckAll,
594
671
  image: image,
595
672
  gridLayout: imageLayout,
596
673
  id: "gallery-element-" + index,
597
- index: index,
674
+ index: index + "-" + image.name,
675
+ number: index,
598
676
  imageType: imageType,
599
677
  imagePackagingType: imagePackagingType,
600
678
  imageInputs: imageInputs,
601
- changeImage: setImages
679
+ setSocketType: setSocketType,
680
+ changeImage: setImages,
681
+ selectedImages: selectedImages,
682
+ setSelectedImages: setSelectedImages
602
683
  }, index);
603
684
  });
604
685
  };
605
686
 
606
687
  var saveDescriptions = /*#__PURE__*/function () {
607
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
608
- var _productSelected$arti4;
688
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
689
+ var _product$article8;
609
690
 
610
- var dataObject;
611
- return _regenerator.default.wrap(function _callee6$(_context6) {
691
+ var productTemp, dataObject;
692
+ return _regenerator.default.wrap(function _callee5$(_context5) {
612
693
  while (1) {
613
- switch (_context6.prev = _context6.next) {
694
+ switch (_context5.prev = _context5.next) {
614
695
  case 0:
696
+ setLoading(true);
697
+ productTemp = product;
615
698
  dataObject = {
616
- articleId: productSelected === null || productSelected === void 0 ? void 0 : (_productSelected$arti4 = productSelected.article) === null || _productSelected$arti4 === void 0 ? void 0 : _productSelected$arti4.id_article,
699
+ articleId: product === null || product === void 0 ? void 0 : (_product$article8 = product.article) === null || _product$article8 === void 0 ? void 0 : _product$article8.id_article,
617
700
  articleData: updatedDescriptions
618
701
  };
619
- _context6.prev = 1;
620
- _context6.next = 4;
702
+ if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
703
+ _context5.prev = 4;
704
+ _context5.next = 7;
621
705
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
622
706
  headers: {
623
707
  Authorization: token
624
708
  }
625
709
  });
626
710
 
627
- case 4:
628
- _context6.next = 9;
711
+ case 7:
712
+ if (productTemp.status === "ASSIGNED") {
713
+ productTemp.status = "IN_PROGRESS";
714
+ setProduct(productTemp);
715
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
716
+ }
717
+
718
+ setMessage("Descripciones guardadas con éxito");
719
+ loadData();
720
+ _context5.next = 15;
629
721
  break;
630
722
 
631
- case 6:
632
- _context6.prev = 6;
633
- _context6.t0 = _context6["catch"](1);
634
- console.log(_context6.t0);
723
+ case 12:
724
+ _context5.prev = 12;
725
+ _context5.t0 = _context5["catch"](4);
726
+ console.log(_context5.t0);
635
727
 
636
- case 9:
728
+ case 15:
637
729
  case "end":
638
- return _context6.stop();
730
+ return _context5.stop();
639
731
  }
640
732
  }
641
- }, _callee6, null, [[1, 6]]);
733
+ }, _callee5, null, [[4, 12]]);
642
734
  }));
643
735
 
644
736
  return function saveDescriptions() {
645
- return _ref7.apply(this, arguments);
737
+ return _ref6.apply(this, arguments);
646
738
  };
647
739
  }();
648
740
 
649
741
  var saveDatasheets = /*#__PURE__*/function () {
650
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
651
- var _productSelected$arti5;
742
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
743
+ var _product$article9;
652
744
 
653
- var dataObject;
654
- return _regenerator.default.wrap(function _callee7$(_context7) {
745
+ var productTemp, dataObject;
746
+ return _regenerator.default.wrap(function _callee6$(_context6) {
655
747
  while (1) {
656
- switch (_context7.prev = _context7.next) {
748
+ switch (_context6.prev = _context6.next) {
657
749
  case 0:
750
+ setLoading(true);
751
+ productTemp = product;
658
752
  dataObject = {
659
- articleId: productSelected === null || productSelected === void 0 ? void 0 : (_productSelected$arti5 = productSelected.article) === null || _productSelected$arti5 === void 0 ? void 0 : _productSelected$arti5.id_article,
753
+ articleId: product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article,
660
754
  articleData: updatedDatasheets
661
755
  };
662
- _context7.prev = 1;
663
- _context7.next = 4;
756
+ console.log(updatedDatasheets, "updatedDatasheets");
757
+ if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
758
+ _context6.prev = 5;
759
+ _context6.next = 8;
664
760
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
665
761
  headers: {
666
762
  Authorization: token
667
763
  }
668
764
  });
669
765
 
670
- case 4:
671
- console.log("saved");
672
- _context7.next = 10;
766
+ case 8:
767
+ setMessage("Fichas técnicas guardadas");
768
+
769
+ if (productTemp.status === "ASSIGNED") {
770
+ productTemp.status = "IN_PROGRESS";
771
+ setProduct(productTemp);
772
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
773
+ }
774
+
775
+ loadData();
776
+ _context6.next = 16;
673
777
  break;
674
778
 
675
- case 7:
676
- _context7.prev = 7;
677
- _context7.t0 = _context7["catch"](1);
678
- console.log(_context7.t0);
779
+ case 13:
780
+ _context6.prev = 13;
781
+ _context6.t0 = _context6["catch"](5);
782
+ console.log(_context6.t0);
679
783
 
680
- case 10:
784
+ case 16:
681
785
  case "end":
682
- return _context7.stop();
786
+ return _context6.stop();
683
787
  }
684
788
  }
685
- }, _callee7, null, [[1, 7]]);
789
+ }, _callee6, null, [[5, 13]]);
686
790
  }));
687
791
 
688
792
  return function saveDatasheets() {
689
- return _ref8.apply(this, arguments);
793
+ return _ref7.apply(this, arguments);
690
794
  };
691
795
  }();
692
796
 
693
- var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
694
- var _images$values2;
797
+ (0, _react.useEffect)(function () {
798
+ var _images$inputs;
695
799
 
696
- var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, promiseArray;
697
- return _regenerator.default.wrap(function _callee8$(_context8) {
800
+ var imageInputs = images === null || images === void 0 ? void 0 : (_images$inputs = images.inputs) === null || _images$inputs === void 0 ? void 0 : _images$inputs.map(function (e) {
801
+ return {
802
+ value: e === null || e === void 0 ? void 0 : e.id,
803
+ name: e === null || e === void 0 ? void 0 : e.name,
804
+ required: e === null || e === void 0 ? void 0 : e.required,
805
+ active: images === null || images === void 0 ? void 0 : images.values.some(function (value) {
806
+ return (value === null || value === void 0 ? void 0 : value.image_id) === (e === null || e === void 0 ? void 0 : e.id);
807
+ })
808
+ };
809
+ });
810
+ setSocketType(imageInputs);
811
+ }, [images]);
812
+ var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
813
+ var _images$values2, _product$article10, _data$articleData, _data$articleData2, _data$updateImages;
814
+
815
+ var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray, productTemp;
816
+
817
+ return _regenerator.default.wrap(function _callee7$(_context7) {
698
818
  while (1) {
699
- switch (_context8.prev = _context8.next) {
819
+ switch (_context7.prev = _context7.next) {
700
820
  case 0:
701
821
  imagesList = images === null || images === void 0 ? void 0 : (_images$values2 = images.values) === null || _images$values2 === void 0 ? void 0 : _images$values2.slice();
702
- imagesListTemp = imagesList.reduce(function (acc, image) {
703
- acc[image.image_id] = ++acc[image.image_id] || 0;
822
+ imagesListTemp = imagesList === null || imagesList === void 0 ? void 0 : imagesList.reduce(function (acc, image) {
823
+ acc[image === null || image === void 0 ? void 0 : image.image_id] = ++acc[image === null || image === void 0 ? void 0 : image.image_id] || 0;
704
824
  return acc;
705
825
  }, {});
706
- duplicated = imagesList.filter(function (image) {
707
- return imagesListTemp[image.image_id];
826
+ duplicated = imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (image) {
827
+ return imagesListTemp[image === null || image === void 0 ? void 0 : image.image_id];
708
828
  });
709
829
  attrForImgs = Object.values(images === null || images === void 0 ? void 0 : images.attrForImgs);
710
830
  attrForImgs.pop();
711
831
  data = {
712
- articleId: articleId,
713
- attrReqImgs: attrForImgs.map(function (e) {
832
+ articleId: product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article,
833
+ attrReqImgs: attrForImgs === null || attrForImgs === void 0 ? void 0 : attrForImgs.map(function (e) {
834
+ var _e$, _e$2;
835
+
714
836
  return {
715
- attrId: e[0].id,
716
- value: e[0].value
837
+ attrId: (_e$ = e[0]) === null || _e$ === void 0 ? void 0 : _e$.id,
838
+ value: (_e$2 = e[0]) === null || _e$2 === void 0 ? void 0 : _e$2.value
717
839
  };
718
840
  }),
719
- articleData: imagesList.filter(function (e) {
841
+ articleData: imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (e) {
720
842
  return !e.id;
721
843
  }),
722
- updateImages: imagesList.filter(function (e) {
844
+ updateImages: imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (e) {
723
845
  return e.id;
724
846
  })
725
847
  };
726
- valid = data.articleData.length === 0 ? true : data.articleData.every(function (e, i) {
727
- if (e.image_id && e.packing_type && e.image_type) {
848
+ if (product !== null && product !== void 0 && product.orderId) data["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
849
+ valid = (data === null || data === void 0 ? void 0 : (_data$articleData = data.articleData) === null || _data$articleData === void 0 ? void 0 : _data$articleData.length) === 0 ? true : data === null || data === void 0 ? void 0 : (_data$articleData2 = data.articleData) === null || _data$articleData2 === void 0 ? void 0 : _data$articleData2.every(function (e, i) {
850
+ if (e !== null && e !== void 0 && e.image_id && e !== null && e !== void 0 && e.packing_type && e !== null && e !== void 0 && e.image_type) {
728
851
  return true;
729
852
  }
730
853
 
731
854
  return false;
732
855
  });
733
856
 
734
- if (valid && data.updateImages.length > 0 && duplicated.length === 0) {
735
- valid = data.updateImages.every(function (e, i) {
736
- if (e.image_id && e.packing_type && e.image_type) {
857
+ if (valid && (data === null || data === void 0 ? void 0 : (_data$updateImages = data.updateImages) === null || _data$updateImages === void 0 ? void 0 : _data$updateImages.length) > 0 && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0) {
858
+ valid = data === null || data === void 0 ? void 0 : (_data$updateImages2 = data.updateImages) === null || _data$updateImages2 === void 0 ? void 0 : _data$updateImages2.every(function (e, i) {
859
+ if (e !== null && e !== void 0 && e.image_id && e !== null && e !== void 0 && e.packing_type && e !== null && e !== void 0 && e.image_type) {
737
860
  return true;
738
861
  }
739
862
 
@@ -741,95 +864,98 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
741
864
  });
742
865
  }
743
866
 
744
- if (!(valid && duplicated.length === 0)) {
745
- _context8.next = 29;
867
+ if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
868
+ _context7.next = 33;
746
869
  break;
747
870
  }
748
871
 
749
- _context8.prev = 9;
750
- data.articleData.forEach(function (e) {
872
+ setLoading(true);
873
+ _context7.prev = 11;
874
+ data === null || data === void 0 ? void 0 : (_data$articleData3 = data.articleData) === null || _data$articleData3 === void 0 ? void 0 : _data$articleData3.forEach(function (e) {
751
875
  e.uuid = (0, _uuid.v4)();
752
876
  });
753
877
  setDataImages(data);
754
878
 
755
- if (!(data.articleData.length > 0)) {
756
- _context8.next = 21;
879
+ if (!((data === null || data === void 0 ? void 0 : (_data$articleData4 = data.articleData) === null || _data$articleData4 === void 0 ? void 0 : _data$articleData4.length) > 0)) {
880
+ _context7.next = 23;
757
881
  break;
758
882
  }
759
883
 
760
884
  setImagesUploaded(false);
761
885
  promiseArray = [];
762
- data.articleData.forEach(function (e) {
886
+ data === null || data === void 0 ? void 0 : (_data$articleData5 = data.articleData) === null || _data$articleData5 === void 0 ? void 0 : _data$articleData5.forEach(function (e) {
763
887
  var file = Buffer.from(e.src.replace(/^data:image\/\w+;base64,/, ""), "base64");
764
888
  var params = {
765
889
  ACL: "public-read",
766
890
  Body: file,
767
891
  Bucket: S3_BUCKET,
768
- Key: "id-".concat(data.articleId, "/").concat(version, "/").concat(e.image_id, "-").concat(e.uuid, ".").concat(e.ext)
892
+ Key: "id-".concat(data.articleId, "/").concat(version, "/").concat(e === null || e === void 0 ? void 0 : e.image_id, "-").concat(e === null || e === void 0 ? void 0 : e.uuid, ".").concat(e === null || e === void 0 ? void 0 : e.ext)
769
893
  };
770
894
  promiseArray.push(myBucket.putObject(params).promise());
771
895
  });
772
- _context8.next = 18;
896
+ _context7.next = 20;
773
897
  return Promise.all(promiseArray);
774
898
 
775
- case 18:
899
+ case 20:
776
900
  setImagesUploaded(true);
777
- _context8.next = 22;
901
+ _context7.next = 24;
778
902
  break;
779
903
 
780
- case 21:
904
+ case 23:
781
905
  setImagesUploaded(true);
782
906
 
783
- case 22:
784
- _context8.next = 27;
907
+ case 24:
908
+ productTemp = product;
909
+
910
+ if (productTemp.status === "ASSIGNED") {
911
+ productTemp.status = "IN_PROGRESS";
912
+ setProduct(productTemp);
913
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
914
+ }
915
+
916
+ _context7.next = 31;
785
917
  break;
786
918
 
787
- case 24:
788
- _context8.prev = 24;
789
- _context8.t0 = _context8["catch"](9);
790
- console.log(_context8.t0); // setMainLoading(false);
919
+ case 28:
920
+ _context7.prev = 28;
921
+ _context7.t0 = _context7["catch"](11);
922
+ console.log(_context7.t0); // setMainLoading(false);
791
923
 
792
- case 27:
793
- _context8.next = 30;
924
+ case 31:
925
+ _context7.next = 34;
794
926
  break;
795
927
 
796
- case 29:
928
+ case 33:
797
929
  // setMainLoading(false);
798
- console.log("Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma.", "Recuerda hay campos obligatorios y no podras avanzar si no estan completos."); // setAlertList((prev) => [
799
- // ...prev,
800
- // {
801
- // titleMsg: "Completa los campos que solicita cada una de la imágenes",
802
- // alertMsg:
803
- // "Recuerda hay campos obligatorios y no podras avanzar si no estan completos.",
804
- // },
805
- // ]);
806
-
807
- case 30:
930
+ setMessage("Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma.\nRecuerda hay campos obligatorios y no podras avanzar si no estan completos.");
931
+
932
+ case 34:
808
933
  case "end":
809
- return _context8.stop();
934
+ return _context7.stop();
810
935
  }
811
936
  }
812
- }, _callee8, null, [[9, 24]]);
937
+ }, _callee7, null, [[11, 28]]);
813
938
  })), [images, imagesUploaded]);
814
- (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
815
- return _regenerator.default.wrap(function _callee9$(_context9) {
939
+ (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
940
+ return _regenerator.default.wrap(function _callee8$(_context8) {
816
941
  while (1) {
817
- switch (_context9.prev = _context9.next) {
942
+ switch (_context8.prev = _context8.next) {
818
943
  case 0:
819
944
  if (!imagesUploaded) {
820
- _context9.next = 11;
945
+ _context8.next = 13;
821
946
  break;
822
947
  }
823
948
 
824
- dataImages.articleData = dataImages.articleData.map(function (e) {
949
+ dataImages.articleData = dataImages === null || dataImages === void 0 ? void 0 : dataImages.articleData.map(function (e) {
825
950
  delete e.src;
826
951
  e.imageID = e.image_id;
827
952
  e.packingType = e.packing_type;
828
953
  e.imageType = e.image_type;
954
+ if (product !== null && product !== void 0 && product.orderId) e["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
829
955
  return e;
830
956
  });
831
- _context9.prev = 2;
832
- _context9.next = 5;
957
+ _context8.prev = 2;
958
+ _context8.next = 5;
833
959
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), dataImages, {
834
960
  headers: {
835
961
  Authorization: token
@@ -837,45 +963,89 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
837
963
  });
838
964
 
839
965
  case 5:
840
- console.log("imágenes guardadas con éxito");
841
- _context9.next = 11;
966
+ setMessage("Imágenes guardadas con éxito");
967
+ sessionStorage.removeItem("imagesList");
968
+ loadData();
969
+ _context8.next = 13;
842
970
  break;
843
971
 
844
- case 8:
845
- _context9.prev = 8;
846
- _context9.t0 = _context9["catch"](2);
847
- console.log(_context9.t0);
972
+ case 10:
973
+ _context8.prev = 10;
974
+ _context8.t0 = _context8["catch"](2);
975
+ console.log(_context8.t0);
848
976
 
849
- case 11:
977
+ case 13:
850
978
  case "end":
851
- return _context9.stop();
979
+ return _context8.stop();
852
980
  }
853
981
  }
854
- }, _callee9, null, [[2, 8]]);
982
+ }, _callee8, null, [[2, 10]]);
855
983
  })), [dataImages, imagesUploaded]);
856
984
 
857
- var approveRejectButtons = function approveRejectButtons(action) {
858
- var concept = "";
985
+ var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {
986
+ var srv = servicesData.filter(function (serv) {
987
+ return serv.service === getConcept(tab);
988
+ });
859
989
 
860
- switch (activeTab) {
861
- case "Descripción":
862
- concept = "description";
990
+ var _srv$filter = srv.filter(function (serv) {
991
+ return serv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
992
+ }),
993
+ _srv$filter2 = (0, _slicedToArray2.default)(_srv$filter, 1),
994
+ srvActive = _srv$filter2[0];
995
+
996
+ var unvalidated = product["".concat(getConcept(tab), "_status")] === "QF" || product["".concat(getConcept(tab), "_status")] === "IN_PROGRESS";
997
+ var auditorUnvalidated = !["RA", "AA", "AC", "AP"].includes(product["".concat(getConcept(tab), "_status")]);
998
+
999
+ switch (userId) {
1000
+ case 7:
1001
+ case 8:
1002
+ return ["RA", "RF"].includes(product === null || product === void 0 ? void 0 : product.status) && //"IN_PROGRESS", "RF", "RA"
1003
+ statusArray.includes(srvActive === null || srvActive === void 0 ? void 0 : srvActive.status) || statusArray.includes(product.status) && srv.filter(function (serv) {
1004
+ return statusArray.includes(serv.status);
1005
+ }).length === srv.length;
1006
+
1007
+ case 4:
1008
+ case 5:
1009
+ return unvalidated && ["IN_PROGRESS", "QF"].includes(product.status) && //"RF", "AF", "AA", "AP", "AC
1010
+ srv.filter(function (serv) {
1011
+ return statusArray.includes(serv.status);
1012
+ }).length === srv.length;
1013
+
1014
+ case 6:
1015
+ return statusArray.includes(product.status) && //RP, RC, AF, RA true
1016
+ srv.every(function (serv) {
1017
+ return ["RA", "AA", "AP", "AC"].includes(serv.status);
1018
+ }) && auditorUnvalidated;
1019
+
1020
+ default:
863
1021
  break;
1022
+ }
1023
+ };
1024
+
1025
+ var getConcept = function getConcept(tab) {
1026
+ switch (tab) {
1027
+ case "Descripción":
1028
+ return "description";
864
1029
 
865
1030
  case "Ficha técnica":
866
- concept = "datasheet";
867
- break;
1031
+ return "datasheet";
868
1032
 
869
1033
  case "Imágenes":
870
- concept = "images";
871
- break;
872
-
873
- default:
874
- break;
1034
+ return "images";
875
1035
  }
1036
+ };
1037
+
1038
+ var approveRejectButtons = function approveRejectButtons(action) {
1039
+ var concept = getConcept(action || activeTab);
876
1040
 
877
- concept = action ? action : concept;
878
- return productSelected["".concat(concept, "_status")] === "QF" && (user.id_role === 1 || user.id_role === 4 || user.id_role === 5) || productSelected["".concat(concept, "_status")] === "AF" && (user.id_role === 1 || user.id_role === 6) || productSelected["".concat(concept, "_status")] === "RP" && (user.id_role === 1 || user.id_role === 6);
1041
+ var _servicesData$filter = servicesData.filter(function (srv) {
1042
+ return srv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && srv.service === concept;
1043
+ }),
1044
+ _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1045
+ retailerStatus = _servicesData$filter2[0];
1046
+
1047
+ return (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "QF" && (user.id_role === 1 || user.id_role === 4 || user.id_role === 5) || (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "AF" && ( //sessionStorage product
1048
+ user.id_role === 1 || user.id_role === 6) || (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "RP" && (user.id_role === 1 || user.id_role === 6) || (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "RC" && (user.id_role === 1 || user.id_role === 6);
879
1049
  };
880
1050
 
881
1051
  var getSectionIcon = function getSectionIcon() {
@@ -897,331 +1067,295 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
897
1067
  }
898
1068
  };
899
1069
 
900
- var updateCompaniesList = function updateCompaniesList(status, result, retailerId, concept) {
901
- var serv = servicesData.slice();
902
- var item = serv.find(function (item) {
903
- return item.id_retailer === retailerId && item.service === concept;
904
- });
905
- var index = serv.indexOf(item);
906
-
907
- if (status === "IN_PROGRESS" || status === "QF" || status === "RF" || status === "RA") {
908
- if (result === "A") {
909
- if (activeTab === "Imágenes") {
910
- serv.map(function (item) {
911
- item.status = "AF";
912
- });
913
- } else {
914
- serv[index].status = "AF";
915
- }
916
- } else if (result === "R") {
917
- if (activeTab === "Imágenes") {
918
- serv.map(function (item) {
919
- item.status = "RF";
920
- });
921
- } else {
922
- serv[index].status = "RF";
923
- }
924
- } else {
925
- if (status === "IN_PROGRESS" || status === "ASSIGNED") {
926
- serv.map(function (item) {
927
- item.status = "QF";
928
- });
929
- } else {
930
- serv.map(function (item) {
931
- if (item.status === "RF" || item.status === "RA") {
932
- item.status = "QF";
933
- }
934
-
935
- return item;
936
- });
937
- }
938
- }
939
- } else if (status === "AF" || status === "RP") {
940
- if (result === "A") {
941
- if (activeTab === "Imágenes") {
942
- serv.map(function (item) {
943
- item.status = "AA";
944
- });
945
- } else {
946
- serv[index].status = "AA";
947
- }
948
- } else {
949
- if (activeTab === "Imágenes") {
950
- serv.map(function (item) {
951
- item.status = "RA";
952
- });
953
- } else {
954
- serv[index].status = "RA";
955
- }
956
- }
957
- }
958
-
959
- setServicesData(serv);
960
- };
961
-
962
1070
  var sendToFacilitator = /*#__PURE__*/function () {
963
- var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(result) {
964
- var concept, evalStatus, productTemp, specialistDone, data;
965
- return _regenerator.default.wrap(function _callee10$(_context10) {
1071
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(result) {
1072
+ var concept, productTemp, evalStatus, data, specialistDone, statusArr, newStatus;
1073
+ return _regenerator.default.wrap(function _callee9$(_context9) {
966
1074
  while (1) {
967
- switch (_context10.prev = _context10.next) {
1075
+ switch (_context9.prev = _context9.next) {
968
1076
  case 0:
969
- concept = "";
970
- _context10.t0 = activeTab;
971
- _context10.next = _context10.t0 === "Descripción" ? 4 : _context10.t0 === "Ficha técnica" ? 6 : _context10.t0 === "Imágenes" ? 8 : 10;
972
- break;
973
-
974
- case 4:
975
- concept = "description";
976
- return _context10.abrupt("break", 11);
977
-
978
- case 6:
979
- concept = "datasheet";
980
- return _context10.abrupt("break", 11);
981
-
982
- case 8:
983
- concept = "images";
984
- return _context10.abrupt("break", 11);
985
-
986
- case 10:
987
- return _context10.abrupt("break", 11);
988
-
989
- case 11:
990
- evalStatus = "";
991
- productTemp = (0, _objectSpread2.default)({}, productSelected);
992
- evalStatus = productSelected["".concat(concept, "_status")];
993
- specialistDone = evalStatus === "RF" || evalStatus === "RA" || evalStatus === "IN_PROGRESS";
994
-
995
- if (specialistDone) {
996
- setMessage("".concat(activeTab, " enviada a facilitador"));
997
- getSectionIcon();
998
- productTemp["".concat(concept, "_status")] = "QF";
999
- } else if (evalStatus === "QF") {
1000
- setMessage("Evaluación enviada");
1001
- getSectionIcon();
1002
- productTemp["".concat(concept, "_status")] = "AF";
1003
- } else if (evalStatus === "AF") {
1004
- setMessage("Evaluación enviada");
1005
- getSectionIcon();
1006
- productTemp["".concat(concept, "_status")] = "AA";
1007
- } else if (evalStatus === "RP") {
1008
- setMessage("Evaluación enviada");
1009
- getSectionIcon();
1010
- productTemp["".concat(concept, "_status")] = "AA";
1011
- }
1012
-
1077
+ setLoading(true);
1078
+ _context9.prev = 1;
1079
+ concept = getConcept(activeTab);
1080
+ productTemp = (0, _objectSpread2.default)({}, product);
1081
+ evalStatus = product["".concat(concept, "_status")];
1013
1082
  data = {};
1014
1083
 
1015
1084
  if (!result) {
1016
- _context10.next = 24;
1085
+ _context9.next = 13;
1017
1086
  break;
1018
1087
  }
1019
1088
 
1020
- updateCompaniesList(evalStatus, result, activeRetailer.id, concept);
1021
1089
  data = {
1022
- articleId: productSelected.article.id_article,
1023
- orderId: productSelected.orderId,
1090
+ articleId: product.article.id_article,
1091
+ orderId: product.orderId,
1024
1092
  concept: concept,
1025
1093
  result: result,
1026
1094
  evalStatus: evalStatus,
1027
1095
  retailerId: activeRetailer.id
1028
1096
  };
1029
- _context10.next = 22;
1097
+ _context9.next = 10;
1030
1098
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1031
1099
  headers: {
1032
1100
  Authorization: token
1033
1101
  }
1034
1102
  });
1035
1103
 
1036
- case 22:
1037
- _context10.next = 37;
1104
+ case 10:
1105
+ getServices();
1106
+ _context9.next = 31;
1038
1107
  break;
1039
1108
 
1040
- case 24:
1109
+ case 13:
1110
+ specialistDone = evalStatus === "RF" || evalStatus === "RA" || evalStatus === "IN_PROGRESS";
1111
+
1041
1112
  if (specialistDone) {
1042
- updateCompaniesList(evalStatus, result, activeRetailer.id);
1113
+ setMessage("".concat(activeTab, " enviada a facilitador"));
1114
+ getSectionIcon();
1115
+ } else if (evalStatus === "QF") {
1116
+ setMessage("Evaluación enviada");
1117
+ getSectionIcon();
1118
+ } else if (evalStatus === "AF") {
1119
+ setMessage("Evaluación enviada");
1120
+ getSectionIcon();
1121
+ } else if (evalStatus === "RP") {
1122
+ setMessage("Evaluación enviada");
1123
+ getSectionIcon();
1124
+ } else if (evalStatus === "RC") {
1125
+ setMessage("Evaluación enviada");
1126
+ getSectionIcon();
1043
1127
  }
1044
1128
 
1129
+ statusArr = [];
1130
+ servicesData.forEach(function (srv) {
1131
+ srv.service === concept && statusArr.push(srv.status);
1132
+ });
1133
+ productTemp["".concat(concept, "_status")] = (0, _data2.getNewStatus)(statusArr);
1134
+ newStatus = (0, _data2.getNewStatus)([productTemp.datasheet_status, productTemp.description_status, productTemp.images_status]);
1135
+ productTemp.status = newStatus;
1045
1136
  data = {
1046
- articleId: productSelected.article.id_article,
1047
- orderId: productSelected.orderId,
1137
+ articleId: product.article.id_article,
1138
+ orderId: product.orderId,
1048
1139
  concept: concept,
1049
1140
  evalStatus: evalStatus,
1050
1141
  retailerId: activeRetailer.id
1051
1142
  };
1052
- _context10.t1 = user.id_role;
1053
- _context10.next = _context10.t1 === 7 ? 29 : _context10.t1 === 8 ? 29 : _context10.t1 === 4 ? 31 : _context10.t1 === 5 ? 31 : 33;
1143
+ _context9.t0 = user.id_role;
1144
+ _context9.next = _context9.t0 === 7 ? 24 : _context9.t0 === 8 ? 24 : _context9.t0 === 4 ? 26 : _context9.t0 === 5 ? 26 : 28;
1054
1145
  break;
1055
1146
 
1056
- case 29:
1147
+ case 24:
1057
1148
  data.especialist = true;
1058
- return _context10.abrupt("break", 34);
1149
+ return _context9.abrupt("break", 29);
1059
1150
 
1060
- case 31:
1151
+ case 26:
1061
1152
  data.facilitator = true;
1062
- return _context10.abrupt("break", 34);
1153
+ return _context9.abrupt("break", 29);
1063
1154
 
1064
- case 33:
1065
- return _context10.abrupt("break", 34);
1155
+ case 28:
1156
+ return _context9.abrupt("break", 29);
1066
1157
 
1067
- case 34:
1068
- _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1158
+ case 29:
1159
+ _context9.next = 31;
1160
+ return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1069
1161
  headers: {
1070
1162
  Authorization: token
1071
1163
  }
1072
1164
  });
1073
1165
 
1166
+ case 31:
1167
+ loadData();
1168
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1074
1169
  setProduct(productTemp);
1075
- setModalSent(true);
1170
+ _context9.next = 39;
1171
+ break;
1076
1172
 
1077
- case 37:
1173
+ case 36:
1174
+ _context9.prev = 36;
1175
+ _context9.t1 = _context9["catch"](1);
1176
+ console.log(_context9.t1);
1177
+
1178
+ case 39:
1179
+ setLoading(false);
1180
+
1181
+ case 40:
1078
1182
  case "end":
1079
- return _context10.stop();
1183
+ return _context9.stop();
1080
1184
  }
1081
1185
  }
1082
- }, _callee10);
1186
+ }, _callee9, null, [[1, 36]]);
1083
1187
  }));
1084
1188
 
1085
- return function sendToFacilitator(_x3) {
1086
- return _ref11.apply(this, arguments);
1189
+ return function sendToFacilitator(_x) {
1190
+ return _ref10.apply(this, arguments);
1087
1191
  };
1088
1192
  }();
1089
1193
 
1090
1194
  var userAssigned = function userAssigned(tab, rol) {
1091
- var concept = "";
1092
-
1093
- switch (tab) {
1094
- case "Ficha técnica":
1095
- concept = "datasheet";
1096
- break;
1097
-
1098
- case "Imágenes":
1099
- concept = "images";
1100
- break;
1101
-
1102
- default:
1103
- concept = "description";
1104
- break;
1195
+ var concept = getConcept(activeTab);
1196
+ var allowedRoles = [1, 4, 5, 6, 7, 8];
1197
+ var validUser = allowedRoles.includes(user === null || user === void 0 ? void 0 : user.id_role);
1198
+
1199
+ if (!rol) {
1200
+ switch (user.id_role) {
1201
+ case 4:
1202
+ case 5:
1203
+ rol = "facilitator";
1204
+ break;
1205
+
1206
+ case 7:
1207
+ case 8:
1208
+ rol = "especialist";
1209
+ break;
1210
+ }
1105
1211
  }
1106
1212
 
1107
- var allowedRoles = [1, 4, 5, 6, 7, 8];
1108
- var validUser = allowedRoles.indexOf(user === null || user === void 0 ? void 0 : user.id_role) !== -1;
1109
- return productSelected.article["id_".concat(concept, "_").concat(rol)] === user.id_user && validUser;
1213
+ return user.id_role === 1 || product.article["id_".concat(concept, "_").concat(rol)] === user.id_user && validUser;
1110
1214
  };
1111
1215
 
1112
1216
  var auditorAssigned = function auditorAssigned() {
1113
- return (productSelected === null || productSelected === void 0 ? void 0 : productSelected.article["id_auditor"]) === user.id_user;
1217
+ return (product === null || product === void 0 ? void 0 : product.article["id_auditor"]) === user.id_user;
1114
1218
  };
1115
1219
 
1116
- function specialistValid(tab) {
1117
- var concept = "";
1118
-
1119
- switch (tab) {
1120
- case "Ficha técnica":
1121
- concept = "datasheet";
1122
- break;
1123
-
1124
- case "Imágenes":
1125
- concept = "images";
1126
- break;
1127
-
1128
- default:
1129
- concept = "description";
1130
- break;
1131
- }
1132
-
1133
- return product["".concat(concept, "_status")] === "IN_PROGRESS" || product["".concat(concept, "_status")] === "RF" || product["".concat(concept, "_status")] === "RA";
1134
- }
1135
-
1136
- function versionMatch() {
1137
- return (productSelected === null || productSelected === void 0 ? void 0 : productSelected.version) === version;
1138
- }
1139
-
1140
1220
  var createComment = /*#__PURE__*/function () {
1141
- var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(e, body, tab) {
1142
- var _product$article;
1221
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(e, body, tab) {
1222
+ var _product$article11;
1143
1223
 
1144
1224
  var concept, data;
1145
- return _regenerator.default.wrap(function _callee11$(_context11) {
1225
+ return _regenerator.default.wrap(function _callee10$(_context10) {
1146
1226
  while (1) {
1147
- switch (_context11.prev = _context11.next) {
1227
+ switch (_context10.prev = _context10.next) {
1148
1228
  case 0:
1149
1229
  concept = "";
1150
- _context11.t0 = activeTab;
1151
- _context11.next = _context11.t0 === "Ficha técnica" ? 4 : _context11.t0 === "Imágenes" ? 6 : 8;
1230
+ _context10.t0 = activeTab;
1231
+ _context10.next = _context10.t0 === "Ficha técnica" ? 4 : _context10.t0 === "Imágenes" ? 6 : 8;
1152
1232
  break;
1153
1233
 
1154
1234
  case 4:
1155
1235
  concept = "datasheet";
1156
- return _context11.abrupt("break", 10);
1236
+ return _context10.abrupt("break", 10);
1157
1237
 
1158
1238
  case 6:
1159
1239
  concept = "images";
1160
- return _context11.abrupt("break", 10);
1240
+ return _context10.abrupt("break", 10);
1161
1241
 
1162
1242
  case 8:
1163
1243
  concept = "description";
1164
- return _context11.abrupt("break", 10);
1244
+ return _context10.abrupt("break", 10);
1165
1245
 
1166
1246
  case 10:
1167
1247
  data = {
1168
- articleId: product === null || product === void 0 ? void 0 : (_product$article = product.article) === null || _product$article === void 0 ? void 0 : _product$article.id_article,
1248
+ articleId: product === null || product === void 0 ? void 0 : (_product$article11 = product.article) === null || _product$article11 === void 0 ? void 0 : _product$article11.id_article,
1169
1249
  orderId: product === null || product === void 0 ? void 0 : product.orderId,
1170
1250
  message: body,
1171
1251
  concept: concept,
1172
1252
  version: version
1173
1253
  };
1174
- e.preventDefault();
1175
- _context11.next = 14;
1254
+ _context10.next = 13;
1176
1255
  return _axios.default.post("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT), data, {
1177
1256
  headers: {
1178
1257
  Authorization: token
1179
1258
  }
1180
1259
  });
1181
1260
 
1182
- case 14:
1183
- _context11.next = 16;
1261
+ case 13:
1262
+ _context10.next = 15;
1184
1263
  return getComments(tab);
1185
1264
 
1186
- case 16:
1265
+ case 15:
1266
+ setMessage("");
1267
+ setComponentsArray([]);
1268
+
1269
+ case 17:
1187
1270
  case "end":
1188
- return _context11.stop();
1271
+ return _context10.stop();
1189
1272
  }
1190
1273
  }
1191
- }, _callee11);
1274
+ }, _callee10);
1192
1275
  }));
1193
1276
 
1194
- return function createComment(_x4, _x5, _x6) {
1195
- return _ref12.apply(this, arguments);
1277
+ return function createComment(_x2, _x3, _x4) {
1278
+ return _ref11.apply(this, arguments);
1196
1279
  };
1197
1280
  }();
1198
1281
 
1199
- (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
1200
- return _regenerator.default.wrap(function _callee12$(_context12) {
1201
- while (1) {
1202
- switch (_context12.prev = _context12.next) {
1203
- case 0:
1204
- setComment(comments[activeTab]);
1282
+ var getRequired = function getRequired(services) {
1283
+ try {
1284
+ var _services$4, _services$4$retailerM, _services$5, _services$5$inputs;
1285
+
1286
+ var objetcTemp = {};
1287
+ var datasheetServicesArray = Object.values(services[0]);
1288
+ var dsInputs = datasheetServicesArray.pop();
1289
+ var descriptionsServicesArray = services[1];
1290
+ var dsInputsRequired = [];
1291
+ var desInputsRequired = 0;
1292
+ datasheetServicesArray === null || datasheetServicesArray === void 0 ? void 0 : datasheetServicesArray.forEach(function (datasheet) {
1293
+ var _servicesData$filter3 = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1294
+ return srv.id_retailer === datasheet.retailer.id && srv.service === getConcept(activeTab);
1295
+ }),
1296
+ _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1297
+ requested = _servicesData$filter4[0];
1298
+
1299
+ requested && (datasheet === null || datasheet === void 0 ? void 0 : datasheet.data) && Object.values(datasheet === null || datasheet === void 0 ? void 0 : datasheet.data).forEach(function (dataGroup) {
1300
+ return dsInputsRequired.push.apply(dsInputsRequired, (0, _toConsumableArray2.default)(dataGroup.inputs.filter(function (input) {
1301
+ return dsInputs[input].required && (dsInputs[input].value === undefined || !dsInputs[input].value);
1302
+ })));
1303
+ });
1304
+ });
1305
+ objetcTemp["Ficha técnica"] = dsInputsRequired.length;
1306
+ descriptionsServicesArray.forEach(function (description) {
1307
+ var _servicesData$filter5 = servicesData.filter(function (srv) {
1308
+ return srv.id_retailer === description.id && srv.service === getConcept(activeTab);
1309
+ }),
1310
+ _servicesData$filter6 = (0, _slicedToArray2.default)(_servicesData$filter5, 1),
1311
+ requested = _servicesData$filter6[0];
1312
+
1313
+ requested && description.inputs.forEach(function (input) {
1314
+ return input.required && (!input.value || input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") === "") && desInputsRequired++;
1315
+ });
1316
+ });
1317
+ objetcTemp["Descripción"] = desInputsRequired;
1318
+ var retailersRequested = [];
1319
+ (_services$4 = services[2]) === null || _services$4 === void 0 ? void 0 : (_services$4$retailerM = _services$4.retailerMandatories) === null || _services$4$retailerM === void 0 ? void 0 : _services$4$retailerM.forEach(function (retMan) {
1320
+ return retMan.forEach(function (rm) {
1321
+ return retailersRequested.push(rm);
1322
+ });
1323
+ });
1324
+ var requiredImages = (_services$5 = services[2]) === null || _services$5 === void 0 ? void 0 : (_services$5$inputs = _services$5.inputs) === null || _services$5$inputs === void 0 ? void 0 : _services$5$inputs.filter(function (e) {
1325
+ return e.required === 1 && retailersRequested.filter(function (ret) {
1326
+ return ret.id_image === e.id && servicesData.filter(function (srv) {
1327
+ return srv.id_retailer === ret.id_retailer;
1328
+ }).length > 0;
1329
+ }).length > 0;
1330
+ });
1331
+ var requiredCounter = 0;
1332
+ requiredImages === null || requiredImages === void 0 ? void 0 : requiredImages.forEach(function (req) {
1333
+ return services[2].values.filter(function (img) {
1334
+ return img.image_id === req.id;
1335
+ }).length === 0 && requiredCounter++;
1336
+ });
1337
+ objetcTemp["Imágenes"] = requiredCounter;
1338
+ setRequiredNull(objetcTemp);
1339
+ } catch (error) {
1340
+ console.log(error);
1341
+ }
1342
+ };
1205
1343
 
1206
- case 1:
1207
- case "end":
1208
- return _context12.stop();
1209
- }
1210
- }
1211
- }, _callee12);
1212
- })), [activeTab]);
1344
+ (0, _react.useEffect)(function () {
1345
+ setComment(comments[activeTab]);
1346
+ }, [activeTab]);
1213
1347
 
1214
1348
  var commentRevised = /*#__PURE__*/function () {
1215
- var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
1349
+ var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
1216
1350
  var data;
1217
- return _regenerator.default.wrap(function _callee13$(_context13) {
1351
+ return _regenerator.default.wrap(function _callee11$(_context11) {
1218
1352
  while (1) {
1219
- switch (_context13.prev = _context13.next) {
1353
+ switch (_context11.prev = _context11.next) {
1220
1354
  case 0:
1221
1355
  data = {
1222
1356
  commentId: comment.id
1223
1357
  };
1224
- _context13.next = 3;
1358
+ _context11.next = 3;
1225
1359
  return _axios.default.put("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT), data, {
1226
1360
  headers: {
1227
1361
  Authorization: sessionStorage.getItem("jwt")
@@ -1230,55 +1364,55 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1230
1364
 
1231
1365
  case 3:
1232
1366
  setCrossComment(false);
1233
- _context13.next = 6;
1367
+ _context11.next = 6;
1234
1368
  return getComments();
1235
1369
 
1236
1370
  case 6:
1237
1371
  case "end":
1238
- return _context13.stop();
1372
+ return _context11.stop();
1239
1373
  }
1240
1374
  }
1241
- }, _callee13);
1375
+ }, _callee11);
1242
1376
  }));
1243
1377
 
1244
1378
  return function commentRevised() {
1245
- return _ref14.apply(this, arguments);
1379
+ return _ref12.apply(this, arguments);
1246
1380
  };
1247
1381
  }();
1248
1382
 
1249
1383
  var setAssignation = /*#__PURE__*/function () {
1250
- var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(assignationType, assignationId) {
1251
- var _product$article2;
1384
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(assignationType, assignationId) {
1385
+ var _product$article12;
1252
1386
 
1253
1387
  var concept, productTemp, data;
1254
- return _regenerator.default.wrap(function _callee14$(_context14) {
1388
+ return _regenerator.default.wrap(function _callee12$(_context12) {
1255
1389
  while (1) {
1256
- switch (_context14.prev = _context14.next) {
1390
+ switch (_context12.prev = _context12.next) {
1257
1391
  case 0:
1258
1392
  concept = "";
1259
- _context14.t0 = activeTab;
1260
- _context14.next = _context14.t0 === "Ficha técnica" ? 4 : _context14.t0 === "Imágenes" ? 6 : 8;
1393
+ _context12.t0 = activeTab;
1394
+ _context12.next = _context12.t0 === "Ficha técnica" ? 4 : _context12.t0 === "Imágenes" ? 6 : 8;
1261
1395
  break;
1262
1396
 
1263
1397
  case 4:
1264
1398
  concept = "datasheet";
1265
- return _context14.abrupt("break", 10);
1399
+ return _context12.abrupt("break", 10);
1266
1400
 
1267
1401
  case 6:
1268
1402
  concept = "images";
1269
- return _context14.abrupt("break", 10);
1403
+ return _context12.abrupt("break", 10);
1270
1404
 
1271
1405
  case 8:
1272
1406
  concept = "description";
1273
- return _context14.abrupt("break", 10);
1407
+ return _context12.abrupt("break", 10);
1274
1408
 
1275
1409
  case 10:
1276
- productTemp = productSelected;
1410
+ productTemp = product;
1277
1411
  productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
1278
1412
  data = (0, _defineProperty2.default)({
1279
1413
  articleList: [{
1280
1414
  orderId: product.orderId,
1281
- articleId: product === null || product === void 0 ? void 0 : (_product$article2 = product.article) === null || _product$article2 === void 0 ? void 0 : _product$article2.id_article
1415
+ articleId: product === null || product === void 0 ? void 0 : (_product$article12 = product.article) === null || _product$article12 === void 0 ? void 0 : _product$article12.id_article
1282
1416
  }],
1283
1417
  concept: concept
1284
1418
  }, "".concat(assignationType, "Id"), assignationId);
@@ -1295,17 +1429,117 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1295
1429
 
1296
1430
  case 16:
1297
1431
  case "end":
1298
- return _context14.stop();
1432
+ return _context12.stop();
1299
1433
  }
1300
1434
  }
1301
- }, _callee14);
1435
+ }, _callee12);
1302
1436
  }));
1303
1437
 
1304
- return function setAssignation(_x7, _x8) {
1305
- return _ref15.apply(this, arguments);
1438
+ return function setAssignation(_x5, _x6) {
1439
+ return _ref13.apply(this, arguments);
1306
1440
  };
1307
1441
  }();
1308
1442
 
1443
+ var downloadImages = function downloadImages() {
1444
+ selectedImages.forEach(function (e) {
1445
+ if (e.id) {
1446
+ (0, _fileSaver.saveAs)("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(product.article.upc, "_").concat(e.name, ".").concat(e.ext));
1447
+ }
1448
+ });
1449
+ };
1450
+
1451
+ var deleteImages = function deleteImages() {
1452
+ setLoading(true);
1453
+ var values = images.values;
1454
+ var imgsInBack = [];
1455
+ selectedImages.forEach(function (selectedImg) {
1456
+ if (selectedImg.id) imgsInBack.push(selectedImg);
1457
+ });
1458
+ var imgsLeft = values.filter(function (value) {
1459
+ return selectedImages.indexOf(value) === -1;
1460
+ });
1461
+
1462
+ if (imgsInBack.length > 0) {
1463
+ var data = {
1464
+ articleId: product.article.id_article,
1465
+ deleteImages: imgsInBack,
1466
+ orderId: product.orderId
1467
+ };
1468
+
1469
+ try {
1470
+ _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), data, {
1471
+ headers: {
1472
+ Authorization: token
1473
+ }
1474
+ });
1475
+ } catch (err) {
1476
+ console.log(err);
1477
+ }
1478
+ }
1479
+
1480
+ setImages({
1481
+ action: "deleteImage",
1482
+ selectedImages: selectedImages
1483
+ });
1484
+ getRequired([services[0], services[1], (0, _objectSpread2.default)((0, _objectSpread2.default)({}, services[2]), {}, {
1485
+ values: imgsLeft
1486
+ })]);
1487
+ setTimeout(function () {
1488
+ setLoading(false);
1489
+ }, 500);
1490
+ setMessage("");
1491
+ setComponentsArray([]);
1492
+ };
1493
+
1494
+ var askToDeleteImages = function askToDeleteImages() {
1495
+ if (selectedImages.length > 0) {
1496
+ setMessage("¿Está seguro de eliminar las imágenes seleccionadas?");
1497
+ setComponentsArray([/*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1498
+ text: "¿Está seguro de eliminar las imágenes seleccionadas?",
1499
+ headerType: "retailer-name-header",
1500
+ color: "white"
1501
+ }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1502
+ buttonType: "general-white-button",
1503
+ label: "Cancelar",
1504
+ onClick: function onClick() {
1505
+ return setMessage("");
1506
+ }
1507
+ }, "2"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1508
+ buttonType: "general-button-default",
1509
+ label: "Aceptar",
1510
+ onClick: function onClick() {
1511
+ setMessage("");
1512
+ deleteImages();
1513
+ }
1514
+ }, "3")]);
1515
+ }
1516
+ };
1517
+
1518
+ var getRetailerStatus = function getRetailerStatus(servicesData, tab) {
1519
+ var arr = servicesData === null || servicesData === void 0 ? void 0 : servicesData.slice();
1520
+ var concept = getConcept(tab);
1521
+ var retailerService = {};
1522
+
1523
+ var _arr$filter = arr === null || arr === void 0 ? void 0 : arr.filter(function (service) {
1524
+ return service.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && service.service === concept;
1525
+ });
1526
+
1527
+ var _arr$filter2 = (0, _slicedToArray2.default)(_arr$filter, 1);
1528
+
1529
+ retailerService = _arr$filter2[0];
1530
+ return retailerService ? retailerService.status : "NS";
1531
+ };
1532
+
1533
+ (0, _react.useEffect)(function () {
1534
+ var status = getRetailerStatus(servicesData, activeTab);
1535
+ setRetailerStatus(status);
1536
+ }, [activeTab, servicesData, activeRetailer]);
1537
+ (0, _react.useEffect)(function () {
1538
+ services.length > 0 && getRequired(services);
1539
+ }, [services, servicesData, activeTab]);
1540
+ (0, _react.useEffect)(function () {
1541
+ setSaving(loading);
1542
+ }, [loading]);
1309
1543
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
1310
1544
  headerTop: headerTop,
1311
1545
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTop.HeaderTop, {
@@ -1322,12 +1556,18 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1322
1556
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageDataTable.ImageDataTable, {
1323
1557
  lists: images,
1324
1558
  activeImage: images !== null && images !== void 0 && images.values ? images === null || images === void 0 ? void 0 : images.values[activeImage] : {},
1325
- retailerSelected: activeRetailer.id,
1559
+ retailerSelected: activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id,
1326
1560
  setImages: setImages,
1327
1561
  assignationsImages: assig["Imágenes"],
1328
- imagesStatus: productSelected === null || productSelected === void 0 ? void 0 : productSelected.images_status,
1562
+ imagesStatus: product === null || product === void 0 ? void 0 : product.images_status,
1329
1563
  setAssignation: setAssignation,
1330
- isRetailer: isRetailer
1564
+ isRetailer: isRetailer,
1565
+ onClickSave: function onClickSave() {
1566
+ var _product$services;
1567
+
1568
+ return (product === null || product === void 0 ? void 0 : (_product$services = product.services) === null || _product$services === void 0 ? void 0 : _product$services.images) === 1 && updateImages();
1569
+ },
1570
+ showSaveButton: userAssigned()
1331
1571
  })]
1332
1572
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1333
1573
  className: "product-information",
@@ -1335,71 +1575,114 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1335
1575
  headerData: product,
1336
1576
  percent: activePercentage,
1337
1577
  activeRetailer: activeRetailer,
1578
+ servicesData: servicesData,
1338
1579
  setActiveRetailer: setActiveRetailer,
1339
- approveRejectButtons: approveRejectButtons,
1340
1580
  sendToFacilitator: sendToFacilitator,
1341
- auditorAssigned: auditorAssigned,
1342
- userAssigned: userAssigned(activeTab, "facilitator")
1581
+ approve: function approve() {
1582
+ sendToFacilitator("A");
1583
+ },
1584
+ reject: function reject() {
1585
+ sendToFacilitator("R");
1586
+ setMessage("Rechazado");
1587
+ setComponentsArray([/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1588
+ src: _errorModal.default
1589
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1590
+ text: "Agrega tu comentarios para enviar el rechazo",
1591
+ headerType: "input-name-header",
1592
+ color: "white"
1593
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
1594
+ label: "Caja de Comentario",
1595
+ inputType: "textarea",
1596
+ inputId: "modal-commentary-box",
1597
+ index: 0,
1598
+ color: "white"
1599
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1600
+ buttonType: "general-default-button",
1601
+ label: "Enviar comentario",
1602
+ onClick: function onClick(e) {
1603
+ return createComment(e, document.querySelector("#modal-commentary-box .ql-container .ql-editor > p").innerHTML, activeTab);
1604
+ }
1605
+ })]);
1606
+ },
1607
+ showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned())
1343
1608
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
1344
1609
  tabsSections: tabsSections,
1345
- status: {
1346
- Descripción: (_servicesData$filter$ = servicesData.filter(function (service) {
1347
- return service.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && service.service === "description";
1348
- })[0]) === null || _servicesData$filter$ === void 0 ? void 0 : _servicesData$filter$.status,
1349
- "Ficha técnica": (_servicesData$filter$2 = servicesData.filter(function (service) {
1350
- return service.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && service.service === "datasheet";
1351
- })[0]) === null || _servicesData$filter$2 === void 0 ? void 0 : _servicesData$filter$2.status,
1352
- Imágenes: product === null || product === void 0 ? void 0 : product.images_status
1353
- },
1354
- profileImage: productData.asigned,
1610
+ status: retailerStatus,
1355
1611
  activeTab: activeTab,
1356
1612
  setActiveTab: setActiveTab,
1357
1613
  setImageLayout: setImageLayout,
1358
- saveDescriptions: saveDescriptions,
1359
- saveDatasheets: saveDatasheets,
1360
- updateImages: updateImages,
1614
+ downloadImages: downloadImages,
1615
+ askToDeleteImages: askToDeleteImages,
1361
1616
  assig: assig[activeTab],
1362
1617
  setAssignation: setAssignation,
1363
- isRetailer: isRetailer
1364
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1618
+ isRetailer: isRetailer,
1619
+ showSaveButton: userAssigned(),
1620
+ onClickSave: function onClickSave() {
1621
+ switch (activeTab) {
1622
+ case "Descripción":
1623
+ !saving && (product === null || product === void 0 ? void 0 : product.description_status) !== "NS" && saveDescriptions();
1624
+ break;
1625
+
1626
+ case "Ficha técnica":
1627
+ !saving && (product === null || product === void 0 ? void 0 : product.datasheet_status) !== "NS" && saveDatasheets();
1628
+ break;
1629
+
1630
+ case "Imágenes":
1631
+ !saving && (product === null || product === void 0 ? void 0 : product.images_status) !== "NS" && updateImages();
1632
+ break;
1633
+
1634
+ default:
1635
+ break;
1636
+ }
1637
+ }
1638
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1365
1639
  className: "services-information-container " + (imageLayout && activeTab === "Imágenes" ? "image-services" : ""),
1366
- children: [!imageLayout && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryHeader.GalleryHeader, {}), activeTab === "Ficha técnica" && ((product === null || product === void 0 ? void 0 : (_product$services = product.services) === null || _product$services === void 0 ? void 0 : _product$services.datasheets) === 1 ? (_datasheets$ = datasheets[0]) === null || _datasheets$ === void 0 ? void 0 : (_datasheets$$data = _datasheets$.data) === null || _datasheets$$data === void 0 ? void 0 : _datasheets$$data.map(function (dataGroup, index) {
1367
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
1368
- articleId: productSelected.article.id_article,
1369
- version: version,
1640
+ children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1641
+ children: [!imageLayout && activeTab === "Imágenes" && (product === null || product === void 0 ? void 0 : (_product$services2 = product.services) === null || _product$services2 === void 0 ? void 0 : _product$services2.images) === 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryHeader.GalleryHeader, {
1642
+ setSelectedImages: setSelectedImages,
1643
+ checkAll: checkAll,
1644
+ setCheckAll: setCheckAll
1645
+ }), activeTab === "Ficha técnica" && ((product === null || product === void 0 ? void 0 : product.datasheet_status) !== "NS" ? (_datasheets$ = datasheets[0]) === null || _datasheets$ === void 0 ? void 0 : (_datasheets$$data = _datasheets$.data) === null || _datasheets$$data === void 0 ? void 0 : _datasheets$$data.map(function (dataGroup, index) {
1646
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
1647
+ articleId: product.article.id_article,
1648
+ version: version,
1649
+ activeSection: activeTab,
1650
+ inputGroup: dataGroup,
1651
+ dataInputs: datasheets[1],
1652
+ updatedDatasheets: updatedDatasheets,
1653
+ setUpdatedDatasheets: setUpdatedDatasheets
1654
+ }, index + "-" + activeRetailer.name);
1655
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1656
+ text: "No cuentas con este servicio",
1657
+ headerType: "input-name-header"
1658
+ })), activeTab === "Descripción" && ((product === null || product === void 0 ? void 0 : product.description_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
1370
1659
  activeSection: activeTab,
1371
- inputGroup: dataGroup,
1372
- dataInputs: datasheets[1],
1373
- updatedDatasheets: updatedDatasheets,
1374
- setUpdatedDatasheets: setUpdatedDatasheets
1375
- }, index + "-" + activeRetailer.name);
1376
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
1377
- children: "no tienes este servicio"
1378
- })), activeTab === "Descripción" && ((product === null || product === void 0 ? void 0 : (_product$services2 = product.services) === null || _product$services2 === void 0 ? void 0 : _product$services2.descriptions) === 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
1379
- activeSection: activeTab,
1380
- inputGroup: descriptions[0],
1381
- updatedDescriptions: updatedDescriptions,
1382
- setUpdatedDescriptions: setUpdatedDescriptions,
1383
- articleId: articleId,
1384
- version: version,
1385
- dinamicHeight: true
1386
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
1387
- children: "no tienes este servicio"
1388
- })), activeTab === "Imágenes" && ((product === null || product === void 0 ? void 0 : (_product$services3 = product.services) === null || _product$services3 === void 0 ? void 0 : _product$services3.images) === 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("section", {
1389
- className: "container",
1390
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getRootProps({
1391
- className: "dropzone"
1392
- })), {}, {
1393
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", (0, _objectSpread2.default)({}, getInputProps())), /*#__PURE__*/(0, _jsxRuntime.jsx)("aside", {
1394
- children: thumbs()
1395
- })]
1396
- }))
1397
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
1398
- children: "no tienes este servicio"
1399
- }))]
1400
- }), (userAssigned(activeTab, "especialist" || "facilitator") || auditorAssigned()) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1660
+ inputGroup: descriptions[0],
1661
+ updatedDescriptions: updatedDescriptions,
1662
+ setUpdatedDescriptions: setUpdatedDescriptions,
1663
+ articleId: product === null || product === void 0 ? void 0 : (_product$article13 = product.article) === null || _product$article13 === void 0 ? void 0 : _product$article13.id_article,
1664
+ version: version,
1665
+ dinamicHeight: true
1666
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1667
+ text: "No cuentas con este servicio",
1668
+ headerType: "input-name-header"
1669
+ })), activeTab === "Imágenes" && ((product === null || product === void 0 ? void 0 : product.images_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)("section", {
1670
+ className: "container",
1671
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getRootProps({
1672
+ className: "dropzone"
1673
+ })), {}, {
1674
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", (0, _objectSpread2.default)({}, getInputProps())), /*#__PURE__*/(0, _jsxRuntime.jsx)("aside", {
1675
+ children: thumbs()
1676
+ })]
1677
+ }))
1678
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1679
+ text: "No cuentas con este servicio",
1680
+ headerType: "input-name-header"
1681
+ }))]
1682
+ })
1683
+ }), (userAssigned(activeTab) || auditorAssigned()) && product["".concat(getConcept(activeTab), "_status")] !== "NS" && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1401
1684
  className: "commentary-box",
1402
- children: !comment ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1685
+ children: [!comment ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1403
1686
  className: "commentary",
1404
1687
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
1405
1688
  label: "Caja de Comentario",
@@ -1408,21 +1691,15 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1408
1691
  inputRows: 4,
1409
1692
  inputId: "commentary-box",
1410
1693
  index: 0
1411
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1694
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1412
1695
  className: "buttons-box",
1413
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1696
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1414
1697
  buttonType: "general-transparent-button",
1415
1698
  label: "Enviar comentario",
1416
1699
  onClick: function onClick(e) {
1417
- return createComment(e, document.getElementById("description-commentary-box-0").value, activeTab);
1700
+ return createComment(e, document.querySelector("#commentary-box .ql-container .ql-editor > p").innerHTML, activeTab);
1418
1701
  }
1419
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1420
- buttonType: requiredNull !== 0 || !specialistValid(activeTab) || !versionMatch() ? "general-button-disabled" : "general-green-button",
1421
- label: "Enviar evaluación",
1422
- onClick: function onClick() {
1423
- return sendToFacilitator();
1424
- }
1425
- })]
1702
+ })
1426
1703
  })]
1427
1704
  }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1428
1705
  className: "feedback-box",
@@ -1431,23 +1708,29 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1431
1708
  reviewed: crossComment
1432
1709
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1433
1710
  buttonType: "circular-button accept-button",
1434
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
1435
- return _regenerator.default.wrap(function _callee15$(_context15) {
1711
+ onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
1712
+ return _regenerator.default.wrap(function _callee13$(_context13) {
1436
1713
  while (1) {
1437
- switch (_context15.prev = _context15.next) {
1714
+ switch (_context13.prev = _context13.next) {
1438
1715
  case 0:
1439
1716
  setCrossComment(true);
1440
1717
  commentRevised();
1441
1718
 
1442
1719
  case 2:
1443
1720
  case "end":
1444
- return _context15.stop();
1721
+ return _context13.stop();
1445
1722
  }
1446
1723
  }
1447
- }, _callee15);
1724
+ }, _callee13);
1448
1725
  }))
1449
1726
  })]
1450
- })
1727
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1728
+ buttonType: evaluationFinished(user.id_role, activeTab, statusArray) && requiredNull[activeTab] === 0 ? "general-green-button" : "general-button-disabled",
1729
+ label: "Enviar evaluación",
1730
+ onClick: function onClick() {
1731
+ return sendToFacilitator();
1732
+ }
1733
+ })]
1451
1734
  })]
1452
1735
  })]
1453
1736
  }), showModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductImageModal.ProductImageModal, {
@@ -1455,6 +1738,19 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1455
1738
  setShowModal: setShowModal,
1456
1739
  sendToFacilitator: sendToFacilitator,
1457
1740
  approveRejectButtons: approveRejectButtons
1741
+ }), message.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GenericModal.GenericModal, {
1742
+ buttonType: componentsArray.length > 0 && "delete-product",
1743
+ componentsArray: componentsArray.length > 0 ? componentsArray : [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1744
+ src: _genericModalCheck.default,
1745
+ alt: "success icon"
1746
+ }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1747
+ headerType: "retailer-name-header",
1748
+ text: message,
1749
+ color: "white"
1750
+ }, "2")],
1751
+ onClick: function onClick() {
1752
+ return setMessage("");
1753
+ }
1458
1754
  })]
1459
1755
  });
1460
1756
  };