contentoh-components-library 21.3.30 → 21.3.31

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 (125) hide show
  1. package/.env.development +3 -0
  2. package/.env.production +2 -3
  3. package/dist/assets/images/generalButton/closeIcon.svg +2 -2
  4. package/dist/components/atoms/ProgressBar/index.js +36 -6
  5. package/dist/components/atoms/ProgressBar/styles.js +11 -3
  6. package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +21 -22
  7. package/dist/components/molecules/CustomSelect/SelectItem.js +10 -1
  8. package/dist/components/molecules/GalleryElement/index.js +1 -1
  9. package/dist/components/molecules/HeaderTop/styles.js +1 -1
  10. package/dist/components/molecules/ProductNameHeader/index.js +6 -4
  11. package/dist/components/molecules/StatusAsignationInfo/index.js +1 -1
  12. package/dist/components/organisms/FullProductNameHeader/index.js +1 -0
  13. package/dist/components/organisms/ProductImageModal/index.js +10 -3
  14. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +214 -30
  15. package/dist/components/pages/ProviderProductEdition/index.js +88 -66
  16. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +73 -41
  17. package/dist/components/pages/RetailerProductEdition/index.js +20 -15
  18. package/dist/components/pages/RetailerProductEdition/utils.js +1 -1
  19. package/dist/global-files/data.js +18 -23
  20. package/dist/global-files/fonts.css +6 -0
  21. package/dist/global-files/variables.js +2 -0
  22. package/dist/index.js +267 -46
  23. package/package.json +13 -1
  24. package/src/assets/images/customSelect/starIcon.svg +14 -0
  25. package/src/assets/images/defaultImages/Spinner.gif +0 -0
  26. package/src/assets/images/defaultImages/notFound.svg +124 -0
  27. package/src/assets/images/generalButton/closeIcon.svg +2 -2
  28. package/src/assets/sounds/newMessage.mp3 +0 -0
  29. package/src/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +47 -0
  30. package/src/components/atoms/ButtonFileChooser/index.js +68 -0
  31. package/src/components/atoms/ButtonFileChooser/styles.js +4 -0
  32. package/src/components/atoms/ButtonV2/ButtonV2.stories.js +53 -0
  33. package/src/components/atoms/ButtonV2/index.js +85 -0
  34. package/src/components/atoms/ButtonV2/styles.js +217 -0
  35. package/src/components/atoms/CustomIcon/CustomIcon.stories.js +36 -0
  36. package/src/components/atoms/CustomIcon/index.js +41 -0
  37. package/src/components/atoms/CustomIcon/styles.js +85 -0
  38. package/src/components/atoms/IconFile/IconFile.stories.js +35 -0
  39. package/src/components/atoms/IconFile/index.js +119 -0
  40. package/src/components/atoms/IconFile/styles.js +67 -0
  41. package/src/components/atoms/Image/Image.stories.js +51 -0
  42. package/src/components/atoms/Image/index.js +55 -0
  43. package/src/components/atoms/Image/styles.js +34 -0
  44. package/src/components/atoms/ImageLink/ImageLink.stories.js +43 -0
  45. package/src/components/atoms/ImageLink/index.js +57 -0
  46. package/src/components/atoms/ImageLink/styles.js +30 -0
  47. package/src/components/atoms/ImagePreview/ImagePreview.stories.js +52 -0
  48. package/src/components/atoms/ImagePreview/index.js +178 -0
  49. package/src/components/atoms/ImagePreview/styles.js +77 -0
  50. package/src/components/atoms/InputText/InputText.stories.js +39 -0
  51. package/src/components/atoms/InputText/index.js +61 -0
  52. package/src/components/atoms/InputText/styles.js +89 -0
  53. package/src/components/atoms/NotFound/NotFound.stories.js +19 -0
  54. package/src/components/atoms/NotFound/index.js +52 -0
  55. package/src/components/atoms/NotFound/styles.js +55 -0
  56. package/src/components/atoms/ProgressBar/index.js +40 -5
  57. package/src/components/atoms/ProgressBar/styles.js +24 -0
  58. package/src/components/atoms/SelectItemV2/SelectItemV2.stories.js +26 -0
  59. package/src/components/atoms/SelectItemV2/index.js +61 -0
  60. package/src/components/atoms/SelectItemV2/styles.js +90 -0
  61. package/src/components/atoms/Tooltip/Tooltip.stories.js +51 -0
  62. package/src/components/atoms/Tooltip/index.js +59 -0
  63. package/src/components/atoms/Tooltip/styles.js +42 -0
  64. package/src/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +54 -0
  65. package/src/components/molecules/ButtonDownloadFile/index.js +109 -0
  66. package/src/components/molecules/ButtonDownloadFile/styles.js +66 -0
  67. package/src/components/molecules/CustomSelect/CustomSelect.stories.js +20 -12
  68. package/src/components/molecules/CustomSelect/SelectItem.js +7 -0
  69. package/src/components/molecules/Dropdown/Dropdown.stories.js +103 -0
  70. package/src/components/molecules/Dropdown/index.js +150 -0
  71. package/src/components/molecules/Dropdown/styles.js +75 -0
  72. package/src/components/molecules/GalleryElement/index.js +1 -1
  73. package/src/components/molecules/HeaderTop/styles.js +5 -2
  74. package/src/components/molecules/ImageTooltip/ImageTooltip.stories.js +68 -0
  75. package/src/components/molecules/ImageTooltip/index.js +63 -0
  76. package/src/components/molecules/ImageTooltip/styles.js +18 -0
  77. package/src/components/molecules/ProductNameHeader/index.js +7 -2
  78. package/src/components/molecules/SelectV2/SelectV2.stories.js +115 -0
  79. package/src/components/molecules/SelectV2/index.js +357 -0
  80. package/src/components/molecules/SelectV2/styles.js +105 -0
  81. package/src/components/molecules/SelectV2/test.js +60 -0
  82. package/src/components/molecules/SelectV2/test.stories.js +10 -0
  83. package/src/components/molecules/StatusAsignationInfo/index.js +11 -9
  84. package/src/components/organisms/Chat/Chat.stories.js +149 -0
  85. package/src/components/organisms/Chat/ChatLists/ChatLists.stories.js +65 -0
  86. package/src/components/organisms/Chat/ChatLists/Rotoplas.jpeg +0 -0
  87. package/src/components/organisms/Chat/ChatLists/THD.png +0 -0
  88. package/src/components/organisms/Chat/ChatLists/index.js +141 -0
  89. package/src/components/organisms/Chat/ChatLists/styles.js +162 -0
  90. package/src/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +142 -0
  91. package/src/components/organisms/Chat/ContainerItems/index.js +522 -0
  92. package/src/components/organisms/Chat/ContainerItems/styles.js +348 -0
  93. package/src/components/organisms/Chat/ContentChat/ContentChat.stories.js +102 -0
  94. package/src/components/organisms/Chat/ContentChat/Rotoplas.jpeg +0 -0
  95. package/src/components/organisms/Chat/ContentChat/THD.png +0 -0
  96. package/src/components/organisms/Chat/ContentChat/index.js +922 -0
  97. package/src/components/organisms/Chat/ContentChat/styles.js +41 -0
  98. package/src/components/organisms/Chat/Footer/Footer.stories.js +22 -0
  99. package/src/components/organisms/Chat/Footer/index.js +661 -0
  100. package/src/components/organisms/Chat/Footer/styles.js +286 -0
  101. package/src/components/organisms/Chat/Header/Header.stories.js +66 -0
  102. package/src/components/organisms/Chat/Header/index.js +93 -0
  103. package/src/components/organisms/Chat/Header/styles.js +49 -0
  104. package/src/components/organisms/Chat/index.js +238 -0
  105. package/src/components/organisms/Chat/styles.js +42 -0
  106. package/src/components/organisms/FullProductNameHeader/index.js +1 -0
  107. package/src/components/organisms/Modal/Modal.stories.js +55 -0
  108. package/src/components/organisms/Modal/index.js +97 -0
  109. package/src/components/organisms/Modal/styles.js +103 -0
  110. package/src/components/organisms/ProductImageModal/index.js +6 -3
  111. package/src/components/organisms/RangeCalendar/RangeCalendar.stories.js +16 -0
  112. package/src/components/organisms/RangeCalendar/index.js +121 -0
  113. package/src/components/organisms/RangeCalendar/styles.js +883 -0
  114. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +239 -32
  115. package/src/components/pages/ProviderProductEdition/index.js +88 -67
  116. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +78 -41
  117. package/src/components/pages/RetailerProductEdition/index.js +19 -21
  118. package/src/components/pages/RetailerProductEdition/utils.js +2 -1
  119. package/src/global-files/data.js +18 -23
  120. package/src/global-files/fonts.css +6 -0
  121. package/src/global-files/handle_http.js +225 -0
  122. package/src/global-files/handle_userTech.js +7 -0
  123. package/src/global-files/utils.js +330 -0
  124. package/src/global-files/variables.js +2 -0
  125. package/src/index.js +17 -0
