contentoh-components-library 21.2.83 → 21.2.85

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 (177) hide show
  1. package/.env.development +6 -1
  2. package/dist/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
  3. package/dist/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  4. package/dist/assets/images/chatPopup/Spinner.gif +0 -0
  5. package/dist/assets/images/chatPopup/close.svg +3 -0
  6. package/dist/assets/images/chatPopup/defaultImage.png +0 -0
  7. package/dist/assets/images/chatPopup/defaultProfile.png +0 -0
  8. package/dist/assets/images/chatPopup/doc.svg +1 -0
  9. package/dist/assets/images/chatPopup/document.svg +1 -0
  10. package/dist/assets/images/chatPopup/iconChat.svg +19 -0
  11. package/dist/assets/images/chatPopup/iconPlus.svg +3 -0
  12. package/dist/assets/images/chatPopup/pdf.svg +75 -0
  13. package/dist/assets/images/chatPopup/remove.svg +4 -0
  14. package/dist/assets/images/chatPopup/send.svg +3 -0
  15. package/dist/assets/images/chatPopup/svgIcon.svg +109 -0
  16. package/dist/assets/images/chatPopup/upload_file.svg +3 -0
  17. package/dist/assets/images/chatPopup/xls.svg +53 -0
  18. package/dist/assets/images/defaultImages/Spinner.gif +0 -0
  19. package/dist/assets/images/defaultImages/notFound.svg +124 -0
  20. package/dist/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +72 -0
  21. package/dist/components/atoms/ButtonFileChooser/index.js +116 -0
  22. package/dist/components/atoms/ButtonFileChooser/styles.js +20 -0
  23. package/dist/components/atoms/ButtonV2/ButtonV2.stories.js +66 -0
  24. package/dist/components/atoms/ButtonV2/index.js +109 -0
  25. package/dist/components/atoms/ButtonV2/styles.js +53 -0
  26. package/dist/components/atoms/CustomIcon/CustomIcon.stories.js +50 -0
  27. package/dist/components/atoms/CustomIcon/index.js +38 -0
  28. package/dist/components/atoms/CustomIcon/styles.js +33 -0
  29. package/dist/components/atoms/IconFile/IconFile.stories.js +48 -0
  30. package/dist/components/atoms/IconFile/index.js +251 -0
  31. package/dist/components/atoms/IconFile/styles.js +23 -0
  32. package/dist/components/atoms/Image/Image.stories.js +63 -0
  33. package/dist/components/atoms/Image/index.js +72 -0
  34. package/dist/components/atoms/Image/styles.js +40 -0
  35. package/dist/components/atoms/ImageLink/ImageLink.stories.js +63 -0
  36. package/dist/components/atoms/ImageLink/index.js +75 -0
  37. package/dist/components/atoms/ImageLink/styles.js +40 -0
  38. package/dist/components/atoms/ImagePreview/ImagePreview.stories.js +70 -0
  39. package/dist/components/atoms/ImagePreview/index.js +220 -0
  40. package/dist/components/atoms/ImagePreview/styles.js +44 -0
  41. package/dist/components/atoms/InputText/InputText.stories.js +62 -0
  42. package/dist/components/atoms/InputText/index.js +64 -0
  43. package/dist/components/atoms/InputText/styles.js +32 -0
  44. package/dist/components/atoms/NotFound/NotFound.stories.js +36 -0
  45. package/dist/components/atoms/NotFound/index.js +73 -0
  46. package/dist/components/atoms/NotFound/styles.js +20 -0
  47. package/dist/components/atoms/Tooltip/Tooltip.stories.js +66 -0
  48. package/dist/components/atoms/Tooltip/index.js +70 -0
  49. package/dist/components/atoms/Tooltip/styles.js +20 -0
  50. package/dist/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +66 -0
  51. package/dist/components/molecules/ButtonDownloadFile/index.js +179 -0
  52. package/dist/components/molecules/ButtonDownloadFile/styles.js +23 -0
  53. package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +21 -22
  54. package/dist/components/molecules/CustomSelect/SelectItem.js +10 -1
  55. package/dist/components/molecules/HeaderTop/index.js +12 -5
  56. package/dist/components/molecules/HeaderTop/styles.js +1 -1
  57. package/dist/components/molecules/ImageTooltip/ImageTooltip.stories.js +72 -0
  58. package/dist/components/molecules/ImageTooltip/index.js +84 -0
  59. package/dist/components/molecules/ImageTooltip/styles.js +33 -0
  60. package/dist/components/organisms/Chat/Chat.stories.js +215 -0
  61. package/dist/components/organisms/Chat/ChatLists/ChatLists.stories.js +83 -0
  62. package/dist/components/organisms/Chat/ChatLists/index.js +158 -0
  63. package/dist/components/organisms/Chat/ChatLists/styles.js +29 -0
  64. package/dist/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +176 -0
  65. package/dist/components/organisms/Chat/ContainerItems/index.js +570 -0
  66. package/dist/components/organisms/Chat/ContainerItems/styles.js +20 -0
  67. package/dist/components/organisms/Chat/ContentChat/ContentChat.stories.js +142 -0
  68. package/dist/components/organisms/Chat/ContentChat/index.js +1422 -0
  69. package/dist/components/organisms/Chat/ContentChat/styles.js +20 -0
  70. package/dist/components/organisms/Chat/Footer/Footer.stories.js +43 -0
  71. package/dist/components/organisms/Chat/Footer/index.js +983 -0
  72. package/dist/components/organisms/Chat/Footer/styles.js +32 -0
  73. package/dist/components/organisms/Chat/Header/Header.stories.js +96 -0
  74. package/dist/components/organisms/Chat/Header/index.js +84 -0
  75. package/dist/components/organisms/Chat/Header/styles.js +20 -0
  76. package/dist/components/organisms/Chat/index.js +325 -0
  77. package/dist/components/organisms/Chat/styles.js +29 -0
  78. package/dist/components/organisms/Modal/Modal.stories.js +66 -0
  79. package/dist/components/organisms/Modal/index.js +95 -0
  80. package/dist/components/organisms/Modal/styles.js +20 -0
  81. package/dist/components/pages/ProviderProductEdition/index.js +3 -2
  82. package/dist/components/pages/RetailerProductEdition/index.js +4 -7
  83. package/dist/global-files/fonts.css +18 -0
  84. package/dist/global-files/handle_http.js +383 -0
  85. package/dist/global-files/utils.js +472 -0
  86. package/dist/global-files/variables.js +3 -1
  87. package/package.json +13 -1
  88. package/src/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
  89. package/src/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  90. package/src/assets/images/chatPopup/Spinner.gif +0 -0
  91. package/src/assets/images/chatPopup/close.svg +3 -0
  92. package/src/assets/images/chatPopup/defaultImage.png +0 -0
  93. package/src/assets/images/chatPopup/defaultProfile.png +0 -0
  94. package/src/assets/images/chatPopup/doc.svg +1 -0
  95. package/src/assets/images/chatPopup/document.svg +1 -0
  96. package/src/assets/images/chatPopup/iconChat.svg +19 -0
  97. package/src/assets/images/chatPopup/iconPlus.svg +3 -0
  98. package/src/assets/images/chatPopup/pdf.svg +75 -0
  99. package/src/assets/images/chatPopup/remove.svg +4 -0
  100. package/src/assets/images/chatPopup/send.svg +3 -0
  101. package/src/assets/images/chatPopup/svgIcon.svg +109 -0
  102. package/src/assets/images/chatPopup/upload_file.svg +3 -0
  103. package/src/assets/images/chatPopup/xls.svg +53 -0
  104. package/src/assets/images/customSelect/starIcon.svg +14 -0
  105. package/src/assets/images/defaultImages/Spinner.gif +0 -0
  106. package/src/assets/images/defaultImages/notFound.svg +124 -0
  107. package/src/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +47 -0
  108. package/src/components/atoms/ButtonFileChooser/index.js +70 -0
  109. package/src/components/atoms/ButtonFileChooser/styles.js +4 -0
  110. package/src/components/atoms/ButtonV2/ButtonV2.stories.js +50 -0
  111. package/src/components/atoms/ButtonV2/index.js +74 -0
  112. package/src/components/atoms/ButtonV2/styles.js +187 -0
  113. package/src/components/atoms/CustomIcon/CustomIcon.stories.js +36 -0
  114. package/src/components/atoms/CustomIcon/index.js +41 -0
  115. package/src/components/atoms/CustomIcon/styles.js +85 -0
  116. package/src/components/atoms/IconFile/IconFile.stories.js +35 -0
  117. package/src/components/atoms/IconFile/index.js +120 -0
  118. package/src/components/atoms/IconFile/styles.js +67 -0
  119. package/src/components/atoms/Image/Image.stories.js +43 -0
  120. package/src/components/atoms/Image/index.js +54 -0
  121. package/src/components/atoms/Image/styles.js +25 -0
  122. package/src/components/atoms/ImageLink/ImageLink.stories.js +43 -0
  123. package/src/components/atoms/ImageLink/index.js +58 -0
  124. package/src/components/atoms/ImageLink/styles.js +30 -0
  125. package/src/components/atoms/ImagePreview/ImagePreview.stories.js +52 -0
  126. package/src/components/atoms/ImagePreview/index.js +192 -0
  127. package/src/components/atoms/ImagePreview/styles.js +77 -0
  128. package/src/components/atoms/InputText/InputText.stories.js +40 -0
  129. package/src/components/atoms/InputText/index.js +63 -0
  130. package/src/components/atoms/InputText/styles.js +89 -0
  131. package/src/components/atoms/NotFound/NotFound.stories.js +19 -0
  132. package/src/components/atoms/NotFound/index.js +53 -0
  133. package/src/components/atoms/NotFound/styles.js +55 -0
  134. package/src/components/atoms/Tooltip/Tooltip.stories.js +51 -0
  135. package/src/components/atoms/Tooltip/index.js +59 -0
  136. package/src/components/atoms/Tooltip/styles.js +42 -0
  137. package/src/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +54 -0
  138. package/src/components/molecules/ButtonDownloadFile/index.js +113 -0
  139. package/src/components/molecules/ButtonDownloadFile/styles.js +66 -0
  140. package/src/components/molecules/CustomSelect/CustomSelect.stories.js +20 -12
  141. package/src/components/molecules/CustomSelect/SelectItem.js +7 -0
  142. package/src/components/molecules/HeaderTop/index.js +11 -6
  143. package/src/components/molecules/HeaderTop/styles.js +4 -0
  144. package/src/components/molecules/ImageTooltip/ImageTooltip.stories.js +46 -0
  145. package/src/components/molecules/ImageTooltip/index.js +64 -0
  146. package/src/components/molecules/ImageTooltip/styles.js +18 -0
  147. package/src/components/organisms/Chat/Chat.stories.js +199 -0
  148. package/src/components/organisms/Chat/ChatLists/ChatLists.stories.js +65 -0
  149. package/src/components/organisms/Chat/ChatLists/Rotoplas.jpeg +0 -0
  150. package/src/components/organisms/Chat/ChatLists/THD.png +0 -0
  151. package/src/components/organisms/Chat/ChatLists/index.js +141 -0
  152. package/src/components/organisms/Chat/ChatLists/styles.js +162 -0
  153. package/src/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +142 -0
  154. package/src/components/organisms/Chat/ContainerItems/index.js +551 -0
  155. package/src/components/organisms/Chat/ContainerItems/styles.js +336 -0
  156. package/src/components/organisms/Chat/ContentChat/ContentChat.stories.js +102 -0
  157. package/src/components/organisms/Chat/ContentChat/Rotoplas.jpeg +0 -0
  158. package/src/components/organisms/Chat/ContentChat/THD.png +0 -0
  159. package/src/components/organisms/Chat/ContentChat/index.js +900 -0
  160. package/src/components/organisms/Chat/ContentChat/styles.js +41 -0
  161. package/src/components/organisms/Chat/Footer/Footer.stories.js +22 -0
  162. package/src/components/organisms/Chat/Footer/index.js +669 -0
  163. package/src/components/organisms/Chat/Footer/styles.js +286 -0
  164. package/src/components/organisms/Chat/Header/Header.stories.js +66 -0
  165. package/src/components/organisms/Chat/Header/index.js +94 -0
  166. package/src/components/organisms/Chat/Header/styles.js +49 -0
  167. package/src/components/organisms/Chat/index.js +295 -0
  168. package/src/components/organisms/Chat/styles.js +42 -0
  169. package/src/components/organisms/Modal/Modal.stories.js +55 -0
  170. package/src/components/organisms/Modal/index.js +97 -0
  171. package/src/components/organisms/Modal/styles.js +103 -0
  172. package/src/components/pages/ProviderProductEdition/index.js +6 -7
  173. package/src/components/pages/RetailerProductEdition/index.js +5 -4
  174. package/src/global-files/fonts.css +18 -0
  175. package/src/global-files/handle_http.js +231 -0
  176. package/src/global-files/utils.js +300 -0
  177. package/src/global-files/variables.js +2 -0
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = Modal;
11
+
12
+ var _react = _interopRequireWildcard(require("react"));
13
+
14
+ var _styles = require("./styles");
15
+
16
+ var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
17
+
18
+ var _reactFontawesome = require("@fortawesome/react-fontawesome");
19
+
20
+ var _material = require("@mui/material");
21
+
22
+ var _ButtonV = _interopRequireDefault(require("../../atoms/ButtonV2"));
23
+
24
+ var _CustomIcon = _interopRequireDefault(require("../../atoms/CustomIcon"));
25
+
26
+ var _jsxRuntime = require("react/jsx-runtime");
27
+
28
+ function Modal(props) {
29
+ var className = props.className,
30
+ show = props.show,
31
+ title = props.title,
32
+ message = props.message,
33
+ icon = props.icon,
34
+ customComponent = props.customComponent,
35
+ buttons = props.buttons,
36
+ onClickModal = props.onClickModal,
37
+ onClickBtnDefault = props.onClickBtnDefault;
38
+ var icons = {
39
+ error: _freeSolidSvgIcons.faClose,
40
+ warning: _freeSolidSvgIcons.faExclamationTriangle,
41
+ info: _freeSolidSvgIcons.faExclamation,
42
+ success: _freeSolidSvgIcons.faCheck
43
+ };
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Backdrop, {
45
+ open: show,
46
+ className: "container-backgroundModal",
47
+ timeout: 400,
48
+ style: {
49
+ backgroundColor: "transparent",
50
+ zIndex: 10
51
+ },
52
+ onClick: function onClick(event) {
53
+ return onClickModal && onClickModal(event);
54
+ },
55
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Fade, {
56
+ in: show,
57
+ timeout: 400,
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ContainerModal, {
59
+ className: className ? className : "",
60
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
61
+ className: "contentModal",
62
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("header", {
63
+ children: ![null, undefined, ""].includes(title === null || title === void 0 ? void 0 : title.trim()) && /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
64
+ className: "label-title",
65
+ children: title.trim()
66
+ })
67
+ }), icons[icon === null || icon === void 0 ? void 0 : icon.toLowerCase()] && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomIcon.default, {
68
+ type: "white",
69
+ className: "iconModal " + "iconModal-" + icon.toLowerCase(),
70
+ size: 35,
71
+ borderType: "circle",
72
+ icon: icons[icon.toLowerCase()]
73
+ }), ![null, undefined, ""].includes(message === null || message === void 0 ? void 0 : message.trim()) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
74
+ className: "label-message",
75
+ children: [" ", message.trim(), " "]
76
+ }), customComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
77
+ className: "container-customComponent",
78
+ children: customComponent
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
80
+ className: "container-buttons",
81
+ children: buttons !== null && buttons !== void 0 && buttons.length ? buttons : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonV.default, {
82
+ type: "white",
83
+ borderType: "oval",
84
+ label: "Aceptar",
85
+ size: 12,
86
+ onClick: function onClick(event) {
87
+ return onClickBtnDefault && onClickBtnDefault(event);
88
+ }
89
+ }, "btn-Aceptar")
90
+ })]
91
+ })
92
+ })
93
+ })
94
+ });
95
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ContainerModal = void 0;
9
+
10
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _variables = require("../../../global-files/variables");
15
+
16
+ var _templateObject;
17
+
18
+ var ContainerModal = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n overflow: auto;\n display: grid;\n place-items: center;\n background-color: rgba(0, 0, 0, 0.4);\n\n .contentModal {\n width: fit-content;\n max-width: 80%;\n min-width: 80px;\n height: fit-content;\n max-height: 90%;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: white;\n border-radius: 10px;\n padding: 25px 25px 20px 25px;\n box-shadow: 0px 2px 4px 0px #00000040;\n\n header {\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n gap: 6px;\n margin-bottom: 20px;\n\n .label-title {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 17px;\n line-height: 1.2;\n color: #262626;\n white-space: pre-wrap;\n }\n }\n\n .iconModal {\n width: 50px;\n height: 50px;\n font-size: 30px;\n border-width: 4px;\n margin-bottom: 20px;\n overflow: hidden;\n\n &.iconModal-error {\n background-color: #953737;\n border-color: #953737;\n color: white;\n }\n &.iconModal-warning {\n font-size: 27px;\n padding-bottom: 8px;\n color: #af9647;\n border-color: #af9647;\n }\n &.iconModal-info {\n border-color: #9e3e26;\n color: #9e3e26;\n }\n &.iconModal-success {\n }\n }\n\n .label-message {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 13px;\n color: #707070;\n white-space: pre-wrap;\n }\n\n .container-customComponent {\n width: 100%;\n max-height: 50vh;\n display: flex;\n flex-direction: column;\n margin-top: 20px;\n padding: 0px 0px;\n //border: 1px solid red;\n }\n\n .container-buttons {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 12px;\n margin-top: 20px;\n //border: 1px solid red;\n }\n }\n"])), _variables.FontFamily.RobotoMedium, _variables.FontFamily.RobotoRegular);
19
+
20
+ exports.ContainerModal = ContainerModal;
@@ -106,7 +106,8 @@ var _jsxRuntime = require("react/jsx-runtime");
106
106
  var reducerImages = function reducerImages(state, action) {
107
107
  var _action$init, _action$init$inputsBy;
108
108
 
109
- var values = state.values,
109
+ var _state$values = state.values,
110
+ values = _state$values === void 0 ? [] : _state$values,
110
111
  attrForImgs = state.attrForImgs,
111
112
  inputsByRetailer = state.inputsByRetailer;
112
113
 
@@ -182,7 +183,7 @@ var reducerImages = function reducerImages(state, action) {
182
183
  inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
183
184
  return imageIdArray.includes(input.id);
184
185
  });
185
- values = orderedImages.length > 0 ? orderedImages : [];
186
+ if (orderedImages.length > 0) values = orderedImages;
186
187
  } catch (error) {
187
188
  console.log(error);
188
189
  }
