contentoh-components-library 21.0.65 → 21.0.66

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