contentoh-components-library 21.2.26 → 21.2.29
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 +2 -0
- package/dist/assets/images/customSelect/searchIcon.png +0 -0
- package/dist/components/atoms/VerticalSideMenuMainPage/index.js +3 -3
- package/dist/components/atoms/VerticalSideMenuMainPage/styles.js +6 -10
- 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 +7 -12
- package/src/components/atoms/VerticalSideMenuMainPage/styles.js +3 -6
- 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
|
@@ -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>
|
|
@@ -7,4 +7,39 @@ export default {
|
|
|
7
7
|
|
|
8
8
|
const Template = (args) => <Dashboard {...args} />;
|
|
9
9
|
export const DashboardDeafult = Template.bind({});
|
|
10
|
-
DashboardDeafult.args = {
|
|
10
|
+
DashboardDeafult.args = {
|
|
11
|
+
user: {
|
|
12
|
+
id_user: 28,
|
|
13
|
+
name: "Proveedor",
|
|
14
|
+
last_name: "Colgate",
|
|
15
|
+
email: "ilopez@contentoh.com",
|
|
16
|
+
position: "Prueba Admin",
|
|
17
|
+
telephone: "+523111366336",
|
|
18
|
+
country: "México",
|
|
19
|
+
id_company: 1,
|
|
20
|
+
id_cognito: "f5927f8e-cbf7-4922-9e09-e69ec0b2731a",
|
|
21
|
+
birth_Date: null,
|
|
22
|
+
about_me: null,
|
|
23
|
+
zip_code: null,
|
|
24
|
+
address: null,
|
|
25
|
+
job: null,
|
|
26
|
+
id_stripe: "cus_KuEt6R6vwmN09f",
|
|
27
|
+
id_role: 0,
|
|
28
|
+
active: 1,
|
|
29
|
+
is_retailer: 0,
|
|
30
|
+
email_notify: 1,
|
|
31
|
+
membership: {
|
|
32
|
+
id: 76,
|
|
33
|
+
start_date: "2022-01-18T17:25:35.000Z",
|
|
34
|
+
end_date: "2023-01-18T17:25:35.000Z",
|
|
35
|
+
planID: 8,
|
|
36
|
+
plan: "prod_KtlhECVSFG2iro",
|
|
37
|
+
name: "Plan Pro",
|
|
38
|
+
user_limit: "20",
|
|
39
|
+
products_limit: "5000",
|
|
40
|
+
type: "Enterprise",
|
|
41
|
+
},
|
|
42
|
+
src: "https://content-management-profile.s3.amazonaws.com/id-28/28.png?1662994279777",
|
|
43
|
+
},
|
|
44
|
+
jwt: "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiI5ZjdmNzA0My1jZWFjLTRjYjktYjYxNy0zNjA1ODJlZDYxODAiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY2Mjk5NDI3OCwibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2NjI5OTc4NzgsImlhdCI6MTY2Mjk5NDI3OCwiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.Qsmp4f9zCqXueUTk-ACPM5VY2wQ1nM9A8z-UVArukCpJNruA2ypaIuVpISDiCuBXBlRyILM7mzbuTADLvim-KbWT16Tsr9Q3dzCwM4KU3tFkxSblyM0hTdBVy6MKa7KVffGMLqScMVyMpavqbqLXC2GsANJMrBnnOwiTmrNSkFsO4bYovFGwsP6qiN85pMpAdHJjrNpCvilMBXWkNoNdah5_YRckTQOxGpGua_599eqgq4pg7wM1rxh4ze5ZynaQjRLwtXCR70hdXjOZCTyawzH4yiWYZNA4Sv9KkwLjT7vrFmBMjmm3yr72edT492qG6Iskkj_EYhKvOSl_4mDZhg",
|
|
45
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
export const getProviders = async (jwt, companyId) => {
|
|
4
|
+
const query = companyId ? `?companyId=${companyId}` : "";
|
|
5
|
+
const companies = await axios.get(
|
|
6
|
+
`${process.env.REACT_APP_READ_PROVIDERS}${query}`,
|
|
7
|
+
{
|
|
8
|
+
headers: {
|
|
9
|
+
Authorization: jwt,
|
|
10
|
+
},
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
const finalArray = transformProvidersArray(
|
|
14
|
+
JSON.parse(companies.data.body || "{}")?.providers || []
|
|
15
|
+
);
|
|
16
|
+
return finalArray;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const transformProvidersArray = (array) => {
|
|
20
|
+
const newArray = [];
|
|
21
|
+
array.forEach((element) => {
|
|
22
|
+
newArray.push({ id: element.id_company, name: element.trade_name });
|
|
23
|
+
});
|
|
24
|
+
return newArray;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getCategories = async () => {
|
|
28
|
+
const response = await axios.get(
|
|
29
|
+
`${process.env.REACT_APP_CATEGORY_ENDPOINT}`
|
|
30
|
+
);
|
|
31
|
+
const categories = JSON.parse(response.data.body)?.data;
|
|
32
|
+
const categoriesKeys = Object.keys(categories || {});
|
|
33
|
+
const subCategories = categoriesKeys?.map(
|
|
34
|
+
(key) => categories[key].sub_category
|
|
35
|
+
);
|
|
36
|
+
const finalArray = [];
|
|
37
|
+
let index = 0;
|
|
38
|
+
subCategories?.forEach((element) => {
|
|
39
|
+
element &&
|
|
40
|
+
Object.keys(element || {}).forEach((key) => {
|
|
41
|
+
const subCategory = element[key]?.sub_category || {};
|
|
42
|
+
const subOptions = [];
|
|
43
|
+
Object.keys(subCategory)?.forEach((subKey) => {
|
|
44
|
+
subOptions.push({
|
|
45
|
+
id: subCategory[subKey].id_category,
|
|
46
|
+
name: subKey,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
finalArray.push({ id: index++, name: key, subOptions });
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return finalArray;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const formatDate = (date) => {
|
|
57
|
+
const newDate = new Date(date);
|
|
58
|
+
const year = newDate.getFullYear();
|
|
59
|
+
const month = newDate.getMonth() + 1;
|
|
60
|
+
const day = newDate.getDate();
|
|
61
|
+
return `${year}-${month}-${day}`;
|
|
62
|
+
};
|