contentoh-components-library 21.2.27 → 21.2.28
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 +2 -0
- package/.env.production +1 -0
- package/dist/assets/images/customSelect/searchIcon.png +0 -0
- package/dist/components/atoms/VerticalSideMenuMainPage/index.js +46 -53
- package/dist/components/atoms/VerticalSideMenuMainPage/styles.js +18 -29
- package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +54 -0
- package/dist/components/molecules/CustomSelect/SelectItem.js +132 -0
- package/dist/components/molecules/CustomSelect/index.js +178 -0
- package/dist/components/molecules/CustomSelect/styles.js +20 -0
- package/dist/components/organisms/Calendar/styles.js +1 -1
- package/dist/components/organisms/DashboardMetric/index.js +5 -80
- package/dist/components/pages/Dashboard/Dashboard.stories.js +36 -1
- package/dist/components/pages/Dashboard/dashboardUtils.js +129 -0
- package/dist/components/pages/Dashboard/index.js +294 -65
- package/dist/components/pages/Dashboard/styles.js +1 -1
- package/dist/global-files/customHooks.js +0 -1
- package/package.json +1 -1
- package/src/assets/images/customSelect/searchIcon.png +0 -0
- package/src/components/atoms/VerticalSideMenuMainPage/index.js +37 -55
- package/src/components/atoms/VerticalSideMenuMainPage/styles.js +69 -140
- package/src/components/molecules/CustomSelect/CustomSelect.stories.js +27 -0
- package/src/components/molecules/CustomSelect/SelectItem.js +97 -0
- package/src/components/molecules/CustomSelect/index.js +134 -0
- package/src/components/molecules/CustomSelect/styles.js +115 -0
- package/src/components/organisms/Calendar/styles.js +2 -0
- package/src/components/organisms/DashboardMetric/index.js +3 -58
- package/src/components/pages/Dashboard/Dashboard.stories.js +36 -1
- package/src/components/pages/Dashboard/dashboardUtils.js +62 -0
- package/src/components/pages/Dashboard/index.js +190 -26
- package/src/components/pages/Dashboard/styles.js +13 -0
- package/src/global-files/customHooks.js +0 -1
- package/dist/components/atoms/ListCommercialRetailers/ListCommercialRetailers.stories.js +0 -36
- package/dist/components/atoms/ListCommercialRetailers/index.js +0 -64
- package/dist/components/atoms/ListCommercialRetailers/styles.js +0 -20
- package/dist/components/atoms/MenuCommercialRetailers/MenuCommercialRetailers.stories.js +0 -37
- package/dist/components/atoms/MenuCommercialRetailers/index.js +0 -25
- package/dist/components/atoms/MenuCommercialRetailers/styles.js +0 -20
- package/dist/components/atoms/MenuProductImage/MenuProductImage.stories.js +0 -28
- package/dist/components/atoms/MenuProductImage/index.js +0 -88
- package/dist/components/atoms/MenuProductImage/styles.js +0 -20
- package/dist/components/molecules/ApproveRejetPanel/ApproveRejetPanel.stories.js +0 -25
- package/dist/components/molecules/ApproveRejetPanel/index.js +0 -49
- package/dist/components/molecules/ApproveRejetPanel/styles.js +0 -18
- package/dist/components/molecules/SignInLoginCreationApp/SignInLogin.stories.js +0 -28
- package/dist/components/molecules/SignInLoginCreationApp/index.js +0 -270
- package/dist/components/molecules/SignInLoginCreationApp/styles.js +0 -20
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
import { BrowserRouter as Router, NavLink } from "react-router-dom";
|
|
3
|
-
import { createGlobalStyle } from "styled-components";
|
|
4
2
|
|
|
5
3
|
export const Container = styled.div`
|
|
6
4
|
height: 98%;
|
|
@@ -8,8 +6,8 @@ export const Container = styled.div`
|
|
|
8
6
|
padding: 23px 10px 70px 10px;
|
|
9
7
|
flex-direction: column;
|
|
10
8
|
justify-content: space-between;
|
|
11
|
-
overflow:
|
|
12
|
-
width: ${({ bar }) => (bar ?
|
|
9
|
+
overflow: auto;
|
|
10
|
+
width: ${({ bar }) => (bar ? 270 : 58)}px;
|
|
13
11
|
border-radius: ${({ bar }) => (bar ? 20 : 50)}px;
|
|
14
12
|
background: linear-gradient(180deg, #e33aa9 0%, #3b1366 100%);
|
|
15
13
|
scrollbar-width: none;
|
|
@@ -26,155 +24,86 @@ export const Container = styled.div`
|
|
|
26
24
|
display: flex;
|
|
27
25
|
flex-direction: column;
|
|
28
26
|
align-items: flex-start;
|
|
29
|
-
margin-top: ${({ bar }) => (bar === "" ? 145 :
|
|
30
|
-
padding-left: ${({ bar }) => (bar ?
|
|
27
|
+
margin-top: ${({ bar }) => (bar === "" ? 145 : 50)}%;
|
|
28
|
+
padding-left: ${({ bar }) => (bar ? 5 : 0)}px;
|
|
31
29
|
.active {
|
|
32
30
|
background: #e33aa9;
|
|
33
31
|
}
|
|
34
32
|
& + div {
|
|
35
33
|
margin-top: 5px;
|
|
36
34
|
}
|
|
35
|
+
a {
|
|
36
|
+
height: ${({ bar }) => (bar ? 32 : 38)}px;
|
|
37
|
+
display: flex;
|
|
38
|
+
justify-content: ${({ bar }) => (bar ? "flex-start" : "center")};
|
|
39
|
+
border-radius: ${({ bar }) => (bar ? 18 : 100)}px;
|
|
40
|
+
align-items: center;
|
|
41
|
+
font-family: sans-serif;
|
|
42
|
+
font-style: normal;
|
|
43
|
+
font-weight: 400;
|
|
44
|
+
font-size: 18px;
|
|
45
|
+
line-height: 21px;
|
|
46
|
+
letter-spacing: -0.015em;
|
|
47
|
+
color: #fafafa;
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
&.option-link {
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
width: ${({ bar }) => (bar ? "160" : "38")}px;
|
|
52
|
+
margin: 5px 0;
|
|
53
|
+
padding-left: ${({ bar }) => (bar ? 15 : 0)}px;
|
|
54
|
+
}
|
|
55
|
+
p {
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
margin: 0%;
|
|
58
|
+
pointer-events: none;
|
|
59
|
+
}
|
|
60
|
+
img {
|
|
61
|
+
width: 22px;
|
|
62
|
+
& + * {
|
|
63
|
+
margin-left: 12px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
.option-link:hover {
|
|
68
|
+
background: #e33aa9;
|
|
69
|
+
}
|
|
37
70
|
.sub-option {
|
|
38
71
|
display: flex;
|
|
39
72
|
flex-direction: column;
|
|
40
73
|
padding-left: ${({ bar }) => (bar ? 28 : 20)}px;
|
|
41
74
|
height: auto;
|
|
42
75
|
width: auto;
|
|
76
|
+
a {
|
|
77
|
+
display: flex;
|
|
78
|
+
justify-content: flex-start;
|
|
79
|
+
text-decoration: none;
|
|
80
|
+
position: relative;
|
|
81
|
+
font-size: 13px;
|
|
82
|
+
border-left: 1px solid #f0eef2;
|
|
83
|
+
border-radius: 0;
|
|
84
|
+
color: #f0eef2;
|
|
85
|
+
padding-top: 14px;
|
|
86
|
+
padding-left: 12px;
|
|
87
|
+
height: 25px;
|
|
88
|
+
&::before {
|
|
89
|
+
border-left: 1px solid #e33aa9;
|
|
90
|
+
width: 10px;
|
|
91
|
+
content: "";
|
|
92
|
+
border-radius: 50%;
|
|
93
|
+
height: 10px;
|
|
94
|
+
background-color: white;
|
|
95
|
+
position: absolute;
|
|
96
|
+
bottom: 0;
|
|
97
|
+
left: ${({ bar }) => (bar ? -4 : -34)}%;
|
|
98
|
+
}
|
|
99
|
+
&.active {
|
|
100
|
+
background: none;
|
|
101
|
+
&::before {
|
|
102
|
+
background-color: #e33aa9;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
43
106
|
}
|
|
44
107
|
}
|
|
45
108
|
}
|
|
46
109
|
`;
|
|
47
|
-
|
|
48
|
-
export const RouterComponent = styled(Router)``;
|
|
49
|
-
|
|
50
|
-
export const NavLinkOption = styled(NavLink)`
|
|
51
|
-
height: ${({ bar }) => (bar ? 32 : 38)}px;
|
|
52
|
-
display: flex;
|
|
53
|
-
justify-content: ${({ bar }) => (bar ? "flex-start" : "center")};
|
|
54
|
-
border-radius: ${({ bar }) => (bar ? 18 : 100)}px;
|
|
55
|
-
align-items: center;
|
|
56
|
-
font-family: sans-serif;
|
|
57
|
-
font-style: normal;
|
|
58
|
-
font-weight: 400;
|
|
59
|
-
font-size: 18px;
|
|
60
|
-
line-height: 21px;
|
|
61
|
-
margin: 5px 0;
|
|
62
|
-
letter-spacing: -0.015em;
|
|
63
|
-
color: #fafafa;
|
|
64
|
-
text-decoration: none;
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
width: ${({ bar }) => (bar ? "160" : "38")}px;
|
|
67
|
-
padding: 0 17px;
|
|
68
|
-
&:hover {
|
|
69
|
-
background: #e33aa9;
|
|
70
|
-
}
|
|
71
|
-
p {
|
|
72
|
-
cursor: pointer;
|
|
73
|
-
margin: 0%;
|
|
74
|
-
pointer-events: none;
|
|
75
|
-
}
|
|
76
|
-
img {
|
|
77
|
-
width: 22px;
|
|
78
|
-
& + * {
|
|
79
|
-
margin-left: 12px;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
&.sub-option-link {
|
|
83
|
-
display: flex;
|
|
84
|
-
justify-content: flex-start;
|
|
85
|
-
text-decoration: none;
|
|
86
|
-
position: relative;
|
|
87
|
-
font-size: 13px;
|
|
88
|
-
border-left: 1px solid #f0eef2;
|
|
89
|
-
border-radius: 0;
|
|
90
|
-
color: #f0eef2;
|
|
91
|
-
padding-top: 14px;
|
|
92
|
-
height: 25px;
|
|
93
|
-
margin: 0;
|
|
94
|
-
padding-left: 12px;
|
|
95
|
-
&::before {
|
|
96
|
-
border-left: 1px solid #e33aa9;
|
|
97
|
-
width: 10px;
|
|
98
|
-
content: "";
|
|
99
|
-
border-radius: 50%;
|
|
100
|
-
height: 10px;
|
|
101
|
-
background-color: white;
|
|
102
|
-
position: absolute;
|
|
103
|
-
bottom: 0;
|
|
104
|
-
left: ${({ bar }) => (bar ? -4 : -16)}%;
|
|
105
|
-
}
|
|
106
|
-
&.active {
|
|
107
|
-
background: none;
|
|
108
|
-
&::before {
|
|
109
|
-
background-color: #e33aa9;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
&:hover {
|
|
113
|
-
background: none;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
`;
|
|
117
|
-
|
|
118
|
-
export const ContainerPrincipal = styled.div`
|
|
119
|
-
width: 100%;
|
|
120
|
-
display: flex;
|
|
121
|
-
height: 100vh;
|
|
122
|
-
justify-content: space-between;
|
|
123
|
-
`;
|
|
124
|
-
|
|
125
|
-
export const GlobalStyle = createGlobalStyle`
|
|
126
|
-
@font-face {
|
|
127
|
-
font-family: 'Avenir Next';
|
|
128
|
-
font-style: normal;
|
|
129
|
-
font-weight: normal;
|
|
130
|
-
src:
|
|
131
|
-
url('../../assets/fonts/AvenirNextLTPro-Bold.otf') format('otf'),
|
|
132
|
-
url('../../assets/fonts/AvenirNextLTPro-Regular.otf') format('otf');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
html, body, div, span, applet, object, iframe,
|
|
136
|
-
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
137
|
-
a, abbr, acronym, address, big, cite, code,
|
|
138
|
-
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
|
139
|
-
small, strike, strong, sub, sup, tt, var,
|
|
140
|
-
b, u, i, center,
|
|
141
|
-
dl, dt, dd, ol, ul, li,
|
|
142
|
-
fieldset, figure, form, label, legend,
|
|
143
|
-
table, caption, tbody, tfoot, thead, tr, th, td {
|
|
144
|
-
margin: 0;
|
|
145
|
-
padding: 0;
|
|
146
|
-
border: 0;
|
|
147
|
-
outline: 0;
|
|
148
|
-
font-size: 100%;
|
|
149
|
-
vertical-align: baseline;
|
|
150
|
-
background: transparent;
|
|
151
|
-
}
|
|
152
|
-
body {
|
|
153
|
-
line-height: 1;
|
|
154
|
-
}
|
|
155
|
-
ol, ul {
|
|
156
|
-
list-style: none;
|
|
157
|
-
}
|
|
158
|
-
blockquote, q {
|
|
159
|
-
quotes: none;
|
|
160
|
-
}
|
|
161
|
-
blockquote:before, blockquote:after,
|
|
162
|
-
q:before, q:after {
|
|
163
|
-
content: '';
|
|
164
|
-
content: none;
|
|
165
|
-
}
|
|
166
|
-
:focus {
|
|
167
|
-
outline: 0;
|
|
168
|
-
}
|
|
169
|
-
ins {
|
|
170
|
-
text-decoration: none;
|
|
171
|
-
}
|
|
172
|
-
del {
|
|
173
|
-
text-decoration: line-through;
|
|
174
|
-
}
|
|
175
|
-
table {
|
|
176
|
-
border-collapse: collapse;
|
|
177
|
-
border-spacing: 0;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CustomSelect } from "./index";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/molecules/CustomSelect",
|
|
5
|
+
component: CustomSelect,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const Template = (args) => <CustomSelect {...args} />;
|
|
9
|
+
export const CustomSelectDefault = Template.bind({});
|
|
10
|
+
CustomSelectDefault.args = {
|
|
11
|
+
selectLabel: "Todos los departamentos",
|
|
12
|
+
defaultOption: "Todos los departamentos",
|
|
13
|
+
options: [
|
|
14
|
+
{
|
|
15
|
+
id: 1,
|
|
16
|
+
value: "Decoración",
|
|
17
|
+
subOptions: [
|
|
18
|
+
{ id: 1, value: "Espejos" },
|
|
19
|
+
{ id: 2, value: "Persianas" },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{ id: 2, value: "Eléctrico" },
|
|
23
|
+
{ id: 3, value: "Ferretería" },
|
|
24
|
+
{ id: 4, value: "Herramientas" },
|
|
25
|
+
{ id: 5, value: "Iluminación" },
|
|
26
|
+
],
|
|
27
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { CheckBox } from "../../atoms/CheckBox";
|
|
3
|
+
|
|
4
|
+
export const SelecItem = ({
|
|
5
|
+
option,
|
|
6
|
+
customSelectId,
|
|
7
|
+
setParameterArray,
|
|
8
|
+
activeFilters,
|
|
9
|
+
setActiveFilters,
|
|
10
|
+
}) => {
|
|
11
|
+
const [showSubOptions, setShowSubOptions] = useState(false);
|
|
12
|
+
const [chkGlobal, setChkGlobal] = useState(false);
|
|
13
|
+
return (
|
|
14
|
+
<div className="option-container" key={customSelectId + option.id}>
|
|
15
|
+
<div className="main-item">
|
|
16
|
+
<CheckBox
|
|
17
|
+
id={"main-item-" + option.id}
|
|
18
|
+
label={option.name}
|
|
19
|
+
onChange={(e) => {
|
|
20
|
+
const subOptions = option.subOptions;
|
|
21
|
+
const filtersCopy = { ...activeFilters };
|
|
22
|
+
if (subOptions) {
|
|
23
|
+
setChkGlobal(e.target.checked);
|
|
24
|
+
if (e.target.checked) {
|
|
25
|
+
subOptions.forEach((element) => {
|
|
26
|
+
if (!filtersCopy[option.name]) filtersCopy[option.name] = {};
|
|
27
|
+
filtersCopy[option.name][element.name] = 1;
|
|
28
|
+
});
|
|
29
|
+
setParameterArray((current) => [
|
|
30
|
+
...current,
|
|
31
|
+
...subOptions.map((element) => element.id),
|
|
32
|
+
]);
|
|
33
|
+
} else {
|
|
34
|
+
setParameterArray((current) =>
|
|
35
|
+
current.filter(
|
|
36
|
+
(item) => !subOptions.map((opt) => opt.id).includes(item)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
delete filtersCopy[option.name];
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (e.target.checked) {
|
|
43
|
+
filtersCopy[option.name] = 1;
|
|
44
|
+
setParameterArray((current) => [...current, option.id]);
|
|
45
|
+
} else {
|
|
46
|
+
delete filtersCopy[option.name];
|
|
47
|
+
setParameterArray((current) =>
|
|
48
|
+
current.filter((item) => option.id !== item)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
setActiveFilters(filtersCopy);
|
|
53
|
+
}}
|
|
54
|
+
defaultChecked={activeFilters[option.name]}
|
|
55
|
+
/>
|
|
56
|
+
{option.subOptions && (
|
|
57
|
+
<div
|
|
58
|
+
onClick={() => setShowSubOptions(!showSubOptions)}
|
|
59
|
+
className="arrow-item"
|
|
60
|
+
>
|
|
61
|
+
◀
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
{showSubOptions && (
|
|
66
|
+
<div className="sub-menu">
|
|
67
|
+
{option?.subOptions?.map((sub) => (
|
|
68
|
+
<div
|
|
69
|
+
className="sub-filter"
|
|
70
|
+
key={customSelectId + "-" + option.id + "-" + sub.id}
|
|
71
|
+
>
|
|
72
|
+
<CheckBox
|
|
73
|
+
id={"sub-item-" + sub.id}
|
|
74
|
+
label={sub.name}
|
|
75
|
+
defaultChecked={
|
|
76
|
+
activeFilters[option.name] &&
|
|
77
|
+
activeFilters[option.name][sub.name]
|
|
78
|
+
}
|
|
79
|
+
onChange={(e) => {
|
|
80
|
+
if (e.target.checked) {
|
|
81
|
+
setParameterArray((current) =>
|
|
82
|
+
[...current, sub.id].sort((a, b) => a - b)
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
setParameterArray((current) =>
|
|
86
|
+
current.filter((item) => sub.id !== item)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
))}
|
|
93
|
+
</div>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Container } from "./styles";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import searchIcon from "../../../assets/images/customSelect/searchIcon.png";
|
|
4
|
+
import { useCloseModal } from "../../../global-files/customHooks";
|
|
5
|
+
import { SelecItem } from "./SelectItem";
|
|
6
|
+
import { Calendar } from "../../organisms/Calendar";
|
|
7
|
+
|
|
8
|
+
export const CustomSelect = ({
|
|
9
|
+
options,
|
|
10
|
+
showSearchBar,
|
|
11
|
+
placeHolder = "Buscar departamento",
|
|
12
|
+
selectLabel = "",
|
|
13
|
+
customSelectId = "defaultSelectId",
|
|
14
|
+
defaultOption,
|
|
15
|
+
setParameterArray,
|
|
16
|
+
}) => {
|
|
17
|
+
const [filters, setFilters] = useState(options || []);
|
|
18
|
+
const [showList, setShowList] = useCloseModal(customSelectId);
|
|
19
|
+
const [text, setText] = useState("");
|
|
20
|
+
const [showDatePicker, setShowDatePicker] = useCloseModal(customSelectId);
|
|
21
|
+
const [startDate, setStartDate] = useState(new Date());
|
|
22
|
+
const [endDate, setEndDate] = useState(new Date());
|
|
23
|
+
const [activeFilters, setActiveFilters] = useState({});
|
|
24
|
+
|
|
25
|
+
const onChange = (evt) => {
|
|
26
|
+
setText(evt.target.value);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const today = new Date();
|
|
31
|
+
const diff = today.getDate() - today.getDay();
|
|
32
|
+
const start = new Date(today.setDate(diff));
|
|
33
|
+
const end = new Date();
|
|
34
|
+
setStartDate(start);
|
|
35
|
+
setEndDate(end);
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const onChangeDatePicker = (dates) => {
|
|
39
|
+
const [start, end] = dates;
|
|
40
|
+
setStartDate(start);
|
|
41
|
+
setEndDate(end);
|
|
42
|
+
if (end)
|
|
43
|
+
setParameterArray((current) => {
|
|
44
|
+
return {
|
|
45
|
+
...current,
|
|
46
|
+
startDate: `${start.getFullYear()}-${
|
|
47
|
+
start.getMonth() + 1
|
|
48
|
+
}-${start.getDate()}`,
|
|
49
|
+
endDate: `${end.getFullYear()}-${
|
|
50
|
+
end.getMonth() + 1
|
|
51
|
+
}-${end.getDate()}`,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
let filteredArray = options?.slice() || [];
|
|
58
|
+
if (text.length > 0) {
|
|
59
|
+
filteredArray = filteredArray.filter((option) =>
|
|
60
|
+
option?.name.toLowerCase().includes(text.toLocaleLowerCase())
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
setFilters(filteredArray);
|
|
64
|
+
}, [text]);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Container id={customSelectId}>
|
|
68
|
+
<div className="button-list" onClick={() => setShowList(true)}>
|
|
69
|
+
<p>{selectLabel}</p>
|
|
70
|
+
<div className="arrow-item">◀</div>
|
|
71
|
+
</div>
|
|
72
|
+
{showList && (
|
|
73
|
+
<div className="select-container">
|
|
74
|
+
{showSearchBar && (
|
|
75
|
+
<div className="search-bar-filter">
|
|
76
|
+
<img src={searchIcon} alt="search icon" />
|
|
77
|
+
<input
|
|
78
|
+
type="text"
|
|
79
|
+
placeholder={placeHolder}
|
|
80
|
+
value={text}
|
|
81
|
+
onChange={onChange}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
{defaultOption && (
|
|
86
|
+
<div
|
|
87
|
+
className="default-option"
|
|
88
|
+
onClick={() => {
|
|
89
|
+
setParameterArray([]);
|
|
90
|
+
setActiveFilters({});
|
|
91
|
+
setShowList(false);
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
<p>{defaultOption}</p>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
<div className="filters-container">
|
|
98
|
+
{filters?.map((option) =>
|
|
99
|
+
customSelectId === "dates-select" ? (
|
|
100
|
+
<div
|
|
101
|
+
className="dates-select-item"
|
|
102
|
+
key={customSelectId + option.id}
|
|
103
|
+
onClick={() => {
|
|
104
|
+
option.function
|
|
105
|
+
? option.function(setShowDatePicker)
|
|
106
|
+
: setShowDatePicker(true);
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<p>{option.name}</p>
|
|
110
|
+
</div>
|
|
111
|
+
) : (
|
|
112
|
+
<SelecItem
|
|
113
|
+
key={customSelectId + option.id}
|
|
114
|
+
option={option}
|
|
115
|
+
customSelectId={customSelectId}
|
|
116
|
+
setParameterArray={setParameterArray}
|
|
117
|
+
activeFilters={activeFilters}
|
|
118
|
+
setActiveFilters={setActiveFilters}
|
|
119
|
+
/>
|
|
120
|
+
)
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
{showDatePicker && (
|
|
126
|
+
<Calendar
|
|
127
|
+
onChange={onChangeDatePicker}
|
|
128
|
+
startDate={startDate}
|
|
129
|
+
endDate={endDate}
|
|
130
|
+
/>
|
|
131
|
+
)}
|
|
132
|
+
</Container>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { FontFamily } from "../../../global-files/variables";
|
|
3
|
+
|
|
4
|
+
export const Container = styled.div`
|
|
5
|
+
width: fit-content;
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
.button-list {
|
|
9
|
+
font-family: ${FontFamily.Raleway};
|
|
10
|
+
font-size: 13px;
|
|
11
|
+
display: flex;
|
|
12
|
+
padding: 10px 15px;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
border-radius: 50px;
|
|
15
|
+
background-color: #fff;
|
|
16
|
+
border: 1px solid #f0f0f0;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
|
|
19
|
+
.arrow-item {
|
|
20
|
+
transform: rotate(-90deg);
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
font-size: 10px;
|
|
23
|
+
}
|
|
24
|
+
& + * {
|
|
25
|
+
margin-top: 10px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.select-container {
|
|
30
|
+
box-shadow: 0px 2px 4px #00000040;
|
|
31
|
+
border-radius: 5px;
|
|
32
|
+
background-color: #fff;
|
|
33
|
+
padding-bottom: 10px;
|
|
34
|
+
position: absolute;
|
|
35
|
+
z-index: 10;
|
|
36
|
+
.search-bar-filter {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
border: 1px solid #f0f0f0;
|
|
40
|
+
padding-left: 10px;
|
|
41
|
+
|
|
42
|
+
img {
|
|
43
|
+
width: 15px;
|
|
44
|
+
height: 15px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
input {
|
|
48
|
+
background-color: transparent;
|
|
49
|
+
padding: 10px 10px;
|
|
50
|
+
outline: none;
|
|
51
|
+
border: none;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
.default-option {
|
|
55
|
+
padding-top: 5px;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
padding: 5px 10px;
|
|
58
|
+
color: #817393;
|
|
59
|
+
font-family: Avenir Next;
|
|
60
|
+
font-weight: 500;
|
|
61
|
+
font-size: 13px;
|
|
62
|
+
line-height: 21px;
|
|
63
|
+
&:hover {
|
|
64
|
+
background-color: #f0f0f0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
.filters-container {
|
|
68
|
+
overflow: auto;
|
|
69
|
+
max-height: 500px;
|
|
70
|
+
.option-container,
|
|
71
|
+
.default-option {
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
padding: 5px 10px;
|
|
74
|
+
.main-item {
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
|
|
78
|
+
.arrow-item {
|
|
79
|
+
transform: rotate(-90deg);
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
font-size: 10px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
.sub-menu {
|
|
85
|
+
padding-left: 20px;
|
|
86
|
+
.sub-filter {
|
|
87
|
+
& + * {
|
|
88
|
+
margin-top: 10px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&:hover {
|
|
94
|
+
background-color: #f0f0f0;
|
|
95
|
+
}
|
|
96
|
+
label {
|
|
97
|
+
white-space: nowrap;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.dates-select-item {
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
padding: 5px 10px;
|
|
104
|
+
color: #817393;
|
|
105
|
+
font-family: Avenir Next;
|
|
106
|
+
font-weight: 500;
|
|
107
|
+
font-size: 13px;
|
|
108
|
+
line-height: 21px;
|
|
109
|
+
&:hover {
|
|
110
|
+
background-color: #f0f0f0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
@@ -2,6 +2,8 @@ import styled from "styled-components";
|
|
|
2
2
|
import { FontFamily, GlobalColors } from "../../../global-files/variables";
|
|
3
3
|
|
|
4
4
|
export const Container = styled.div`
|
|
5
|
+
z-index: 20;
|
|
6
|
+
position: absolute;
|
|
5
7
|
@charset "UTF-8";
|
|
6
8
|
.react-datepicker__year-read-view--down-arrow,
|
|
7
9
|
.react-datepicker__month-read-view--down-arrow,
|
|
@@ -1,64 +1,18 @@
|
|
|
1
1
|
import { Container } from "./styles";
|
|
2
|
-
import { MetricSelect } from "../../atoms/MetricSelect";
|
|
3
2
|
import { Graphic } from "../../atoms/Graphic";
|
|
4
|
-
import { Calendar } from "../Calendar";
|
|
5
|
-
import { useEffect, useState } from "react";
|
|
6
3
|
|
|
7
4
|
export const DashboardMetric = ({
|
|
8
5
|
label,
|
|
9
6
|
description,
|
|
10
|
-
retailerSelected,
|
|
11
7
|
dataObject = { AA: 89 },
|
|
12
8
|
indexAxis = "y",
|
|
13
9
|
type = "bar",
|
|
14
10
|
scale = "x",
|
|
15
11
|
displayScale = false,
|
|
16
|
-
|
|
17
|
-
setQueryObject,
|
|
18
|
-
queryObject,
|
|
12
|
+
displayLegend = false,
|
|
19
13
|
}) => {
|
|
20
|
-
const onChangeRetailer = (e) => {
|
|
21
|
-
setQueryObject({ ...queryObject, retailerId: e.target.value });
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const [startDate, setStartDate] = useState(new Date());
|
|
25
|
-
const [endDate, setEndDate] = useState(new Date());
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const today = new Date();
|
|
29
|
-
const diff = today.getDate() - today.getDay();
|
|
30
|
-
const start = new Date(today.setDate(diff));
|
|
31
|
-
const end = new Date();
|
|
32
|
-
setStartDate(start);
|
|
33
|
-
setEndDate(end);
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
const onChange = (dates) => {
|
|
37
|
-
const [start, end] = dates;
|
|
38
|
-
setStartDate(start);
|
|
39
|
-
setEndDate(end);
|
|
40
|
-
if (end)
|
|
41
|
-
setQueryObject({
|
|
42
|
-
...queryObject,
|
|
43
|
-
startDate: `${start.getFullYear()}-${
|
|
44
|
-
start.getMonth() + 1
|
|
45
|
-
}-${start.getDate()}`,
|
|
46
|
-
endDate: `${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()}`,
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
14
|
const labels = Object.keys(dataObject);
|
|
51
15
|
const values = Object.values(dataObject);
|
|
52
|
-
const retailersArray = Object.values(retailers).sort((a, b) => {
|
|
53
|
-
if (a.name > b.name) {
|
|
54
|
-
return 1;
|
|
55
|
-
}
|
|
56
|
-
if (a.name < b.name) {
|
|
57
|
-
return -1;
|
|
58
|
-
}
|
|
59
|
-
// a must be equal to b
|
|
60
|
-
return 0;
|
|
61
|
-
});
|
|
62
16
|
const colorsArray = values.map(
|
|
63
17
|
() => `#${Math.floor(Math.random() * 16777215).toString(16)}`
|
|
64
18
|
);
|
|
@@ -86,7 +40,7 @@ export const DashboardMetric = ({
|
|
|
86
40
|
plugins: {
|
|
87
41
|
legend: {
|
|
88
42
|
position: "right",
|
|
89
|
-
display:
|
|
43
|
+
display: displayLegend,
|
|
90
44
|
},
|
|
91
45
|
title: {
|
|
92
46
|
display: false,
|
|
@@ -107,16 +61,7 @@ export const DashboardMetric = ({
|
|
|
107
61
|
<p>{label}</p>
|
|
108
62
|
<p>{description}</p>
|
|
109
63
|
</div>
|
|
110
|
-
<div className="select-container">
|
|
111
|
-
<Calendar onChange={onChange} startDate={startDate} endDate={endDate} />
|
|
112
|
-
<MetricSelect
|
|
113
|
-
className={"select"}
|
|
114
|
-
label={"Cadena comercial"}
|
|
115
|
-
optionSelected={retailerSelected}
|
|
116
|
-
options={retailersArray}
|
|
117
|
-
onChange={onChangeRetailer}
|
|
118
|
-
/>
|
|
119
|
-
</div>
|
|
64
|
+
<div className="select-container"></div>
|
|
120
65
|
<div className="graphic-cotainer">
|
|
121
66
|
<Graphic data={data} options={options} type={type} />
|
|
122
67
|
</div>
|