contentoh-components-library 21.2.57 → 21.2.59
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 +4 -1
- package/dist/assets/images/chatPopup/Spinner.gif +0 -0
- package/dist/assets/images/chatPopup/close.svg +3 -0
- package/dist/assets/images/chatPopup/defaultImage.png +0 -0
- package/dist/assets/images/chatPopup/defaultProfile.png +0 -0
- package/dist/assets/images/chatPopup/doc.svg +1 -0
- package/dist/assets/images/chatPopup/document.svg +1 -0
- package/dist/assets/images/chatPopup/iconChat.svg +19 -0
- package/dist/assets/images/chatPopup/iconPlus.svg +3 -0
- package/dist/assets/images/chatPopup/pdf.svg +75 -0
- package/dist/assets/images/chatPopup/remove.svg +4 -0
- package/dist/assets/images/chatPopup/send.svg +3 -0
- package/dist/assets/images/chatPopup/svgIcon.svg +109 -0
- package/dist/assets/images/chatPopup/upload_file.svg +3 -0
- package/dist/assets/images/chatPopup/xls.svg +53 -0
- package/dist/assets/images/customSelect/starIcon.svg +14 -0
- package/dist/components/atoms/ChatPopUp/ChatPopUp.stories.js +28 -0
- package/dist/components/atoms/ChatPopUp/index.js +843 -0
- package/dist/components/atoms/ChatPopUp/styles.js +27 -0
- package/dist/components/atoms/ChatPopUp/utils/handlersChat.js +182 -0
- package/dist/components/atoms/ListCommercialRetailers/ListCommercialRetailers.stories.js +36 -0
- package/dist/components/atoms/ListCommercialRetailers/index.js +64 -0
- package/dist/components/atoms/ListCommercialRetailers/styles.js +20 -0
- package/dist/components/atoms/MenuCommercialRetailers/MenuCommercialRetailers.stories.js +37 -0
- package/dist/components/atoms/MenuCommercialRetailers/index.js +25 -0
- package/dist/components/atoms/MenuCommercialRetailers/styles.js +20 -0
- package/dist/components/atoms/MenuProductImage/MenuProductImage.stories.js +28 -0
- package/dist/components/atoms/MenuProductImage/index.js +88 -0
- package/dist/components/atoms/MenuProductImage/styles.js +20 -0
- package/dist/components/atoms/Tooltip/Tooltip.stories.js +36 -0
- package/dist/components/atoms/Tooltip/index.js +55 -0
- package/dist/components/atoms/Tooltip/styles.js +18 -0
- package/dist/components/molecules/ApproveRejetPanel/ApproveRejetPanel.stories.js +25 -0
- package/dist/components/molecules/ApproveRejetPanel/index.js +49 -0
- package/dist/components/molecules/ApproveRejetPanel/styles.js +18 -0
- package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +21 -22
- package/dist/components/molecules/CustomSelect/SelectItem.js +10 -1
- package/dist/components/molecules/CustomSelect/index.js +36 -9
- package/dist/components/molecules/CustomSelect/styles.js +3 -1
- package/dist/components/molecules/HeaderTop/index.js +19 -6
- package/dist/components/molecules/HeaderTop/styles.js +1 -1
- package/dist/components/molecules/SignInLoginCreationApp/SignInLogin.stories.js +28 -0
- package/dist/components/molecules/SignInLoginCreationApp/index.js +270 -0
- package/dist/components/molecules/SignInLoginCreationApp/styles.js +20 -0
- package/dist/components/pages/Dashboard/Dashboard.stories.js +20 -51
- package/dist/components/pages/Dashboard/index.js +1 -1
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +1 -0
- package/dist/components/pages/ProviderProductEdition/index.js +7 -2
- package/package.json +6 -1
- package/src/assets/images/chatPopup/Spinner.gif +0 -0
- package/src/assets/images/chatPopup/close.svg +3 -0
- package/src/assets/images/chatPopup/defaultImage.png +0 -0
- package/src/assets/images/chatPopup/defaultProfile.png +0 -0
- package/src/assets/images/chatPopup/doc.svg +1 -0
- package/src/assets/images/chatPopup/document.svg +1 -0
- package/src/assets/images/chatPopup/iconChat.svg +19 -0
- package/src/assets/images/chatPopup/iconPlus.svg +3 -0
- package/src/assets/images/chatPopup/pdf.svg +75 -0
- package/src/assets/images/chatPopup/remove.svg +4 -0
- package/src/assets/images/chatPopup/send.svg +3 -0
- package/src/assets/images/chatPopup/svgIcon.svg +109 -0
- package/src/assets/images/chatPopup/upload_file.svg +3 -0
- package/src/assets/images/chatPopup/xls.svg +53 -0
- package/src/assets/images/customSelect/starIcon.svg +14 -0
- package/src/components/atoms/ChatPopUp/ChatPopUp.stories.js +11 -0
- package/src/components/atoms/ChatPopUp/index.js +545 -0
- package/src/components/atoms/ChatPopUp/styles.js +278 -0
- package/src/components/atoms/ChatPopUp/utils/handlersChat.js +104 -0
- package/src/components/atoms/Tooltip/Tooltip.stories.js +15 -0
- package/src/components/atoms/Tooltip/index.js +35 -0
- package/src/components/atoms/Tooltip/styles.js +5 -0
- package/src/components/molecules/CustomSelect/CustomSelect.stories.js +19 -11
- package/src/components/molecules/CustomSelect/SelectItem.js +7 -0
- package/src/components/molecules/CustomSelect/index.js +83 -58
- package/src/components/molecules/CustomSelect/styles.js +3 -1
- package/src/components/molecules/HeaderTop/index.js +23 -7
- package/src/components/molecules/HeaderTop/styles.js +4 -0
- package/src/components/pages/Dashboard/Dashboard.stories.js +20 -56
- package/src/components/pages/Dashboard/index.js +1 -1
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +1 -0
- package/src/components/pages/ProviderProductEdition/index.js +8 -1
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { GlobalColors, FontFamily } from "../../../global-files/variables";
|
|
3
|
+
|
|
4
|
+
export const Container = styled.button`
|
|
5
|
+
height: 34px;
|
|
6
|
+
width: 34px;
|
|
7
|
+
background-color: transparent;
|
|
8
|
+
border: 1px solid #f0f0f0;
|
|
9
|
+
border-radius: 50px;
|
|
10
|
+
padding: 10px;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
position: relative;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
&:hover {
|
|
17
|
+
background-color: #f0f0f0;
|
|
18
|
+
}
|
|
19
|
+
.icon-chat {
|
|
20
|
+
margin: 0;
|
|
21
|
+
width: 15px;
|
|
22
|
+
height: 15px;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
export const Slider = styled.div`
|
|
26
|
+
-webkit-box-shadow: 0px 0px 10px -1px rgba(0, 0, 0, 0.8);
|
|
27
|
+
box-shadow: 0px 0px 10px -1px rgba(0, 0, 0, 0.8);
|
|
28
|
+
z-index: 200;
|
|
29
|
+
width: 425px;
|
|
30
|
+
height: 600px;
|
|
31
|
+
border-radius: 10px;
|
|
32
|
+
background: white;
|
|
33
|
+
padding: 37px 16px 17px 20px;
|
|
34
|
+
position: absolute;
|
|
35
|
+
right: ${({ showMenu }) => (showMenu ? 2 : -50)}%;
|
|
36
|
+
top: 3%;
|
|
37
|
+
transition: right 2s ease 0;
|
|
38
|
+
.image {
|
|
39
|
+
display: flex;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
align-content: center;
|
|
42
|
+
background-color: #f7f7f7;
|
|
43
|
+
border-radius: 10px;
|
|
44
|
+
#myList {
|
|
45
|
+
list-style: none;
|
|
46
|
+
img {
|
|
47
|
+
width: 365px;
|
|
48
|
+
border-radius: 10px;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
.close {
|
|
53
|
+
background-color: #e33aa9;
|
|
54
|
+
border: 3px solid white;
|
|
55
|
+
height: 35px;
|
|
56
|
+
width: 35px;
|
|
57
|
+
border-radius: 50%;
|
|
58
|
+
position: absolute;
|
|
59
|
+
top: -18px;
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
align-items: center;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
.content-chat {
|
|
66
|
+
height: 495px;
|
|
67
|
+
max-height: 495px;
|
|
68
|
+
overflow-y: auto;
|
|
69
|
+
overflow-x: hidden;
|
|
70
|
+
background-color: transparent;
|
|
71
|
+
font-family: sans-serif;
|
|
72
|
+
font-size: 12px;
|
|
73
|
+
& + * {
|
|
74
|
+
margin-top: 12px;
|
|
75
|
+
}
|
|
76
|
+
::-webkit-scrollbar {
|
|
77
|
+
width: 0;
|
|
78
|
+
}
|
|
79
|
+
.cargar-mas {
|
|
80
|
+
border: none;
|
|
81
|
+
border-radius: 10px;
|
|
82
|
+
font: normal normal normal 11px/11px sans-serif;
|
|
83
|
+
letter-spacing: 0.1px;
|
|
84
|
+
color: #8a6caa;
|
|
85
|
+
background-color: #f7f7fc;
|
|
86
|
+
padding: 5px 17px;
|
|
87
|
+
margin: 0 35%;
|
|
88
|
+
display: flex;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
&:hover {
|
|
92
|
+
background-color: #f0f0f0;
|
|
93
|
+
}
|
|
94
|
+
img {
|
|
95
|
+
margin-right: 7px;
|
|
96
|
+
height: 13px;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
#myListChat {
|
|
100
|
+
list-style: none;
|
|
101
|
+
margin: 0;
|
|
102
|
+
padding: 0;
|
|
103
|
+
height: 100%;
|
|
104
|
+
overflow-y: auto;
|
|
105
|
+
overflow-x: hidden;
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: column-reverse;
|
|
108
|
+
gap: 3px;
|
|
109
|
+
.group-date {
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
align-items: center;
|
|
113
|
+
hr {
|
|
114
|
+
width: 120px;
|
|
115
|
+
border: 0.3px solid #f0f0f0;
|
|
116
|
+
}
|
|
117
|
+
p {
|
|
118
|
+
margin: 0 10px;
|
|
119
|
+
color: #b3b3b3;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
li {
|
|
123
|
+
width: 100%;
|
|
124
|
+
padding: 5px 0;
|
|
125
|
+
margin: 0;
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: row-reverse;
|
|
128
|
+
justify-content: flex-start;
|
|
129
|
+
flex-wrap: nowrap;
|
|
130
|
+
gap: 5px;
|
|
131
|
+
align-items: center;
|
|
132
|
+
.tooltip-userName {
|
|
133
|
+
background-color: #f0f0f0;
|
|
134
|
+
padding: 6px 10px;
|
|
135
|
+
color: #000000;
|
|
136
|
+
font-size: 11px;
|
|
137
|
+
margin-bottom: 6px;
|
|
138
|
+
.MuiTooltip-arrow {
|
|
139
|
+
color: #f0f0f0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.profile {
|
|
144
|
+
display: grid;
|
|
145
|
+
place-items: center;
|
|
146
|
+
align-self: start;
|
|
147
|
+
width: 34px;
|
|
148
|
+
height: 34px;
|
|
149
|
+
border-radius: 50%;
|
|
150
|
+
overflow: hidden;
|
|
151
|
+
img {
|
|
152
|
+
width: 100%;
|
|
153
|
+
height: 100%;
|
|
154
|
+
border-radius: inherit;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
.img-file {
|
|
158
|
+
margin: 0 10px;
|
|
159
|
+
width: 165px;
|
|
160
|
+
img {
|
|
161
|
+
width: 100%;
|
|
162
|
+
object-fit: contain;
|
|
163
|
+
border-radius: 10px;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
.body-message {
|
|
167
|
+
margin: 0 10px;
|
|
168
|
+
border-radius: 10px;
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
background-color: #f0f0f0;
|
|
171
|
+
padding: 10px 10px 10px 12px;
|
|
172
|
+
max-width: 280px;
|
|
173
|
+
p {
|
|
174
|
+
color: #262626;
|
|
175
|
+
margin: 0;
|
|
176
|
+
padding: 0;
|
|
177
|
+
}
|
|
178
|
+
a {
|
|
179
|
+
text-decoration: none;
|
|
180
|
+
}
|
|
181
|
+
div {
|
|
182
|
+
cursor: pointer;
|
|
183
|
+
background-color: white;
|
|
184
|
+
border-radius: 10px;
|
|
185
|
+
padding: 7px 10px;
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
img {
|
|
189
|
+
height: 20px;
|
|
190
|
+
width: 20px;
|
|
191
|
+
margin-right: 5px;
|
|
192
|
+
}
|
|
193
|
+
p {
|
|
194
|
+
color: #262626 !important;
|
|
195
|
+
white-space: nowrap;
|
|
196
|
+
text-overflow: ellipsis;
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
.date {
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
white-space: nowrap;
|
|
205
|
+
p {
|
|
206
|
+
color: #d9d9d9;
|
|
207
|
+
font-size: 9px;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
&.own-message {
|
|
211
|
+
flex-direction: row;
|
|
212
|
+
justify-content: flex-start;
|
|
213
|
+
.body-message {
|
|
214
|
+
background-color: #8386ee;
|
|
215
|
+
p {
|
|
216
|
+
margin: 0;
|
|
217
|
+
padding: 0;
|
|
218
|
+
color: #ffffff;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
.input-chat {
|
|
226
|
+
display: flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
border-radius: 17px;
|
|
229
|
+
background-color: #f7f7f7;
|
|
230
|
+
padding: 10px 7px 10px 15px;
|
|
231
|
+
.send-message {
|
|
232
|
+
background-color: transparent;
|
|
233
|
+
width: 157%;
|
|
234
|
+
border: none;
|
|
235
|
+
font-family: sans-serif;
|
|
236
|
+
font-size: 13px;
|
|
237
|
+
line-height: initial;
|
|
238
|
+
color: #242424;
|
|
239
|
+
::placeholder {
|
|
240
|
+
font: normal normal medium 12px/14px sans-serif;
|
|
241
|
+
letter-spacing: 0.6px;
|
|
242
|
+
color: #b3b3b3;
|
|
243
|
+
}
|
|
244
|
+
:focus {
|
|
245
|
+
outline: none;
|
|
246
|
+
}
|
|
247
|
+
& + * {
|
|
248
|
+
margin-left: 10px;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
.upload {
|
|
252
|
+
border: none;
|
|
253
|
+
background: transparent;
|
|
254
|
+
cursor: pointer;
|
|
255
|
+
& + * {
|
|
256
|
+
margin-left: 7px;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
.add-picture-input {
|
|
260
|
+
display: none;
|
|
261
|
+
}
|
|
262
|
+
.send {
|
|
263
|
+
width: 35.4px;
|
|
264
|
+
height: 20px;
|
|
265
|
+
border: none;
|
|
266
|
+
background-color: #e33aa9;
|
|
267
|
+
border-radius: 50%;
|
|
268
|
+
display: flex;
|
|
269
|
+
justify-content: center;
|
|
270
|
+
cursor: pointer;
|
|
271
|
+
align-items: center;
|
|
272
|
+
img {
|
|
273
|
+
width: 11px;
|
|
274
|
+
height: 11px;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
`;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const getBD = (
|
|
6
|
+
id_article,
|
|
7
|
+
version_article,
|
|
8
|
+
get_type,
|
|
9
|
+
item_date ,
|
|
10
|
+
tokenUser
|
|
11
|
+
) => {
|
|
12
|
+
return new Promise(async (response, error) => {
|
|
13
|
+
try {
|
|
14
|
+
let URL = `https://fc069ovhuk.execute-api.us-east-1.amazonaws.com/dev/products-chat`; // endpoint
|
|
15
|
+
URL += `?id_article=${id_article}`;
|
|
16
|
+
URL += `&version_article=${version_article}`;
|
|
17
|
+
URL += `&get_type=${get_type}`;
|
|
18
|
+
URL += `&item_date=${item_date}`;
|
|
19
|
+
|
|
20
|
+
const respHTTPjson = await axios.get(URL, {
|
|
21
|
+
headers: {
|
|
22
|
+
// AQUI COLOCAR EL TOKEN DEL USUARIO CONECTADO
|
|
23
|
+
Authorization: tokenUser,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
//console.log( "respHTTPjson" , respHTTPjson )
|
|
27
|
+
// verificar si existe un error en la peticion realizada
|
|
28
|
+
if (respHTTPjson.status != 200) {
|
|
29
|
+
response({
|
|
30
|
+
message: "No fue posible llevar a cabo la operacion",
|
|
31
|
+
errorDetails: respHTTPjson.statusText,
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// obtener body backend
|
|
36
|
+
const body = JSON.parse(respHTTPjson.data.body);
|
|
37
|
+
//console.log( "resHTTP body:" , body );
|
|
38
|
+
// verificar si existe error desde el backend
|
|
39
|
+
if (respHTTPjson.data.statusCode != 200) {
|
|
40
|
+
response({
|
|
41
|
+
message: body.message,
|
|
42
|
+
errorDetails: body.errorDetail,
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// cuando se ejecuto bien el create ... tomar un posible message
|
|
47
|
+
response({ body });
|
|
48
|
+
} catch (err) {
|
|
49
|
+
//console.log("error catch get items chat" , err);
|
|
50
|
+
response({
|
|
51
|
+
message: "Algo salio mal al obtener los items del chat",
|
|
52
|
+
errorDetails: err.message,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export const createItemBD = (
|
|
60
|
+
id_article,
|
|
61
|
+
version_article,
|
|
62
|
+
value_type,
|
|
63
|
+
value ,
|
|
64
|
+
tokenUser
|
|
65
|
+
) => {
|
|
66
|
+
return new Promise(async (response, error) => {
|
|
67
|
+
try {
|
|
68
|
+
const URL = `https://fc069ovhuk.execute-api.us-east-1.amazonaws.com/dev/products-chat`;
|
|
69
|
+
const bodyData = {
|
|
70
|
+
id_article: id_article,
|
|
71
|
+
version_article: version_article,
|
|
72
|
+
value_type: value_type,
|
|
73
|
+
value: value,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const respHTTPjson = await axios.post(URL, bodyData, {
|
|
77
|
+
headers: {
|
|
78
|
+
Authorization: tokenUser,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
if (respHTTPjson.status != 200) {
|
|
82
|
+
response({
|
|
83
|
+
message: "No fue posible llevar a cabo la operacion",
|
|
84
|
+
errorDetails: respHTTPjson.statusText,
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const body = JSON.parse(respHTTPjson.data.body);
|
|
89
|
+
if (respHTTPjson.data.statusCode != 200) {
|
|
90
|
+
response({
|
|
91
|
+
message: body.message,
|
|
92
|
+
errorDetails: body.errorDetail,
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
response({ body: true });
|
|
97
|
+
} catch (err) {
|
|
98
|
+
response({
|
|
99
|
+
message: "Algo salio mal al agregar el item en el chat",
|
|
100
|
+
errorDetails: err.message,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CustomTooltip } from "./index";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/atoms/CustomTooltip",
|
|
5
|
+
component: CustomTooltip
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const Template = (args) => <CustomTooltip {...args} />;
|
|
9
|
+
|
|
10
|
+
export const TooltipDefault = Template.bind({});
|
|
11
|
+
TooltipDefault.args = {
|
|
12
|
+
componentTooltip: (<p> hola soy tooltip </p>) ,
|
|
13
|
+
children: (<button> abrir tooltip </button>) ,
|
|
14
|
+
className: "container-tooltip"
|
|
15
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { Tooltip } from "@mui/material";
|
|
3
|
+
import { Container } from "./styles";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
export const CustomTooltip = ({
|
|
7
|
+
componentTooltip ,
|
|
8
|
+
children ,
|
|
9
|
+
className ,
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
|
|
13
|
+
const MyComponent = React.forwardRef(function MyComponent(props, ref) {
|
|
14
|
+
return (
|
|
15
|
+
<div {...props} ref={ref}>
|
|
16
|
+
Bin
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Tooltip
|
|
23
|
+
{...props}
|
|
24
|
+
arrow
|
|
25
|
+
placement="top"
|
|
26
|
+
componentsProps={{
|
|
27
|
+
tooltip: {className: className} ,
|
|
28
|
+
popper: {disablePortal: true}
|
|
29
|
+
}}
|
|
30
|
+
title={ componentTooltip }
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</Tooltip>
|
|
34
|
+
)
|
|
35
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CustomSelect } from "./index";
|
|
2
|
+
import iconStar from "../../../assets/images/customSelect/starIcon.svg";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
title: "Components/molecules/CustomSelect",
|
|
@@ -8,20 +9,27 @@ export default {
|
|
|
8
9
|
const Template = (args) => <CustomSelect {...args} />;
|
|
9
10
|
export const CustomSelectDefault = Template.bind({});
|
|
10
11
|
CustomSelectDefault.args = {
|
|
11
|
-
selectLabel: "Todos los departamentos",
|
|
12
|
+
// selectLabel: "Todos los departamentos",
|
|
12
13
|
defaultOption: "Todos los departamentos",
|
|
13
14
|
options: [
|
|
14
15
|
{
|
|
15
|
-
id:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
id: 47,
|
|
17
|
+
name: "Enero 2023",
|
|
18
|
+
isSelected: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 49,
|
|
22
|
+
name: "Mis Favoritos",
|
|
21
23
|
},
|
|
22
|
-
{ id: 2, value: "Eléctrico" },
|
|
23
|
-
{ id: 3, value: "Ferretería" },
|
|
24
|
-
{ id: 4, value: "Herramientas" },
|
|
25
|
-
{ id: 5, value: "Iluminación" },
|
|
26
24
|
],
|
|
25
|
+
onClickItem: (v, id) => {
|
|
26
|
+
if (v) {
|
|
27
|
+
console.log("Agregar a la lista", id);
|
|
28
|
+
} else {
|
|
29
|
+
console.log("Eliminar a la lista", id);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
icon: iconStar,
|
|
33
|
+
showSearchBar: true,
|
|
34
|
+
customOptions: <p>Esto es un customOptions</p>
|
|
27
35
|
};
|
|
@@ -7,6 +7,7 @@ export const SelecItem = ({
|
|
|
7
7
|
setParameterArray,
|
|
8
8
|
activeFilters,
|
|
9
9
|
setActiveFilters,
|
|
10
|
+
onClickItem,
|
|
10
11
|
}) => {
|
|
11
12
|
const [showSubOptions, setShowSubOptions] = useState(false);
|
|
12
13
|
const [chkGlobal, setChkGlobal] = useState(false);
|
|
@@ -17,6 +18,9 @@ export const SelecItem = ({
|
|
|
17
18
|
id={"main-item-" + option.id}
|
|
18
19
|
label={option.name}
|
|
19
20
|
onChange={(e) => {
|
|
21
|
+
if (onClickItem) {
|
|
22
|
+
onClickItem(e.target.checked, option.id)
|
|
23
|
+
}
|
|
20
24
|
const subOptions = option.subOptions;
|
|
21
25
|
const filtersCopy = { ...activeFilters };
|
|
22
26
|
if (subOptions) {
|
|
@@ -77,6 +81,9 @@ export const SelecItem = ({
|
|
|
77
81
|
activeFilters[option.name][sub.name]
|
|
78
82
|
}
|
|
79
83
|
onChange={(e) => {
|
|
84
|
+
if (onClickItem) {
|
|
85
|
+
onClickItem(e.target.checked, sub.id)
|
|
86
|
+
}
|
|
80
87
|
if (e.target.checked) {
|
|
81
88
|
setParameterArray((current) =>
|
|
82
89
|
[...current, sub.id].sort((a, b) => a - b)
|
|
@@ -13,9 +13,12 @@ export const CustomSelect = ({
|
|
|
13
13
|
customSelectId = "defaultSelectId",
|
|
14
14
|
defaultOption,
|
|
15
15
|
setParameterArray,
|
|
16
|
+
onClickItem,
|
|
17
|
+
icon,
|
|
18
|
+
customOptions,
|
|
16
19
|
showFilterString,
|
|
17
20
|
}) => {
|
|
18
|
-
const [filters, setFilters] = useState(
|
|
21
|
+
const [filters, setFilters] = useState([]);
|
|
19
22
|
const [showList, setShowList] = useCloseModal(customSelectId);
|
|
20
23
|
const [text, setText] = useState("");
|
|
21
24
|
const [showDatePicker, setShowDatePicker] = useCloseModal(customSelectId);
|
|
@@ -36,7 +39,21 @@ export const CustomSelect = ({
|
|
|
36
39
|
const end = new Date();
|
|
37
40
|
setStartDate(start);
|
|
38
41
|
setEndDate(end);
|
|
39
|
-
|
|
42
|
+
const obj = {};
|
|
43
|
+
options.forEach((o) => {
|
|
44
|
+
const { name, isSelected, subOptions } = o;
|
|
45
|
+
if (isSelected) obj[name] = {};
|
|
46
|
+
subOptions?.forEach((so) => {
|
|
47
|
+
const { name: nameSO, isSelected: isSelectedSO } = so;
|
|
48
|
+
if (isSelectedSO) {
|
|
49
|
+
if (!obj[name]) obj[name] = {};
|
|
50
|
+
obj[name][nameSO] = true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
setActiveFilters(obj);
|
|
55
|
+
setFilters(options);
|
|
56
|
+
}, [options]);
|
|
40
57
|
|
|
41
58
|
const onChangeDatePicker = (dates) => {
|
|
42
59
|
const [start, end] = dates;
|
|
@@ -82,68 +99,76 @@ export const CustomSelect = ({
|
|
|
82
99
|
}, [activeFilters]);
|
|
83
100
|
|
|
84
101
|
return (
|
|
85
|
-
<Container id={customSelectId}>
|
|
102
|
+
<Container id={customSelectId} selectLabel={selectLabel}>
|
|
86
103
|
<div className="button-list" onClick={() => setShowList(!showList)}>
|
|
87
|
-
<p>{filtersString}</p>
|
|
104
|
+
<p>{filtersString} </p>
|
|
88
105
|
<p>{filtersCounter > 0 && `+${filtersCounter}`}</p>
|
|
89
|
-
|
|
106
|
+
{icon ? (
|
|
107
|
+
<img src={icon} alt="Favorite" width={"20px"} />
|
|
108
|
+
) : (
|
|
109
|
+
<div className="arrow-item">◀</div>
|
|
110
|
+
)}
|
|
90
111
|
</div>
|
|
91
|
-
{showList &&
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{defaultOption && (
|
|
105
|
-
<div
|
|
106
|
-
className="default-option"
|
|
107
|
-
onClick={() => {
|
|
108
|
-
setParameterArray([]);
|
|
109
|
-
setActiveFilters({});
|
|
110
|
-
setShowList(false);
|
|
111
|
-
setFiltersString(selectLabel);
|
|
112
|
-
setFiltersCounter(0);
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
<p>{defaultOption}</p>
|
|
116
|
-
</div>
|
|
117
|
-
)}
|
|
118
|
-
<div className="filters-container">
|
|
119
|
-
{filters?.map((option) =>
|
|
120
|
-
customSelectId === "dates-select" ? (
|
|
121
|
-
<div
|
|
122
|
-
className="dates-select-item"
|
|
123
|
-
key={customSelectId + option.id}
|
|
124
|
-
onClick={() => {
|
|
125
|
-
option.function
|
|
126
|
-
? option.function(setShowDatePicker)
|
|
127
|
-
: setShowDatePicker(true);
|
|
128
|
-
setFiltersString(option.name);
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
<p>{option.name}</p>
|
|
132
|
-
</div>
|
|
133
|
-
) : (
|
|
134
|
-
<SelecItem
|
|
135
|
-
key={customSelectId + option.id}
|
|
136
|
-
option={option}
|
|
137
|
-
customSelectId={customSelectId}
|
|
138
|
-
setParameterArray={setParameterArray}
|
|
139
|
-
activeFilters={activeFilters}
|
|
140
|
-
setActiveFilters={setActiveFilters}
|
|
112
|
+
{showList &&
|
|
113
|
+
(customOptions ? (
|
|
114
|
+
customOptions
|
|
115
|
+
) : (
|
|
116
|
+
<div className="select-container">
|
|
117
|
+
{showSearchBar && (
|
|
118
|
+
<div className="search-bar-filter">
|
|
119
|
+
<img src={searchIcon} alt="search icon" />
|
|
120
|
+
<input
|
|
121
|
+
type="text"
|
|
122
|
+
placeholder={placeHolder}
|
|
123
|
+
value={text}
|
|
124
|
+
onChange={onChange}
|
|
141
125
|
/>
|
|
142
|
-
|
|
126
|
+
</div>
|
|
143
127
|
)}
|
|
128
|
+
{defaultOption && (
|
|
129
|
+
<div
|
|
130
|
+
className="default-option"
|
|
131
|
+
onClick={() => {
|
|
132
|
+
setParameterArray && setParameterArray([]);
|
|
133
|
+
setActiveFilters({});
|
|
134
|
+
setShowList(false);
|
|
135
|
+
setFiltersString(selectLabel);
|
|
136
|
+
setFiltersCounter(0);
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<p>{defaultOption}</p>
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
<div className="filters-container">
|
|
143
|
+
{filters?.map((option) =>
|
|
144
|
+
customSelectId === "dates-select" ? (
|
|
145
|
+
<div
|
|
146
|
+
className="dates-select-item"
|
|
147
|
+
key={customSelectId + option.id}
|
|
148
|
+
onClick={() => {
|
|
149
|
+
option.function
|
|
150
|
+
? option.function(setShowDatePicker)
|
|
151
|
+
: setShowDatePicker(true);
|
|
152
|
+
setFiltersString(option.name);
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<p>{option.name}</p>
|
|
156
|
+
</div>
|
|
157
|
+
) : (
|
|
158
|
+
<SelecItem
|
|
159
|
+
key={customSelectId + option.id}
|
|
160
|
+
option={option}
|
|
161
|
+
customSelectId={customSelectId}
|
|
162
|
+
setParameterArray={setParameterArray}
|
|
163
|
+
activeFilters={activeFilters}
|
|
164
|
+
setActiveFilters={setActiveFilters}
|
|
165
|
+
onClickItem={onClickItem}
|
|
166
|
+
/>
|
|
167
|
+
)
|
|
168
|
+
)}
|
|
169
|
+
</div>
|
|
144
170
|
</div>
|
|
145
|
-
|
|
146
|
-
)}
|
|
171
|
+
))}
|
|
147
172
|
{showDatePicker && (
|
|
148
173
|
<Calendar
|
|
149
174
|
onChange={onChangeDatePicker}
|
|
@@ -10,7 +10,9 @@ export const Container = styled.div`
|
|
|
10
10
|
font-family: ${FontFamily.Raleway};
|
|
11
11
|
font-size: 13px;
|
|
12
12
|
display: flex;
|
|
13
|
-
padding: 10px 15px;
|
|
13
|
+
padding: ${(props) => (props.selectLabel !== "" ? "10px 15px" : "5px 5px")};
|
|
14
|
+
//padding: 10px 15px;
|
|
15
|
+
//padding: 5px 5px;
|
|
14
16
|
justify-content: space-between;
|
|
15
17
|
border-radius: 50px;
|
|
16
18
|
background-color: #fff;
|