contentoh-components-library 21.2.4 → 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 +42 -216
  12. package/dist/components/pages/RetailerProductEdition/index.js +1 -1
  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 +41 -254
  24. package/src/components/pages/RetailerProductEdition/index.js +1 -1
  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 -36
  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 -286
  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 -142
  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,142 +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
- setRetailers(JSON.parse(retailersResponse.data.body).data);
47
- };
48
-
49
- const loadProductsByStatus = async (orderByStatus) => {
50
- const { orders, fullData } = await loadProductVersions(orderByStatus, true);
51
- const { total, R, ACA, PA } = fullData;
52
- const inProcess = Object.keys(fullData).reduce((prev, curr) =>
53
- !['total', 'ACA', 'PA', 'R'].includes(curr) ? prev + fullData[curr] : prev
54
- , 0);
55
- setMetricsData([
56
- { label: "Productos totales", value: total },
57
- { label: "Productos sin asignar", value: PA + R },
58
- { label: "Productos en proceso", value: inProcess },
59
- { label: "Productos terminados", value: ACA },
60
- ]);
61
- setProductsByStatus(orders);
62
- };
63
-
64
- const loadRequiredProducts = async (orderByRequired) => {
65
- const { dates } = await loadProductVersions(orderByRequired);
66
- setRequiredProducts(dates);
67
- };
68
-
69
- useEffect(() => {
70
- const today = new Date();
71
- const firstWeekDay = today.getDate() - today.getDay();
72
- const startDate = `${today.getFullYear()}-${
73
- today.getMonth() + 1
74
- }-${firstWeekDay}`;
75
- const endDate = `${today.getFullYear()}-${
76
- today.getMonth() + 1
77
- }-${today.getDate()}`;
78
- const queryObject = { retailerId: "58", startDate, endDate };
79
- setOrderByStatus(queryObject);
80
- setOrderByRequired(queryObject);
81
- getRetailers();
82
- loadProductsByStatus(queryObject);
83
- loadRequiredProducts(queryObject);
84
- }, []);
85
-
86
- useEffect(() => {
87
- orderByRequired?.retailerId &&
88
- orderByStatus?.retailerId &&
89
- metricsData.length > 0 &&
90
- setLoading(false);
91
- }, [orderByRequired, orderByStatus, metricsData]);
92
-
93
- return loading ? (
94
- <Loading />
95
- ) : (
96
- <Container>
97
- <div className="metric-cards">
98
- {metricsData.map((metric, index) => (
99
- <MetricCard
100
- key={`${index}-${metric.value}`}
101
- label={metric.label}
102
- number={metric.value}
103
- />
104
- ))}
105
- </div>
106
- <div className="metrics-main-container">
107
- <DashboardMetric
108
- label={"Productos por estatus"}
109
- description={
110
- "Revisa el avance individual de cada estatus, utiliza los filtros para encontrar información precisa."
111
- }
112
- dataObject={productsByStatus}
113
- retailerSelected={orderByStatus.retailerId}
114
- retailers={retailers}
115
- queryObject={orderByStatus}
116
- setQueryObject={(evt) => {
117
- loadProductsByStatus(evt);
118
- setOrderByStatus(evt);
119
- }}
120
- />
121
- <DashboardMetric
122
- label={"Productos solicitados"}
123
- description={
124
- "Filtra los productos solicitados por fecha y alcance para revisar rápidamente el flujo de trabajo."
125
- }
126
- dataObject={requiredProducts}
127
- type="line"
128
- indexAxis="x"
129
- scale="x"
130
- displayScale={true}
131
- retailers={retailers}
132
- retailerSelected={orderByRequired.retailerId}
133
- queryObject={orderByRequired}
134
- setQueryObject={(evt) => {
135
- loadRequiredProducts(evt);
136
- setOrderByRequired(evt);
137
- }}
138
- />
139
- </div>
140
- </Container>
141
- );
142
- };
@@ -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
- `;