contentoh-components-library 10.0.0 → 12.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) 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 +41 -28
  119. package/dist/components/atoms/VerticalSideMenuMainPage/VerticalSideMenuMainPage.stories.js +28 -0
  120. package/dist/components/atoms/VerticalSideMenuMainPage/index.js +98 -0
  121. package/dist/components/atoms/VerticalSideMenuMainPage/styles.js +24 -0
  122. package/dist/components/molecules/AddProvidersAndProducts/AddProvidersAndProducts.stories.js +5 -1
  123. package/dist/components/molecules/AddProvidersAndProducts/index.js +18 -12
  124. package/dist/components/molecules/AssignedWork/AssignedWork.stories.js +5 -1
  125. package/dist/components/molecules/AssignedWork/index.js +36 -30
  126. package/dist/components/molecules/AvatarAndValidation/AvatarAndValidation.stories.js +7 -1
  127. package/dist/components/molecules/AvatarAndValidation/index.js +27 -25
  128. package/dist/components/molecules/CarouselImagesLogin/CarouselImagesLogin.stories.js +37 -0
  129. package/dist/components/molecules/CarouselImagesLogin/index.js +92 -0
  130. package/dist/components/molecules/CarouselImagesLogin/styles.js +21 -0
  131. package/dist/components/molecules/EditionActiveImage/EditionActiveImage.stories.js +7 -1
  132. package/dist/components/molecules/EditionActiveImage/index.js +14 -10
  133. package/dist/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +28 -0
  134. package/dist/components/molecules/EmailResetPasswordLogin/index.js +153 -0
  135. package/dist/components/molecules/EmailResetPasswordLogin/styles.js +20 -0
  136. package/dist/components/molecules/FeaturesBar/FeaturesBar.stories.js +7 -1
  137. package/dist/components/molecules/FeaturesBar/index.js +11 -9
  138. package/dist/components/molecules/GalleryElement/GalleryElement.stories.js +7 -1
  139. package/dist/components/molecules/GalleryElement/index.js +96 -57
  140. package/dist/components/molecules/GalleryHeader/GalleryHeader.stories.js +7 -1
  141. package/dist/components/molecules/GalleryHeader/index.js +46 -16
  142. package/dist/components/molecules/HeaderTop/HeaderTop.stories.js +7 -1
  143. package/dist/components/molecules/HeaderTop/index.js +10 -7
  144. package/dist/components/molecules/ImageSelector/ImageSelector.stories.js +7 -1
  145. package/dist/components/molecules/ImageSelector/index.js +15 -13
  146. package/dist/components/molecules/LoginPasswordStrength/LoginPasswordStrength.stories.js +28 -0
  147. package/dist/components/molecules/LoginPasswordStrength/index.js +126 -0
  148. package/dist/components/molecules/LoginPasswordStrength/styles.js +78 -0
  149. package/dist/components/molecules/LogoLoading/Loading.stories.js +28 -0
  150. package/dist/components/molecules/LogoLoading/index.js +22 -0
  151. package/dist/components/molecules/LogoLoading/styles.js +18 -0
  152. package/dist/components/molecules/ParentComponent/ParentComponent.stories.js +10 -2
  153. package/dist/components/molecules/ParentComponent/index.js +9 -5
  154. package/dist/components/molecules/PayMethod/PayMethod.stories.js +7 -1
  155. package/dist/components/molecules/PayMethod/index.js +38 -33
  156. package/dist/components/molecules/PlanSelection/PlanSelection.stories.js +7 -1
  157. package/dist/components/molecules/PlanSelection/index.js +14 -11
  158. package/dist/components/molecules/ProductNameHeader/ProductNameHeader.stories.js +7 -1
  159. package/dist/components/molecules/ProductNameHeader/index.js +18 -14
  160. package/dist/components/molecules/ProductNotification/ProductNotification.stories.js +7 -1
  161. package/dist/components/molecules/ProductNotification/index.js +12 -9
  162. package/dist/components/molecules/ProfileHeader/ProfileHeader.stories.js +5 -1
  163. package/dist/components/molecules/ProfileHeader/index.js +21 -15
  164. package/dist/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +28 -0
  165. package/dist/components/molecules/RegistrationFirstStep/index.js +308 -0
  166. package/dist/components/molecules/RegistrationFirstStep/styles.js +20 -0
  167. package/dist/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +28 -0
  168. package/dist/components/molecules/RegistrationSecondStep/index.js +172 -0
  169. package/dist/components/molecules/RegistrationSecondStep/styles.js +20 -0
  170. package/dist/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +28 -0
  171. package/dist/components/molecules/RegistrationThirdStep/index.js +155 -0
  172. package/dist/components/molecules/RegistrationThirdStep/styles.js +20 -0
  173. package/dist/components/molecules/RetailerSelector/RetailerSelector.stories.js +7 -1
  174. package/dist/components/molecules/RetailerSelector/index.js +36 -25
  175. package/dist/components/molecules/RetailerSelector/styles.js +1 -1
  176. package/dist/components/molecules/SidebarNotification/SidebarNotification.stories.js +5 -1
  177. package/dist/components/molecules/SidebarNotification/index.js +43 -37
  178. package/dist/components/molecules/SignInLogin/SignInLogin.stories.js +28 -0
  179. package/dist/components/molecules/SignInLogin/index.js +315 -0
  180. package/dist/components/molecules/SignInLogin/styles.js +20 -0
  181. package/dist/components/molecules/StatusAsignationInfo/StatusAsignationInfo.stories.js +7 -1
  182. package/dist/components/molecules/StatusAsignationInfo/index.js +111 -98
  183. package/dist/components/molecules/StatusAsignationInfo/styles.js +1 -1
  184. package/dist/components/molecules/TableHeader/TableHeader.stories.js +7 -1
  185. package/dist/components/molecules/TableHeader/index.js +21 -9
  186. package/dist/components/molecules/TableHeader/styles.js +1 -1
  187. package/dist/components/molecules/TableRow/TableRow.stories.js +7 -1
  188. package/dist/components/molecules/TableRow/index.js +11 -7
  189. package/dist/components/molecules/TabsMenu/TabsMenu.stories.js +7 -1
  190. package/dist/components/molecules/TabsMenu/index.js +13 -10
  191. package/dist/components/molecules/TagAndInput/TagAndInput.stories.js +7 -1
  192. package/dist/components/molecules/TagAndInput/index.js +43 -23
  193. package/dist/components/molecules/TagAndInput/styles.js +10 -2
  194. package/dist/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +28 -0
  195. package/dist/components/molecules/VerificationCodeResetPasswordLogin/index.js +211 -0
  196. package/dist/components/molecules/VerificationCodeResetPasswordLogin/styles.js +20 -0
  197. package/dist/components/molecules/VerificationCodeResetPasswordLogin/utils.js +69 -0
  198. package/dist/components/organisms/ChangePassword/ChangePassword.stories.js +28 -0
  199. package/dist/components/organisms/ChangePassword/index.js +124 -0
  200. package/dist/components/organisms/ChangePassword/styles.js +18 -0
  201. package/dist/components/organisms/FullProductNameHeader/FullProductNameHeader.stories.js +7 -1
  202. package/dist/components/organisms/FullProductNameHeader/index.js +64 -34
  203. package/dist/components/organisms/FullTabsMenu/FullTabsMenu.stories.js +7 -1
  204. package/dist/components/organisms/FullTabsMenu/index.js +30 -23
  205. package/dist/components/organisms/Fullplan/FullPlan.stories.js +7 -1
  206. package/dist/components/organisms/Fullplan/index.js +23 -15
  207. package/dist/components/organisms/GlobalModal/index.js +73 -0
  208. package/dist/components/organisms/GlobalModal/styles.js +66 -0
  209. package/dist/components/organisms/ImageDataTable/ImageDataTable.stories.js +7 -1
  210. package/dist/components/organisms/ImageDataTable/index.js +85 -62
  211. package/dist/components/organisms/ImagePreviewer/ImagePreviewer.stories.js +7 -1
  212. package/dist/components/organisms/ImagePreviewer/index.js +12 -8
  213. package/dist/components/organisms/ImagesGroup/index.js +5 -1
  214. package/dist/components/organisms/InputGroup/InputGroup.stories.js +7 -1
  215. package/dist/components/organisms/InputGroup/index.js +44 -37
  216. package/dist/components/organisms/InputGroup/styles.js +1 -1
  217. package/dist/components/organisms/ProductImageModal/ProductImageModal.stories.js +7 -1
  218. package/dist/components/organisms/ProductImageModal/index.js +49 -46
  219. package/dist/components/organisms/ProductImageModal/styles.js +1 -1
  220. package/dist/components/pages/ChangePasswordLogin/ChangePasswordLogin.stories.js +38 -0
  221. package/dist/components/pages/ChangePasswordLogin/index.js +108 -0
  222. package/dist/components/pages/ChangePasswordLogin/styles.js +18 -0
  223. package/dist/components/pages/CustomerLogin/CustomerLogin.stories.js +52 -47
  224. package/dist/components/pages/CustomerLogin/index.js +18 -12
  225. package/dist/components/pages/CustomerPayMethod/CustomerPayMethod.stories.js +36 -28
  226. package/dist/components/pages/CustomerPayMethod/index.js +18 -12
  227. package/dist/components/pages/CustomerType/CustomerType.stories.js +21 -22
  228. package/dist/components/pages/CustomerType/index.js +18 -12
  229. package/dist/components/pages/EmailResetPassword/EmailResetPassword.stories.js +37 -0
  230. package/dist/components/pages/EmailResetPassword/index.js +130 -0
  231. package/dist/components/pages/EmailResetPassword/styles.js +20 -0
  232. package/dist/components/pages/OnboardPlan/OnboardPlan.stories.js +12 -9
  233. package/dist/components/pages/OnboardPlan/index.js +18 -12
  234. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +175 -0
  235. package/dist/components/pages/ProviderProductEdition/index.js +1800 -0
  236. package/dist/components/pages/ProviderProductEdition/styles.js +23 -0
  237. package/dist/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +37 -0
  238. package/dist/components/pages/RegistrationLoginFirstStep/index.js +269 -0
  239. package/dist/components/pages/RegistrationLoginFirstStep/styles.js +20 -0
  240. package/dist/components/pages/RegistrationLoginSecondStep/RegistrationLoginSecondStep.stories.js +38 -0
  241. package/dist/components/pages/RegistrationLoginSecondStep/index.js +176 -0
  242. package/dist/components/pages/RegistrationLoginSecondStep/styles.js +20 -0
  243. package/dist/components/pages/RegistrationLoginThirdStep/RegistrationLoginThirdStep.stories.js +37 -0
  244. package/dist/components/pages/RegistrationLoginThirdStep/index.js +178 -0
  245. package/dist/components/pages/RegistrationLoginThirdStep/styles.js +20 -0
  246. package/dist/components/pages/RetailerPlan/RetailerPlan.stories.js +13 -10
  247. package/dist/components/pages/RetailerPlan/index.js +18 -12
  248. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +41 -75
  249. package/dist/components/pages/RetailerProductEdition/index.js +1180 -590
  250. package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
  251. package/dist/components/pages/VerificationCodeResetPassword/VerificationCodeResetPassword.stories.js +37 -0
  252. package/dist/components/pages/VerificationCodeResetPassword/index.js +121 -0
  253. package/dist/components/pages/VerificationCodeResetPassword/styles.js +20 -0
  254. package/dist/components/pages/VerificationCodeResetPassword/utils.js +69 -0
  255. package/dist/global-files/data.js +85 -14
  256. package/dist/index.js +316 -100
  257. package/package.json +28 -8
  258. package/src/assets/images/carouselImagesLogin/login2.svg +117 -0
  259. package/src/assets/images/carouselImagesLogin/login3.svg +147 -0
  260. package/src/assets/images/carouselImagesLogin/loginImage.svg +301 -0
  261. package/src/assets/images/editField/showPassword.png +0 -0
  262. package/src/assets/images/generalButton/downloadIcon.svg +3 -0
  263. package/src/assets/images/genericModal/closeWhite.svg +3 -0
  264. package/src/assets/images/genericModal/errorModal.svg +3 -0
  265. package/src/assets/images/genericModal/yellowAlert.svg +12 -0
  266. package/src/assets/images/sliderToolTip/infoIcon.svg +4 -0
  267. package/src/assets/images/sliderToolTip/slide1.svg +5 -0
  268. package/src/assets/images/sliderToolTip/slide2.svg +9 -0
  269. package/src/assets/images/sliderToolTip/slide3.svg +9 -0
  270. package/src/assets/images/sliderToolTip/slide4.svg +9 -0
  271. package/src/assets/images/sliderToolTip/slide5.svg +40 -0
  272. package/src/assets/images/verticalSideMenuMainPage/closeMenu.svg +4 -0
  273. package/src/assets/images/verticalSideMenuMainPage/iconFAQS.svg +12 -0
  274. package/src/assets/images/verticalSideMenuMainPage/iconGroup.svg +3 -0
  275. package/src/assets/images/verticalSideMenuMainPage/iconLogo.svg +12 -0
  276. package/src/assets/images/verticalSideMenuMainPage/iconLogoContentoh.svg +15 -0
  277. package/src/assets/images/verticalSideMenuMainPage/iconProduct.svg +3 -0
  278. package/src/assets/images/verticalSideMenuMainPage/iconSpeedometer.svg +12 -0
  279. package/src/assets/images/verticalSideMenuMainPage/iconTask.svg +10 -0
  280. package/src/assets/images/verticalSideMenuMainPage/openMenu.svg +4 -0
  281. package/src/components/atoms/AsignationOption/index.js +18 -1
  282. package/src/components/atoms/AsignationOption/styles.js +19 -1
  283. package/src/components/atoms/CharCounter/CharCounter.stories.js +11 -0
  284. package/src/components/atoms/CharCounter/index.js +13 -0
  285. package/src/components/atoms/CharCounter/styles.js +10 -0
  286. package/src/components/atoms/CheckBox/index.js +8 -2
  287. package/src/components/atoms/Commentary/index.js +2 -2
  288. package/src/components/atoms/Commentary/styles.js +1 -0
  289. package/src/components/atoms/DropDownButton/styles.js +6 -0
  290. package/src/components/atoms/GeneralButton/index.js +1 -0
  291. package/src/components/atoms/GeneralButton/styles.js +14 -0
  292. package/src/components/atoms/GeneralInput/index.js +109 -62
  293. package/src/components/atoms/GeneralInput/styles.js +34 -0
  294. package/src/components/atoms/GenericModal/index.js +2 -2
  295. package/src/components/atoms/GenericModal/styles.js +11 -3
  296. package/src/components/atoms/GradientPanel/styles.js +8 -1
  297. package/src/components/atoms/Input/index.js +2 -1
  298. package/src/components/atoms/Input/style.js +9 -5
  299. package/src/components/atoms/InputFormatter/Wysiwyg.stories.js +12 -0
  300. package/src/components/atoms/InputFormatter/index.js +146 -0
  301. package/src/components/atoms/InputFormatter/styles.js +41 -0
  302. package/src/components/atoms/LabelToInput/index.js +0 -1
  303. package/src/components/atoms/LabelToInput/style.js +15 -4
  304. package/src/components/atoms/Loading/Loading.stories.js +10 -0
  305. package/src/components/atoms/Loading/index.js +13 -0
  306. package/src/components/atoms/Loading/styles.js +57 -0
  307. package/src/components/atoms/LogoImage/index.js +1 -1
  308. package/src/components/atoms/ProductPercentCard/Percent.stories.js +41 -0
  309. package/src/components/atoms/ProductPercentCard/index.js +23 -0
  310. package/src/components/atoms/{Percent → ProductPercentCard}/styles.js +11 -7
  311. package/src/components/atoms/ProgressBar/styles.js +2 -1
  312. package/src/components/atoms/ScreenHeader/index.js +7 -3
  313. package/src/components/atoms/ScreenHeader/styles.js +14 -2
  314. package/src/components/atoms/Select/index.js +3 -1
  315. package/src/components/atoms/Select/style.js +1 -2
  316. package/src/components/atoms/SliderToolTip/SliderToolTip.stories.js +23 -0
  317. package/src/components/atoms/SliderToolTip/index.js +182 -0
  318. package/src/components/atoms/SliderToolTip/styles.js +168 -0
  319. package/src/components/atoms/StatusTag/index.js +30 -2
  320. package/src/components/atoms/StatusTag/styles.js +9 -4
  321. package/src/components/atoms/ValidationPanel/index.js +4 -3
  322. package/src/components/atoms/VerticalSideMenuMainPage/VerticalSideMenuMainPage.stories.js +12 -0
  323. package/src/components/atoms/VerticalSideMenuMainPage/index.js +54 -0
  324. package/src/components/atoms/VerticalSideMenuMainPage/styles.js +45 -0
  325. package/src/components/molecules/AvatarAndValidation/index.js +14 -15
  326. package/src/components/molecules/CarouselImagesLogin/CarouselImagesLogin.stories.js +17 -0
  327. package/src/components/molecules/CarouselImagesLogin/index.js +65 -0
  328. package/src/components/molecules/CarouselImagesLogin/styles.js +60 -0
  329. package/src/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +11 -0
  330. package/src/components/molecules/EmailResetPasswordLogin/index.js +85 -0
  331. package/src/components/molecules/EmailResetPasswordLogin/styles.js +23 -0
  332. package/src/components/molecules/GalleryElement/index.js +26 -6
  333. package/src/components/molecules/GalleryHeader/index.js +8 -2
  334. package/src/components/molecules/LoginPasswordStrength/LoginPasswordStrength.stories.js +8 -0
  335. package/src/components/molecules/LoginPasswordStrength/index.js +84 -0
  336. package/src/components/molecules/LoginPasswordStrength/styles.js +91 -0
  337. package/src/components/molecules/LogoLoading/Loading.stories.js +10 -0
  338. package/src/components/molecules/LogoLoading/index.js +12 -0
  339. package/src/components/molecules/LogoLoading/styles.js +16 -0
  340. package/src/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +11 -0
  341. package/src/components/molecules/RegistrationFirstStep/index.js +227 -0
  342. package/src/components/molecules/RegistrationFirstStep/styles.js +87 -0
  343. package/src/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +11 -0
  344. package/src/components/molecules/RegistrationSecondStep/index.js +135 -0
  345. package/src/components/molecules/RegistrationSecondStep/styles.js +64 -0
  346. package/src/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +11 -0
  347. package/src/components/molecules/RegistrationThirdStep/index.js +130 -0
  348. package/src/components/molecules/RegistrationThirdStep/styles.js +44 -0
  349. package/src/components/molecules/RetailerSelector/index.js +7 -1
  350. package/src/components/molecules/RetailerSelector/styles.js +3 -0
  351. package/src/components/molecules/SignInLogin/SignInLogin.stories.js +11 -0
  352. package/src/components/molecules/SignInLogin/index.js +226 -0
  353. package/src/components/molecules/SignInLogin/styles.js +120 -0
  354. package/src/components/molecules/StatusAsignationInfo/index.js +60 -53
  355. package/src/components/molecules/StatusAsignationInfo/styles.js +8 -2
  356. package/src/components/molecules/TableHeader/index.js +14 -2
  357. package/src/components/molecules/TableHeader/styles.js +8 -0
  358. package/src/components/molecules/TagAndInput/index.js +19 -1
  359. package/src/components/molecules/TagAndInput/styles.js +28 -0
  360. package/src/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +11 -0
  361. package/src/components/molecules/VerificationCodeResetPasswordLogin/index.js +171 -0
  362. package/src/components/molecules/VerificationCodeResetPasswordLogin/styles.js +54 -0
  363. package/src/components/molecules/VerificationCodeResetPasswordLogin/utils.js +54 -0
  364. package/src/components/organisms/ChangePassword/ChangePassword.stories.js +11 -0
  365. package/src/components/organisms/ChangePassword/index.js +77 -0
  366. package/src/components/organisms/ChangePassword/styles.js +13 -0
  367. package/src/components/organisms/FullProductNameHeader/index.js +47 -16
  368. package/src/components/organisms/FullTabsMenu/index.js +15 -12
  369. package/src/components/organisms/GlobalModal/index.js +68 -0
  370. package/src/components/organisms/GlobalModal/styles.js +113 -0
  371. package/src/components/organisms/ImageDataTable/index.js +29 -8
  372. package/src/components/organisms/InputGroup/index.js +28 -8
  373. package/src/components/organisms/InputGroup/styles.js +2 -2
  374. package/src/components/organisms/ProductImageModal/index.js +8 -9
  375. package/src/components/organisms/ProductImageModal/styles.js +3 -0
  376. package/src/components/pages/ChangePasswordLogin/ChangePasswordLogin.stories.js +18 -0
  377. package/src/components/pages/ChangePasswordLogin/index.js +77 -0
  378. package/src/components/pages/ChangePasswordLogin/styles.js +20 -0
  379. package/src/components/pages/EmailResetPassword/EmailResetPassword.stories.js +17 -0
  380. package/src/components/pages/EmailResetPassword/index.js +77 -0
  381. package/src/components/pages/EmailResetPassword/styles.js +27 -0
  382. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +172 -0
  383. package/src/components/pages/ProviderProductEdition/index.js +1275 -0
  384. package/src/components/pages/ProviderProductEdition/styles.js +118 -0
  385. package/src/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +17 -0
  386. package/src/components/pages/RegistrationLoginFirstStep/index.js +160 -0
  387. package/src/components/pages/RegistrationLoginFirstStep/styles.js +85 -0
  388. package/src/components/pages/RegistrationLoginSecondStep/RegistrationLoginSecondStep.stories.js +18 -0
  389. package/src/components/pages/RegistrationLoginSecondStep/index.js +111 -0
  390. package/src/components/pages/RegistrationLoginSecondStep/styles.js +64 -0
  391. package/src/components/pages/RegistrationLoginThirdStep/RegistrationLoginThirdStep.stories.js +17 -0
  392. package/src/components/pages/RegistrationLoginThirdStep/index.js +106 -0
  393. package/src/components/pages/RegistrationLoginThirdStep/styles.js +48 -0
  394. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +32 -65
  395. package/src/components/pages/RetailerProductEdition/index.js +924 -442
  396. package/src/components/pages/RetailerProductEdition/styles.js +17 -3
  397. package/src/components/pages/VerificationCodeResetPassword/VerificationCodeResetPassword.stories.js +17 -0
  398. package/src/components/pages/VerificationCodeResetPassword/index.js +92 -0
  399. package/src/components/pages/VerificationCodeResetPassword/styles.js +54 -0
  400. package/src/components/pages/VerificationCodeResetPassword/utils.js +56 -0
  401. package/src/global-files/data.js +56 -8
  402. package/src/index.js +23 -8
  403. package/src/components/atoms/Percent/Percent.stories.js +0 -38
  404. 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,20 @@ 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
