contentoh-components-library 21.2.6 → 21.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.env.development +1 -3
  2. package/.env.production +1 -3
  3. package/dist/components/atoms/FeatureTag/styles.js +1 -1
  4. package/dist/components/atoms/Graphic/Graphic.stories.js +1 -9
  5. package/dist/components/atoms/Graphic/index.js +9 -4
  6. package/dist/components/atoms/Graphic/styles.js +1 -1
  7. package/dist/components/molecules/VersionItem/index.js +11 -1
  8. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  9. package/dist/components/organisms/VersionSelector/index.js +2 -1
  10. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +121 -73
  11. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +55 -55
  12. package/dist/components/pages/RetailerProductEdition/index.js +3 -3
  13. package/dist/index.js +0 -13
  14. package/package.json +1 -2
  15. package/src/components/atoms/FeatureTag/styles.js +0 -6
  16. package/src/components/atoms/Graphic/Graphic.stories.js +0 -8
  17. package/src/components/atoms/Graphic/index.js +9 -3
  18. package/src/components/atoms/Graphic/styles.js +2 -1
  19. package/src/components/molecules/VersionItem/index.js +8 -0
  20. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  21. package/src/components/organisms/VersionSelector/index.js +2 -0
  22. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +146 -80
  23. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +58 -58
  24. package/src/components/pages/RetailerProductEdition/index.js +2 -3
  25. package/src/index.js +0 -1
  26. package/dist/components/atoms/MetricCard/MetricCard.stories.js +0 -31
  27. package/dist/components/atoms/MetricCard/index.js +0 -24
  28. package/dist/components/atoms/MetricCard/styles.js +0 -20
  29. package/dist/components/atoms/MetricSelect/MetricSelect.stories.js +0 -46
  30. package/dist/components/atoms/MetricSelect/index.js +0 -37
  31. package/dist/components/atoms/MetricSelect/styles.js +0 -20
  32. package/dist/components/organisms/Calendar/Calendar.stories.js +0 -28
  33. package/dist/components/organisms/Calendar/index.js +0 -33
  34. package/dist/components/organisms/Calendar/styles.js +0 -20
  35. package/dist/components/organisms/DashboardMetric/DashboardMetric.stories.js +0 -45
  36. package/dist/components/organisms/DashboardMetric/index.js +0 -168
  37. package/dist/components/organisms/DashboardMetric/styles.js +0 -20
  38. package/dist/components/pages/Dashboard/Dashboard.stories.js +0 -28
  39. package/dist/components/pages/Dashboard/index.js +0 -292
  40. package/dist/components/pages/Dashboard/styles.js +0 -18
  41. package/src/components/atoms/MetricCard/MetricCard.stories.js +0 -14
  42. package/src/components/atoms/MetricCard/index.js +0 -10
  43. package/src/components/atoms/MetricCard/styles.js +0 -30
  44. package/src/components/atoms/MetricSelect/MetricSelect.stories.js +0 -37
  45. package/src/components/atoms/MetricSelect/index.js +0 -22
  46. package/src/components/atoms/MetricSelect/styles.js +0 -20
  47. package/src/components/organisms/Calendar/Calendar.stories.js +0 -10
  48. package/src/components/organisms/Calendar/index.js +0 -17
  49. package/src/components/organisms/Calendar/styles.js +0 -851
  50. package/src/components/organisms/DashboardMetric/DashboardMetric.stories.js +0 -28
  51. package/src/components/organisms/DashboardMetric/index.js +0 -128
  52. package/src/components/organisms/DashboardMetric/styles.js +0 -60
  53. package/src/components/pages/Dashboard/Dashboard.stories.js +0 -10
  54. package/src/components/pages/Dashboard/index.js +0 -146
  55. package/src/components/pages/Dashboard/styles.js +0 -24
