contentoh-components-library 21.3.18 → 21.3.19
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.
- package/.env.development +0 -5
- package/dist/assets/images/generalButton/closeIcon.svg +2 -2
- package/dist/components/atoms/GeneralInput/index.js +14 -1
- package/dist/components/atoms/ProgressBar/index.js +6 -36
- package/dist/components/atoms/ProgressBar/styles.js +3 -11
- package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +22 -21
- package/dist/components/molecules/CustomSelect/SelectItem.js +1 -10
- package/dist/components/molecules/HeaderTop/index.js +6 -23
- package/dist/components/molecules/HeaderTop/styles.js +1 -1
- package/dist/components/molecules/ProductNameHeader/index.js +4 -6
- package/dist/components/organisms/FullProductNameHeader/index.js +0 -1
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +50 -65
- package/dist/components/pages/ProviderProductEdition/index.js +11 -15
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +44 -36
- package/dist/components/pages/RetailerProductEdition/index.js +12 -13
- package/dist/global-files/data.js +23 -18
- package/dist/global-files/fonts.css +0 -6
- package/dist/global-files/variables.js +0 -2
- package/dist/index.js +46 -267
- package/package.json +1 -12
- package/src/assets/images/generalButton/closeIcon.svg +2 -2
- package/src/components/atoms/GeneralInput/index.js +10 -0
- package/src/components/atoms/ProgressBar/index.js +5 -40
- package/src/components/atoms/ProgressBar/styles.js +0 -24
- package/src/components/molecules/CustomSelect/CustomSelect.stories.js +12 -20
- package/src/components/molecules/CustomSelect/SelectItem.js +0 -7
- package/src/components/molecules/HeaderTop/index.js +8 -29
- package/src/components/molecules/HeaderTop/styles.js +0 -4
- package/src/components/molecules/ProductNameHeader/index.js +2 -7
- package/src/components/organisms/FullProductNameHeader/index.js +0 -1
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +49 -67
- package/src/components/pages/ProviderProductEdition/index.js +9 -16
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +46 -36
- package/src/components/pages/RetailerProductEdition/index.js +10 -14
- package/src/global-files/data.js +23 -18
- package/src/global-files/fonts.css +0 -6
- package/src/global-files/variables.js +0 -2
- package/src/index.js +0 -17
- package/dist/assets/images/customSelect/starIcon.svg +0 -14
- package/dist/assets/images/defaultImages/Spinner.gif +0 -0
- package/dist/assets/images/defaultImages/notFound.svg +0 -124
- package/dist/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +0 -72
- package/dist/components/atoms/ButtonFileChooser/index.js +0 -110
- package/dist/components/atoms/ButtonFileChooser/styles.js +0 -20
- package/dist/components/atoms/ButtonV2/ButtonV2.stories.js +0 -66
- package/dist/components/atoms/ButtonV2/index.js +0 -110
- package/dist/components/atoms/ButtonV2/styles.js +0 -53
- package/dist/components/atoms/CustomIcon/CustomIcon.stories.js +0 -50
- package/dist/components/atoms/CustomIcon/index.js +0 -40
- package/dist/components/atoms/CustomIcon/styles.js +0 -33
- package/dist/components/atoms/IconFile/IconFile.stories.js +0 -48
- package/dist/components/atoms/IconFile/index.js +0 -249
- package/dist/components/atoms/IconFile/styles.js +0 -23
- package/dist/components/atoms/Image/Image.stories.js +0 -73
- package/dist/components/atoms/Image/index.js +0 -76
- package/dist/components/atoms/Image/styles.js +0 -43
- package/dist/components/atoms/ImageLink/ImageLink.stories.js +0 -63
- package/dist/components/atoms/ImageLink/index.js +0 -77
- package/dist/components/atoms/ImageLink/styles.js +0 -40
- package/dist/components/atoms/ImagePreview/ImagePreview.stories.js +0 -70
- package/dist/components/atoms/ImagePreview/index.js +0 -208
- package/dist/components/atoms/ImagePreview/styles.js +0 -44
- package/dist/components/atoms/InputText/InputText.stories.js +0 -60
- package/dist/components/atoms/InputText/index.js +0 -66
- package/dist/components/atoms/InputText/styles.js +0 -32
- package/dist/components/atoms/NotFound/NotFound.stories.js +0 -36
- package/dist/components/atoms/NotFound/index.js +0 -75
- package/dist/components/atoms/NotFound/styles.js +0 -20
- package/dist/components/atoms/SelectItemV2/SelectItemV2.stories.js +0 -45
- package/dist/components/atoms/SelectItemV2/index.js +0 -57
- package/dist/components/atoms/SelectItemV2/styles.js +0 -30
- package/dist/components/atoms/Tooltip/Tooltip.stories.js +0 -66
- package/dist/components/atoms/Tooltip/index.js +0 -72
- package/dist/components/atoms/Tooltip/styles.js +0 -20
- package/dist/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +0 -66
- package/dist/components/molecules/ButtonDownloadFile/index.js +0 -179
- package/dist/components/molecules/ButtonDownloadFile/styles.js +0 -23
- package/dist/components/molecules/Dropdown/Dropdown.stories.js +0 -98
- package/dist/components/molecules/Dropdown/index.js +0 -150
- package/dist/components/molecules/Dropdown/styles.js +0 -26
- package/dist/components/molecules/ImageTooltip/ImageTooltip.stories.js +0 -82
- package/dist/components/molecules/ImageTooltip/index.js +0 -85
- package/dist/components/molecules/ImageTooltip/styles.js +0 -33
- package/dist/components/molecules/SelectV2/SelectV2.stories.js +0 -120
- package/dist/components/molecules/SelectV2/index.js +0 -306
- package/dist/components/molecules/SelectV2/styles.js +0 -42
- package/dist/components/molecules/SelectV2/test.js +0 -95
- package/dist/components/molecules/SelectV2/test.stories.js +0 -27
- package/dist/components/organisms/Chat/Chat.stories.js +0 -160
- package/dist/components/organisms/Chat/ChatLists/ChatLists.stories.js +0 -83
- package/dist/components/organisms/Chat/ChatLists/index.js +0 -160
- package/dist/components/organisms/Chat/ChatLists/styles.js +0 -29
- package/dist/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +0 -176
- package/dist/components/organisms/Chat/ContainerItems/index.js +0 -537
- package/dist/components/organisms/Chat/ContainerItems/styles.js +0 -20
- package/dist/components/organisms/Chat/ContentChat/ContentChat.stories.js +0 -142
- package/dist/components/organisms/Chat/ContentChat/index.js +0 -1429
- package/dist/components/organisms/Chat/ContentChat/styles.js +0 -20
- package/dist/components/organisms/Chat/Footer/Footer.stories.js +0 -43
- package/dist/components/organisms/Chat/Footer/index.js +0 -976
- package/dist/components/organisms/Chat/Footer/styles.js +0 -32
- package/dist/components/organisms/Chat/Header/Header.stories.js +0 -96
- package/dist/components/organisms/Chat/Header/index.js +0 -84
- package/dist/components/organisms/Chat/Header/styles.js +0 -20
- package/dist/components/organisms/Chat/index.js +0 -253
- package/dist/components/organisms/Chat/styles.js +0 -29
- package/dist/components/organisms/Modal/Modal.stories.js +0 -66
- package/dist/components/organisms/Modal/index.js +0 -95
- package/dist/components/organisms/Modal/styles.js +0 -20
- package/dist/components/organisms/RangeCalendar/RangeCalendar.stories.js +0 -33
- package/dist/components/organisms/RangeCalendar/index.js +0 -149
- package/dist/components/organisms/RangeCalendar/styles.js +0 -27
- package/dist/global-files/handle_http.js +0 -381
- package/dist/global-files/handle_userTech.js +0 -20
- package/dist/global-files/utils.js +0 -514
- package/src/assets/images/customSelect/starIcon.svg +0 -14
- package/src/assets/images/defaultImages/Spinner.gif +0 -0
- package/src/assets/images/defaultImages/notFound.svg +0 -124
- package/src/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +0 -47
- package/src/components/atoms/ButtonFileChooser/index.js +0 -68
- package/src/components/atoms/ButtonFileChooser/styles.js +0 -4
- package/src/components/atoms/ButtonV2/ButtonV2.stories.js +0 -53
- package/src/components/atoms/ButtonV2/index.js +0 -85
- package/src/components/atoms/ButtonV2/styles.js +0 -217
- package/src/components/atoms/CustomIcon/CustomIcon.stories.js +0 -36
- package/src/components/atoms/CustomIcon/index.js +0 -41
- package/src/components/atoms/CustomIcon/styles.js +0 -85
- package/src/components/atoms/IconFile/IconFile.stories.js +0 -35
- package/src/components/atoms/IconFile/index.js +0 -119
- package/src/components/atoms/IconFile/styles.js +0 -67
- package/src/components/atoms/Image/Image.stories.js +0 -51
- package/src/components/atoms/Image/index.js +0 -55
- package/src/components/atoms/Image/styles.js +0 -34
- package/src/components/atoms/ImageLink/ImageLink.stories.js +0 -43
- package/src/components/atoms/ImageLink/index.js +0 -57
- package/src/components/atoms/ImageLink/styles.js +0 -30
- package/src/components/atoms/ImagePreview/ImagePreview.stories.js +0 -52
- package/src/components/atoms/ImagePreview/index.js +0 -178
- package/src/components/atoms/ImagePreview/styles.js +0 -77
- package/src/components/atoms/InputText/InputText.stories.js +0 -39
- package/src/components/atoms/InputText/index.js +0 -61
- package/src/components/atoms/InputText/styles.js +0 -89
- package/src/components/atoms/NotFound/NotFound.stories.js +0 -19
- package/src/components/atoms/NotFound/index.js +0 -52
- package/src/components/atoms/NotFound/styles.js +0 -55
- package/src/components/atoms/SelectItemV2/SelectItemV2.stories.js +0 -26
- package/src/components/atoms/SelectItemV2/index.js +0 -61
- package/src/components/atoms/SelectItemV2/styles.js +0 -90
- package/src/components/atoms/Tooltip/Tooltip.stories.js +0 -51
- package/src/components/atoms/Tooltip/index.js +0 -59
- package/src/components/atoms/Tooltip/styles.js +0 -42
- package/src/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +0 -54
- package/src/components/molecules/ButtonDownloadFile/index.js +0 -109
- package/src/components/molecules/ButtonDownloadFile/styles.js +0 -66
- package/src/components/molecules/Dropdown/Dropdown.stories.js +0 -103
- package/src/components/molecules/Dropdown/index.js +0 -150
- package/src/components/molecules/Dropdown/styles.js +0 -75
- package/src/components/molecules/ImageTooltip/ImageTooltip.stories.js +0 -68
- package/src/components/molecules/ImageTooltip/index.js +0 -63
- package/src/components/molecules/ImageTooltip/styles.js +0 -18
- package/src/components/molecules/SelectV2/SelectV2.stories.js +0 -115
- package/src/components/molecules/SelectV2/index.js +0 -357
- package/src/components/molecules/SelectV2/styles.js +0 -105
- package/src/components/molecules/SelectV2/test.js +0 -61
- package/src/components/molecules/SelectV2/test.stories.js +0 -10
- package/src/components/organisms/Chat/Chat.stories.js +0 -147
- package/src/components/organisms/Chat/ChatLists/ChatLists.stories.js +0 -65
- package/src/components/organisms/Chat/ChatLists/Rotoplas.jpeg +0 -0
- package/src/components/organisms/Chat/ChatLists/THD.png +0 -0
- package/src/components/organisms/Chat/ChatLists/index.js +0 -141
- package/src/components/organisms/Chat/ChatLists/styles.js +0 -162
- package/src/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +0 -142
- package/src/components/organisms/Chat/ContainerItems/index.js +0 -512
- package/src/components/organisms/Chat/ContainerItems/styles.js +0 -328
- package/src/components/organisms/Chat/ContentChat/ContentChat.stories.js +0 -102
- package/src/components/organisms/Chat/ContentChat/Rotoplas.jpeg +0 -0
- package/src/components/organisms/Chat/ContentChat/THD.png +0 -0
- package/src/components/organisms/Chat/ContentChat/index.js +0 -897
- package/src/components/organisms/Chat/ContentChat/styles.js +0 -41
- package/src/components/organisms/Chat/Footer/Footer.stories.js +0 -22
- package/src/components/organisms/Chat/Footer/index.js +0 -661
- package/src/components/organisms/Chat/Footer/styles.js +0 -286
- package/src/components/organisms/Chat/Header/Header.stories.js +0 -66
- package/src/components/organisms/Chat/Header/index.js +0 -94
- package/src/components/organisms/Chat/Header/styles.js +0 -49
- package/src/components/organisms/Chat/index.js +0 -235
- package/src/components/organisms/Chat/styles.js +0 -42
- package/src/components/organisms/Modal/Modal.stories.js +0 -55
- package/src/components/organisms/Modal/index.js +0 -97
- package/src/components/organisms/Modal/styles.js +0 -103
- package/src/components/organisms/RangeCalendar/RangeCalendar.stories.js +0 -16
- package/src/components/organisms/RangeCalendar/index.js +0 -121
- package/src/components/organisms/RangeCalendar/styles.js +0 -883
- package/src/global-files/handle_http.js +0 -225
- package/src/global-files/handle_userTech.js +0 -7
- package/src/global-files/utils.js +0 -330
|
@@ -1,225 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import { Base64 } from "js-base64";
|
|
2
|
-
import moment from "moment";
|
|
3
|
-
|
|
4
|
-
/*====================================================================
|
|
5
|
-
UTILERIAS PARA EL MANEJO DE ARCHIVOS
|
|
6
|
-
======================================================================*/
|
|
7
|
-
/*------------------------
|
|
8
|
-
devolver el base64
|
|
9
|
-
completo de un file
|
|
10
|
-
--------------------------*/
|
|
11
|
-
export const getBase64 = async (file) => {
|
|
12
|
-
return new Promise((success) => {
|
|
13
|
-
const reader = new FileReader();
|
|
14
|
-
reader.addEventListener("loadend", () => {
|
|
15
|
-
success(reader.result);
|
|
16
|
-
});
|
|
17
|
-
reader.readAsDataURL(file);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/*------------------------
|
|
22
|
-
devolver la data de un string base64
|
|
23
|
-
--------------------------*/
|
|
24
|
-
export const getDataBase64 = (base64Full) => {
|
|
25
|
-
//const base64 = reader.result.replace(/^data:\w+\/\w+.*;base64,/, "");
|
|
26
|
-
try {
|
|
27
|
-
const base64 = base64Full.split("base64,");
|
|
28
|
-
return base64.length ? base64[1] : undefined;
|
|
29
|
-
} catch (err) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/*------------------------
|
|
35
|
-
devolver un data Buffer a partir
|
|
36
|
-
de un data base64
|
|
37
|
-
--------------------------*/
|
|
38
|
-
export const getDataBuffer = (dataBase64) => {
|
|
39
|
-
try {
|
|
40
|
-
const dataBuffer = Buffer.from(dataBase64, "base64");
|
|
41
|
-
return dataBuffer;
|
|
42
|
-
} catch (err) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/*------------------------
|
|
48
|
-
devolver la extension de un file
|
|
49
|
-
a partir de un string: "name.ext"
|
|
50
|
-
--------------------------*/
|
|
51
|
-
export const getFileExtension = (fileName = "") => {
|
|
52
|
-
const nameParts = fileName.split(".");
|
|
53
|
-
let ext = "";
|
|
54
|
-
nameParts.forEach((part, index) => {
|
|
55
|
-
if (index !== 0) {
|
|
56
|
-
if (index + 1 === nameParts.length) ext += part;
|
|
57
|
-
else ext += part + ".";
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return ext === "" ? undefined : ext;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/*------------------------
|
|
64
|
-
devolver el nombre de un file
|
|
65
|
-
a partir de un string: "name.ext"
|
|
66
|
-
--------------------------*/
|
|
67
|
-
export const getFileName = (fileName = "") => {
|
|
68
|
-
const nameParts = fileName.split(".");
|
|
69
|
-
if (nameParts.length) return nameParts[0];
|
|
70
|
-
return undefined;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/*------------------------
|
|
74
|
-
obtener la URL de una imagen
|
|
75
|
-
con un peso mas pequeño al
|
|
76
|
-
peso original pasando como
|
|
77
|
-
parametros:
|
|
78
|
-
=> bucket: <string> bucket en donde se ecuentra la img
|
|
79
|
-
=> key: <string> ruta y nombre completa de la img (keyS3)
|
|
80
|
-
=> width: <number> largo de la img en px
|
|
81
|
-
=> height: <number> altura de la img en px
|
|
82
|
-
--------------------------*/
|
|
83
|
-
export const getImageURL = (bucket, key, width, height) => {
|
|
84
|
-
try {
|
|
85
|
-
const configAWS = {
|
|
86
|
-
bucket: bucket,
|
|
87
|
-
key: key,
|
|
88
|
-
edits: {
|
|
89
|
-
resize: {
|
|
90
|
-
width: width,
|
|
91
|
-
height: height,
|
|
92
|
-
fit: "contain",
|
|
93
|
-
background: { r: 255, g: 255, b: 255, alpha: 0 },
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
let url = "https://d24s337exbt5zr.cloudfront.net/";
|
|
98
|
-
url += Base64.encode(JSON.stringify(configAWS));
|
|
99
|
-
return url;
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.log(`ERROR al obtener la URL de la imagen (${key})`, err.message);
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
/*------------------------
|
|
107
|
-
obtener la dimension de una imagen
|
|
108
|
-
a partir de un objeto <File>
|
|
109
|
-
retorno: {
|
|
110
|
-
=> width: <number> largo de la img en px
|
|
111
|
-
=> height: <number> altura de la img en px
|
|
112
|
-
}
|
|
113
|
-
NOTA regresa <undefined> si no se pudo
|
|
114
|
-
obtener la dimension de la imagen
|
|
115
|
-
--------------------------*/
|
|
116
|
-
export const getImageSize = (file) => {
|
|
117
|
-
return new Promise(async (response) => {
|
|
118
|
-
const img = new Image();
|
|
119
|
-
img.onload = () => response({ width: img.width, height: img.height });
|
|
120
|
-
img.onerror = () => response(undefined);
|
|
121
|
-
const base64 = await getBase64(file);
|
|
122
|
-
img.src = base64;
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/*------------------------
|
|
127
|
-
obtener una redimension (height) proporcional
|
|
128
|
-
a la dimension original (height) a partir de
|
|
129
|
-
un width deseado
|
|
130
|
-
retorno:
|
|
131
|
-
=> newHeight: <number> altura de la img en px
|
|
132
|
-
NOTA regresa <undefined> si no se pudo
|
|
133
|
-
obtener el nuevo <height> de la imagen
|
|
134
|
-
--------------------------*/
|
|
135
|
-
export const getResizeImgHeight = (originalWidth, originalHeight, newWidth) => {
|
|
136
|
-
const scale = (newWidth * 100) / originalWidth / 100;
|
|
137
|
-
return Math.ceil(originalHeight * scale);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/*====================================================================
|
|
141
|
-
UTILERIAS PARA EL MANEJO DE FECHAS
|
|
142
|
-
======================================================================*/
|
|
143
|
-
/*------------------------
|
|
144
|
-
nombres de los dias de la semana
|
|
145
|
-
--------------------------*/
|
|
146
|
-
const weekdayName = {
|
|
147
|
-
1: { short: "Dom", full: "Domingo" },
|
|
148
|
-
2: { short: "Lun", full: "Lunes" },
|
|
149
|
-
3: { short: "Mar", full: "Martes" },
|
|
150
|
-
4: { short: "Mié", full: "Miércoles" },
|
|
151
|
-
5: { short: "Jue", full: "Jueves" },
|
|
152
|
-
6: { short: "Vie", full: "Viernes" },
|
|
153
|
-
7: { short: "Sab", full: "Sabado" },
|
|
154
|
-
};
|
|
155
|
-
/*------------------------
|
|
156
|
-
nombres de los meses
|
|
157
|
-
--------------------------*/
|
|
158
|
-
const monthName = {
|
|
159
|
-
1: { short: "Ene", full: "Enero" },
|
|
160
|
-
2: { short: "Feb", full: "Febrero" },
|
|
161
|
-
3: { short: "Mar", full: "Marzo" },
|
|
162
|
-
4: { short: "Abr", full: "Abril" },
|
|
163
|
-
5: { short: "May", full: "Mayo" },
|
|
164
|
-
6: { short: "Jun", full: "Junio" },
|
|
165
|
-
7: { short: "Jul", full: "Julio" },
|
|
166
|
-
8: { short: "Ago", full: "Agosto" },
|
|
167
|
-
9: { short: "Sep", full: "Septiembre" },
|
|
168
|
-
10: { short: "Oct", full: "Octubre" },
|
|
169
|
-
11: { short: "Nov", full: "Noviembre" },
|
|
170
|
-
12: { short: "Dic", full: "Diciembre" },
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
/*------------------------
|
|
174
|
-
Obtener una fecha a partir de
|
|
175
|
-
un objeto Date() en formato:
|
|
176
|
-
'DDD dd MMM aaaa'
|
|
177
|
-
ejemplo: 'Ene 12 Jul 2022'
|
|
178
|
-
--------------------------*/
|
|
179
|
-
export const getFullDate = (date = new Date()) => {
|
|
180
|
-
if (isNaN(date)) return undefined;
|
|
181
|
-
let dateString = `${weekdayName[date.getDay() + 1].short} `;
|
|
182
|
-
dateString += date.getDate() + " ";
|
|
183
|
-
dateString += `${monthName[date.getMonth() + 1].short} `;
|
|
184
|
-
dateString += date.getFullYear();
|
|
185
|
-
return dateString;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
/*------------------------
|
|
189
|
-
Obtener una fecha a partir de
|
|
190
|
-
un objeto Date() en formato:
|
|
191
|
-
'aaaa-MM-dd'
|
|
192
|
-
ejemplo: '2022-12-25'
|
|
193
|
-
--------------------------*/
|
|
194
|
-
export const getFormatedDate = (date = new Date(), separator = "/") => {
|
|
195
|
-
if (isNaN(date)) return undefined;
|
|
196
|
-
let dateString = "";
|
|
197
|
-
dateString += date.getFullYear() + separator;
|
|
198
|
-
dateString += date.getMonth() + 1 + separator;
|
|
199
|
-
dateString += date.getDate();
|
|
200
|
-
return dateString;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
/*------------------------
|
|
204
|
-
Obtener una fecha a partir de
|
|
205
|
-
un objeto Date() en formato:
|
|
206
|
-
'dd de MMMM del aaaa'
|
|
207
|
-
ejemplo: '12 de octubre del 2022'
|
|
208
|
-
=> si es la fecha del dia actual:
|
|
209
|
-
devolvera 'Hoy'
|
|
210
|
-
=> si es la fecha del dia de ayer:
|
|
211
|
-
devolvera 'Ayer'
|
|
212
|
-
=> si es fecha del mismo año:
|
|
213
|
-
devolvera '12 de octubre'
|
|
214
|
-
--------------------------*/
|
|
215
|
-
export const getCustomDate = (date = new Date()) => {
|
|
216
|
-
if (isNaN(date)) return "";
|
|
217
|
-
let dateString = date.getDate() + " de ";
|
|
218
|
-
dateString += `${monthName[date.getMonth() + 1].full}`;
|
|
219
|
-
const today = new Date();
|
|
220
|
-
const yesterday = new Date();
|
|
221
|
-
yesterday.setDate(today.getDate() - 1);
|
|
222
|
-
|
|
223
|
-
// fecha de Hoy
|
|
224
|
-
if (
|
|
225
|
-
date.getDate() === today.getDate() &&
|
|
226
|
-
date.getMonth() === today.getMonth() &&
|
|
227
|
-
date.getFullYear() === today.getFullYear()
|
|
228
|
-
) {
|
|
229
|
-
return "Hoy";
|
|
230
|
-
}
|
|
231
|
-
// fecha de Ayer
|
|
232
|
-
if (
|
|
233
|
-
date.getDate() === yesterday.getDate() &&
|
|
234
|
-
date.getMonth() === yesterday.getMonth() &&
|
|
235
|
-
date.getFullYear() === yesterday.getFullYear()
|
|
236
|
-
) {
|
|
237
|
-
return "Ayer";
|
|
238
|
-
}
|
|
239
|
-
// fechas del mismo año
|
|
240
|
-
if (date.getFullYear() === today.getFullYear()) return dateString;
|
|
241
|
-
// fechas de diferente año
|
|
242
|
-
return dateString + " del " + date.getFullYear();
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
/*------------------------
|
|
246
|
-
Obtener una hora a partir de
|
|
247
|
-
una fecha string (current_timestamp)
|
|
248
|
-
en formato: 'hh:mm PM/AM'
|
|
249
|
-
ejemplo: '12:34 PM'
|
|
250
|
-
--------------------------*/
|
|
251
|
-
export const getTime = (time = "") => {
|
|
252
|
-
if ([undefined, null, ""].includes(time))
|
|
253
|
-
return moment(new Date()).format("LT");
|
|
254
|
-
return moment(time).format("LT");
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/*====================================================================
|
|
258
|
-
UTILERIAS PARA EL MANEJO DE VALIDACIONES
|
|
259
|
-
======================================================================*/
|
|
260
|
-
/*------------------------
|
|
261
|
-
recibe un number o string
|
|
262
|
-
y determina si es numero natural
|
|
263
|
-
0,1,2,...
|
|
264
|
-
--------------------------*/
|
|
265
|
-
export const isValidNaturalNumber = (number) => {
|
|
266
|
-
if ([undefined, null, ""].includes(number)) return false;
|
|
267
|
-
if (!["string", "number"].includes(typeof number)) return false;
|
|
268
|
-
try {
|
|
269
|
-
const numberString = number + "";
|
|
270
|
-
for (let i = 0; i < numberString.length; i++) {
|
|
271
|
-
if ("0123456789".indexOf(numberString.charAt(i)) === -1) return false;
|
|
272
|
-
}
|
|
273
|
-
return true;
|
|
274
|
-
} catch (err) {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
/*------------------------
|
|
280
|
-
recibe un array y determina si
|
|
281
|
-
el array esta vacio []
|
|
282
|
-
--------------------------*/
|
|
283
|
-
export const isArrayEmpty = (array) => {
|
|
284
|
-
if (Array.isArray(array) && array.length) return false;
|
|
285
|
-
return true;
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
/*------------------------
|
|
289
|
-
recibe un string y determina si
|
|
290
|
-
esta vacio ""
|
|
291
|
-
--------------------------*/
|
|
292
|
-
export const isStringEmpty = (cad) => {
|
|
293
|
-
if (cad && typeof cad === "string" && cad.trim().length !== 0) return false;
|
|
294
|
-
return true;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
/*------------------------
|
|
298
|
-
recibe un string JSON y lo
|
|
299
|
-
decodifica a su valor original
|
|
300
|
-
--------------------------*/
|
|
301
|
-
export const decodeJSON = (valueJSON) => {
|
|
302
|
-
try {
|
|
303
|
-
const decodeValue = JSON.parse(valueJSON);
|
|
304
|
-
return decodeValue;
|
|
305
|
-
} catch (err) {
|
|
306
|
-
return valueJSON;
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
/*------------------------
|
|
311
|
-
recibe un dato y determina si
|
|
312
|
-
es objeto JS
|
|
313
|
-
--------------------------*/
|
|
314
|
-
export const isObject = (obj) => {
|
|
315
|
-
if (obj && typeof obj === "object" && !Array.isArray(obj)) return true;
|
|
316
|
-
return false;
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
/*------------------------
|
|
320
|
-
recibe un value y lo codifica
|
|
321
|
-
primero a JSON y luego a URI
|
|
322
|
-
--------------------------*/
|
|
323
|
-
export const encodeUriJson = (value) => {
|
|
324
|
-
try {
|
|
325
|
-
const encodeValue = encodeURIComponent(JSON.stringify(value));
|
|
326
|
-
return encodeValue;
|
|
327
|
-
} catch (err) {
|
|
328
|
-
return undefined;
|
|
329
|
-
}
|
|
330
|
-
};
|