contentoh-components-library 10.0.0 → 10.0.1

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 (406) hide show
  1. package/.env.development +20 -12
  2. package/.env.production +10 -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/ActivedFilter/ActivedFilter.stories.js +7 -1
  28. package/dist/components/atoms/ActivedFilter/index.js +12 -4
  29. package/dist/components/atoms/AsignationOption/AsignationOptions.stories.js +7 -1
  30. package/dist/components/atoms/AsignationOption/index.js +52 -23
  31. package/dist/components/atoms/AsignationOption/styles.js +1 -1
  32. package/dist/components/atoms/AtomList/AtomList.stories.js +7 -1
  33. package/dist/components/atoms/AtomList/index.js +14 -9
  34. package/dist/components/atoms/Avatar/AsignationImage.stories.js +7 -1
  35. package/dist/components/atoms/Avatar/index.js +11 -8
  36. package/dist/components/atoms/Card/Card.stories.js +7 -1
  37. package/dist/components/atoms/Card/index.js +8 -4
  38. package/dist/components/atoms/CharCounter/CharCounter.stories.js +31 -0
  39. package/dist/components/atoms/CharCounter/index.js +22 -0
  40. package/dist/components/atoms/CharCounter/styles.js +20 -0
  41. package/dist/components/atoms/CheckBox/CheckBox.stories.js +7 -1
  42. package/dist/components/atoms/CheckBox/index.js +19 -13
  43. package/dist/components/atoms/Commentary/index.js +10 -2
  44. package/dist/components/atoms/Commentary/styles.js +4 -1
  45. package/dist/components/atoms/CustomerTypeImage/CustomerTypeImage.stories.js +7 -1
  46. package/dist/components/atoms/CustomerTypeImage/index.js +8 -6
  47. package/dist/components/atoms/DropDownButton/DropDownButton.stories.js +7 -1
  48. package/dist/components/atoms/DropDownButton/index.js +9 -6
  49. package/dist/components/atoms/DropDownButton/styles.js +1 -1
  50. package/dist/components/atoms/EditField/EditField.stories.js +7 -1
  51. package/dist/components/atoms/EditField/index.js +17 -10
  52. package/dist/components/atoms/FeatureTag/FeatureTag.stories.js +7 -1
  53. package/dist/components/atoms/FeatureTag/index.js +11 -5
  54. package/dist/components/atoms/GeneralButton/GeneralButton.stories.js +7 -1
  55. package/dist/components/atoms/GeneralButton/index.js +13 -7
  56. package/dist/components/atoms/GeneralButton/styles.js +4 -2
  57. package/dist/components/atoms/GeneralInput/GeneralInput.stories.js +7 -1
  58. package/dist/components/atoms/GeneralInput/index.js +128 -69
  59. package/dist/components/atoms/GeneralInput/styles.js +8 -2
  60. package/dist/components/atoms/GeneralTextBox/GeneralTextBox.stories.js +7 -1
  61. package/dist/components/atoms/GeneralTextBox/index.js +12 -7
  62. package/dist/components/atoms/GenericModal/GenericModal.stories.js +46 -59
  63. package/dist/components/atoms/GenericModal/index.js +15 -8
  64. package/dist/components/atoms/GenericModal/styles.js +1 -1
  65. package/dist/components/atoms/GradientPanel/GradientPanel.stories.js +85 -80
  66. package/dist/components/atoms/GradientPanel/index.js +11 -7
  67. package/dist/components/atoms/GradientPanel/styles.js +2 -2
  68. package/dist/components/atoms/Graphic/Graphic.stories.js +7 -1
  69. package/dist/components/atoms/Graphic/index.js +9 -5
  70. package/dist/components/atoms/Input/index.js +15 -8
  71. package/dist/components/atoms/Input/style.js +4 -4
  72. package/dist/components/atoms/InputFormatter/Wysiwyg.stories.js +30 -0
  73. package/dist/components/atoms/InputFormatter/index.js +187 -0
  74. package/dist/components/atoms/InputFormatter/styles.js +33 -0
  75. package/dist/components/atoms/LabelToInput/index.js +18 -13
  76. package/dist/components/atoms/LabelToInput/style.js +3 -3
  77. package/dist/components/atoms/LoadImageMenu/LoadImageMenu.stories.js +7 -1
  78. package/dist/components/atoms/LoadImageMenu/index.js +33 -22
  79. package/dist/components/atoms/Loading/Loading.stories.js +28 -0
  80. package/dist/components/atoms/Loading/index.js +27 -0
  81. package/dist/components/atoms/Loading/styles.js +22 -0
  82. package/dist/components/atoms/LogoImage/LogoImage.stories.js +7 -1
  83. package/dist/components/atoms/LogoImage/index.js +9 -6
  84. package/dist/components/atoms/MenuNotification/MenuNotification.stories.js +7 -1
  85. package/dist/components/atoms/MenuNotification/index.js +21 -15
  86. package/dist/components/atoms/MenuProfile/MenuProfile.stories.js +7 -1
  87. package/dist/components/atoms/MenuProfile/index.js +25 -15
  88. package/dist/components/atoms/Notification/Notification.stories.js +5 -1
  89. package/dist/components/atoms/Notification/index.js +15 -9
  90. package/dist/components/atoms/Percent/Percent.stories.js +7 -1
  91. package/dist/components/atoms/Percent/index.js +21 -14
  92. package/dist/components/atoms/PriorityFlag/PriorityFlag.stories.js +7 -1
  93. package/dist/components/atoms/PriorityFlag/index.js +8 -4
  94. package/dist/components/atoms/ProductImage/ProductImage.stories.js +7 -1
  95. package/dist/components/atoms/ProductImage/index.js +11 -8
  96. package/dist/components/atoms/ProductPercentCard/Percent.stories.js +41 -0
  97. package/dist/components/atoms/ProductPercentCard/index.js +45 -0
  98. package/dist/components/atoms/ProductPercentCard/styles.js +20 -0
  99. package/dist/components/atoms/ProgressBar/ProgressBar.stories.js +7 -1
  100. package/dist/components/atoms/ProgressBar/index.js +8 -3
  101. package/dist/components/atoms/ProgressBar/styles.js +1 -1
  102. package/dist/components/atoms/ScreenHeader/ScreenHeader.stories.js +7 -1
  103. package/dist/components/atoms/ScreenHeader/index.js +9 -3
  104. package/dist/components/atoms/ScreenHeader/styles.js +1 -1
  105. package/dist/components/atoms/Select/index.js +27 -20
  106. package/dist/components/atoms/Select/style.js +1 -1
  107. package/dist/components/atoms/SideMenuButton/SideMenuButton.stories.js +5 -1
  108. package/dist/components/atoms/SideMenuButton/index.js +10 -4
  109. package/dist/components/atoms/SliderToolTip/SliderToolTip.stories.js +47 -0
  110. package/dist/components/atoms/SliderToolTip/index.js +200 -0
  111. package/dist/components/atoms/SliderToolTip/styles.js +24 -0
  112. package/dist/components/atoms/StatusTag/StatusTag.stories.js +7 -1
  113. package/dist/components/atoms/StatusTag/index.js +43 -3
  114. package/dist/components/atoms/StatusTag/styles.js +1 -1
  115. package/dist/components/atoms/TabSection/TabSection.stories.js +7 -1
  116. package/dist/components/atoms/TabSection/index.js +8 -3
  117. package/dist/components/atoms/ValidationPanel/ValidationPanel.stories.js +7 -1
  118. package/dist/components/atoms/ValidationPanel/index.js +57 -34
  119. package/dist/components/atoms/ValidationPanel/styles.js +1 -1
  120. package/dist/components/atoms/VerticalSideMenuMainPage/VerticalSideMenuMainPage.stories.js +28 -0
  121. package/dist/components/atoms/VerticalSideMenuMainPage/index.js +98 -0
  122. package/dist/components/atoms/VerticalSideMenuMainPage/styles.js +24 -0
  123. package/dist/components/molecules/AddProvidersAndProducts/AddProvidersAndProducts.stories.js +5 -1
  124. package/dist/components/molecules/AddProvidersAndProducts/index.js +18 -12
  125. package/dist/components/molecules/AssignedWork/AssignedWork.stories.js +5 -1
  126. package/dist/components/molecules/AssignedWork/index.js +36 -30
  127. package/dist/components/molecules/AvatarAndValidation/AvatarAndValidation.stories.js +7 -1
  128. package/dist/components/molecules/AvatarAndValidation/index.js +33 -25
  129. package/dist/components/molecules/CarouselImagesLogin/CarouselImagesLogin.stories.js +37 -0
  130. package/dist/components/molecules/CarouselImagesLogin/index.js +92 -0
  131. package/dist/components/molecules/CarouselImagesLogin/styles.js +21 -0
  132. package/dist/components/molecules/EditionActiveImage/EditionActiveImage.stories.js +7 -1
  133. package/dist/components/molecules/EditionActiveImage/index.js +14 -10
  134. package/dist/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +28 -0
  135. package/dist/components/molecules/EmailResetPasswordLogin/index.js +153 -0
  136. package/dist/components/molecules/EmailResetPasswordLogin/styles.js +20 -0
  137. package/dist/components/molecules/FeaturesBar/FeaturesBar.stories.js +7 -1
  138. package/dist/components/molecules/FeaturesBar/index.js +11 -9
  139. package/dist/components/molecules/GalleryElement/GalleryElement.stories.js +7 -1
  140. package/dist/components/molecules/GalleryElement/index.js +96 -57
  141. package/dist/components/molecules/GalleryHeader/GalleryHeader.stories.js +7 -1
  142. package/dist/components/molecules/GalleryHeader/index.js +46 -16
  143. package/dist/components/molecules/HeaderTop/HeaderTop.stories.js +7 -1
  144. package/dist/components/molecules/HeaderTop/index.js +10 -7
  145. package/dist/components/molecules/ImageSelector/ImageSelector.stories.js +7 -1
  146. package/dist/components/molecules/ImageSelector/index.js +15 -13
  147. package/dist/components/molecules/LoginPasswordStrength/LoginPasswordStrength.stories.js +28 -0
  148. package/dist/components/molecules/LoginPasswordStrength/index.js +126 -0
  149. package/dist/components/molecules/LoginPasswordStrength/styles.js +78 -0
  150. package/dist/components/molecules/LogoLoading/Loading.stories.js +28 -0
  151. package/dist/components/molecules/LogoLoading/index.js +22 -0
  152. package/dist/components/molecules/LogoLoading/styles.js +18 -0
  153. package/dist/components/molecules/ParentComponent/ParentComponent.stories.js +10 -2
  154. package/dist/components/molecules/ParentComponent/index.js +9 -5
  155. package/dist/components/molecules/PayMethod/PayMethod.stories.js +7 -1
  156. package/dist/components/molecules/PayMethod/index.js +38 -33
  157. package/dist/components/molecules/PlanSelection/PlanSelection.stories.js +7 -1
  158. package/dist/components/molecules/PlanSelection/index.js +14 -11
  159. package/dist/components/molecules/ProductNameHeader/ProductNameHeader.stories.js +7 -1
  160. package/dist/components/molecules/ProductNameHeader/index.js +18 -14
  161. package/dist/components/molecules/ProductNotification/ProductNotification.stories.js +7 -1
  162. package/dist/components/molecules/ProductNotification/index.js +12 -9
  163. package/dist/components/molecules/ProfileHeader/ProfileHeader.stories.js +5 -1
  164. package/dist/components/molecules/ProfileHeader/index.js +21 -15
  165. package/dist/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +28 -0
  166. package/dist/components/molecules/RegistrationFirstStep/index.js +308 -0
  167. package/dist/components/molecules/RegistrationFirstStep/styles.js +20 -0
  168. package/dist/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +28 -0
  169. package/dist/components/molecules/RegistrationSecondStep/index.js +172 -0
  170. package/dist/components/molecules/RegistrationSecondStep/styles.js +20 -0
  171. package/dist/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +28 -0
  172. package/dist/components/molecules/RegistrationThirdStep/index.js +155 -0
  173. package/dist/components/molecules/RegistrationThirdStep/styles.js +20 -0
  174. package/dist/components/molecules/RetailerSelector/RetailerSelector.stories.js +7 -1
  175. package/dist/components/molecules/RetailerSelector/index.js +36 -25
  176. package/dist/components/molecules/RetailerSelector/styles.js +1 -1
  177. package/dist/components/molecules/SidebarNotification/SidebarNotification.stories.js +5 -1
  178. package/dist/components/molecules/SidebarNotification/index.js +43 -37
  179. package/dist/components/molecules/SignInLogin/SignInLogin.stories.js +28 -0
  180. package/dist/components/molecules/SignInLogin/index.js +315 -0
  181. package/dist/components/molecules/SignInLogin/styles.js +20 -0
  182. package/dist/components/molecules/StatusAsignationInfo/StatusAsignationInfo.stories.js +7 -1
  183. package/dist/components/molecules/StatusAsignationInfo/index.js +111 -98
  184. package/dist/components/molecules/StatusAsignationInfo/styles.js +1 -1
  185. package/dist/components/molecules/TableHeader/TableHeader.stories.js +7 -1
  186. package/dist/components/molecules/TableHeader/index.js +21 -9
  187. package/dist/components/molecules/TableHeader/styles.js +1 -1
  188. package/dist/components/molecules/TableRow/TableRow.stories.js +7 -1
  189. package/dist/components/molecules/TableRow/index.js +11 -7
  190. package/dist/components/molecules/TabsMenu/TabsMenu.stories.js +7 -1
  191. package/dist/components/molecules/TabsMenu/index.js +13 -10
  192. package/dist/components/molecules/TagAndInput/TagAndInput.stories.js +7 -1
  193. package/dist/components/molecules/TagAndInput/index.js +43 -23
  194. package/dist/components/molecules/TagAndInput/styles.js +10 -2
  195. package/dist/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +28 -0
  196. package/dist/components/molecules/VerificationCodeResetPasswordLogin/index.js +211 -0
  197. package/dist/components/molecules/VerificationCodeResetPasswordLogin/styles.js +20 -0
  198. package/dist/components/molecules/VerificationCodeResetPasswordLogin/utils.js +69 -0
  199. package/dist/components/organisms/ChangePassword/ChangePassword.stories.js +28 -0
  200. package/dist/components/organisms/ChangePassword/index.js +124 -0
  201. package/dist/components/organisms/ChangePassword/styles.js +18 -0
  202. package/dist/components/organisms/FullProductNameHeader/FullProductNameHeader.stories.js +7 -1
  203. package/dist/components/organisms/FullProductNameHeader/index.js +70 -34
  204. package/dist/components/organisms/FullTabsMenu/FullTabsMenu.stories.js +7 -1
  205. package/dist/components/organisms/FullTabsMenu/index.js +30 -23
  206. package/dist/components/organisms/Fullplan/FullPlan.stories.js +7 -1
  207. package/dist/components/organisms/Fullplan/index.js +23 -15
  208. package/dist/components/organisms/GlobalModal/index.js +73 -0
  209. package/dist/components/organisms/GlobalModal/styles.js +66 -0
  210. package/dist/components/organisms/ImageDataTable/ImageDataTable.stories.js +7 -1
  211. package/dist/components/organisms/ImageDataTable/index.js +85 -62
  212. package/dist/components/organisms/ImagePreviewer/ImagePreviewer.stories.js +7 -1
  213. package/dist/components/organisms/ImagePreviewer/index.js +12 -8
  214. package/dist/components/organisms/ImagesGroup/index.js +5 -1
  215. package/dist/components/organisms/InputGroup/InputGroup.stories.js +7 -1
  216. package/dist/components/organisms/InputGroup/index.js +44 -37
  217. package/dist/components/organisms/InputGroup/styles.js +1 -1
  218. package/dist/components/organisms/ProductImageModal/ProductImageModal.stories.js +7 -1
  219. package/dist/components/organisms/ProductImageModal/index.js +49 -46
  220. package/dist/components/organisms/ProductImageModal/styles.js +1 -1
  221. package/dist/components/pages/ChangePasswordLogin/ChangePasswordLogin.stories.js +38 -0
  222. package/dist/components/pages/ChangePasswordLogin/index.js +108 -0
  223. package/dist/components/pages/ChangePasswordLogin/styles.js +18 -0
  224. package/dist/components/pages/CustomerLogin/CustomerLogin.stories.js +52 -47
  225. package/dist/components/pages/CustomerLogin/index.js +18 -12
  226. package/dist/components/pages/CustomerPayMethod/CustomerPayMethod.stories.js +36 -28
  227. package/dist/components/pages/CustomerPayMethod/index.js +18 -12
  228. package/dist/components/pages/CustomerType/CustomerType.stories.js +21 -22
  229. package/dist/components/pages/CustomerType/index.js +18 -12
  230. package/dist/components/pages/EmailResetPassword/EmailResetPassword.stories.js +37 -0
  231. package/dist/components/pages/EmailResetPassword/index.js +130 -0
  232. package/dist/components/pages/EmailResetPassword/styles.js +20 -0
  233. package/dist/components/pages/OnboardPlan/OnboardPlan.stories.js +12 -9
  234. package/dist/components/pages/OnboardPlan/index.js +18 -12
  235. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +186 -0
  236. package/dist/components/pages/ProviderProductEdition/index.js +1932 -0
  237. package/dist/components/pages/ProviderProductEdition/styles.js +23 -0
  238. package/dist/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +37 -0
  239. package/dist/components/pages/RegistrationLoginFirstStep/index.js +269 -0
  240. package/dist/components/pages/RegistrationLoginFirstStep/styles.js +20 -0
  241. package/dist/components/pages/RegistrationLoginSecondStep/RegistrationLoginSecondStep.stories.js +38 -0
  242. package/dist/components/pages/RegistrationLoginSecondStep/index.js +176 -0
  243. package/dist/components/pages/RegistrationLoginSecondStep/styles.js +20 -0
  244. package/dist/components/pages/RegistrationLoginThirdStep/RegistrationLoginThirdStep.stories.js +37 -0
  245. package/dist/components/pages/RegistrationLoginThirdStep/index.js +178 -0
  246. package/dist/components/pages/RegistrationLoginThirdStep/styles.js +20 -0
  247. package/dist/components/pages/RetailerPlan/RetailerPlan.stories.js +13 -10
  248. package/dist/components/pages/RetailerPlan/index.js +18 -12
  249. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +36 -72
  250. package/dist/components/pages/RetailerProductEdition/index.js +1295 -590
  251. package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
  252. package/dist/components/pages/VerificationCodeResetPassword/VerificationCodeResetPassword.stories.js +37 -0
  253. package/dist/components/pages/VerificationCodeResetPassword/index.js +121 -0
  254. package/dist/components/pages/VerificationCodeResetPassword/styles.js +20 -0
  255. package/dist/components/pages/VerificationCodeResetPassword/utils.js +69 -0
  256. package/dist/global-files/data.js +104 -24
  257. package/dist/index.js +316 -100
  258. package/package.json +28 -8
  259. package/src/assets/images/carouselImagesLogin/login2.svg +117 -0
  260. package/src/assets/images/carouselImagesLogin/login3.svg +147 -0
  261. package/src/assets/images/carouselImagesLogin/loginImage.svg +301 -0
  262. package/src/assets/images/editField/showPassword.png +0 -0
  263. package/src/assets/images/generalButton/downloadIcon.svg +3 -0
  264. package/src/assets/images/genericModal/closeWhite.svg +3 -0
  265. package/src/assets/images/genericModal/errorModal.svg +3 -0
  266. package/src/assets/images/genericModal/yellowAlert.svg +12 -0
  267. package/src/assets/images/sliderToolTip/infoIcon.svg +4 -0
  268. package/src/assets/images/sliderToolTip/slide1.svg +5 -0
  269. package/src/assets/images/sliderToolTip/slide2.svg +9 -0
  270. package/src/assets/images/sliderToolTip/slide3.svg +9 -0
  271. package/src/assets/images/sliderToolTip/slide4.svg +9 -0
  272. package/src/assets/images/sliderToolTip/slide5.svg +40 -0
  273. package/src/assets/images/verticalSideMenuMainPage/closeMenu.svg +4 -0
  274. package/src/assets/images/verticalSideMenuMainPage/iconFAQS.svg +12 -0
  275. package/src/assets/images/verticalSideMenuMainPage/iconGroup.svg +3 -0
  276. package/src/assets/images/verticalSideMenuMainPage/iconLogo.svg +12 -0
  277. package/src/assets/images/verticalSideMenuMainPage/iconLogoContentoh.svg +15 -0
  278. package/src/assets/images/verticalSideMenuMainPage/iconProduct.svg +3 -0
  279. package/src/assets/images/verticalSideMenuMainPage/iconSpeedometer.svg +12 -0
  280. package/src/assets/images/verticalSideMenuMainPage/iconTask.svg +10 -0
  281. package/src/assets/images/verticalSideMenuMainPage/openMenu.svg +4 -0
  282. package/src/components/atoms/AsignationOption/index.js +18 -1
  283. package/src/components/atoms/AsignationOption/styles.js +19 -1
  284. package/src/components/atoms/CharCounter/CharCounter.stories.js +11 -0
  285. package/src/components/atoms/CharCounter/index.js +13 -0
  286. package/src/components/atoms/CharCounter/styles.js +10 -0
  287. package/src/components/atoms/CheckBox/index.js +8 -2
  288. package/src/components/atoms/Commentary/index.js +2 -2
  289. package/src/components/atoms/Commentary/styles.js +2 -1
  290. package/src/components/atoms/DropDownButton/styles.js +6 -0
  291. package/src/components/atoms/GeneralButton/index.js +1 -0
  292. package/src/components/atoms/GeneralButton/styles.js +14 -0
  293. package/src/components/atoms/GeneralInput/index.js +109 -62
  294. package/src/components/atoms/GeneralInput/styles.js +35 -1
  295. package/src/components/atoms/GenericModal/index.js +2 -2
  296. package/src/components/atoms/GenericModal/styles.js +11 -3
  297. package/src/components/atoms/GradientPanel/styles.js +8 -1
  298. package/src/components/atoms/Input/index.js +2 -1
  299. package/src/components/atoms/Input/style.js +9 -5
  300. package/src/components/atoms/InputFormatter/Wysiwyg.stories.js +12 -0
  301. package/src/components/atoms/InputFormatter/index.js +146 -0
  302. package/src/components/atoms/InputFormatter/styles.js +41 -0
  303. package/src/components/atoms/LabelToInput/index.js +0 -1
  304. package/src/components/atoms/LabelToInput/style.js +15 -4
  305. package/src/components/atoms/Loading/Loading.stories.js +10 -0
  306. package/src/components/atoms/Loading/index.js +13 -0
  307. package/src/components/atoms/Loading/styles.js +57 -0
  308. package/src/components/atoms/LogoImage/index.js +1 -1
  309. package/src/components/atoms/ProductPercentCard/Percent.stories.js +41 -0
  310. package/src/components/atoms/ProductPercentCard/index.js +23 -0
  311. package/src/components/atoms/{Percent → ProductPercentCard}/styles.js +11 -7
  312. package/src/components/atoms/ProgressBar/styles.js +2 -1
  313. package/src/components/atoms/ScreenHeader/index.js +7 -3
  314. package/src/components/atoms/ScreenHeader/styles.js +14 -2
  315. package/src/components/atoms/Select/index.js +3 -1
  316. package/src/components/atoms/Select/style.js +1 -2
  317. package/src/components/atoms/SliderToolTip/SliderToolTip.stories.js +23 -0
  318. package/src/components/atoms/SliderToolTip/index.js +182 -0
  319. package/src/components/atoms/SliderToolTip/styles.js +168 -0
  320. package/src/components/atoms/StatusTag/index.js +30 -2
  321. package/src/components/atoms/StatusTag/styles.js +9 -4
  322. package/src/components/atoms/ValidationPanel/index.js +29 -17
  323. package/src/components/atoms/ValidationPanel/styles.js +6 -2
  324. package/src/components/atoms/VerticalSideMenuMainPage/VerticalSideMenuMainPage.stories.js +12 -0
  325. package/src/components/atoms/VerticalSideMenuMainPage/index.js +54 -0
  326. package/src/components/atoms/VerticalSideMenuMainPage/styles.js +45 -0
  327. package/src/components/molecules/AvatarAndValidation/index.js +20 -15
  328. package/src/components/molecules/CarouselImagesLogin/CarouselImagesLogin.stories.js +17 -0
  329. package/src/components/molecules/CarouselImagesLogin/index.js +65 -0
  330. package/src/components/molecules/CarouselImagesLogin/styles.js +60 -0
  331. package/src/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +11 -0
  332. package/src/components/molecules/EmailResetPasswordLogin/index.js +85 -0
  333. package/src/components/molecules/EmailResetPasswordLogin/styles.js +23 -0
  334. package/src/components/molecules/GalleryElement/index.js +26 -6
  335. package/src/components/molecules/GalleryHeader/index.js +8 -2
  336. package/src/components/molecules/LoginPasswordStrength/LoginPasswordStrength.stories.js +8 -0
  337. package/src/components/molecules/LoginPasswordStrength/index.js +84 -0
  338. package/src/components/molecules/LoginPasswordStrength/styles.js +91 -0
  339. package/src/components/molecules/LogoLoading/Loading.stories.js +10 -0
  340. package/src/components/molecules/LogoLoading/index.js +12 -0
  341. package/src/components/molecules/LogoLoading/styles.js +16 -0
  342. package/src/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +11 -0
  343. package/src/components/molecules/RegistrationFirstStep/index.js +227 -0
  344. package/src/components/molecules/RegistrationFirstStep/styles.js +87 -0
  345. package/src/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +11 -0
  346. package/src/components/molecules/RegistrationSecondStep/index.js +135 -0
  347. package/src/components/molecules/RegistrationSecondStep/styles.js +64 -0
  348. package/src/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +11 -0
  349. package/src/components/molecules/RegistrationThirdStep/index.js +130 -0
  350. package/src/components/molecules/RegistrationThirdStep/styles.js +44 -0
  351. package/src/components/molecules/RetailerSelector/index.js +7 -1
  352. package/src/components/molecules/RetailerSelector/styles.js +3 -0
  353. package/src/components/molecules/SignInLogin/SignInLogin.stories.js +11 -0
  354. package/src/components/molecules/SignInLogin/index.js +226 -0
  355. package/src/components/molecules/SignInLogin/styles.js +120 -0
  356. package/src/components/molecules/StatusAsignationInfo/index.js +60 -53
  357. package/src/components/molecules/StatusAsignationInfo/styles.js +8 -2
  358. package/src/components/molecules/TableHeader/index.js +14 -2
  359. package/src/components/molecules/TableHeader/styles.js +8 -0
  360. package/src/components/molecules/TagAndInput/index.js +19 -1
  361. package/src/components/molecules/TagAndInput/styles.js +28 -0
  362. package/src/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +11 -0
  363. package/src/components/molecules/VerificationCodeResetPasswordLogin/index.js +171 -0
  364. package/src/components/molecules/VerificationCodeResetPasswordLogin/styles.js +54 -0
  365. package/src/components/molecules/VerificationCodeResetPasswordLogin/utils.js +54 -0
  366. package/src/components/organisms/ChangePassword/ChangePassword.stories.js +11 -0
  367. package/src/components/organisms/ChangePassword/index.js +77 -0
  368. package/src/components/organisms/ChangePassword/styles.js +13 -0
  369. package/src/components/organisms/FullProductNameHeader/index.js +53 -16
  370. package/src/components/organisms/FullTabsMenu/index.js +15 -12
  371. package/src/components/organisms/GlobalModal/index.js +68 -0
  372. package/src/components/organisms/GlobalModal/styles.js +113 -0
  373. package/src/components/organisms/ImageDataTable/index.js +29 -8
  374. package/src/components/organisms/InputGroup/index.js +28 -8
  375. package/src/components/organisms/InputGroup/styles.js +2 -2
  376. package/src/components/organisms/ProductImageModal/index.js +8 -9
  377. package/src/components/organisms/ProductImageModal/styles.js +3 -0
  378. package/src/components/pages/ChangePasswordLogin/ChangePasswordLogin.stories.js +18 -0
  379. package/src/components/pages/ChangePasswordLogin/index.js +77 -0
  380. package/src/components/pages/ChangePasswordLogin/styles.js +20 -0
  381. package/src/components/pages/EmailResetPassword/EmailResetPassword.stories.js +17 -0
  382. package/src/components/pages/EmailResetPassword/index.js +77 -0
  383. package/src/components/pages/EmailResetPassword/styles.js +27 -0
  384. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +186 -0
  385. package/src/components/pages/ProviderProductEdition/index.js +1400 -0
  386. package/src/components/pages/ProviderProductEdition/styles.js +118 -0
  387. package/src/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +17 -0
  388. package/src/components/pages/RegistrationLoginFirstStep/index.js +160 -0
  389. package/src/components/pages/RegistrationLoginFirstStep/styles.js +85 -0
  390. package/src/components/pages/RegistrationLoginSecondStep/RegistrationLoginSecondStep.stories.js +18 -0
  391. package/src/components/pages/RegistrationLoginSecondStep/index.js +111 -0
  392. package/src/components/pages/RegistrationLoginSecondStep/styles.js +64 -0
  393. package/src/components/pages/RegistrationLoginThirdStep/RegistrationLoginThirdStep.stories.js +17 -0
  394. package/src/components/pages/RegistrationLoginThirdStep/index.js +106 -0
  395. package/src/components/pages/RegistrationLoginThirdStep/styles.js +48 -0
  396. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +27 -63
  397. package/src/components/pages/RetailerProductEdition/index.js +1034 -442
  398. package/src/components/pages/RetailerProductEdition/styles.js +17 -3
  399. package/src/components/pages/VerificationCodeResetPassword/VerificationCodeResetPassword.stories.js +17 -0
  400. package/src/components/pages/VerificationCodeResetPassword/index.js +92 -0
  401. package/src/components/pages/VerificationCodeResetPassword/styles.js +54 -0
  402. package/src/components/pages/VerificationCodeResetPassword/utils.js +56 -0
  403. package/src/global-files/data.js +88 -28
  404. package/src/index.js +23 -8
  405. package/src/components/atoms/Percent/Percent.stories.js +0 -38
  406. package/src/components/atoms/Percent/index.js +0 -15