@@ -1,28 +0,0 @@
1
- import { DashboardMetric } from "./index";
2
-
3
- export default {
4
- title: "Components/organisms/DashboardMetric",
5
- component: DashboardMetric,
6
- };
7
-
8
- const Template = (args) => <DashboardMetric {...args} />;
9
- export const DashboardMetricDefault = Template.bind({});
10
- DashboardMetricDefault.args = {
11
- label: "Productos por estatus",
12
- description:
13
- "Revisa el avance individual de cada estatus, utiliza los filtros para encontrar información precisa.",
14
- dataObject: {
15
- AA: 89,
16
- ACA: 11,
17
- AC: 100,
18
- AP: 60,
19
- AS: 300,
20
- CA: 50,
21
- PA: 100,
22
- IE: 700,
23
- RA: 50,
24
- RCA: 90,
25
- RC: 11,
26
- RP: 49,
27
- },
28
- };
@@ -1,128 +0,0 @@
1
- import { Container } from "./styles";
2
- import { MetricSelect } from "../../atoms/MetricSelect";
3
- import { Graphic } from "../../atoms/Graphic";
4
- import { Calendar } from "../Calendar";
5
- import { useEffect, useState } from "react";
6
-
7
- export const DashboardMetric = ({
8
- label,
9
- description,
10
- retailerSelected,
11
- dataObject = { AA: 89 },
12
- indexAxis = "y",
13
- type = "bar",
14
- scale = "x",
15
- displayScale = false,
16
- retailers = [],
17
- setQueryObject,
18
- queryObject
19
- }) => {
20
-
21
- const onChangeRetailer = (e) => {
22
- setQueryObject({ ...queryObject, retailerId: e.target.value });
23
- };
24
-
25
- const [startDate, setStartDate] = useState(new Date());
26
- const [endDate, setEndDate] = useState(new Date());
27
-
28
- useEffect(() => {
29
- const today = new Date();
30
- const firstWeekDay = today.getDate() - today.getDay();
31
- const start = `${today.getFullYear()}-${
32
- today.getMonth() + 1
33
- }-${firstWeekDay}`;
34
- const end = new Date();
35
- setStartDate(new Date(start));
36
- setEndDate(end);
37
- }, []);
38
-
39
- const onChange = (dates) => {
40
- const [start, end] = dates;
41
- setStartDate(start);
42
- setEndDate(end);
43
- if (end)
44
- setQueryObject({
45
- ...queryObject,
46
- startDate: `${start.getFullYear()}-${
47
- start.getMonth() + 1
48
- }-${start.getDate()}`,
49
- endDate: `${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()}`,
50
- });
51
- };
52
-
53
- const labels = Object.keys(dataObject);
54
- const values = Object.values(dataObject);
55
- const retailersArray = Object.values(retailers).sort((a, b) => {
56
- if (a.name > b.name) {
57
- return 1;
58
- }
59
- if (a.name < b.name) {
60
- return -1;
61
- }
62
- // a must be equal to b
63
- return 0;
64
- });
65
- const colorsArray = values.map(
66
- () => `#${Math.floor(Math.random() * 16777215).toString(16)}`
67
- );
68
-
69
- const data = {
70
- labels,
71
- datasets: [
72
- {
73
- data: values,
74
- backgroundColor: colorsArray,
75
- },
76
- ],
77
- };
78
-
79
- const options = {
80
- indexAxis,
81
- elements: {
82
- bar: {
83
- borderWidth: 2,
84
- },
85
- },
86
- responsive: true,
87
- maintainAspectRatio: false,
88
- aspectRatio: 1,
89
- plugins: {
90
- legend: {
91
- position: "right",
92
- display: false,
93
- },
94
- title: {
95
- display: false,
96
- },
97
- },
98
- scales: {
99
- [scale]: {
100
- ticks: {
101
- display: displayScale,
102
- },
103
- },
104
- },
105
- };
106
-
107
- return (
108
- <Container>
109
- <div className="text-container">
110
- <p>{label}</p>
111
- <p>{description}</p>
112
- </div>
113
- <div className="select-container">
114
- <Calendar onChange={onChange} startDate={startDate} endDate={endDate} />
115
- <MetricSelect
116
- className={"select"}
117
- label={"Cadena comercial"}
118
- optionSelected={retailerSelected}
119
- options={retailersArray}
120
- onChange={onChangeRetailer}
121
- />
122
- </div>
123
- <div className="graphic-cotainer">
124
- <Graphic data={data} options={options} type={type} />
125
- </div>
126
- </Container>
127
- );
128
- };
@@ -1,60 +0,0 @@
1
- import styled from "styled-components";
2
- import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
-
4
- export const Container = styled.div`
5
- border: 1px solid ${GlobalColors.s3};
6
- border-radius: 5px;
7
- padding: 24px;
8
-
9
- .text-container {
10
- p {
11
- font-family: ${FontFamily.Raleway};
12
- color: ${GlobalColors.s5};
13
- font-size: 17px;
14
-
15
- &:last-of-type {
16
- font-size: 12px;
17
- color: ${GlobalColors.s4};
18
- }
19
-
20
- & + * {
21
- margin-top: 5px;
22
- }
23
- }
24
-
25
- & + * {
26
- margin-top: 15px;
27
- }
28
- }
29
-
30
- .select-container {
31
- display: flex;
32
-
33
- .select {
34
- flex: 0.1 1 30%;
35
-
36
- select {
37
- width: 100%;
38
- }
39
-
40
- & + * {
41
- margin-left: 10px;
42
- }
43
- }
44
-
45
- & + * {
46
- margin-top: 10px;
47
- }
48
- }
49
-
50
- .graphic-cotainer {
51
- height: 300px;
52
- border: 1px solid ${GlobalColors.s3};
53
- padding: 10px;
54
- border-radius: 5px;
55
-
56
- div {
57
- height: fill-available;
58
- }
59
- }
60
- `;
@@ -1,10 +0,0 @@
1
- import { Dashboard } from ".";
2
-
3
- export default {
4
- title: "Components/pages/Dashboard",
5
- component: Dashboard,
6
- };
7
-
8
- const Template = (args) => <Dashboard {...args} />;
9
- export const DashboardDeafult = Template.bind({});
10
- DashboardDeafult.args = {};
@@ -1,146 +0,0 @@
1
- import { Container } from "./styles";
2
- import { MetricCard } from "../../atoms/MetricCard";
3
- import { DashboardMetric } from "../../organisms/DashboardMetric";
4
- import { useEffect, useState } from "react";
5
- import { Loading } from "../../atoms/Loading";
6
- import axios from "axios";
7
-
8
- export const Dashboard = () => {
9
- const [metricsData, setMetricsData] = useState([]);
10
- const [productsByStatus, setProductsByStatus] = useState({});
11
- const [requiredProducts, setRequiredProducts] = useState([]);
12
- const [orderByStatus, setOrderByStatus] = useState({
13
- retailerId: null,
14
- startDate: null,
15
- endDate: null,
16
- });
17
- const [orderByRequired, setOrderByRequired] = useState({
18
- retailerId: null,
19
- startDate: null,
20
- endDate: null,
21
- });
22
- const [retailers, setRetailers] = useState({});
23
- const [loading, setLoading] = useState(true);
24
-
25
- const loadProductVersions = async (queryObject, byStatus = false) => {
26
- const { retailerId, startDate, endDate} = queryObject;
27
- const query = `retailerId=${retailerId}&startDate=${startDate}&endDate=${endDate}`;
28
- const endpoint = byStatus ? process.env.REACT_APP_READ_ORDERS_BY_STATUS : process.env.REACT_APP_READ_REQUIRED_ORDERS
29
- try {
30
- const response = await axios.get(`${endpoint}?${query}`);
31
- return JSON.parse(response.data.body);
32
- } catch (error) {
33
- console.log(error);
34
- }
35
- };
36
-
37
- const getRetailers = async () => {
38
- const retailersResponse = await axios.get(
39
- `${process.env.REACT_APP_RETAILER_ENDPOINT}`,
40
- {
41
- headers: {
42
- Authorization: sessionStorage.getItem("jwt"),
43
- },
44
- }
45
- );
46
- const parsed = JSON.parse(retailersResponse.data.body).data;
47
- const retailers = Object.keys(parsed).map((key) => {
48
- if (key.includes('The Home Depot')) return parsed[key];
49
- }).filter((f) => f);
50
- setRetailers(retailers);
51
- };
52
-
53
- const loadProductsByStatus = async (orderByStatus) => {
54
- const { orders, fullData } = await loadProductVersions(orderByStatus, true);
55
- const { total, R, ACA, PA } = fullData;
56
- const inProcess = Object.keys(fullData).reduce((prev, curr) =>
57
- !['total', 'ACA', 'PA', 'R'].includes(curr) ? prev + fullData[curr] : prev
58
- , 0);
59
- setMetricsData([
60
- { label: "Productos totales", value: total },
61
- { label: "Productos sin asignar", value: PA + R },
62
- { label: "Productos en proceso", value: inProcess },
63
- { label: "Productos terminados", value: ACA },
64
- ]);
65
- setProductsByStatus(orders);
66
- };
67
-
68
- const loadRequiredProducts = async (orderByRequired) => {
69
- const { dates } = await loadProductVersions(orderByRequired);
70
- setRequiredProducts(dates);
71
- };
72
-
73
- useEffect(() => {
74
- const today = new Date();
75
- const firstWeekDay = today.getDate() - today.getDay();
76
- const startDate = `${today.getFullYear()}-${
77
- today.getMonth() + 1
78
- }-${firstWeekDay}`;
79
- const endDate = `${today.getFullYear()}-${
80
- today.getMonth() + 1
81
- }-${today.getDate()}`;
82
- const queryObject = { retailerId: "58", startDate, endDate };
83
- setOrderByStatus(queryObject);
84
- setOrderByRequired(queryObject);
85
- getRetailers();
86
- loadProductsByStatus(queryObject);
87
- loadRequiredProducts(queryObject);
88
- }, []);
89
-
90
- useEffect(() => {
91
- orderByRequired?.retailerId &&
92
- orderByStatus?.retailerId &&
93
- metricsData.length > 0 &&
94
- setLoading(false);
95
- }, [orderByRequired, orderByStatus, metricsData]);
96
-
97
- return loading ? (
98
- <Loading />
99
- ) : (
100
- <Container>
101
- <div className="metric-cards">
102
- {metricsData.map((metric, index) => (
103
- <MetricCard
104
- key={`${index}-${metric.value}`}
105
- label={metric.label}
106
- number={metric.value}
107
- />
108
- ))}
109
- </div>
110
- <div className="metrics-main-container">
111
- <DashboardMetric
112
- label={"Productos por estatus"}
113
- description={
114
- "Revisa el avance individual de cada estatus, utiliza los filtros para encontrar información precisa."
115
- }
116
- dataObject={productsByStatus}
117
- retailerSelected={orderByStatus.retailerId}
118
- retailers={retailers}
119
- queryObject={orderByStatus}
120
- setQueryObject={(evt) => {
121
- loadProductsByStatus(evt);
122
- setOrderByStatus(evt);
123
- }}
124
- />
125
- <DashboardMetric
126
- label={"Productos solicitados"}
127
- description={
128
- "Filtra los productos solicitados por fecha y alcance para revisar rápidamente el flujo de trabajo."
129
- }
130
- dataObject={requiredProducts}
131
- type="line"
132
- indexAxis="x"
133
- scale="x"
134
- displayScale={true}
135
- retailers={retailers}
136
- retailerSelected={orderByRequired.retailerId}
137
- queryObject={orderByRequired}
138
- setQueryObject={(evt) => {
139
- loadRequiredProducts(evt);
140
- setOrderByRequired(evt);
141
- }}
142
- />
143
- </div>
144
- </Container>
145
- );
146
- };
@@ -1,24 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- export const Container = styled.div`
4
- padding: 30px;
5
- .metric-cards {
6
- display: flex;
7
-
8
- > * + * {
9
- margin-left: 10px;
10
- }
11
-
12
- & + * {
13
- margin-top: 10px;
14
- }
15
- }
16
-
17
- .metrics-main-container {
18
- display: flex;
19
-
20
- > * + * {
21
- margin-left: 10px;
22
- }
23
- }
24
- `;