@@ -84,7 +84,8 @@ var _jsxRuntime = require("react/jsx-runtime");
84
84
  var reducerImages = function reducerImages(state, action) {
85
85
  var _action$init, _action$init$inputsBy;
86
86
 
87
- var values = state.values,
87
+ var _state$values = state.values,
88
+ values = _state$values === void 0 ? [] : _state$values,
88
89
  attrForImgs = state.attrForImgs,
89
90
  inputsByRetailer = state.inputsByRetailer;
90
91
 
@@ -156,11 +157,7 @@ var reducerImages = function reducerImages(state, action) {
156
157
 
157
158
  var orderedImages = [];
158
159
  var imageIdArray = [];
159
-
160
- if (action !== null && action !== void 0 && action.retailerId && !_inputsByRetailer[action.retailerId]) {
161
- _inputsByRetailer[action.retailerId] = [];
162
- }
163
-
160
+ if (action !== null && action !== void 0 && action.retailerId && !_inputsByRetailer[action.retailerId]) _inputsByRetailer[action.retailerId] = [];
164
161
  action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
165
162
  imageIdArray.push(input.id_image);
166
163
  valuesInitial.forEach(function (value) {
@@ -170,7 +167,7 @@ var reducerImages = function reducerImages(state, action) {
170
167
  inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
171
168
  return imageIdArray.includes(input.id);
172
169
  });
173
- values = orderedImages.length > 0 ? orderedImages : [];
170
+ if (orderedImages.length > 0) values = orderedImages;
174
171
  } catch (error) {
175
172
  console.log(error);
176
173
  }
@@ -43,3 +43,21 @@
43
43
  src: url("../assets/fonts/raleway/Raleway-Black.ttf");
44
44
  font-weight: 900;
45
45
  }
46
+
47
+ @font-face {
48
+ font-family: "RobotoMedium";
49
+ src: url("../assets/fonts/Roboto/Roboto-Medium.ttf");
50
+ font-weight: 500;
51
+ }
52
+
53
+ @font-face {
54
+ font-family: "RobotoRegular";
55
+ src: url("../assets/fonts/Roboto/Roboto-Regular.ttf");
56
+ font-weight: 400;
57
+ }
58
+
59
+ .prueba {
60
+ color: #9e3e26;
61
+ color: #b42983;
62
+ color: #e7e7e7;
63
+ }
@@ -0,0 +1,383 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.fetchPUT = exports.fetchPOST = exports.fetchGET = exports.fetchDELETE = void 0;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
13
+
14
+ var _axios = _interopRequireDefault(require("axios"));
15
+
16
+ //============================================================
17
+
18
+ /**
19
+ * funcion que realiza un axios GET
20
+ *
21
+ * Si <body> es undefined significa que hubo error
22
+
23
+ * @returns { Promise<{
24
+ * body: {} | undefined ,
25
+ * message: string,
26
+ * errorDetail: string
27
+ * }> }
28
+ *
29
+ */
30
+ //============================================================
31
+ var fetchGET = function fetchGET() {
32
+ var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
33
+ var paramsQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34
+ var paramsHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
35
+ return new Promise( /*#__PURE__*/function () {
36
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(response) {
37
+ var URL, keysParamsQuery, respHTTPjson, body, _body$message, _body$errorDetail;
38
+
39
+ return _regenerator.default.wrap(function _callee$(_context) {
40
+ while (1) {
41
+ switch (_context.prev = _context.next) {
42
+ case 0:
43
+ _context.prev = 0;
44
+ URL = endpoint;
45
+ keysParamsQuery = Object.keys(paramsQuery); // agregar cada param query a la URL
46
+
47
+ keysParamsQuery.forEach(function (key, index) {
48
+ if (index == 0) {
49
+ URL += "?".concat(key, "=").concat(paramsQuery[key]);
50
+ } else {
51
+ URL += "&".concat(key, "=").concat(paramsQuery[key]);
52
+ }
53
+ }); //console.log("URL:", URL);
54
+
55
+ _context.next = 6;
56
+ return _axios.default.get(URL, {
57
+ headers: paramsHeaders
58
+ });
59
+
60
+ case 6:
61
+ respHTTPjson = _context.sent;
62
+
63
+ if (!(respHTTPjson.status !== 200)) {
64
+ _context.next = 9;
65
+ break;
66
+ }
67
+
68
+ return _context.abrupt("return", response({
69
+ message: "No fue posible llevar a cabo la operación",
70
+ errorDetail: respHTTPjson.statusText
71
+ }));
72
+
73
+ case 9:
74
+ // obtener body backend
75
+ body = JSON.parse(respHTTPjson.data.body); // verificar si existe error desde el backend
76
+
77
+ if (!(respHTTPjson.data.statusCode !== 200)) {
78
+ _context.next = 12;
79
+ break;
80
+ }
81
+
82
+ return _context.abrupt("return", response({
83
+ message: (_body$message = body.message) !== null && _body$message !== void 0 ? _body$message : "",
84
+ errorDetail: (_body$errorDetail = body.errorDetail) !== null && _body$errorDetail !== void 0 ? _body$errorDetail : ""
85
+ }));
86
+
87
+ case 12:
88
+ return _context.abrupt("return", response({
89
+ body: body
90
+ }));
91
+
92
+ case 15:
93
+ _context.prev = 15;
94
+ _context.t0 = _context["catch"](0);
95
+ return _context.abrupt("return", response({
96
+ message: "Error al obtener los datos",
97
+ errorDetail: _context.t0.message
98
+ }));
99
+
100
+ case 18:
101
+ case "end":
102
+ return _context.stop();
103
+ }
104
+ }
105
+ }, _callee, null, [[0, 15]]);
106
+ }));
107
+
108
+ return function (_x) {
109
+ return _ref.apply(this, arguments);
110
+ };
111
+ }());
112
+ }; //============================================================
113
+
114
+ /**
115
+ * funcion que realiza un axios POST
116
+ *
117
+ * Si <body> es undefined significa que hubo error
118
+
119
+ * @returns { Promise<{
120
+ * body: {} | undefined ,
121
+ * message: string,
122
+ * errorDetail: string
123
+ * }> }
124
+ *
125
+ */
126
+ //============================================================
127
+
128
+
129
+ exports.fetchGET = fetchGET;
130
+
131
+ var fetchPOST = function fetchPOST() {
132
+ var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
133
+ var paramsBody = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
134
+ var paramsHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
135
+ return new Promise( /*#__PURE__*/function () {
136
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(response) {
137
+ var respHTTPjson, body, _body$message2, _body$errorDetail2;
138
+
139
+ return _regenerator.default.wrap(function _callee2$(_context2) {
140
+ while (1) {
141
+ switch (_context2.prev = _context2.next) {
142
+ case 0:
143
+ _context2.prev = 0;
144
+ _context2.next = 3;
145
+ return _axios.default.post(endpoint, paramsBody, {
146
+ headers: paramsHeaders
147
+ });
148
+
149
+ case 3:
150
+ respHTTPjson = _context2.sent;
151
+
152
+ if (!(respHTTPjson.status !== 200)) {
153
+ _context2.next = 6;
154
+ break;
155
+ }
156
+
157
+ return _context2.abrupt("return", response({
158
+ message: "No fue posible llevar a cabo la operación",
159
+ errorDetail: respHTTPjson.statusText
160
+ }));
161
+
162
+ case 6:
163
+ // obtener body backend
164
+ body = JSON.parse(respHTTPjson.data.body); // verificar si existe error desde el backend
165
+
166
+ if (!(respHTTPjson.data.statusCode !== 200)) {
167
+ _context2.next = 10;
168
+ break;
169
+ }
170
+
171
+ console.log(body);
172
+ return _context2.abrupt("return", response({
173
+ message: (_body$message2 = body.message) !== null && _body$message2 !== void 0 ? _body$message2 : "",
174
+ errorDetail: (_body$errorDetail2 = body.errorDetail) !== null && _body$errorDetail2 !== void 0 ? _body$errorDetail2 : ""
175
+ }));
176
+
177
+ case 10:
178
+ return _context2.abrupt("return", response({
179
+ body: body
180
+ }));
181
+
182
+ case 13:
183
+ _context2.prev = 13;
184
+ _context2.t0 = _context2["catch"](0);
185
+ return _context2.abrupt("return", response({
186
+ message: "Error al guardar los datos",
187
+ errorDetail: _context2.t0.message
188
+ }));
189
+
190
+ case 16:
191
+ case "end":
192
+ return _context2.stop();
193
+ }
194
+ }
195
+ }, _callee2, null, [[0, 13]]);
196
+ }));
197
+
198
+ return function (_x2) {
199
+ return _ref2.apply(this, arguments);
200
+ };
201
+ }());
202
+ }; //============================================================
203
+
204
+ /**
205
+ * funcion que realiza un axios GET
206
+ *
207
+ * Si <body> es undefined significa que hubo error
208
+
209
+ * @returns { Promise<{
210
+ * body: {} | undefined ,
211
+ * message: string,
212
+ * errorDetail: string
213
+ * }> }
214
+ *
215
+ */
216
+ //============================================================
217
+
218
+
219
+ exports.fetchPOST = fetchPOST;
220
+
221
+ var fetchPUT = function fetchPUT() {
222
+ var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
223
+ var paramsBody = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
224
+ var paramsHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
225
+ return new Promise( /*#__PURE__*/function () {
226
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(response) {
227
+ var respHTTPjson, body, _body$message3, _body$errorDetail3;
228
+
229
+ return _regenerator.default.wrap(function _callee3$(_context3) {
230
+ while (1) {
231
+ switch (_context3.prev = _context3.next) {
232
+ case 0:
233
+ _context3.prev = 0;
234
+ _context3.next = 3;
235
+ return _axios.default.put(endpoint, paramsBody, {
236
+ headers: paramsHeaders
237
+ });
238
+
239
+ case 3:
240
+ respHTTPjson = _context3.sent;
241
+
242
+ if (!(respHTTPjson.status !== 200)) {
243
+ _context3.next = 6;
244
+ break;
245
+ }
246
+
247
+ return _context3.abrupt("return", response({
248
+ message: "No fue posible llevar a cabo la operación",
249
+ errorDetail: respHTTPjson.statusText
250
+ }));
251
+
252
+ case 6:
253
+ // obtener body backend
254
+ body = JSON.parse(respHTTPjson.data.body); // verificar si existe error desde el backend
255
+
256
+ if (!(respHTTPjson.data.statusCode !== 200)) {
257
+ _context3.next = 9;
258
+ break;
259
+ }
260
+
261
+ return _context3.abrupt("return", response({
262
+ message: (_body$message3 = body.message) !== null && _body$message3 !== void 0 ? _body$message3 : "",
263
+ errorDetail: (_body$errorDetail3 = body.errorDetail) !== null && _body$errorDetail3 !== void 0 ? _body$errorDetail3 : ""
264
+ }));
265
+
266
+ case 9:
267
+ return _context3.abrupt("return", response({
268
+ body: body
269
+ }));
270
+
271
+ case 12:
272
+ _context3.prev = 12;
273
+ _context3.t0 = _context3["catch"](0);
274
+ return _context3.abrupt("return", response({
275
+ message: "Error al actualizar los datos",
276
+ errorDetail: _context3.t0.message
277
+ }));
278
+
279
+ case 15:
280
+ case "end":
281
+ return _context3.stop();
282
+ }
283
+ }
284
+ }, _callee3, null, [[0, 12]]);
285
+ }));
286
+
287
+ return function (_x3) {
288
+ return _ref3.apply(this, arguments);
289
+ };
290
+ }());
291
+ }; //============================================================
292
+
293
+ /**
294
+ * funcion que realiza un axios GET
295
+ *
296
+ * Si <body> es undefined significa que hubo error
297
+
298
+ * @returns { Promise<{
299
+ * body: {} | undefined ,
300
+ * message: string,
301
+ * errorDetail: string
302
+ * }> }
303
+ *
304
+ */
305
+ //============================================================
306
+
307
+
308
+ exports.fetchPUT = fetchPUT;
309
+
310
+ var fetchDELETE = function fetchDELETE() {
311
+ var endpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
312
+ var paramsBody = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
313
+ var paramsHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
314
+ return new Promise( /*#__PURE__*/function () {
315
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(response) {
316
+ var respHTTPjson, body, _body$message4, _body$errorDetail4;
317
+
318
+ return _regenerator.default.wrap(function _callee4$(_context4) {
319
+ while (1) {
320
+ switch (_context4.prev = _context4.next) {
321
+ case 0:
322
+ _context4.prev = 0;
323
+ _context4.next = 3;
324
+ return _axios.default.delete(endpoint, {
325
+ data: paramsBody,
326
+ headers: paramsHeaders
327
+ });
328
+
329
+ case 3:
330
+ respHTTPjson = _context4.sent;
331
+
332
+ if (!(respHTTPjson.status !== 200)) {
333
+ _context4.next = 6;
334
+ break;
335
+ }
336
+
337
+ return _context4.abrupt("return", response({
338
+ message: "No fue posible llevar a cabo la operación",
339
+ errorDetail: respHTTPjson.statusText
340
+ }));
341
+
342
+ case 6:
343
+ // obtener body backend
344
+ body = JSON.parse(respHTTPjson.data.body); // verificar si existe error desde el backend
345
+
346
+ if (!(respHTTPjson.data.statusCode !== 200)) {
347
+ _context4.next = 9;
348
+ break;
349
+ }
350
+
351
+ return _context4.abrupt("return", response({
352
+ message: (_body$message4 = body.message) !== null && _body$message4 !== void 0 ? _body$message4 : "",
353
+ errorDetail: (_body$errorDetail4 = body.errorDetail) !== null && _body$errorDetail4 !== void 0 ? _body$errorDetail4 : ""
354
+ }));
355
+
356
+ case 9:
357
+ return _context4.abrupt("return", response({
358
+ body: body
359
+ }));
360
+
361
+ case 12:
362
+ _context4.prev = 12;
363
+ _context4.t0 = _context4["catch"](0);
364
+ return _context4.abrupt("return", response({
365
+ message: "Error al actualizar los datos",
366
+ errorDetail: _context4.t0.message
367
+ }));
368
+
369
+ case 15:
370
+ case "end":
371
+ return _context4.stop();
372
+ }
373
+ }
374
+ }, _callee4, null, [[0, 12]]);
375
+ }));
376
+
377
+ return function (_x4) {
378
+ return _ref4.apply(this, arguments);
379
+ };
380
+ }());
381
+ };
382
+
383
+ exports.fetchDELETE = fetchDELETE;