@@ -7,7 +7,12 @@ import { FullTabsMenu } from "../../organisms/FullTabsMenu";
7
7
  import { InputGroup } from "../../organisms/InputGroup";
8
8
  import { useEffect, useReducer, useState, useCallback } from "react";
9
9
  import { GalleryElement } from "../../molecules/GalleryElement";
10
- import { getRetailerServices, getPercentage } from "../../../global-files/data";
10
+ import { saveAs } from "file-saver";
11
+ import {
12
+ getRetailerServices,
13
+ getPercentage,
14
+ fetchUsers,
15
+ } from "../../../global-files/data";
11
16
  import { GalleryHeader } from "../../molecules/GalleryHeader";
12
17
  import { ProductImageModal } from "../../organisms/ProductImageModal";
13
18
  import { useDropzone } from "react-dropzone";
@@ -20,6 +25,12 @@ import imagesSent from "../../../assets/images/modalsSVGs/uploadingImages.svg";
20
25
  import { TagAndInput } from "../../molecules/TagAndInput/index";
21
26
  import { Button } from "../../atoms/GeneralButton";
22
27
  import { Commentary } from "../../atoms/Commentary";
28
+ import { GenericModal } from "../../atoms/GenericModal";
29
+ import { ScreenHeader } from "../../atoms/ScreenHeader";
30
+ import { Loading } from "../../atoms/Loading";
31
+ import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
32
+ import { getNewStatus } from "../../../global-files/data";
33
+ import errorModal from "../../../assets/images/genericModal/errorModal.svg";
23
34
 