+ location = {},
81
+ token,
62
82
  }) => {
63
83
  const [activeTab, setActiveTab] = useState("Descripción");
64
84
  const [activeImage, setActiveImage] = useState();
65
- const [imageLayout, setImageLayout] = useState(true);
85
+ const [imageLayout, setImageLayout] = useState(false);
66
86
  const [headerTop, setHeaderTop] = useState(0);
67
87
  const [descriptions, setDescriptions] = useState([]);
68
88
  const [datasheets, setDatasheets] = useState([]);
69
89
  const [images, setImages] = useReducer(reducerImages, {});
70
90
  const [showModal, setShowModal] = useState(false);
71
- const [retailerSelected, setRetailerSelected] = useState(54); // revisar después como trabajar esto de mejor forma
72
91
  const { getRootProps, getInputProps } = useDropzone({
73
92
  accept: "image/*",
74
93
  noKeyboard: true,
@@ -79,23 +98,25 @@ export const RetailerProductEdition = ({
79
98
  acceptedFiles.map((file) => {
80
99
  const reader = new FileReader();
81
100
  reader.fileName = file.name;
82
- reader.onload = async function (e) {
101
+ reader.onload = function (e) {
83
102
  const ext = e.srcElement.fileName.split(".");
84
103
  const img = new Image();
85
104
  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);
105
+ setTimeout(() => {
106
+ const width = img.width;
107
+ const height = img.height;
108
+ const newImg = {
109
+ action: "addImg",
110
+ img: {
111
+ src: e.target.result,
112
+ name: e.target.fileName,
113
+ ext: ext[ext.length - 1],
114
+ width: width,
115
+ height: height,
116
+ },
117
+ };
118
+ setImages(newImg);
119
+ }, 500);
99
120
  };
100
121
  reader.onerror = function (error) {
101
122
  console.log("dropzoneError: ", error);
@@ -110,63 +131,90 @@ export const RetailerProductEdition = ({
110
131
  const [imagesUploaded, setImagesUploaded] = useState(false);
111
132
  const [dataImages, setDataImages] = useState();
112
133
  const [percentages, setPercentages] = useState(
113
- new Array(productSelected.retailers.length).fill({ percentage: 0 })
134
+ new Array(product?.retailers?.length).fill({ percentage: 0 })
114
135
  );
115
136
  const [activePercentage, setActivePercentage] = useState(0);
116
137
  const [activeRetailer, setActiveRetailer] = useState({});
117
138
  const [services, setServices] = useState([]);
118
139
  const [servicesData, setServicesData] = useState([]);
119
140
  const [message, setMessage] = useState("");
120
- const [product, setProduct] = useState({});
141
+ const [product, setProduct] = useState(
142
+ JSON.parse(sessionStorage.getItem("productSelected"))
143
+ ? JSON.parse(sessionStorage.getItem("productSelected"))
144
+ : productSelected
145
+ );
121
146
  const [icon, setIcon] = useState(null);
122
- const [version, setVersion] = useState(productSelected?.version);
147
+ const [version, setVersion] = useState(product?.version);
123
148
  const [comments, setComments] = useState({});
124
- const [requiredNull, setRequiredNull] = useState(0);
149
+ const [comment, setComment] = useState("");
150
+ const [requiredNull, setRequiredNull] = useState({
151
+ "Ficha técnica": 0,
152
+ Descripción: 0,
153
+ Imágenes: 0,
154
+ });
155
+ const [crossComment, setCrossComment] = useState(false);
156
+ const [userGroups, setUserGroups] = useState([]);
157
+ const [assig, setAssig] = useState({});
158
+ const [selectedImages, setSelectedImages] = useState([]);
159
+ const [componentsArray, setComponentsArray] = useState([]);
160
+ const [checkAll, setCheckAll] = useState(false);
161
+ const isRetailer = user?.is_retailer;
162
+ const [loading, setLoading] = useState(true);
163
+ const [retailerStatus, setRetailerStatus] = useState("-");
164
+ const [statusArray, setStatusArray] = useState([]);
165
+ const [socketType, setSocketType] = useState(null);
166
+ const [servicesStatus, setServicesStatus] = useState([]);
167
+ const [saving, setSaving] = useState(loading);
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
+ parseInt(product?.article?.id_category),
178
+ product?.version
179
+ );
180
+ //Converts the data inside the datasheets object to array
181
+ setServices(services);
182
+ getServices();
143
183
 
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;
184
+ //setActiveRetailer(product?.retailers[0]);
185
+ setImages({
186
+ action: "init",
187
+ init: services[2],
188
+ });
189
+ if (services[2]?.values?.length > 0) setActiveImage(0);
190
+
191
+ getPercentage({ data: [product] }).then((res) => setPercentages(res));
192
+ setLoading(false);
193
+ } catch (error) {
194
+ console.log(error);
156
195
  }
157
- const selected = productSelected;
196
+ };
197
+
198
+ const getServices = async () => {
158
199
  const servicesResponse = await axios.get(
159
- `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${selected.article.id_article}&orderId=${selected.article.id_order}&end=true`
200
+ `${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${
201
+ product?.article?.id_article
202
+ }&orderId=${product?.article?.id_order || product.orderId}&end=true`
160
203
  );
161
- const parsedResponse = JSON.parse(servicesResponse.data.body).data;
204
+ const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
162
205
 
206
+ let retailers = product.retailers || product.retailersAvailable;
207
+ let active = retailers?.filter((retailer) =>
208
+ parsedResponse?.map((srv) => srv.id_retailer).includes(retailer.id)
209
+ )[0];
210
+ !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
163
211
  setServicesData(parsedResponse);
164
212
  };
165
213
 
166
214
  const translateConcept = (concept) => {
167
215
  let translation = "";
168
216
  if (concept === "datasheet") {
169
- translation = "Ficha ténica";
217
+ translation = "Ficha técnica";
170
218
  } else if (concept === "description") {
171
219
  translation = "Descripción";
172
220
  } else if (concept === "images") {
@@ -175,183 +223,292 @@ export const RetailerProductEdition = ({
175
223
  return translation;
176
224
  };
177
225
 
178
- const getComments = async (tab) => {
226
+ const getComments = async (tab = "Descripción") => {
179
227
  const commentsResponse = await Promise.all([
180
228
  axios.get(
181
- `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${productSelected?.article?.id_article}&concept=description&orderIdColab=${productSelected?.orderId}&version=${version}`
229
+ `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${product?.article?.id_article}&concept=description&orderIdColab=${product?.orderId}&version=${version}`
182
230
  ),
183
231
  axios.get(
184
- `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${productSelected?.article?.id_article}&concept=datasheet&orderIdColab=${productSelected?.orderId}&version=${version}`
232
+ `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${product?.article?.id_article}&concept=datasheet&orderIdColab=${product?.orderId}&version=${version}`
185
233
  ),
186
234
  axios.get(
187
- `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${productSelected?.article?.id_article}&concept=images&orderIdColab=${productSelected?.orderId}&version=${version}`
235
+ `${process.env.REACT_APP_COMMENTS_ENDPOINT}?articleId=${product?.article?.id_article}&concept=images&orderIdColab=${product?.orderId}&version=${version}`
188
236
  ),
189
237
  ]);
190
238
 
191
239
  let comments = {};
192
- commentsResponse.map(
240
+ commentsResponse.forEach(
193
241
  (comment) =>
194
- JSON.parse(comment.data.body).data[0] &&
242
+ JSON.parse(comment?.data?.body).data[0] &&
195
243
  (comments[
196
- translateConcept(JSON.parse(comment.data.body).data[0]?.concept)
197
- ] = JSON.parse(comment.data.body).data[0])
244
+ translateConcept(JSON.parse(comment?.data?.body)?.data[0]?.concept)
245
+ ] = JSON.parse(comment?.data?.body).data[0])
198
246
  );
247
+ setComment(comments[tab]);
199
248
  setComments(comments);
200
- //const comment = JSON.parse(commentsResponse.data.body).data;
201
- //setComment(comment[0]);
202
249
  };
203
250
 
204
- useEffect(() => {
251
+ useEffect(async () => {
205
252
  loadData();
206
- getPercentage({ data: [productSelected] }).then((res) =>
207
- setPercentages(res)
208
- );
209
- getServices();
210
253
  getComments();
211
- }, []);
254
+ setUserGroups(await fetchUsers(token));
255
+ let arr = [];
256
+ switch (user.id_role) {
257
+ case 7:
258
+ case 8:
259
+ arr = ["IN_PROGRESS", "RF", "RA"];
260
+ break;
261
+ case 4:
262
+ case 5:
263
+ arr = ["RF", "AF", "AA", "AP", "AC"];
264
+ break;
265
+ case 6:
266
+ arr = ["RP", "RC", "AF", "RA"];
267
+ break;
268
+ default:
269
+ arr = [];
270
+ break;
271
+ }
272
+ setStatusArray(arr);
273
+ }, [product]);
274
+
275
+ const loadAssignations = (currentProduct) => {
276
+ setAssig({
277
+ Descripción: {
278
+ assignations: [
279
+ {
280
+ collaboratorType: "especialist",
281
+ id: currentProduct?.article?.id_description_especialist,
282
+ },
283
+ {
284
+ collaboratorType: "facilitator",
285
+ id: currentProduct?.article?.id_description_facilitator,
286
+ },
287
+ ],
288
+ collaborators: {
289
+ especialist: userGroups[0] || [],
290
+ facilitator: userGroups[2] || [],
291
+ },
292
+ },
293
+ "Ficha técnica": {
294
+ assignations: [
295
+ {
296
+ collaboratorType: "especialist",
297
+ id: currentProduct?.article?.id_datasheet_especialist,
298
+ },
299
+ {
300
+ collaboratorType: "facilitator",
301
+ id: currentProduct?.article?.id_datasheet_facilitator,
302
+ },
303
+ ],
304
+ collaborators: {
305
+ especialist: userGroups[0] || [],
306
+ facilitator: userGroups[2] || [],
307
+ },
308
+ },
309
+ Imágenes: {
310
+ assignations: [
311
+ {
312
+ collaboratorType: "especialist",
313
+ id: currentProduct?.article?.id_images_especialist,
314
+ },
315
+ {
316
+ collaboratorType: "facilitator",
317
+ id: currentProduct?.article?.id_images_facilitator,
318
+ },
319
+ ],
320
+ collaborators: {
321
+ especialist: userGroups[1] || [],
322
+ facilitator: userGroups[3] || [],
323
+ },
324
+ },
325
+ });
326
+ };
212
327
 
213
328
  useEffect(() => {
214
- productSelected.retailers.forEach((retailer) => {
215
- retailer["percentage"] = percentages.filter(
216
- (percent) => retailer.id === percent.id_retailer
329
+ loadAssignations(product);
330
+ }, [userGroups]);
331
+
332
+ useEffect(() => {
333
+ product?.retailers?.forEach((retailer) => {
334
+ retailer["percentage"] = percentages?.filter(
335
+ (percent) => retailer?.id === percent?.id_retailer
217
336
  )[0]?.percentage;
218
337
  });
219
- setActivePercentage(productSelected?.retailers[0]?.percentage);
338
+ setActivePercentage(product?.retailers[0]?.percentage);
220
339
  }, [percentages]);
221
340
 
222
341
  useEffect(() => {
223
342
  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)
343
+ if (services[0][activeRetailer.id]?.data)
344
+ services[0][activeRetailer.id].data = Object.values(
345
+ services[0][activeRetailer.id].data
346
+ );
347
+ setActivePercentage(Math.round(activeRetailer?.percentage, 0));
348
+
349
+ const datagroups = services[0][activeRetailer?.id];
350
+ const inputs = services[0]?.inputs;
351
+ const descriptions = services[1]?.filter(
352
+ (service) => service?.id === activeRetailer?.id
231
353
  );
354
+ setDatasheets([datagroups, inputs]);
355
+ setDescriptions(descriptions);
232
356
  }
233
- }, [activeRetailer]);
357
+ }, [activeRetailer, services]);
234
358
 
235
359
  const thumbs = () => {
236
- const imageInputs = images.inputs.map((e) => ({
237
- value: e.id,
238
- name: e.name,
360
+ const imageInputs = socketType?.slice();
361
+ const imageType = images?.imageType?.map((e) => ({
362
+ value: e?.id,
363
+ name: e?.name,
239
364
  }));
240
- const imageType = images.imageType.map((e) => ({
241
- value: e.id,
242
- name: e.name,
243
- }));
244
- const imagePackagingType = images.imagePackagingType.map((e) => ({
245
- value: e.id,
246
- name: e.name,
365
+ const imagePackagingType = images?.imagePackagingType?.map((e) => ({
366
+ value: e?.id,
367
+ name: e?.name,
247
368
  }));
248
369
  return images?.values?.map((image, index) => (
249
370
  <GalleryElement
371
+ setCheckAll={setCheckAll}
250
372
  key={index}
251
373
  image={image}
252
374
  gridLayout={imageLayout}
253
375
  id={"gallery-element-" + index}
254
- index={index}
376
+ index={index + "-" + image.name}
377
+ number={index}
255
378
  imageType={imageType}
256
379
  imagePackagingType={imagePackagingType}
257
380
  imageInputs={imageInputs}
381
+ setSocketType={setSocketType}
258
382
  changeImage={setImages}
383
+ selectedImages={selectedImages}
384
+ setSelectedImages={setSelectedImages}
259
385
  />
260
386
  ));
261
387
  };
262
388
 
263
389
  const saveDescriptions = async () => {
390
+ setLoading(true);
391
+ const productTemp = product;
264
392
  const dataObject = {
265
- articleId: productSelected?.article?.id_article,
393
+ articleId: product?.article?.id_article,
266
394
  articleData: updatedDescriptions,
267
395
  };
396
+ if (product?.orderId) dataObject["orderId"] = product?.orderId;
268
397
  try {
269
398
  await axios.put(
270
399
  `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?description=true&version=${version}`,
271
400
  dataObject,
272
401
  {
273
402
  headers: {
274
- Authorization:
275
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIxYTk4MzZlNS1kMDYyLTQ4ZjQtYjY4Yi04NDZhZWEwMDFlMDIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY0NjM1MzAyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2NDYzNTY2MjMsImlhdCI6MTY0NjM1MzAyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.LX6wMUK1eiE49heX3nVIMR4oRrWEaI-xyUErYx9_AWlxLn5jksbmmZmXujeaailxxcvaVQDYIbKSyrahwmqUohaDChM3TgDHCHTvAeiDGoVAFIjKyzk_wzttgVrKu5P_45bNrds7PVmLC981W8aVdQO32JklWhCpO_jEbtIgGeklQ6PF9yOd5TEWtq4kJTuYrbZpl21qnZ_wopbLSOz4Ty_OoIbvkFFcPV2jSBsMggQns3GqlHjlCLMtSN43IgQbuZ711BPWk6MMIFI48tl7HEC9rm1z1l0aejtn7ooiYKNsV2V__OL0Mi3ziDmoTDp3Ra02m0J176b99V17mFmj7A",
403
+ Authorization: token,
276
404
  },
277
405
  }
278
406
  );
407
+ if (productTemp.status === "ASSIGNED") {
408
+ productTemp.status = "IN_PROGRESS";
409
+ setProduct(productTemp);
410
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
411
+ }
412
+
413
+ setMessage("Descripciones guardadas con éxito");
414
+ loadData();
279
415
  } catch (error) {
280
416
  console.log(error);
281
417
  }
282
418
  };
283
419
 
284
420
  const saveDatasheets = async () => {
421
+ setLoading(true);
422
+ const productTemp = product;
285
423
  const dataObject = {
286
- articleId: productSelected?.article?.id_article,
424
+ articleId: product?.article?.id_article,
287
425
  articleData: updatedDatasheets,
288
426
  };
427
+ console.log(updatedDatasheets, "updatedDatasheets");
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);
597
767
 
768
+ const allowedRoles = [1, 4, 5, 6, 7, 8];
769
+ const validUser = allowedRoles.includes(user?.id_role);
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,146 @@ 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.forEach((e) => {
960
+ if (e.id) {
961
+ saveAs(
962
+ `https://${process.env.REACT_APP_IMAGES_BUCKET}.s3.amazonaws.com/${e.srcDB}`,
963
+ `${product.article.upc}_${e.name}.${e.ext}`
964
+ );
965
+ }
966
+ });
967
+ };
968
+
969
+ const deleteImages = () => {
970
+ setLoading(true);
971
+ const { values } = images;
972
+ const imgsInBack = [];
973
+
974
+ selectedImages.forEach((selectedImg) => {
975
+ if (selectedImg.id) imgsInBack.push(selectedImg);
976
+ });
977
+
978
+ const imgsLeft = values.filter(
979
+ (value) => selectedImages.indexOf(value) === -1
669
980
  );
670
- }
671
981
 
672
- function versionMatch() {
673
- return productSelected?.version === version;
674
- }
982
+ if (imgsInBack.length > 0) {
983
+ const data = {
984
+ articleId: product.article.id_article,
985
+ deleteImages: imgsInBack,
986
+ orderId: product.orderId,
987
+ };
988
+ try {
989
+ axios.put(
990
+ `${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
991
+ data,
992
+ {
993
+ headers: { Authorization: token },
994
+ }
995
+ );
996
+ } catch (err) {
997
+ console.log(err);
998
+ }
999
+ }
1000
+
1001
+ setImages({
1002
+ action: "deleteImage",
1003
+ selectedImages,
1004
+ });
1005
+
1006
+ getRequired([
1007
+ services[0],
1008
+ services[1],
1009
+ { ...services[2], values: imgsLeft },
1010
+ ]);
1011
+
1012
+ setTimeout(() => {
1013
+ setLoading(false);
1014
+ }, 500);
1015
+
1016
+ setMessage("");
1017
+ setComponentsArray([]);
1018
+ };
1019
+
1020
+ const askToDeleteImages = () => {
1021
+ if (selectedImages.length > 0) {
1022
+ setMessage("¿Está seguro de eliminar las imágenes seleccionadas?");
1023
+ setComponentsArray([
1024
+ <ScreenHeader
1025
+ key={"1"}
1026
+ text={"¿Está seguro de eliminar las imágenes seleccionadas?"}
1027
+ headerType="retailer-name-header"
1028
+ color={"white"}
1029
+ />,
1030
+ <Button
1031
+ key={"2"}
1032
+ buttonType="general-white-button"
1033
+ label={"Cancelar"}
1034
+ onClick={() => setMessage("")}
1035
+ />,
1036
+ <Button
1037
+ key={"3"}
1038
+ buttonType="general-button-default"
1039
+ label={"Aceptar"}
1040
+ onClick={() => {
1041
+ setMessage("");
1042
+ deleteImages();
1043
+ }}
1044
+ />,
1045
+ ]);
1046
+ }
1047
+ };
1048
+
1049
+ const getRetailerStatus = (servicesData, tab) => {
1050
+ const arr = servicesData?.slice();
1051
+ let concept = getConcept(tab);
1052
+
1053
+ let retailerService = {};
1054
+ [retailerService] = arr?.filter(
1055
+ (service) =>
1056
+ service.id_retailer === activeRetailer?.id &&
1057
+ service.service === concept
1058
+ );
1059
+ return retailerService ? retailerService.status : "NS";
1060
+ };
675
1061
 
676
1062
  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]);
1063
+ let status = getRetailerStatus(servicesData, activeTab);
1064
+ setRetailerStatus(status);
1065
+ }, [activeTab, servicesData, activeRetailer]);
1066
+
1067
+ useEffect(() => {
1068
+ services.length > 0 && getRequired(services);
1069
+ }, [services, servicesData, activeTab]);
1070
+
1071
+ useEffect(() => {
1072
+ setSaving(loading);
1073
+ }, [loading]);
691
1074
 
692
1075
  return (
693
1076
  <Container headerTop={headerTop}>
@@ -703,13 +1086,16 @@ export const RetailerProductEdition = ({
703
1086
  <ImageDataTable
704
1087
  lists={images}
705
1088
  activeImage={images?.values ? images?.values[activeImage] : {}}
706
- retailerSelected={activeRetailer.id}
1089
+ retailerSelected={activeRetailer?.id}
707
1090
  setImages={setImages}
708
- assignationsImages={[
709
- productSelected.article.id_images_especialist,
710
- productSelected.article.id_images_facilitator,
711
- ]}
712
- imagesStatus={productSelected?.images_status}
1091
+ assignationsImages={assig["Imágenes"]}
1092
+ imagesStatus={product?.images_status}
1093
+ setAssignation={setAssignation}
1094
+ isRetailer={isRetailer}
1095
+ onClickSave={() =>
1096
+ product?.services?.images === 1 && updateImages()
1097
+ }
1098
+ showSaveButton={userAssigned()}
713
1099
  />
714
1100
  </div>
715
1101
  <div className="product-information">
@@ -717,47 +1103,79 @@ export const RetailerProductEdition = ({
717
1103
  headerData={product}
718
1104
  percent={activePercentage}
719
1105
  activeRetailer={activeRetailer}
1106
+ servicesData={servicesData}
720
1107
  setActiveRetailer={setActiveRetailer}
721
- approveRejectButtons={approveRejectButtons}
722
1108
  sendToFacilitator={sendToFacilitator}
723
- auditorAssigned={auditorAssigned}
724
- userAssigned={userAssigned(activeTab, "facilitator")}
1109
+ approve={() => {
1110
+ sendToFacilitator("A");
1111
+ }}
1112
+ reject={() => {
1113
+ sendToFacilitator("R");
1114
+ setMessage("Rechazado");
1115
+ setComponentsArray([
1116
+ <img src={errorModal} />,
1117
+ <ScreenHeader
1118
+ text={"Agrega tu comentarios para enviar el rechazo"}
1119
+ headerType={"input-name-header"}
1120
+ color={"white"}
1121
+ />,
1122
+ <TagAndInput
1123
+ label={"Caja de Comentario"}
1124
+ inputType={"textarea"}
1125
+ inputId={"modal-commentary-box"}
1126
+ index={0}
1127
+ color={"white"}
1128
+ />,
1129
+ <Button
1130
+ buttonType={"general-default-button"}
1131
+ label={"Enviar comentario"}
1132
+ onClick={(e) =>
1133
+ createComment(
1134
+ e,
1135
+ document.querySelector(
1136
+ "#modal-commentary-box .ql-container .ql-editor > p"
1137
+ ).innerHTML,
1138
+ activeTab
1139
+ )
1140
+ }
1141
+ />,
1142
+ ]);
1143
+ }}
1144
+ showValidationButtons={
1145
+ approveRejectButtons() && (auditorAssigned() || userAssigned())
1146
+ }
725
1147
  />
726
1148
  <FullTabsMenu
727
1149
  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}
1150
+ status={retailerStatus}
742
1151
  activeTab={activeTab}
743
1152
  setActiveTab={setActiveTab}
744
1153
  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
- ],
1154
+ downloadImages={downloadImages}
1155
+ askToDeleteImages={askToDeleteImages}
1156
+ assig={assig[activeTab]}
1157
+ setAssignation={setAssignation}
1158
+ isRetailer={isRetailer}
1159
+ showSaveButton={userAssigned()}
1160
+ onClickSave={() => {
1161
+ switch (activeTab) {
1162
+ case "Descripción":
1163
+ !saving &&
1164
+ product?.description_status !== "NS" &&
1165
+ saveDescriptions();
1166
+ break;
1167
+ case "Ficha técnica":
1168
+ !saving &&
1169
+ product?.datasheet_status !== "NS" &&
1170
+ saveDatasheets();
1171
+ break;
1172
+ case "Imágenes":
1173
+ !saving && product?.images_status !== "NS" && updateImages();
1174
+ break;
1175
+
1176
+ default:
1177
+ break;
1178
+ }
761
1179
  }}
762
1180
  />
763
1181
  <div
@@ -766,85 +1184,130 @@ export const RetailerProductEdition = ({
766
1184
  (imageLayout && activeTab === "Imágenes" ? "image-services" : "")
767
1185
  }
768
1186
  >
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
- ))}
1187
+ {loading ? (
1188
+ <Loading />
1189
+ ) : (
1190
+ <>
1191
+ {!imageLayout &&
1192
+ activeTab === "Imágenes" &&
1193
+ product?.services?.images === 1 && (
1194
+ <GalleryHeader
1195
+ setSelectedImages={setSelectedImages}
1196
+ checkAll={checkAll}
1197
+ setCheckAll={setCheckAll}
1198
+ />
1199
+ )}
1200
+ {activeTab === "Ficha técnica" &&
1201
+ (product?.datasheet_status !== "NS" ? (
1202
+ datasheets[0]?.data?.map((dataGroup, index) => (
1203
+ <InputGroup
1204
+ key={index + "-" + activeRetailer.name}
1205
+ articleId={product.article.id_article}
1206
+ version={version}
1207
+ activeSection={activeTab}
1208
+ inputGroup={dataGroup}
1209
+ dataInputs={datasheets[1]}
1210
+ updatedDatasheets={updatedDatasheets}
1211
+ setUpdatedDatasheets={setUpdatedDatasheets}
1212
+ />
1213
+ ))
1214
+ ) : (
1215
+ <ScreenHeader
1216
+ text={"No cuentas con este servicio"}
1217
+ headerType={"input-name-header"}
1218
+ />
1219
+ ))}
1220
+ {activeTab === "Descripción" &&
1221
+ (product?.description_status !== "NS" ? (
1222
+ <InputGroup
1223
+ activeSection={activeTab}
1224
+ inputGroup={descriptions[0]}
1225
+ updatedDescriptions={updatedDescriptions}
1226
+ setUpdatedDescriptions={setUpdatedDescriptions}
1227
+ articleId={product?.article?.id_article}
1228
+ version={version}
1229
+ dinamicHeight={true}
1230
+ />
1231
+ ) : (
1232
+ <ScreenHeader
1233
+ text={"No cuentas con este servicio"}
1234
+ headerType={"input-name-header"}
1235
+ />
1236
+ ))}
1237
+
1238
+ {activeTab === "Imágenes" &&
1239
+ (product?.images_status !== "NS" ? (
1240
+ <section className="container">
1241
+ <div {...getRootProps({ className: "dropzone" })}>
1242
+ <input {...getInputProps()} />
1243
+ <aside>{thumbs()}</aside>
1244
+ </div>
1245
+ </section>
1246
+ ) : (
1247
+ <ScreenHeader
1248
+ text={"No cuentas con este servicio"}
1249
+ headerType={"input-name-header"}
1250
+ />
1251
+ ))}
1252
+ </>
1253
+ )}
813
1254
  </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"}
1255
+ {(userAssigned(activeTab) || auditorAssigned()) &&
1256
+ product[`${getConcept(activeTab)}_status`] !== "NS" && (
1257
+ <div className="commentary-box">
1258
+ {!comment ? (
1259
+ <div className="commentary">
1260
+ <TagAndInput
1261
+ label={"Caja de Comentario"}
1262
+ inputType={"textarea"}
1263
+ inputCols={80}
1264
+ inputRows={4}
1265
+ inputId={"commentary-box"}
1266
+ index={0}
1267
+ />
1268
+ <div className="buttons-box">
1269
+ <Button
1270
+ buttonType={"general-transparent-button"}
1271
+ label={"Enviar comentario"}
1272
+ onClick={(e) =>
1273
+ createComment(
1274
+ e,
1275
+ document.querySelector(
1276
+ "#commentary-box .ql-container .ql-editor > p"
1277
+ ).innerHTML,
1278
+ activeTab
1279
+ )
1280
+ }
1281
+ />
1282
+ </div>
1283
+ </div>
1284
+ ) : (
1285
+ <div className="feedback-box">
1286
+ <Commentary
1287
+ comment={comment.message}
1288
+ reviewed={crossComment}
829
1289
  />
830
1290
  <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()}
1291
+ buttonType={"circular-button accept-button"}
1292
+ onClick={async () => {
1293
+ setCrossComment(true);
1294
+ commentRevised();
1295
+ }}
840
1296
  />
841
1297
  </div>
842
- </div>
843
- ) : (
844
- <Commentary comment={comments[activeTab].message} />
845
- )}
846
- </div>
847
- )}
1298
+ )}
1299
+ <Button
1300
+ buttonType={
1301
+ evaluationFinished(user.id_role, activeTab, statusArray) &&
1302
+ requiredNull[activeTab] === 0
1303
+ ? "general-green-button"
1304
+ : "general-button-disabled"
1305
+ }
1306
+ label={"Enviar evaluación"}
1307
+ onClick={() => sendToFacilitator()}
1308
+ />
1309
+ </div>
1310
+ )}
848
1311
  </div>
849
1312
  </div>
850
1313
  {showModal && (
@@ -855,6 +1318,25 @@ export const RetailerProductEdition = ({
855
1318
  approveRejectButtons={approveRejectButtons}
856
1319
  />
857
1320
  )}
1321
+ {message.length > 0 && (
1322
+ <GenericModal
1323
+ buttonType={componentsArray.length > 0 && "delete-product"}
1324
+ componentsArray={
1325
+ componentsArray.length > 0
1326
+ ? componentsArray
1327
+ : [
1328
+ <img key="1" src={succes} alt="success icon" />,
1329
+ <ScreenHeader
1330
+ key="2"
1331
+ headerType={"retailer-name-header"}
1332
+ text={message}
1333
+ color={"white"}
1334
+ />,
1335
+ ]
1336
+ }
1337
+ onClick={() => setMessage("")}
1338
+ />
1339
+ )}
858
1340
  </Container>
859
1341
  );
860
1342
  };