@@ -12,90 +12,127 @@ export const RetailerProductEditionDefault = Template.bind({});
12
12
  RetailerProductEditionDefault.args = {
13
13
  tabsSections: {
14
14
  Descripción: true,
15
- "Ficha técnica": false,
16
- Imágenes: false,
15
+ "Ficha técnica": true,
16
+ Imágenes: true,
17
17
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WoO3h0tAsF_Z4f_6BLIOXaL__TzHUxZyQlDAULQ2cT1HkUs0EmTZXRzRZ4oce7rV5osco9gCWfhc03rQ-C12jmU-Yt7jq3vuuoHUz4JqkLpelZPS8jHSsCAUWu_ekOIgDzvNegiyKk2R4qnd7IRPzWOAx1houg-KKT7kxCxjkTyJJGtzb7pYDLSJSV871nS8MeXGf5VZG5rQ3Smfl8ANqypLUEQQ6gSOr30Ztt1lZaHRmhF8WKo_GWwY3jNScmX_o9QGOSvKVl8hTqz4gA9xbiNJ3zpoh_5PzY-N4Sl8pE3gt_9Zw_o5ItLNHpnXuav_0NENvhXDu7p7VTLEpG8DTA",
20
20
  productSelected: {
21
21
  services: {
22
22
  datasheets: 1,
23
23
  descriptions: 1,
24
24
  images: 1,
25
25
  },
26
- orderId: 130,
27
- status: "PA",
28
- datasheet_status: "PA",
26
+ orderId: 14606,
27
+ status: "AS",
28
+ datasheet_status: "CA",
29
29
  prio: "none",
30
- version: 17,
31
- description_status: "PA",
32
- images_status: "PA",
30
+ version: 3,
31
+ description_status: "CA",
32
+ images_status: "AS",
33
33
  statusByRetailer: {
34
- 58: {
35
- datasheet: "PA",
36
- description: "PA",
37
- images: "PA",
34
+ 4: {
35
+ datasheet: "AC",
36
+ description: "CA",
37
+ images: "AS",
38
+ },
39
+ 5: {
40
+ datasheet: "CA",
41
+ description: "CA",
42
+ images: "AS",
43
+ },
44
+ 6: {
45
+ description: "CA",
46
+ images: "AS",
47
+ datasheet: "CA",
48
+ },
49
+ 12: {
50
+ datasheet: "CA",
51
+ description: "CA",
52
+ images: "AS",
53
+ },
54
+ 17: {
55
+ datasheet: "CA",
56
+ description: "AC",
57
+ images: "AS",
38
58
  },
39
59
  },
40
60
  article: {
41
- id_article: 3,
42
- id_category: "2032",
43
- name: "CORTINA BLACKOUT DE POLIÉSTER CAFÉ 2.13 X 1.06 M",
44
- upc: "161157",
45
- timestamp: "2022-11-14T16:02:47.000Z",
61
+ id_article: 37317,
62
+ id_category: "157",
63
+ name: "Detergente lavatrastres líquido Axion Complete tricloro 1.1 l",
64
+ upc: "7509546078915",
65
+ timestamp: "2023-03-10T20:19:15.000Z",
46
66
  id_user: 28,
47
67
  status: "NULL",
48
68
  active: 1,
49
69
  company_id: 1,
50
70
  company_name: "GRUPO BRAHMA",
51
71
  country: "México",
52
- id_order: 130,
53
- id_datasheet_especialist: null,
54
- id_datasheet_facilitator: null,
55
- id_description_especialist: null,
56
- id_description_facilitator: null,
57
- id_images_especialist: null,
58
- id_images_facilitator: null,
59
- id_auditor: null,
72
+ id_order: 14606,
73
+ id_datasheet_especialist: 54,
74
+ id_datasheet_facilitator: 52,
75
+ id_description_especialist: 54,
76
+ id_description_facilitator: 52,
77
+ id_images_especialist: 55,
78
+ id_images_facilitator: 53,
79
+ id_auditor: 37,
60
80
  id_recepcionist: null,
61
- category: "Decoración|Cortinas y Persianas|Cortinas",
81
+ category:
82
+ "Consumibles|Productos de Limpieza y Lavandería|Jabones y Lavatrastes",
62
83
  missingAttributes: 0,
63
84
  missingDescriptions: 0,
64
85
  missingImages: 0,
65
86
  },
66
87
  retailers: [
67
88
  {
68
- id: 58,
69
- name: "The Home Depot Golden",
89
+ id: 4,
90
+ name: "Walmart Super y Superama",
91
+ },
92
+ {
93
+ id: 5,
94
+ name: "Chedraui",
95
+ },
96
+ {
97
+ id: 6,
98
+ name: "HEB",
99
+ },
100
+ {
101
+ id: 12,
102
+ name: "La Comer",
103
+ },
104
+ {
105
+ id: 17,
106
+ name: "Genérico",
70
107
  },
71
108
  ],
72
109
  country: "México",
73
- upc: "161157",
110
+ upc: "7509546078915",
74
111
  },
75
112
  location: {
76
- product: { articleId: 109485, versionId: 3 },
113
+ product: { articleId: 354, versionId: 3 },
77
114
  },
78
115
  user: {
79
- id_user: 30,
80
- name: "Admin",
81
- last_name: "Ulises",
82
- email: "salmeron.5@hotmail.com",
83
- position: "Admin",
116
+ id_user: 51,
117
+ name: "ADMIN PRUEBA",
118
+ last_name: "",
119
+ email: "etc@contentoh.com",
120
+ position: "",
84
121
  telephone: "",
85
- country: "México",
122
+ country: "",
86
123
  id_company: 2,
87
- id_cognito: "c94a7305-9365-46ff-a423-4b4bc3b8b180",
124
+ id_cognito: "a6c4d3d6-24a4-41d4-ad0f-d087438ab5b6",
88
125
  birth_Date: null,
89
126
  about_me: "",
90
127
  zip_code: "",
91
128
  address: "",
92
129
  job: "",
93
130
  id_stripe: "",
94
- id_role: 6,
131
+ id_role: 1,
95
132
  active: 1,
96
133
  is_retailer: 0,
97
134
  email_notify: 1,
98
- is_user_tech: "ADMIN-AS",
135
+ is_user_tech: null,
99
136
  membership: {
100
137
  id: 2,
101
138
  start_date: "2021-11-05T02:35:12.000Z",
@@ -107,6 +144,6 @@ RetailerProductEditionDefault.args = {
107
144
  products_limit: "3",
108
145
  type: "PyMES",
109
146
  },
110
- src: "https://content-management-profile.s3.amazonaws.com/id-30/30.png?1676494961913",
147
+ src: "https://content-management-profile.s3.amazonaws.com/id-51/51.png?1678494637588",
111
148
  },
112
149
  };
@@ -176,6 +176,7 @@ export const RetailerProductEdition = ({
176
176
  const [percentages, setPercentages] = useState(
177
177
  new Array(product?.retailers?.length).fill({ percentage: 0 })
178
178
  );
179
+ // const [percentages, setPercentages] = useState([{ retailers: {} }]);
179
180
  const [activePercentage, setActivePercentage] = useState(0);
180
181
  const [activeRetailer, setActiveRetailer] = useState({});
181
182
  const [services, setServices] = useState([]);
@@ -243,7 +244,9 @@ export const RetailerProductEdition = ({
243
244
  };
244
245
 
245
246
  useEffect(() => {
246
- loadAuditableData();
247
+ if (auditableVersion) {
248
+ loadAuditableData();
249
+ }
247
250
  }, [auditableVersion]);
248
251
 
249
252
  useEffect(() => {
@@ -264,12 +267,9 @@ export const RetailerProductEdition = ({
264
267
  //Converts the data inside the datasheets object to array
265
268
  setServices(services);
266
269
  getServices();
267
-
268
- // setActiveRetailer(product?.retailers[0]);
269
270
  setImages({ action: "init", init: services[2] });
270
271
  if (services[2]?.values?.length > 0) setActiveImage(0);
271
-
272
- getPercentage({ data: [product] }).then((res) => setPercentages(res));
272
+ getPercentage({ data: [product] }).then((res) => setPercentages(res[0]));
273
273
  setLoading(false);
274
274
  } catch (error) {
275
275
  console.log(error);
@@ -410,25 +410,23 @@ export const RetailerProductEdition = ({
410
410
  }, [userGroups]);
411
411
 
412
412
  useEffect(() => {
413
- product?.retailers?.forEach((retailer) => {
414
- retailer["percentage"] = percentages.length
415
- ? percentages?.filter(
416
- (percent) => retailer?.id === percent?.id_retailer
417
- )[0]?.percentage
418
- : 0;
419
- });
420
- setActivePercentage(product?.retailers[0]?.percentage);
413
+ const retailers = product?.retailersAvailable || product?.retailers;
414
+ if (
415
+ Object.keys(percentages[product.article.id_article] ?? {})?.length > 0
416
+ ) {
417
+ retailers?.forEach((retailer, index) => {
418
+ retailer["percentage"] = Number(
419
+ percentages[product.article.id_article][retailer.id]
420
+ ?.percentageRequired
421
+ );
422
+ });
423
+ }
424
+ setActivePercentage(retailers[0]?.percentage);
421
425
  }, [percentages]);
422
426
 
423
427
  useEffect(() => {
424
428
  getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
425
- auditableVersion &&
426
- getInputsData(
427
- auditServices,
428
- activeRetailer,
429
- setAuditDatasheets,
430
- setAuditDescriptions
431
- );
429
+ auditableVersion && loadAuditableData();
432
430
  setActivePercentage(Math.round(activeRetailer?.percentage, 0));
433
431
  activeRetailer?.id &&
434
432
  setImages({ action: "orderImages", retailerId: activeRetailer.id });
@@ -1564,7 +1562,7 @@ export const RetailerProductEdition = ({
1564
1562
  images={images}
1565
1563
  setShowModal={setShowModal}
1566
1564
  sendToFacilitator={sendToFacilitator}
1567
- approveRejectButtons={approveRejectButtons}
1565
+ approveRejectButtons={approveRejectButtons()}
1568
1566
  />
1569
1567
  )}
1570
1568
  {message.length > 0 && (
@@ -5,8 +5,9 @@ export const getAuditVersion = async (articleId, setState, token) => {
5
5
  `${process.env.REACT_APP_GET_AUDIT}?articleId=${articleId}`,
6
6
  { headers: { Authorization: token } }
7
7
  );
8
+
8
9
  if (auditResponse.status === 200) {
9
- setState(JSON.parse(auditResponse.data.body).data);
10
+ setState(JSON.parse(auditResponse.data.body).data || "{}");
10
11
  }
11
12
  };
12
13
 
@@ -86,32 +86,27 @@ export const getImage = (imageGeneral, width = 250, height = 250) => {
86
86
  export const getPercentage = async (params = {}) => {
87
87
  const func = async () => {
88
88
  const dataToSend = [];
89
+ const arrayRetailers = [];
89
90
  let retailers =
90
91
  params.data[0].retailers || params.data[0].retailersAvailable;
91
- params.data.forEach((product) => {
92
+ params.data.forEach((product, i) => {
93
+ dataToSend.push(
94
+ product.article
95
+ ? {
96
+ id_article: product.article.id_article,
97
+ id_category: product.article.id_category,
98
+ version: product.version,
99
+ }
100
+ : {
101
+ id_article: product.id_article,
102
+ id_category: product.id_category,
103
+ version: product.version,
104
+ }
105
+ );
92
106
  retailers.forEach((retailer) => {
93
- dataToSend.push(
94
- product.article
95
- ? {
96
- id_article: product.article.id_article,
97
- id_category: product.article.id_category,
98
- id_retailer: retailer.id,
99
- version: product.version,
100
- upc: product.article.upc,
101
- name: product.article.name,
102
- retailerName: retailer.name,
103
- }
104
- : {
105
- id_article: product.id_article,
106
- id_category: product.id_category,
107
- id_retailer: retailer.id,
108
- version: product.version,
109
- upc: product.upc,
110
- name: product.name,
111
- retailerName: retailer.name,
112
- }
113
- );
107
+ arrayRetailers.push(retailer.id);
114
108
  });
109
+ dataToSend[i].id_retailer_array = arrayRetailers;
115
110
  });
116
111
 
117
112
  return await axios
@@ -125,7 +120,7 @@ export const getPercentage = async (params = {}) => {
125
120
  }
126
121
  )
127
122
  .then((response) => {
128
- return response.data;
123
+ return [response.data];
129
124
  })
130
125
  .catch((err) => console.log(err, "Errror"));
131
126
  };
@@ -61,3 +61,9 @@
61
61
  src: url("../assets/fonts/roboto/Roboto-Regular.ttf");
62
62
  font-weight: 400;
63
63
  }
64
+
65
+ .prueba {
66
+ color: #9e3e26;
67
+ color: #b42983;
68
+ color: #e7e7e7;
69
+ }
@@ -0,0 +1,225 @@
1
+ import axios from "axios";
2
+
3
+ //============================================================
4
+ /**
5
+ * funcion que realiza un axios GET
6
+ *
7
+ * Si <body> es undefined significa que hubo error
8
+
9
+ * @returns { Promise<{
10
+ * body: {} | undefined ,
11
+ * message: string,
12
+ * errorDetail: string
13
+ * }> }
14
+ *
15
+ */
16
+ //============================================================
17
+ export const fetchGET = (
18
+ endpoint = "",
19
+ paramsQuery = {},
20
+ paramsHeaders = {}
21
+ ) => {
22
+ return new Promise(async (response) => {
23
+ try {
24
+ let URL = endpoint;
25
+ const keysParamsQuery = Object.keys(paramsQuery);
26
+ // agregar cada param query a la URL
27
+ keysParamsQuery.forEach((key, index) => {
28
+ if (index == 0) {
29
+ URL += `?${key}=${paramsQuery[key]}`;
30
+ } else {
31
+ URL += `&${key}=${paramsQuery[key]}`;
32
+ }
33
+ });
34
+ const respHTTPjson = await axios.get(URL, { headers: paramsHeaders });
35
+ // verificar si existe un error en la peticion realizada
36
+ if (respHTTPjson.status !== 200) {
37
+ return response({
38
+ message: "No fue posible llevar a cabo la operación",
39
+ errorDetail: respHTTPjson.statusText,
40
+ });
41
+ }
42
+ // obtener body backend
43
+ const body = JSON.parse(respHTTPjson.data.body);
44
+
45
+ // verificar si existe error desde el backend
46
+ if (respHTTPjson.data.statusCode !== 200) {
47
+ return response({
48
+ message: body.message ?? "",
49
+ errorDetail: body.errorDetail ?? "",
50
+ });
51
+ }
52
+ // success
53
+ return response({ body });
54
+ } catch (err) {
55
+ return response({
56
+ message: "Error al obtener los datos",
57
+ errorDetail: err.message,
58
+ });
59
+ }
60
+ });
61
+ };
62
+
63
+ //============================================================
64
+ /**
65
+ * funcion que realiza un axios POST
66
+ *
67
+ * Si <body> es undefined significa que hubo error
68
+
69
+ * @returns { Promise<{
70
+ * body: {} | undefined ,
71
+ * message: string,
72
+ * errorDetail: string
73
+ * }> }
74
+ *
75
+ */
76
+ //============================================================
77
+ export const fetchPOST = (
78
+ endpoint = "",
79
+ paramsBody = {},
80
+ paramsHeaders = {}
81
+ ) => {
82
+ return new Promise(async (response) => {
83
+ try {
84
+ const respHTTPjson = await axios.post(endpoint, paramsBody, {
85
+ headers: paramsHeaders,
86
+ });
87
+
88
+ // verificar si existe un error en la peticion realizada
89
+ if (respHTTPjson.status !== 200) {
90
+ return response({
91
+ message: "No fue posible llevar a cabo la operación",
92
+ errorDetail: respHTTPjson.statusText,
93
+ });
94
+ }
95
+ // obtener body backend
96
+ const body = JSON.parse(respHTTPjson.data.body);
97
+
98
+ // verificar si existe error desde el backend
99
+ if (respHTTPjson.data.statusCode !== 200) {
100
+ return response({
101
+ message: body.message ?? "",
102
+ errorDetail: body.errorDetail ?? "",
103
+ });
104
+ }
105
+ // success
106
+ return response({ body });
107
+ } catch (err) {
108
+ return response({
109
+ message: "Error al guardar los datos",
110
+ errorDetail: err.message,
111
+ });
112
+ }
113
+ });
114
+ };
115
+
116
+ //============================================================
117
+ /**
118
+ * funcion que realiza un axios GET
119
+ *
120
+ * Si <body> es undefined significa que hubo error
121
+
122
+ * @returns { Promise<{
123
+ * body: {} | undefined ,
124
+ * message: string,
125
+ * errorDetail: string
126
+ * }> }
127
+ *
128
+ */
129
+ //============================================================
130
+ export const fetchPUT = (
131
+ endpoint = "",
132
+ paramsBody = {},
133
+ paramsHeaders = {}
134
+ ) => {
135
+ return new Promise(async (response) => {
136
+ try {
137
+ const respHTTPjson = await axios.put(endpoint, paramsBody, {
138
+ headers: paramsHeaders,
139
+ });
140
+
141
+ // verificar si existe un error en la peticion realizada
142
+ if (respHTTPjson.status !== 200) {
143
+ return response({
144
+ message: "No fue posible llevar a cabo la operación",
145
+ errorDetail: respHTTPjson.statusText,
146
+ });
147
+ }
148
+
149
+ // obtener body backend
150
+ const body = JSON.parse(respHTTPjson.data.body);
151
+
152
+ // verificar si existe error desde el backend
153
+ if (respHTTPjson.data.statusCode !== 200) {
154
+ return response({
155
+ message: body.message ?? "",
156
+ errorDetail: body.errorDetail ?? "",
157
+ });
158
+ }
159
+
160
+ // success
161
+ return response({ body });
162
+ } catch (err) {
163
+ return response({
164
+ message: "Error al actualizar los datos",
165
+ errorDetail: err.message,
166
+ });
167
+ }
168
+ });
169
+ };
170
+
171
+ //============================================================
172
+ /**
173
+ * funcion que realiza un axios GET
174
+ *
175
+ * Si <body> es undefined significa que hubo error
176
+
177
+ * @returns { Promise<{
178
+ * body: {} | undefined ,
179
+ * message: string,
180
+ * errorDetail: string
181
+ * }> }
182
+ *
183
+ */
184
+ //============================================================
185
+ export const fetchDELETE = (
186
+ endpoint = "",
187
+ paramsBody = {},
188
+ paramsHeaders = {}
189
+ ) => {
190
+ return new Promise(async (response) => {
191
+ try {
192
+ const respHTTPjson = await axios.delete(endpoint, {
193
+ data: paramsBody,
194
+ headers: paramsHeaders,
195
+ });
196
+
197
+ // verificar si existe un error en la peticion realizada
198
+ if (respHTTPjson.status !== 200) {
199
+ return response({
200
+ message: "No fue posible llevar a cabo la operación",
201
+ errorDetail: respHTTPjson.statusText,
202
+ });
203
+ }
204
+
205
+ // obtener body backend
206
+ const body = JSON.parse(respHTTPjson.data.body);
207
+
208
+ // verificar si existe error desde el backend
209
+ if (respHTTPjson.data.statusCode !== 200) {
210
+ return response({
211
+ message: body.message ?? "",
212
+ errorDetail: body.errorDetail ?? "",
213
+ });
214
+ }
215
+
216
+ // success
217
+ return response({ body });
218
+ } catch (err) {
219
+ return response({
220
+ message: "Error al actualizar los datos",
221
+ errorDetail: err.message,
222
+ });
223
+ }
224
+ });
225
+ };
@@ -0,0 +1,7 @@
1
+ export const isUserTech = (value = "") => {
2
+ return ["AS", "ADMIN-AS", "ADMIN"].includes(value);
3
+ };
4
+
5
+ export const isUserAdminTech = (value = "") => {
6
+ return ["ADMIN-AS", "ADMIN"].includes(value);
7
+ };