24
35
  const reducerImages = (state, action) => {
25
36
  let { values, attrForImgs } = state;
@@ -33,8 +44,17 @@ const reducerImages = (state, action) => {
33
44
  values[action.index][action.attribute] = action.value;
34
45
  return { ...state, values };
35
46
  case "changeAttrValue":
36
- attrForImgs[action.retailer][action.index].value = action.value;
47
+ action.retailersId.forEach((ret) => {
48
+ attrForImgs[ret][action.index].name === action.name &&
49
+ (attrForImgs[ret][action.index].value = action.value);
50
+ });
51
+
37
52
  return { ...state, attrForImgs, values };
53
+ case "deleteImage":
54
+ values = values.filter(
55
+ (value) => action.selectedImages.indexOf(value) === -1
56
+ );
57
+ return { ...state, values };
38
58
  default:
39
59
  return state;
40
60
  }
@@ -54,21 +74,19 @@ const myBucket = new AWS.S3({
54
74
  });
55
75
 
56
76
  export const RetailerProductEdition = ({
57
- productData,
58
77
  tabsSections,
59
- articleId,
60
78
  productSelected = {},
61
79
  user = {},
80
+ token,
62
81
  }) => {
63
82
  const [activeTab, setActiveTab] = useState("Descripción");
64
83
  const [activeImage, setActiveImage] = useState();
65
- const [imageLayout, setImageLayout] = useState(true);
84
+ const [imageLayout, setImageLayout] = useState(false);
66
85
  const [headerTop, setHeaderTop] = useState(0);
67
86
  const [descriptions, setDescriptions] = useState([]);
68
87
  const [datasheets, setDatasheets] = useState([]);
69
88
  const [images, setImages] = useReducer(reducerImages, {});
70
89
  const [showModal, setShowModal] = useState(false);
71
- const [retailerSelected, setRetailerSelected] = useState(54); // revisar después como trabajar esto de mejor forma
72
90
  const { getRootProps, getInputProps } = useDropzone({
73
91
  accept: "image/*",
74
92
  noKeyboard: true,
@@ -79,23 +97,25 @@ export const RetailerProductEdition = ({
79
97
  acceptedFiles.map((file) => {
80
98
  const reader = new FileReader();
81
99
  reader.fileName = file.name;
82
- reader.onload = async function (e) {
100
+ reader.onload = function (e) {
83
101
  const ext = e.srcElement.fileName.split(".");
84
102
  const img = new Image();
85
103
  img.src = e.target.result;
86
- const width = img.width;
87
- const height = img.height;
88
- const newImg = {
89
- action: "addImg",
90
- img: {
91
- src: e.target.result,
92
- name: e.target.fileName,
93
- ext: ext[ext.length - 1],
94
- width: width,
95
- height: width,
96
- },
97
- };
98
- setImages(newImg);
104
+ setTimeout(() => {
105
+ const width = img.width;
106
+ const height = img.height;
107
+ const newImg = {
108
+ action: "addImg",
109
+ img: {
110
+ src: e.target.result,
111
+ name: e.target.fileName,
112
+ ext: ext[ext.length - 1],
113
+ width: width,
114
+ height: height,
115
+ },
116
+ };
117
+ setImages(newImg);
118
+ }, 500);
99
119
  };
100
120
  reader.onerror = function (error) {
101
121
  console.log("dropzoneError: ", error);
@@ -110,63 +130,92 @@ export const RetailerProductEdition = ({
110
130
  const [imagesUploaded, setImagesUploaded] = useState(false);
111
131
  const [dataImages, setDataImages] = useState();
112
132
  const [percentages, setPercentages] = useState(
113
- new Array(productSelected.retailers.length).fill({ percentage: 0 })
133
+ new Array(product?.retailers?.length).fill({ percentage: 0 })
114
134
  );
115
135
  const [activePercentage, setActivePercentage] = useState(0);
116
136
  const [activeRetailer, setActiveRetailer] = useState({});
117
137
  const [services, setServices] = useState([]);
118
138
  const [servicesData, setServicesData] = useState([]);
119
139
  const [message, setMessage] = useState("");
120
- const [product, setProduct] = useState({});
140
+ const [product, setProduct] = useState(
141
+ JSON.parse(sessionStorage.getItem("productSelected"))
142
+ ? JSON.parse(sessionStorage.getItem("productSelected"))
143
+ : productSelected
144
+ );
121
145
  const [icon, setIcon] = useState(null);
122
- const [version, setVersion] = useState(productSelected?.version);
146
+ const [version, setVersion] = useState(product?.version);
123
147
  const [comments, setComments] = useState({});
124
- const [requiredNull, setRequiredNull] = useState(0);
148
+ const [comment, setComment] = useState("");
149
+ const [requiredNull, setRequiredNull] = useState({
150
+ "Ficha técnica": 0,
151
+ Descripción: 0,
152
+ Imágenes: 0,
153
+ });
154
+ const [crossComment, setCrossComment] = useState(false);
155
+ const [userGroups, setUserGroups] = useState([]);
156
+ const [assig, setAssig] = useState({});
157
+ const [selectedImages, setSelectedImages] = useState([]);
158
+ const [componentsArray, setComponentsArray] = useState([]);
159
+ const [checkAll, setCheckAll] = useState(false);
160
+ const isRetailer = user?.is_retailer;
161
+ const [loading, setLoading] = useState(true);
162
+ const [retailerStatus, setRetailerStatus] = useState("-");
163
+ const [statusArray, setStatusArray] = useState([]);
164
+ const [socketType, setSocketType] = useState(null);
165
+ const [servicesStatus, setServicesStatus] = useState([]);
166
+ const [saving, setSaving] = useState(loading);
167
+ const isAuditor = user.id_role === 6;
168
+
169
+ useEffect(() => {
170
+ checkAll && setSelectedImages(images.values);
171
+ }, [checkAll]);
125
172
 
126
173
  const loadData = async () => {
127
- const services = await getRetailerServices(
128
- productSelected.article.id_article,
129
- parseInt(productSelected.article.id_category),
130
- productSelected.version
131
- );
132
- console.log(services, "parsedResponse");
133
- //Converts the data inside the datasheets object to array
134
- setServices(services);
135
- setActiveRetailer(productSelected?.retailers[0]);
136
- setImages({
137
- action: "init",
138
- init: services[2],
139
- });
140
- if (services[2]?.values?.length > 0) setActiveImage(0);
141
- setProduct(productSelected);
142
- };
174
+ try {
175
+ const services = await getRetailerServices(
176
+ product?.article?.id_article,
177
+ product?.article?.category,
178
+ parseInt(product?.article?.id_category),
179
+ product?.version
180
+ );
181
+ //Converts the data inside the datasheets object to array
182
+ setServices(services);
183
+ getServices();
143
184
 
144
- const getServices = async (tab) => {
145
- let serviceActive = "";
146
- switch (tab) {
147
- case "Ficha técnica":
148
- serviceActive = "datasheet";
149
- break;
150
- case "Imágenes":
151
- serviceActive = "images";
152
- break;
153
- default:
154
- serviceActive = "description";
155
- break;
185
+ //setActiveRetailer(product?.retailers[0]);
186
+ setImages({
187
+ action: "init",
188
+ init: services[2],
189
+ });
190
+ if (services[2]?.values?.length > 0) setActiveImage(0);
191
+
192
+ getPercentage({ data: [product] }).then((res) => setPercentages(res));
193
+ setLoading(false);
194
+ } catch (error) {
195
+ console.log(error);
156
196
  }
157
- const selected = productSelected;
197
+ };
198
+
199
+ const getServices = async () => {
158
200
  const servicesResponse = await axios.get(
159
- `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${selected.article.id_article}&orderId=${selected.article.id_order}&end=true`
201
+ `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${
202
+ product?.article?.id_article
203
+ }&orderId=${product?.article?.id_order || product.orderId}&end=true`
160
204
  );
161
- const parsedResponse = JSON.parse(servicesResponse.data.body).data;
205
+ const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
162
206
 
207
+ let retailers = product.retailers || product.retailersAvailable;
208
+ let active = retailers?.filter((retailer) =>
209
+ parsedResponse?.map((srv) => srv.id_retailer).includes(retailer.id)
210
+ )[0];
211
+ !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
163
212
  setServicesData(parsedResponse);
164
213
  };
165
214
 
166
215
  const translateConcept = (concept) => {
167
216
  let translation = "";
168
217
  if (concept === "datasheet") {
169
- translation = "Ficha ténica";
218
+ translation = "Ficha técnica";
170
219
  } else if (concept === "description") {
171
220
  translation = "Descripción";
172
221
  } else if (concept === "images") {
@@ -175,183 +224,291 @@ export const RetailerProductEdition = ({
175
224
  return translation;
176
225
  };
177
226
 
178
- const getComments = async (tab) => {
227
+ const getComments = async (tab = "Descripción") => {
179
228
  const commentsResponse = await Promise.all([
180
229
  axios.get(
181
- `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${productSelected?.article?.id_article}&concept=description&orderIdColab=${productSelected?.orderId}&version=${version}`
230
+ `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${product?.article?.id_article}&concept=description&orderIdColab=${product?.orderId}&version=${version}`
182
231
  ),
183
232
  axios.get(
184
- `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${productSelected?.article?.id_article}&concept=datasheet&orderIdColab=${productSelected?.orderId}&version=${version}`
233
+ `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${product?.article?.id_article}&concept=datasheet&orderIdColab=${product?.orderId}&version=${version}`
185
234
  ),
186
235
  axios.get(
187
- `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${productSelected?.article?.id_article}&concept=images&orderIdColab=${productSelected?.orderId}&version=${version}`
236
+ `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${product?.article?.id_article}&concept=images&orderIdColab=${product?.orderId}&version=${version}`
188
237
  ),
189
238
  ]);
190
239
 
191
240
  let comments = {};
192
- commentsResponse.map(
241
+ commentsResponse.forEach(
193
242
  (comment) =>
194
- JSON.parse(comment.data.body).data[0] &&
243
+ JSON.parse(comment?.data?.body).data[0] &&
195
244
  (comments[
196
- translateConcept(JSON.parse(comment.data.body).data[0]?.concept)
197
- ] = JSON.parse(comment.data.body).data[0])
245
+ translateConcept(JSON.parse(comment?.data?.body)?.data[0]?.concept)
246
+ ] = JSON.parse(comment?.data?.body).data[0])
198
247
  );
248
+ setComment(comments[tab]);
199
249
  setComments(comments);
200
- //const comment = JSON.parse(commentsResponse.data.body).data;
201
- //setComment(comment[0]);
202
250
  };
203
251
 
204
- useEffect(() => {
252
+ useEffect(async () => {
205
253
  loadData();
206
- getPercentage({ data: [productSelected] }).then((res) =>
207
- setPercentages(res)
208
- );
209
- getServices();
210
254
  getComments();
211
- }, []);
255
+ setUserGroups(await fetchUsers(token));
256
+ let arr = [];
257
+ switch (user.id_role) {
258
+ case 7:
259
+ case 8:
260
+ arr = ["IN_PROGRESS", "RF", "RA"];
261
+ break;
262
+ case 4:
263
+ case 5:
264
+ arr = ["RF", "AF", "AA", "AP", "AC"];
265
+ break;
266
+ case 6:
267
+ arr = ["RP", "RC", "AF", "RA"];
268
+ break;
269
+ default:
270
+ arr = [];
271
+ break;
272
+ }
273
+ setStatusArray(arr);
274
+ }, [product]);
275
+
276
+ const loadAssignations = (currentProduct) => {
277
+ setAssig({
278
+ Descripción: {
279
+ assignations: [
280
+ {
281
+ collaboratorType: "especialist",
282
+ id: currentProduct?.article?.id_description_especialist,
283
+ },
284
+ {
285
+ collaboratorType: "facilitator",
286
+ id: currentProduct?.article?.id_description_facilitator,
287
+ },
288
+ ],
289
+ collaborators: {
290
+ especialist: userGroups[0] || [],
291
+ facilitator: userGroups[2] || [],
292
+ },
293
+ },
294
+ "Ficha técnica": {
295
+ assignations: [
296
+ {
297
+ collaboratorType: "especialist",
298
+ id: currentProduct?.article?.id_datasheet_especialist,
299
+ },
300
+ {
301
+ collaboratorType: "facilitator",
302
+ id: currentProduct?.article?.id_datasheet_facilitator,
303
+ },
304
+ ],
305
+ collaborators: {
306
+ especialist: userGroups[0] || [],
307
+ facilitator: userGroups[2] || [],
308
+ },
309
+ },
310
+ Imágenes: {
311
+ assignations: [
312
+ {
313
+ collaboratorType: "especialist",
314
+ id: currentProduct?.article?.id_images_especialist,
315
+ },
316
+ {
317
+ collaboratorType: "facilitator",
318
+ id: currentProduct?.article?.id_images_facilitator,
319
+ },
320
+ ],
321
+ collaborators: {
322
+ especialist: userGroups[1] || [],
323
+ facilitator: userGroups[3] || [],
324
+ },
325
+ },
326
+ });
327
+ };
212
328
 
213
329
  useEffect(() => {
214
- productSelected.retailers.forEach((retailer) => {
215
- retailer["percentage"] = percentages.filter(
216
- (percent) => retailer.id === percent.id_retailer
330
+ loadAssignations(product);
331
+ }, [userGroups]);
332
+
333
+ useEffect(() => {
334
+ product?.retailers?.forEach((retailer) => {
335
+ retailer["percentage"] = percentages?.filter(
336
+ (percent) => retailer?.id === percent?.id_retailer
217
337
  )[0]?.percentage;
218
338
  });
219
- setActivePercentage(productSelected?.retailers[0]?.percentage);
339
+ setActivePercentage(product?.retailers[0]?.percentage);
220
340
  }, [percentages]);
221
341
 
222
342
  useEffect(() => {
223
343
  if (services.length > 0) {
224
- services[0][activeRetailer?.id].data = Object.values(
225
- services[0][activeRetailer?.id].data
226
- );
227
- setActivePercentage(Math.round(activeRetailer.percentage, 0));
228
- setDatasheets([services[0][activeRetailer.id], services[0].inputs]);
229
- setDescriptions(
230
- services[1].filter((service) => service.id === activeRetailer.id)
344
+ if (services[0][activeRetailer.id]?.data)
345
+ services[0][activeRetailer.id].data = Object.values(
346
+ services[0][activeRetailer.id].data
347
+ );
348
+ setActivePercentage(Math.round(activeRetailer?.percentage, 0));
349
+
350
+ const datagroups = services[0][activeRetailer?.id];
351
+ const inputs = services[0]?.inputs;
352
+ const descriptions = services[1]?.filter(
353
+ (service) => service?.id === activeRetailer?.id
231
354
  );
355
+ setDatasheets([datagroups, inputs]);
356
+ setDescriptions(descriptions);
232
357
  }
233
- }, [activeRetailer]);
358
+ }, [activeRetailer, services]);
234
359
 
235
360
  const thumbs = () => {
236
- const imageInputs = images.inputs.map((e) => ({
237
- value: e.id,
238
- name: e.name,
239
- }));
240
- const imageType = images.imageType.map((e) => ({
241
- value: e.id,
242
- name: e.name,
361
+ const imageInputs = socketType?.slice();
362
+ const imageType = images?.imageType?.map((e) => ({
363
+ value: e?.id,
364
+ name: e?.name,
243
365
  }));
244
- const imagePackagingType = images.imagePackagingType.map((e) => ({
245
- value: e.id,
246
- name: e.name,
366
+ const imagePackagingType = images?.imagePackagingType?.map((e) => ({
367
+ value: e?.id,
368
+ name: e?.name,
247
369
  }));
248
370
  return images?.values?.map((image, index) => (
249
371
  <GalleryElement
372
+ setCheckAll={setCheckAll}
250
373
  key={index}
251
374
  image={image}
252
375
  gridLayout={imageLayout}
253
376
  id={"gallery-element-" + index}
254
- index={index}
377
+ index={index + "-" + image.name}
378
+ number={index}
255
379
  imageType={imageType}
256
380
  imagePackagingType={imagePackagingType}
257
381
  imageInputs={imageInputs}
382
+ setSocketType={setSocketType}
258
383
  changeImage={setImages}
384
+ selectedImages={selectedImages}
385
+ setSelectedImages={setSelectedImages}
259
386
  />
260
387
  ));
261
388
  };
262
389
 
263
390
  const saveDescriptions = async () => {
391
+ setLoading(true);
392
+ const productTemp = product;
264
393
  const dataObject = {
265
- articleId: productSelected?.article?.id_article,
394
+ articleId: product?.article?.id_article,
266
395
  articleData: updatedDescriptions,
267
396
  };
397
+ if (product?.orderId) dataObject["orderId"] = product?.orderId;
268
398
  try {
269
399
  await axios.put(
270
400
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?description=true&version=${version}`,
271
401
  dataObject,
272
402
  {
273
403
  headers: {
274
- Authorization:
275
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIxYTk4MzZlNS1kMDYyLTQ4ZjQtYjY4Yi04NDZhZWEwMDFlMDIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY0NjM1MzAyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2NDYzNTY2MjMsImlhdCI6MTY0NjM1MzAyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.LX6wMUK1eiE49heX3nVIMR4oRrWEaI-xyUErYx9_AWlxLn5jksbmmZmXujeaailxxcvaVQDYIbKSyrahwmqUohaDChM3TgDHCHTvAeiDGoVAFIjKyzk_wzttgVrKu5P_45bNrds7PVmLC981W8aVdQO32JklWhCpO_jEbtIgGeklQ6PF9yOd5TEWtq4kJTuYrbZpl21qnZ_wopbLSOz4Ty_OoIbvkFFcPV2jSBsMggQns3GqlHjlCLMtSN43IgQbuZ711BPWk6MMIFI48tl7HEC9rm1z1l0aejtn7ooiYKNsV2V__OL0Mi3ziDmoTDp3Ra02m0J176b99V17mFmj7A",
404
+ Authorization: token,
276
405
  },
277
406
  }
278
407
  );
408
+ if (productTemp.status === "ASSIGNED") {
409
+ productTemp.status = "IN_PROGRESS";
410
+ setProduct(productTemp);
411
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
412
+ }
413
+
414
+ setMessage("Descripciones guardadas con éxito");
415
+ loadData();
279
416
  } catch (error) {
280
417
  console.log(error);
281
418
  }
282
419
  };
283
420
 
284
421
  const saveDatasheets = async () => {
422
+ setLoading(true);
423
+ const productTemp = product;
285
424
  const dataObject = {
286
- articleId: productSelected?.article?.id_article,
425
+ articleId: product?.article?.id_article,
287
426
  articleData: updatedDatasheets,
288
427
  };
428
+ if (product?.orderId) dataObject["orderId"] = product?.orderId;
289
429
  try {
290
430
  await axios.put(
291
431
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?datasheet=true&version=${version}`,
292
432
  dataObject,
293
433
  {
294
434
  headers: {
295
- Authorization:
296
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIxYTk4MzZlNS1kMDYyLTQ4ZjQtYjY4Yi04NDZhZWEwMDFlMDIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY0NjM1MzAyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2NDYzNTY2MjMsImlhdCI6MTY0NjM1MzAyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.LX6wMUK1eiE49heX3nVIMR4oRrWEaI-xyUErYx9_AWlxLn5jksbmmZmXujeaailxxcvaVQDYIbKSyrahwmqUohaDChM3TgDHCHTvAeiDGoVAFIjKyzk_wzttgVrKu5P_45bNrds7PVmLC981W8aVdQO32JklWhCpO_jEbtIgGeklQ6PF9yOd5TEWtq4kJTuYrbZpl21qnZ_wopbLSOz4Ty_OoIbvkFFcPV2jSBsMggQns3GqlHjlCLMtSN43IgQbuZ711BPWk6MMIFI48tl7HEC9rm1z1l0aejtn7ooiYKNsV2V__OL0Mi3ziDmoTDp3Ra02m0J176b99V17mFmj7A",
435
+ Authorization: token,
297
436
  },
298
437
  }
299
438
  );
300
- console.log("saved");
439
+ setMessage("Fichas técnicas guardadas");
440
+ if (productTemp.status === "ASSIGNED") {
441
+ productTemp.status = "IN_PROGRESS";
442
+ setProduct(productTemp);
443
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
444
+ }
445
+ loadData();
301
446
  } catch (error) {
302
447
  console.log(error);
303
448
  }
304
449
  };
305
450
 
451
+ useEffect(() => {
452
+ const imageInputs = images?.inputs?.map((e) => ({
453
+ value: e?.id,
454
+ name: e?.name,
455
+ required: e?.required,
456
+ active: images?.values.some((value) => value?.image_id === e?.id),
457
+ }));
458
+ setSocketType(imageInputs);
459
+ }, [images]);
460
+
306
461
  const updateImages = useCallback(async () => {
307
462
  const imagesList = images?.values?.slice();
308
- const imagesListTemp = imagesList.reduce((acc, image) => {
309
- acc[image.image_id] = ++acc[image.image_id] || 0;
463
+ const imagesListTemp = imagesList?.reduce((acc, image) => {
464
+ acc[image?.image_id] = ++acc[image?.image_id] || 0;
310
465
  return acc;
311
466
  }, {});
312
467
 
313
- const duplicated = imagesList.filter((image) => {
314
- return imagesListTemp[image.image_id];
468
+ const duplicated = imagesList?.filter((image) => {
469
+ return imagesListTemp[image?.image_id];
315
470
  });
316
471
 
317
472
  const attrForImgs = Object.values(images?.attrForImgs);
318
473
  attrForImgs.pop();
319
474
  const data = {
320
- articleId,
321
- attrReqImgs: attrForImgs.map((e) => ({
322
- attrId: e[0].id,
323
- value: e[0].value,
475
+ articleId: product?.article?.id_article,
476
+ attrReqImgs: attrForImgs?.map((e) => ({
477
+ attrId: e[0]?.id,
478
+ value: e[0]?.value,
324
479
  })),
325
- articleData: imagesList.filter((e) => !e.id),
326
- updateImages: imagesList.filter((e) => e.id),
480
+ articleData: imagesList?.filter((e) => !e.id),
481
+ updateImages: imagesList?.filter((e) => e.id),
327
482
  };
483
+ if (product?.orderId) data["orderId"] = product?.orderId;
328
484
  let valid =
329
- data.articleData.length === 0
485
+ data?.articleData?.length === 0
330
486
  ? true
331
- : data.articleData.every((e, i) => {
332
- if (e.image_id && e.packing_type && e.image_type) {
487
+ : data?.articleData?.every((e, i) => {
488
+ if (e?.image_id && e?.packing_type && e?.image_type) {
333
489
  return true;
334
490
  }
335
491
  return false;
336
492
  });
337
- if (valid && data.updateImages.length > 0 && duplicated.length === 0) {
338
- valid = data.updateImages.every((e, i) => {
339
- if (e.image_id && e.packing_type && e.image_type) {
493
+ if (valid && data?.updateImages?.length > 0 && duplicated?.length === 0) {
494
+ valid = data?.updateImages?.every((e, i) => {
495
+ if (e?.image_id && e?.packing_type && e?.image_type) {
340
496
  return true;
341
497
  }
342
498
  return false;
343
499
  });
344
500
  }
345
- if (valid && duplicated.length === 0) {
501
+ if (valid && duplicated?.length === 0) {
502
+ setLoading(true);
346
503
  try {
347
- data.articleData.forEach((e) => {
504
+ data?.articleData?.forEach((e) => {
348
505
  e.uuid = uuidv4();
349
506
  });
350
507
  setDataImages(data);
351
- if (data.articleData.length > 0) {
508
+ if (data?.articleData?.length > 0) {
352
509
  setImagesUploaded(false);
353
510
  const promiseArray = [];
354
- data.articleData.forEach((e) => {
511
+ data?.articleData?.forEach((e) => {
355
512
  const file = Buffer.from(
356
513
  e.src.replace(/^data:image\/\w+;base64,/, ""),
357
514
  "base64"
@@ -360,7 +517,7 @@ export const RetailerProductEdition = ({
360
517
  ACL: "public-read",
361
518
  Body: file,
362
519
  Bucket: S3_BUCKET,
363
- Key: `id-${data.articleId}/${version}/${e.image_id}-${e.uuid}.${e.ext}`,
520
+ Key: `id-${data.articleId}/${version}/${e?.image_id}-${e?.uuid}.${e?.ext}`,
364
521
  };
365
522
  promiseArray.push(myBucket.putObject(params).promise());
366
523
  });
@@ -369,35 +526,36 @@ export const RetailerProductEdition = ({
369
526
  } else {
370
527
  setImagesUploaded(true);
371
528
  }
529
+ let productTemp = product;
530
+ if (productTemp.status === "ASSIGNED") {
531
+ productTemp.status = "IN_PROGRESS";
532
+ setProduct(productTemp);
533
+ sessionStorage.setItem(
534
+ "productSelected",
535
+ JSON.stringify(productTemp)
536
+ );
537
+ }
372
538
  } catch (err) {
373
539
  console.log(err);
374
540
  // setMainLoading(false);
375
541
  }
376
542
  } else {
377
543
  // setMainLoading(false);
378
- console.log(
379
- "Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma.",
380
- "Recuerda hay campos obligatorios y no podras avanzar si no estan completos."
544
+ setMessage(
545
+ "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."
381
546
  );
382
- // setAlertList((prev) => [
383
- // ...prev,
384
- // {
385
- // titleMsg: "Completa los campos que solicita cada una de la imágenes",
386
- // alertMsg:
387
- // "Recuerda hay campos obligatorios y no podras avanzar si no estan completos.",
388
- // },
389
- // ]);
390
547
  }
391
548
  // eslint-disable-next-line react-hooks/exhaustive-deps
392
549
  }, [images, imagesUploaded]);
393
550
 
394
551
  useEffect(async () => {
395
552
  if (imagesUploaded) {
396
- dataImages.articleData = dataImages.articleData.map((e) => {
553
+ dataImages.articleData = dataImages?.articleData.map((e) => {
397
554
  delete e.src;
398
555
  e.imageID = e.image_id;
399
556
  e.packingType = e.packing_type;
400
557
  e.imageType = e.image_type;
558
+ if (product?.orderId) e["orderId"] = product?.orderId;
401
559
  return e;
402
560
  });
403
561
  try {
@@ -406,40 +564,87 @@ export const RetailerProductEdition = ({
406
564
  dataImages,
407
565
  {
408
566
  headers: {
409
- Authorization:
410
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIxYTk4MzZlNS1kMDYyLTQ4ZjQtYjY4Yi04NDZhZWEwMDFlMDIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY0NjM1MzAyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2NDYzNTY2MjMsImlhdCI6MTY0NjM1MzAyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.LX6wMUK1eiE49heX3nVIMR4oRrWEaI-xyUErYx9_AWlxLn5jksbmmZmXujeaailxxcvaVQDYIbKSyrahwmqUohaDChM3TgDHCHTvAeiDGoVAFIjKyzk_wzttgVrKu5P_45bNrds7PVmLC981W8aVdQO32JklWhCpO_jEbtIgGeklQ6PF9yOd5TEWtq4kJTuYrbZpl21qnZ_wopbLSOz4Ty_OoIbvkFFcPV2jSBsMggQns3GqlHjlCLMtSN43IgQbuZ711BPWk6MMIFI48tl7HEC9rm1z1l0aejtn7ooiYKNsV2V__OL0Mi3ziDmoTDp3Ra02m0J176b99V17mFmj7A",
567
+ Authorization: token,
411
568
  },
412
569
  }
413
570
  );
414
- console.log("imágenes guardadas con éxito");
571
+ setMessage("Imágenes guardadas con éxito");
572
+ sessionStorage.removeItem("imagesList");
573
+ loadData();
415
574
  } catch (error) {
416
575
  console.log(error);
417
576
  }
418
577
  }
419
578
  }, [dataImages, imagesUploaded]);
420
579
 
421
- const approveRejectButtons = (action) => {
422
- let concept = "";
423
- switch (activeTab) {
424
- case "Descripción":
425
- concept = "description";
580
+ const evaluationFinished = (userId, tab, statusArray) => {
581
+ const srv = servicesData.filter((serv) => serv.service === getConcept(tab));
582
+ const [srvActive] = srv.filter(
583
+ (serv) => serv.id_retailer === activeRetailer?.id
584
+ );
585
+ const unvalidated =
586
+ product[`${getConcept(tab)}_status`] === "QF" ||
587
+ product[`${getConcept(tab)}_status`] === "IN_PROGRESS";
588
+
589
+ const auditorUnvalidated = !["RA", "AA", "AC", "AP"].includes(
590
+ product[`${getConcept(tab)}_status`]
591
+ );
592
+
593
+ switch (userId) {
594
+ case 7:
595
+ case 8:
596
+ return (
597
+ (["RA", "RF"].includes(product?.status) && //"IN_PROGRESS", "RF", "RA"
598
+ statusArray.includes(srvActive?.status)) ||
599
+ (statusArray.includes(product.status) &&
600
+ srv.filter((serv) => statusArray.includes(serv.status)).length ===
601
+ srv.length)
602
+ );
603
+ case 4:
604
+ case 5:
605
+ return (
606
+ unvalidated &&
607
+ ["IN_PROGRESS", "QF"].includes(product.status) && //"RF", "AF", "AA", "AP", "AC
608
+ srv.filter((serv) => statusArray.includes(serv.status)).length ===
609
+ srv.length
610
+ );
611
+ case 6:
612
+ return (
613
+ statusArray.includes(product.status) && //RP, RC, AF, RA true
614
+ srv.every((serv) => ["RA", "AA", "AP", "AC"].includes(serv.status)) &&
615
+ auditorUnvalidated
616
+ );
617
+ default:
426
618
  break;
619
+ }
620
+ };
621
+
622
+ const getConcept = (tab) => {
623
+ switch (tab) {
624
+ case "Descripción":
625
+ return "description";
427
626
  case "Ficha técnica":
428
- concept = "datasheet";
429
- break;
627
+ return "datasheet";
430
628
  case "Imágenes":
431
- concept = "images";
432
- break;
433
- default:
434
- break;
629
+ return "images";
435
630
  }
436
- concept = action ? action : concept;
631
+ };
632
+
633
+ const approveRejectButtons = (action) => {
634
+ let concept = getConcept(action || activeTab);
635
+
636
+ const [retailerStatus] = servicesData.filter(
637
+ (srv) => srv.id_retailer === activeRetailer?.id && srv.service === concept
638
+ );
639
+
437
640
  return (
438
- (productSelected[`${concept}_status`] === "QF" &&
641
+ (retailerStatus?.status === "QF" &&
439
642
  (user.id_role === 1 || user.id_role === 4 || user.id_role === 5)) ||
440
- (productSelected[`${concept}_status`] === "AF" &&
643
+ (retailerStatus?.status === "AF" && //sessionStorage product
644
+ (user.id_role === 1 || user.id_role === 6)) ||
645
+ (retailerStatus?.status === "RP" &&
441
646
  (user.id_role === 1 || user.id_role === 6)) ||
442
- (productSelected[`${concept}_status`] === "RP" &&
647
+ (retailerStatus?.status === "RC" &&
443
648
  (user.id_role === 1 || user.id_role === 6))
444
649
  );
445
650
  };
@@ -460,168 +665,135 @@ export const RetailerProductEdition = ({
460
665
  }
461
666
  };
462
667
 
463
- const updateCompaniesList = (status, result, retailerId, concept) => {
464
- let serv = servicesData.slice();
465
- let item = serv.find(
466
- (item) => item.id_retailer === retailerId && item.service === concept
467
- );
468
- let index = serv.indexOf(item);
469
- if (
470
- status === "IN_PROGRESS" ||
471
- status === "QF" ||
472
- status === "RF" ||
473
- status === "RA"
474
- ) {
475
- if (result === "A") {
476
- if (activeTab === "Imágenes") {
477
- serv.map((item) => {
478
- item.status = "AF";
479
- });
480
- } else {
481
- serv[index].status = "AF";
482
- }
483
- } else if (result === "R") {
484
- if (activeTab === "Imágenes") {
485
- serv.map((item) => {
486
- item.status = "RF";
487
- });
488
- } else {
489
- serv[index].status = "RF";
490
- }
668
+ const sendToFacilitator = async (result) => {
669
+ setLoading(true);
670
+ try {
671
+ let concept = getConcept(activeTab);
672
+
673
+ let productTemp = { ...product };
674
+ let evalStatus = product[`${concept}_status`];
675
+
676
+ let data = {};
677
+ if (result) {
678
+ data = {
679
+ articleId: product.article.id_article,
680
+ orderId: product.orderId,
681
+ concept: concept,
682
+ result: result,
683
+ evalStatus: evalStatus,
684
+ retailerId: activeRetailer.id,
685
+ };
686
+
687
+ await axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
688
+ headers: {
689
+ Authorization: token,
690
+ },
691
+ });
692
+ getServices();
491
693
  } else {
492
- if (status === "IN_PROGRESS" || status === "ASSIGNED") {
493
- serv.map((item) => {
494
- item.status = "QF";
495
- });
496
- } else {
497
- serv.map((item) => {
498
- if (item.status === "RF" || item.status === "RA") {
499
- item.status = "QF";
500
- }
501
- return item;
502
- });
503
- }
504
- }
505
- } else if (status === "AF" || status === "RP") {
506
- if (result === "A") {
507
- if (activeTab === "Imágenes") {
508
- serv.map((item) => {
509
- item.status = "AA";
510
- });
511
- } else {
512
- serv[index].status = "AA";
694
+ const specialistDone =
695
+ evalStatus === "RF" ||
696
+ evalStatus === "RA" ||
697
+ evalStatus === "IN_PROGRESS";
698
+
699
+ if (specialistDone) {
700
+ setMessage(`${activeTab} enviada a facilitador`);
701
+ getSectionIcon();
702
+ } else if (evalStatus === "QF") {
703
+ setMessage("Evaluación enviada");
704
+ getSectionIcon();
705
+ } else if (evalStatus === "AF") {
706
+ setMessage("Evaluación enviada");
707
+ getSectionIcon();
708
+ } else if (evalStatus === "RP") {
709
+ setMessage("Evaluación enviada");
710
+ getSectionIcon();
711
+ } else if (evalStatus === "RC") {
712
+ setMessage("Evaluación enviada");
713
+ getSectionIcon();
513
714
  }
514
- } else {
515
- if (activeTab === "Imágenes") {
516
- serv.map((item) => {
517
- item.status = "RA";
518
- });
519
- } else {
520
- serv[index].status = "RA";
715
+ let statusArr = [];
716
+ servicesData.forEach((srv) => {
717
+ srv.service === concept && statusArr.push(srv.status);
718
+ });
719
+
720
+ productTemp[`${concept}_status`] = getNewStatus(statusArr);
721
+
722
+ let newStatus = getNewStatus([
723
+ productTemp.datasheet_status,
724
+ productTemp.description_status,
725
+ productTemp.images_status,
726
+ ]);
727
+
728
+ productTemp.status = newStatus;
729
+
730
+ data = {
731
+ articleId: product.article.id_article,
732
+ orderId: product.orderId,
733
+ concept: concept,
734
+ evalStatus: evalStatus,
735
+ retailerId: activeRetailer.id,
736
+ };
737
+
738
+ switch (user.id_role) {
739
+ case 7:
740
+ case 8:
741
+ data.especialist = true;
742
+ break;
743
+ case 4:
744
+ case 5:
745
+ data.facilitator = true;
746
+ break;
747
+ default:
748
+ break;
521
749
  }
750
+ await axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
751
+ headers: {
752
+ Authorization: token,
753
+ },
754
+ });
522
755
  }
756
+ loadData();
757
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
758
+ setProduct(productTemp);
759
+ } catch (error) {
760
+ console.log(error);
523
761
  }
524
- //console.log(serv, "serv");
525
- setServicesData(serv);
762
+ setLoading(false);
526
763
  };
527
764
 
528
- const sendToFacilitator = async (result) => {
529
- console.log("exce");
530
- let concept = "";
531
- switch (activeTab) {
532
- case "Descripción":
533
- concept = "description";
534
- break;
535
- case "Ficha técnica":
536
- concept = "datasheet";
537
- break;
538
- case "Imágenes":
539
- concept = "images";
540
- break;
541
- default:
542
- break;
543
- }
544
- let evalStatus = "";
545
- let productTemp = { ...productSelected };
546
- evalStatus = productSelected[`${concept}_status`];
547
- const specialistDone =
548
- evalStatus === "RF" ||
549
- evalStatus === "RA" ||
550
- evalStatus === "IN_PROGRESS";
551
-
552
- if (specialistDone) {
553
- setMessage(`${activeTab} enviada a facilitador`);
554
- getSectionIcon();
555
- productTemp[`${concept}_status`] = "QF";
556
- } else if (evalStatus === "QF") {
557
- setMessage("Evaluación enviada");
558
- getSectionIcon();
559
- productTemp[`${concept}_status`] = "AF";
560
- } else if (evalStatus === "AF") {
561
- setMessage("Evaluación enviada");
562
- getSectionIcon();
563
- productTemp[`${concept}_status`] = "AA";
564
- } else if (evalStatus === "RP") {
565
- setMessage("Evaluación enviada");
566
- getSectionIcon();
567
- productTemp[`${concept}_status`] = "AA";
568
- }
569
- let data = {};
570
- if (result) {
571
- updateCompaniesList(evalStatus, result, activeRetailer.id, concept);
572
- data = {
573
- articleId: productSelected.article.id_article,
574
- orderId: productSelected.orderId,
575
- concept: concept,
576
- result: result,
577
- evalStatus: evalStatus,
578
- retailerId: activeRetailer.id,
579
- };
580
- await axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
581
- headers: {
582
- Authorization:
583
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIxYTk4MzZlNS1kMDYyLTQ4ZjQtYjY4Yi04NDZhZWEwMDFlMDIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY0NjM1MzAyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2NDYzNTY2MjMsImlhdCI6MTY0NjM1MzAyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.LX6wMUK1eiE49heX3nVIMR4oRrWEaI-xyUErYx9_AWlxLn5jksbmmZmXujeaailxxcvaVQDYIbKSyrahwmqUohaDChM3TgDHCHTvAeiDGoVAFIjKyzk_wzttgVrKu5P_45bNrds7PVmLC981W8aVdQO32JklWhCpO_jEbtIgGeklQ6PF9yOd5TEWtq4kJTuYrbZpl21qnZ_wopbLSOz4Ty_OoIbvkFFcPV2jSBsMggQns3GqlHjlCLMtSN43IgQbuZ711BPWk6MMIFI48tl7HEC9rm1z1l0aejtn7ooiYKNsV2V__OL0Mi3ziDmoTDp3Ra02m0J176b99V17mFmj7A",
584
- },
585
- });
586
- } else {
587
- if (specialistDone) {
588
- updateCompaniesList(evalStatus, result, activeRetailer.id);
589
- }
590
- data = {
591
- articleId: productSelected.article.id_article,
592
- orderId: productSelected.orderId,
593
- concept: concept,
594
- evalStatus: evalStatus,
595
- retailerId: activeRetailer.id,
596
- };
765
+ const userAssigned = (tab, rol) => {
766
+ let concept = getConcept(activeTab);
767
+
768
+ const allowedRoles = [1, 4, 5, 6, 7, 8];
769
+ const validUser = allowedRoles.includes(user?.id_role);
597
770
 
771
+ if (!rol) {
598
772
  switch (user.id_role) {
599
- case 7:
600
- case 8:
601
- data.especialist = true;
602
- break;
603
773
  case 4:
604
774
  case 5:
605
- data.facilitator = true;
775
+ rol = "facilitator";
606
776
  break;
607
- default:
777
+ case 7:
778
+ case 8:
779
+ rol = "especialist";
608
780
  break;
609
781
  }
610
-
611
- axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
612
- headers: {
613
- Authorization:
614
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIxYTk4MzZlNS1kMDYyLTQ4ZjQtYjY4Yi04NDZhZWEwMDFlMDIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY0NjM1MzAyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2NDYzNTY2MjMsImlhdCI6MTY0NjM1MzAyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.LX6wMUK1eiE49heX3nVIMR4oRrWEaI-xyUErYx9_AWlxLn5jksbmmZmXujeaailxxcvaVQDYIbKSyrahwmqUohaDChM3TgDHCHTvAeiDGoVAFIjKyzk_wzttgVrKu5P_45bNrds7PVmLC981W8aVdQO32JklWhCpO_jEbtIgGeklQ6PF9yOd5TEWtq4kJTuYrbZpl21qnZ_wopbLSOz4Ty_OoIbvkFFcPV2jSBsMggQns3GqlHjlCLMtSN43IgQbuZ711BPWk6MMIFI48tl7HEC9rm1z1l0aejtn7ooiYKNsV2V__OL0Mi3ziDmoTDp3Ra02m0J176b99V17mFmj7A",
615
- },
616
- });
617
- setProduct(productTemp);
618
- setModalSent(true);
619
782
  }
783
+
784
+ return (
785
+ user.id_role === 1 ||
786
+ (product.article[`id_${concept}_${rol}`] === user.id_user && validUser)
787
+ );
620
788
  };
621
789
 
622
- const userAssigned = (tab, rol) => {
790
+ const auditorAssigned = () => {
791
+ return product?.article[`id_auditor`] === user.id_user;
792
+ };
793
+
794
+ const createComment = async (e, body, tab) => {
623
795
  let concept = "";
624
- switch (tab) {
796
+ switch (activeTab) {
625
797
  case "Ficha técnica":
626
798
  concept = "datasheet";
627
799
  break;
@@ -633,24 +805,121 @@ export const RetailerProductEdition = ({
633
805
  concept = "description";
634
806
  break;
635
807
  }
808
+ const data = {
809
+ articleId: product?.article?.id_article,
810
+ orderId: product?.orderId,
811
+ message: body,
812
+ concept: concept,
813
+ version: version,
814
+ };
815
+ await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
816
+ headers: {
817
+ Authorization: token,
818
+ },
819
+ });
820
+ await getComments(tab);
821
+ setMessage("");
822
+ setComponentsArray([]);
823
+ };
636
824
 
637
- const allowedRoles = [1, 4, 5, 6, 7, 8];
825
+ const getRequired = (services) => {
826
+ try {
827
+ const objetcTemp = {};
828
+ const datasheetServicesArray = Object.values(services[0]);
829
+ const dsInputs = datasheetServicesArray.pop();
830
+ const descriptionsServicesArray = services[1];
638
831
 
639
- const validUser = allowedRoles.indexOf(user?.id_role) !== -1;
832
+ let dsInputsRequired = [];
833
+ let desInputsRequired = 0;
834
+ datasheetServicesArray?.forEach((datasheet) => {
835
+ const [requested] = servicesData?.filter(
836
+ (srv) =>
837
+ srv.id_retailer === datasheet.retailer.id &&
838
+ srv.service === getConcept(activeTab)
839
+ );
840
+ requested &&
841
+ datasheet?.data &&
842
+ Object.values(datasheet?.data).forEach((dataGroup) =>
843
+ dsInputsRequired.push(
844
+ ...dataGroup.inputs.filter(
845
+ (input) =>
846
+ dsInputs[input].required &&
847
+ (dsInputs[input].value === undefined ||
848
+ !dsInputs[input].value)
849
+ )
850
+ )
851
+ );
852
+ });
640
853
 
641
- return (
642
- productSelected.article[`id_${concept}_${rol}`] === user.id_user &&
643
- validUser
644
- );
854
+ objetcTemp["Ficha técnica"] = dsInputsRequired.length;
855
+
856
+ descriptionsServicesArray.forEach((description) => {
857
+ const [requested] = servicesData.filter(
858
+ (srv) =>
859
+ srv.id_retailer === description.id &&
860
+ srv.service === getConcept(activeTab)
861
+ );
862
+ requested &&
863
+ description.inputs.forEach(
864
+ (input) =>
865
+ input.required &&
866
+ (!input.value ||
867
+ input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") ===
868
+ "") &&
869
+ desInputsRequired++
870
+ );
871
+ });
872
+
873
+ objetcTemp["Descripción"] = desInputsRequired;
874
+
875
+ const retailersRequested = [];
876
+ services[2]?.retailerMandatories?.forEach((retMan) =>
877
+ retMan.forEach((rm) => retailersRequested.push(rm))
878
+ );
879
+ const requiredImages = services[2]?.inputs?.filter(
880
+ (e) =>
881
+ e.required === 1 &&
882
+ retailersRequested.filter(
883
+ (ret) =>
884
+ ret.id_image === e.id &&
885
+ servicesData.filter((srv) => srv.id_retailer === ret.id_retailer)
886
+ .length > 0
887
+ ).length > 0
888
+ );
889
+
890
+ let requiredCounter = 0;
891
+ requiredImages?.forEach(
892
+ (req) =>
893
+ services[2].values.filter((img) => img.image_id === req.id).length ===
894
+ 0 && requiredCounter++
895
+ );
896
+ objetcTemp["Imágenes"] = requiredCounter;
897
+ setRequiredNull(objetcTemp);
898
+ } catch (error) {
899
+ console.log(error);
900
+ }
645
901
  };
646
902
 
647
- const auditorAssigned = () => {
648
- return productSelected?.article[`id_auditor`] === user.id_user;
903
+ useEffect(() => {
904
+ setComment(comments[activeTab]);
905
+ }, [activeTab]);
906
+
907
+ const commentRevised = async () => {
908
+ const data = {
909
+ commentId: comment.id,
910
+ };
911
+ await axios.put(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
912
+ headers: {
913
+ Authorization: sessionStorage.getItem("jwt"),
914
+ },
915
+ });
916
+ setCrossComment(false);
917
+ await getComments();
649
918
  };
650
919
 
651
- function specialistValid(tab) {
920
+ const setAssignation = async (assignationType, assignationId) => {
652
921
  let concept = "";
653
- switch (tab) {
922
+ switch (activeTab) {
654
923
  case "Ficha técnica":
655
924
  concept = "datasheet";
656
925
  break;
@@ -662,32 +931,215 @@ export const RetailerProductEdition = ({
662
931
  concept = "description";
663
932
  break;
664
933
  }
665
- return (
666
- product[`${concept}_status`] === "IN_PROGRESS" ||
667
- product[`${concept}_status`] === "RF" ||
668
- product[`${concept}_status`] === "RA"
934
+ const productTemp = product;
935
+ productTemp.article[`id_${concept}_${assignationType}`] = assignationId;
936
+ const data = {
937
+ articleList: [
938
+ {
939
+ orderId: product.orderId,
940
+ articleId: product?.article?.id_article,
941
+ },
942
+ ],
943
+ concept: concept,
944
+ [`${assignationType}Id`]: assignationId,
945
+ };
946
+ axios({
947
+ method: "post",
948
+ url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
949
+ data: data,
950
+ headers: {
951
+ Authorization: token,
952
+ },
953
+ });
954
+ loadAssignations(productTemp);
955
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
956
+ };
957
+
958
+ const downloadImages = () => {
959
+ selectedImages.length > 0
960
+ ? selectedImages.forEach((e) => {
961
+ if (e.id) {
962
+ saveAs(
963
+ `https://${process.env.REACT_APP_IMAGES_BUCKET}.s3.amazonaws.com/${e.srcDB}`,
964
+ `${product.article.upc}_${e.name}.${e.ext}`
965
+ );
966
+ }
967
+ })
968
+ : images?.values?.forEach((e) => {
969
+ if (e.id) {
970
+ saveAs(
971
+ `https://${process.env.REACT_APP_IMAGES_BUCKET}.s3.amazonaws.com/${e.srcDB}`,
972
+ `${product.article.upc}_${e.name}.${e.ext}`
973
+ );
974
+ }
975
+ });
976
+ };
977
+
978
+ const deleteImages = () => {
979
+ setLoading(true);
980
+ const { values } = images;
981
+ const imgsInBack = [];
982
+
983
+ selectedImages.forEach((selectedImg) => {
984
+ if (selectedImg.id) imgsInBack.push(selectedImg);
985
+ });
986
+
987
+ const imgsLeft = values.filter(
988
+ (value) => selectedImages.indexOf(value) === -1
669
989
  );
670
- }
671
990
 
672
- function versionMatch() {
673
- return productSelected?.version === version;
674
- }
991
+ if (imgsInBack.length > 0) {
992
+ const data = {
993
+ articleId: product.article.id_article,
994
+ deleteImages: imgsInBack,
995
+ orderId: product.orderId,
996
+ };
997
+ try {
998
+ axios.put(
999
+ `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
1000
+ data,
1001
+ {
1002
+ headers: { Authorization: token },
1003
+ }
1004
+ );
1005
+ } catch (err) {
1006
+ console.log(err);
1007
+ }
1008
+ }
1009
+
1010
+ setImages({
1011
+ action: "deleteImage",
1012
+ selectedImages,
1013
+ });
1014
+
1015
+ getRequired([
1016
+ services[0],
1017
+ services[1],
1018
+ { ...services[2], values: imgsLeft },
1019
+ ]);
1020
+
1021
+ setTimeout(() => {
1022
+ setLoading(false);
1023
+ }, 500);
1024
+
1025
+ setMessage("");
1026
+ setComponentsArray([]);
1027
+ };
1028
+
1029
+ const askToDeleteImages = () => {
1030
+ if (selectedImages.length > 0) {
1031
+ setMessage("¿Está seguro de eliminar las imágenes seleccionadas?");
1032
+ setComponentsArray([
1033
+ <ScreenHeader
1034
+ key={"1"}
1035
+ text={"¿Está seguro de eliminar las imágenes seleccionadas?"}
1036
+ headerType="retailer-name-header"
1037
+ color={"white"}
1038
+ />,
1039
+ <Button
1040
+ key={"2"}
1041
+ buttonType="general-white-button"
1042
+ label={"Cancelar"}
1043
+ onClick={() => setMessage("")}
1044
+ />,
1045
+ <Button
1046
+ key={"3"}
1047
+ buttonType="general-button-default"
1048
+ label={"Aceptar"}
1049
+ onClick={() => {
1050
+ setMessage("");
1051
+ deleteImages();
1052
+ }}
1053
+ />,
1054
+ ]);
1055
+ }
1056
+ };
1057
+
1058
+ const getRetailerStatus = (servicesData, tab) => {
1059
+ const arr = servicesData?.slice();
1060
+ let concept = getConcept(tab);
1061
+
1062
+ let retailerService = {};
1063
+ [retailerService] = arr?.filter(
1064
+ (service) =>
1065
+ service.id_retailer === activeRetailer?.id &&
1066
+ service.service === concept
1067
+ );
1068
+ return retailerService ? retailerService.status : "NS";
1069
+ };
675
1070
 
676
1071
  useEffect(() => {
677
- // let concept = "";
678
- // switch (activeTab) {
679
- // case "Ficha técnica":
680
- // concept = "datasheet";
681
- // break;
682
- // case "Imágenes":
683
- // concept = "images";
684
- // break;
685
- // default:
686
- // concept = "description";
687
- // break;
688
- // }
689
- // getComments(concept);
690
- }, [activeTab]);
1072
+ let status = getRetailerStatus(servicesData, activeTab);
1073
+ setRetailerStatus(status);
1074
+ }, [activeTab, servicesData, activeRetailer]);
1075
+
1076
+ useEffect(() => {
1077
+ services.length > 0 && getRequired(services);
1078
+ }, [services, servicesData, activeTab]);
1079
+
1080
+ useEffect(() => {
1081
+ setSaving(loading);
1082
+ }, [loading]);
1083
+
1084
+ const validateAll = async (result) => {
1085
+ try {
1086
+ setLoading(true);
1087
+ const evaluationArray = [];
1088
+ const sendAll = [];
1089
+ const conceptArray = ["description", "datasheet", "images"];
1090
+
1091
+ servicesData?.forEach((ret) => {
1092
+ let data = {
1093
+ articleId: product.article.id_article,
1094
+ orderId: product.id_order ?? product.orderId,
1095
+ concept: ret.service,
1096
+ result: result,
1097
+ evalStatus: product[`${ret.service}_status`],
1098
+ retailerId: ret.id_retailer,
1099
+ };
1100
+ evaluationArray.push(
1101
+ axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
1102
+ headers: {
1103
+ Authorization: token,
1104
+ },
1105
+ })
1106
+ );
1107
+ });
1108
+
1109
+ await Promise.all(evaluationArray);
1110
+
1111
+ conceptArray?.forEach((concept) => {
1112
+ let data = {
1113
+ articleId: product.article.id_article,
1114
+ orderId: product.id_order ?? product.orderId,
1115
+ concept,
1116
+ evalStatus: product[`${concept}_status`],
1117
+ };
1118
+ sendAll.push(
1119
+ axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
1120
+ headers: {
1121
+ Authorization: token,
1122
+ },
1123
+ })
1124
+ );
1125
+ });
1126
+ await Promise.all(sendAll);
1127
+ const productTemp = product;
1128
+ productTemp.status = `${result}A`;
1129
+ productTemp.datasheet_status =
1130
+ productTemp.datasheet_status === "NA" ? "NA" : `${result}A`;
1131
+ productTemp.description_status =
1132
+ productTemp.description_status === "NA" ? "NA" : `${result}A`;
1133
+ productTemp.images_status =
1134
+ productTemp.images_status === "NA" ? "NA" : `${result}A`;
1135
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1136
+ setProduct(productTemp);
1137
+
1138
+ loadData();
1139
+ } catch (error) {
1140
+ console.log(error);
1141
+ }
1142
+ };
691
1143
 
692
1144
  return (
693
1145
  <Container headerTop={headerTop}>
@@ -703,13 +1155,16 @@ export const RetailerProductEdition = ({
703
1155
  <ImageDataTable
704
1156
  lists={images}
705
1157
  activeImage={images?.values ? images?.values[activeImage] : {}}
706
- retailerSelected={activeRetailer.id}
1158
+ retailerSelected={activeRetailer?.id}
707
1159
  setImages={setImages}
708
- assignationsImages={[
709
- productSelected.article.id_images_especialist,
710
- productSelected.article.id_images_facilitator,
711
- ]}
712
- imagesStatus={productSelected?.images_status}
1160
+ assignationsImages={assig["Imágenes"]}
1161
+ imagesStatus={product?.images_status}
1162
+ setAssignation={setAssignation}
1163
+ isRetailer={isRetailer}
1164
+ onClickSave={() =>
1165
+ product?.services?.images === 1 && updateImages()
1166
+ }
1167
+ showSaveButton={userAssigned()}
713
1168
  />
714
1169
  </div>
715
1170
  <div className="product-information">
@@ -717,47 +1172,120 @@ export const RetailerProductEdition = ({
717
1172
  headerData={product}
718
1173
  percent={activePercentage}
719
1174
  activeRetailer={activeRetailer}
1175
+ servicesData={servicesData}
720
1176
  setActiveRetailer={setActiveRetailer}
721
- approveRejectButtons={approveRejectButtons}
722
1177
  sendToFacilitator={sendToFacilitator}
723
- auditorAssigned={auditorAssigned}
724
- userAssigned={userAssigned(activeTab, "facilitator")}
1178
+ approve={() => {
1179
+ sendToFacilitator("A");
1180
+ }}
1181
+ reject={() => {
1182
+ sendToFacilitator("R");
1183
+ setMessage("Rechazado");
1184
+ setComponentsArray([
1185
+ <img src={errorModal} />,
1186
+ <ScreenHeader
1187
+ text={"Agrega tu comentarios para enviar el rechazo"}
1188
+ headerType={"input-name-header"}
1189
+ color={"white"}
1190
+ />,
1191
+ <TagAndInput
1192
+ label={"Caja de Comentario"}
1193
+ inputType={"textarea"}
1194
+ inputId={"modal-commentary-box"}
1195
+ index={0}
1196
+ color={"white"}
1197
+ />,
1198
+ <Button
1199
+ buttonType={"general-default-button"}
1200
+ label={"Enviar comentario"}
1201
+ onClick={(e) =>
1202
+ createComment(
1203
+ e,
1204
+ document.querySelector(
1205
+ "#modal-commentary-box .ql-container .ql-editor > p"
1206
+ ).innerHTML,
1207
+ activeTab
1208
+ )
1209
+ }
1210
+ />,
1211
+ ]);
1212
+ }}
1213
+ showApproveRejectAll={
1214
+ isAuditor &&
1215
+ servicesData.every((serv) =>
1216
+ ["RA", "AA", "AP", "AC", "AF"].includes(serv.status)
1217
+ ) &&
1218
+ approveRejectButtons() &&
1219
+ (auditorAssigned() || userAssigned())
1220
+ }
1221
+ showValidationButtons={
1222
+ approveRejectButtons() && (auditorAssigned() || userAssigned())
1223
+ }
1224
+ approveAll={() => validateAll("A")}
1225
+ rejectAll={() => {
1226
+ validateAll("R");
1227
+ setMessage("Rechazado");
1228
+ setComponentsArray([
1229
+ <img src={errorModal} />,
1230
+ <ScreenHeader
1231
+ text={"Agrega tu comentarios para enviar el rechazo"}
1232
+ headerType={"input-name-header"}
1233
+ color={"white"}
1234
+ />,
1235
+ <TagAndInput
1236
+ label={"Caja de Comentario"}
1237
+ inputType={"textarea"}
1238
+ inputId={"modal-commentary-box"}
1239
+ index={0}
1240
+ color={"white"}
1241
+ />,
1242
+ <Button
1243
+ buttonType={"general-default-button"}
1244
+ label={"Enviar comentario"}
1245
+ onClick={(e) =>
1246
+ createComment(
1247
+ e,
1248
+ document.querySelector(
1249
+ "#modal-commentary-box .ql-container .ql-editor > p"
1250
+ ).innerHTML,
1251
+ activeTab
1252
+ )
1253
+ }
1254
+ />,
1255
+ ]);
1256
+ }}
725
1257
  />
726
1258
  <FullTabsMenu
727
1259
  tabsSections={tabsSections}
728
- status={{
729
- Descripción: servicesData.filter(
730
- (service) =>
731
- service.id_retailer === activeRetailer?.id &&
732
- service.service === "description"
733
- )[0]?.status,
734
- "Ficha técnica": servicesData.filter(
735
- (service) =>
736
- service.id_retailer === activeRetailer?.id &&
737
- service.service === "datasheet"
738
- )[0]?.status,
739
- Imágenes: product?.images_status,
740
- }}
741
- profileImage={productData.asigned}
1260
+ status={retailerStatus}
742
1261
  activeTab={activeTab}
743
1262
  setActiveTab={setActiveTab}
744
1263
  setImageLayout={setImageLayout}
745
- saveDescriptions={saveDescriptions}
746
- saveDatasheets={saveDatasheets}
747
- updateImages={updateImages}
748
- assignations={{
749
- Descripción: [
750
- productSelected.article.id_description_especialist,
751
- productSelected.article.id_description_facilitator,
752
- ],
753
- "Ficha técnica": [
754
- productSelected.article.id_datasheet_especialist,
755
- productSelected.article.id_datasheet_facilitator,
756
- ],
757
- Imágenes: [
758
- productSelected.article.id_images_especialist,
759
- productSelected.article.id_images_facilitator,
760
- ],
1264
+ downloadImages={downloadImages}
1265
+ askToDeleteImages={askToDeleteImages}
1266
+ assig={assig[activeTab]}
1267
+ setAssignation={setAssignation}
1268
+ isRetailer={isRetailer}
1269
+ showSaveButton={userAssigned()}
1270
+ onClickSave={() => {
1271
+ switch (activeTab) {
1272
+ case "Descripción":
1273
+ !saving &&
1274
+ product?.description_status !== "NS" &&
1275
+ saveDescriptions();
1276
+ break;
1277
+ case "Ficha técnica":
1278
+ !saving &&
1279
+ product?.datasheet_status !== "NS" &&
1280
+ saveDatasheets();
1281
+ break;
1282
+ case "Imágenes":
1283
+ !saving && product?.images_status !== "NS" && updateImages();
1284
+ break;
1285
+
1286
+ default:
1287
+ break;
1288
+ }
761
1289
  }}
762
1290
  />
763
1291
  <div
@@ -766,85 +1294,130 @@ export const RetailerProductEdition = ({
766
1294
  (imageLayout && activeTab === "Imágenes" ? "image-services" : "")
767
1295
  }
768
1296
  >
769
- {!imageLayout && <GalleryHeader />}
770
- {activeTab === "Ficha técnica" &&
771
- (product?.services?.datasheets === 1 ? (
772
- datasheets[0]?.data?.map((dataGroup, index) => (
773
- <InputGroup
774
- key={index + "-" + activeRetailer.name}
775
- articleId={productSelected.article.id_article}
776
- version={version}
777
- activeSection={activeTab}
778
- inputGroup={dataGroup}
779
- dataInputs={datasheets[1]}
780
- updatedDatasheets={updatedDatasheets}
781
- setUpdatedDatasheets={setUpdatedDatasheets}
782
- />
783
- ))
784
- ) : (
785
- <p>no tienes este servicio</p>
786
- ))}
787
- {activeTab === "Descripción" &&
788
- (product?.services?.descriptions === 1 ? (
789
- <InputGroup
790
- activeSection={activeTab}
791
- inputGroup={descriptions[0]}
792
- updatedDescriptions={updatedDescriptions}
793
- setUpdatedDescriptions={setUpdatedDescriptions}
794
- articleId={articleId}
795
- version={version}
796
- dinamicHeight={true}
797
- />
798
- ) : (
799
- <p>no tienes este servicio</p>
800
- ))}
801
-
802
- {activeTab === "Imágenes" &&
803
- (product?.services?.images === 1 ? (
804
- <section className="container">
805
- <div {...getRootProps({ className: "dropzone" })}>
806
- <input {...getInputProps()} />
807
- <aside>{thumbs()}</aside>
808
- </div>
809
- </section>
810
- ) : (
811
- <p>no tienes este servicio</p>
812
- ))}
1297
+ {loading ? (
1298
+ <Loading />
1299
+ ) : (
1300
+ <>
1301
+ {!imageLayout &&
1302
+ activeTab === "Imágenes" &&
1303
+ product?.services?.images === 1 && (
1304
+ <GalleryHeader
1305
+ setSelectedImages={setSelectedImages}
1306
+ checkAll={checkAll}
1307
+ setCheckAll={setCheckAll}
1308
+ />
1309
+ )}
1310
+ {activeTab === "Ficha técnica" &&
1311
+ (product?.datasheet_status !== "NS" ? (
1312
+ datasheets[0]?.data?.map((dataGroup, index) => (
1313
+ <InputGroup
1314
+ key={index + "-" + activeRetailer.name}
1315
+ articleId={product.article.id_article}
1316
+ version={version}
1317
+ activeSection={activeTab}
1318
+ inputGroup={dataGroup}
1319
+ dataInputs={datasheets[1]}
1320
+ updatedDatasheets={updatedDatasheets}
1321
+ setUpdatedDatasheets={setUpdatedDatasheets}
1322
+ />
1323
+ ))
1324
+ ) : (
1325
+ <ScreenHeader
1326
+ text={"No cuentas con este servicio"}
1327
+ headerType={"input-name-header"}
1328
+ />
1329
+ ))}
1330
+ {activeTab === "Descripción" &&
1331
+ (product?.description_status !== "NS" ? (
1332
+ <InputGroup
1333
+ activeSection={activeTab}
1334
+ inputGroup={descriptions[0]}
1335
+ updatedDescriptions={updatedDescriptions}
1336
+ setUpdatedDescriptions={setUpdatedDescriptions}
1337
+ articleId={product?.article?.id_article}
1338
+ version={version}
1339
+ dinamicHeight={true}
1340
+ />
1341
+ ) : (
1342
+ <ScreenHeader
1343
+ text={"No cuentas con este servicio"}
1344
+ headerType={"input-name-header"}
1345
+ />
1346
+ ))}
1347
+
1348
+ {activeTab === "Imágenes" &&
1349
+ (product?.images_status !== "NS" ? (
1350
+ <section className="container">
1351
+ <div {...getRootProps({ className: "dropzone" })}>
1352
+ <input {...getInputProps()} />
1353
+ <aside>{thumbs()}</aside>
1354
+ </div>
1355
+ </section>
1356
+ ) : (
1357
+ <ScreenHeader
1358
+ text={"No cuentas con este servicio"}
1359
+ headerType={"input-name-header"}
1360
+ />
1361
+ ))}
1362
+ </>
1363
+ )}
813
1364
  </div>
814
- {(userAssigned(activeTab, "especialist" || "facilitator") ||
815
- auditorAssigned()) && (
816
- <div className="commentary-box">
817
- {!comments[activeTab] ? (
818
- <div className="commentary">
819
- <TagAndInput
820
- label={"Caja de Comentario"}
821
- inputType={"textarea"}
822
- inputCols={80}
823
- inputRows={4}
824
- />
825
- <div className="buttons-box">
826
- <Button
827
- buttonType={"general-transparent-button"}
828
- label={"Enviar comentario"}
1365
+ {(userAssigned(activeTab) || auditorAssigned()) &&
1366
+ product[`${getConcept(activeTab)}_status`] !== "NS" && (
1367
+ <div className="commentary-box">
1368
+ {!comment ? (
1369
+ <div className="commentary">
1370
+ <TagAndInput
1371
+ label={"Caja de Comentario"}
1372
+ inputType={"textarea"}
1373
+ inputCols={80}
1374
+ inputRows={4}
1375
+ inputId={"commentary-box"}
1376
+ index={0}
1377
+ />
1378
+ <div className="buttons-box">
1379
+ <Button
1380
+ buttonType={"general-transparent-button"}
1381
+ label={"Enviar comentario"}
1382
+ onClick={(e) =>
1383
+ createComment(
1384
+ e,
1385
+ document.querySelector(
1386
+ "#commentary-box .ql-container .ql-editor > p"
1387
+ ).innerHTML,
1388
+ activeTab
1389
+ )
1390
+ }
1391
+ />
1392
+ </div>
1393
+ </div>
1394
+ ) : (
1395
+ <div className="feedback-box">
1396
+ <Commentary
1397
+ comment={comment.message}
1398
+ reviewed={crossComment}
829
1399
  />
830
1400
  <Button
831
- buttonType={
832
- requiredNull !== 0 ||
833
- !specialistValid(activeTab) ||
834
- !versionMatch()
835
- ? "general-button-disabled"
836
- : "general-green-button"
837
- }
838
- label={"Enviar evaluación"}
839
- onClick={() => sendToFacilitator()}
1401
+ buttonType={"circular-button accept-button"}
1402
+ onClick={async () => {
1403
+ setCrossComment(true);
1404
+ commentRevised();
1405
+ }}
840
1406
  />
841
1407
  </div>
842
- </div>
843
- ) : (
844
- <Commentary comment={comments[activeTab].message} />
845
- )}
846
- </div>
847
- )}
1408
+ )}
1409
+ <Button
1410
+ buttonType={
1411
+ evaluationFinished(user.id_role, activeTab, statusArray) &&
1412
+ requiredNull[activeTab] === 0
1413
+ ? "general-green-button"
1414
+ : "general-button-disabled"
1415
+ }
1416
+ label={"Enviar evaluación"}
1417
+ onClick={() => sendToFacilitator()}
1418
+ />
1419
+ </div>
1420
+ )}
848
1421
  </div>
849
1422
  </div>
850
1423
  {showModal && (
@@ -855,6 +1428,25 @@ export const RetailerProductEdition = ({
855
1428
  approveRejectButtons={approveRejectButtons}
856
1429
  />
857
1430
  )}
1431
+ {message.length > 0 && (
1432
+ <GenericModal
1433
+ buttonType={componentsArray.length > 0 && "delete-product"}
1434
+ componentsArray={
1435
+ componentsArray.length > 0
1436
+ ? componentsArray
1437
+ : [
1438
+ <img key="1" src={succes} alt="success icon" />,
1439
+ <ScreenHeader
1440
+ key="2"
1441
+ headerType={"retailer-name-header"}
1442
+ text={message}
1443
+ color={"white"}
1444
+ />,
1445
+ ]
1446
+ }
1447
+ onClick={() => setMessage("")}
1448
+ />
1449
+ )}
858
1450
  </Container>
859
1451
  );
860
1452
  };