contentoh-components-library 21.1.99 → 21.2.2

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 (47) hide show
  1. package/.env.development +3 -1
  2. package/.env.production +3 -1
  3. package/dist/components/atoms/FeatureTag/styles.js +1 -1
  4. package/dist/components/atoms/Graphic/Graphic.stories.js +9 -1
  5. package/dist/components/atoms/Graphic/index.js +4 -9
  6. package/dist/components/atoms/Graphic/styles.js +1 -1
  7. package/dist/components/atoms/MetricCard/MetricCard.stories.js +31 -0
  8. package/dist/components/atoms/MetricCard/index.js +24 -0
  9. package/dist/components/atoms/MetricCard/styles.js +20 -0
  10. package/dist/components/atoms/MetricSelect/MetricSelect.stories.js +46 -0
  11. package/dist/components/atoms/MetricSelect/index.js +36 -0
  12. package/dist/components/atoms/MetricSelect/styles.js +20 -0
  13. package/dist/components/organisms/Calendar/Calendar.stories.js +28 -0
  14. package/dist/components/organisms/Calendar/index.js +33 -0
  15. package/dist/components/organisms/Calendar/styles.js +20 -0
  16. package/dist/components/organisms/DashboardMetric/DashboardMetric.stories.js +45 -0
  17. package/dist/components/organisms/DashboardMetric/index.js +171 -0
  18. package/dist/components/organisms/DashboardMetric/styles.js +20 -0
  19. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  20. package/dist/components/pages/Dashboard/Dashboard.stories.js +28 -0
  21. package/dist/components/pages/Dashboard/index.js +272 -0
  22. package/dist/components/pages/Dashboard/styles.js +18 -0
  23. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +73 -121
  24. package/dist/index.js +13 -0
  25. package/package.json +1 -1
  26. package/src/components/atoms/FeatureTag/styles.js +6 -0
  27. package/src/components/atoms/Graphic/Graphic.stories.js +8 -0
  28. package/src/components/atoms/Graphic/index.js +3 -9
  29. package/src/components/atoms/Graphic/styles.js +1 -2
  30. package/src/components/atoms/MetricCard/MetricCard.stories.js +14 -0
  31. package/src/components/atoms/MetricCard/index.js +10 -0
  32. package/src/components/atoms/MetricCard/styles.js +30 -0
  33. package/src/components/atoms/MetricSelect/MetricSelect.stories.js +37 -0
  34. package/src/components/atoms/MetricSelect/index.js +22 -0
  35. package/src/components/atoms/MetricSelect/styles.js +20 -0
  36. package/src/components/organisms/Calendar/Calendar.stories.js +10 -0
  37. package/src/components/organisms/Calendar/index.js +17 -0
  38. package/src/components/organisms/Calendar/styles.js +851 -0
  39. package/src/components/organisms/DashboardMetric/DashboardMetric.stories.js +28 -0
  40. package/src/components/organisms/DashboardMetric/index.js +126 -0
  41. package/src/components/organisms/DashboardMetric/styles.js +60 -0
  42. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  43. package/src/components/pages/Dashboard/Dashboard.stories.js +10 -0
  44. package/src/components/pages/Dashboard/index.js +145 -0
  45. package/src/components/pages/Dashboard/styles.js +24 -0
  46. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +80 -146
  47. package/src/index.js +1 -0
@@ -0,0 +1,28 @@
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
+ };
@@ -0,0 +1,126 @@
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
+ }) => {
19
+ const onChangeRetailer = (e) => {
20
+ setQueryObject((current) => ({ ...current, retailerId: e.target.value }));
21
+ };
22
+
23
+ const [startDate, setStartDate] = useState(new Date());
24
+ const [endDate, setEndDate] = useState(new Date());
25
+
26
+ useEffect(() => {
27
+ const today = new Date();
28
+ const firstWeekDay = today.getDate() - today.getDay();
29
+ const start = `${today.getFullYear()}-${
30
+ today.getMonth() + 1
31
+ }-${firstWeekDay}`;
32
+ const end = new Date();
33
+ setStartDate(new Date(start));
34
+ setEndDate(end);
35
+ }, []);
36
+
37
+ const onChange = (dates) => {
38
+ const [start, end] = dates;
39
+ setStartDate(start);
40
+ setEndDate(end);
41
+ if (end)
42
+ setQueryObject((current) => ({
43
+ ...current,
44
+ startDate: `${start.getFullYear()}-${
45
+ start.getMonth() + 1
46
+ }-${start.getDate()}`,
47
+ endDate: `${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()}`,
48
+ }));
49
+ };
50
+
51
+ const labels = Object.keys(dataObject);
52
+ const values = Object.values(dataObject);
53
+ const retailersArray = Object.values(retailers).sort((a, b) => {
54
+ if (a.name > b.name) {
55
+ return 1;
56
+ }
57
+ if (a.name < b.name) {
58
+ return -1;
59
+ }
60
+ // a must be equal to b
61
+ return 0;
62
+ });
63
+ const colorsArray = values.map(
64
+ () => `#${Math.floor(Math.random() * 16777215).toString(16)}`
65
+ );
66
+
67
+ const data = {
68
+ labels,
69
+ datasets: [
70
+ {
71
+ data: values,
72
+ backgroundColor: colorsArray,
73
+ },
74
+ ],
75
+ };
76
+
77
+ const options = {
78
+ indexAxis,
79
+ elements: {
80
+ bar: {
81
+ borderWidth: 2,
82
+ },
83
+ },
84
+ responsive: true,
85
+ maintainAspectRatio: false,
86
+ aspectRatio: 1,
87
+ plugins: {
88
+ legend: {
89
+ position: "right",
90
+ display: false,
91
+ },
92
+ title: {
93
+ display: false,
94
+ },
95
+ },
96
+ scales: {
97
+ [scale]: {
98
+ ticks: {
99
+ display: displayScale,
100
+ },
101
+ },
102
+ },
103
+ };
104
+
105
+ return (
106
+ <Container>
107
+ <div className="text-container">
108
+ <p>{label}</p>
109
+ <p>{description}</p>
110
+ </div>
111
+ <div className="select-container">
112
+ <Calendar onChange={onChange} startDate={startDate} endDate={endDate} />
113
+ <MetricSelect
114
+ className={"select"}
115
+ label={"Cadena comercial"}
116
+ optionSelected={retailerSelected}
117
+ options={retailersArray}
118
+ onChange={onChangeRetailer}
119
+ />
120
+ </div>
121
+ <div className="graphic-cotainer">
122
+ <Graphic data={data} options={options} type={type} />
123
+ </div>
124
+ </Container>
125
+ );
126
+ };
@@ -0,0 +1,60 @@
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
+ `;
@@ -60,7 +60,7 @@ export const FullProductNameHeader = ({
60
60
  value: headerData?.article?.company_name,
61
61
  },
62
62
  {
63
- feature: "UPC",
63
+ feature: "SKU",
64
64
  value: headerData?.article?.upc || headerData?.upc,
65
65
  },
66
66
  ]}
@@ -0,0 +1,10 @@
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 = {};
@@ -0,0 +1,145 @@
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 (byStatus, queryObject) => {
26
+ const { retailerId, startDate, endDate, fullData } = queryObject;
27
+ const query = fullData
28
+ ? `fullData=true`
29
+ : `retailerId=${retailerId}&startDate=${startDate}&endDate=${endDate}`;
30
+ try {
31
+ const response = await axios.get(
32
+ byStatus
33
+ ? `${process.env.REACT_APP_READ_ORDERS_BY_STATUS}?${query}`
34
+ : `${process.env.REACT_APP_READ_REQUIRED_ORDERS}?retailerId=${retailerId}&startDate=${startDate}&endDate=${endDate}`
35
+ );
36
+
37
+ const versionList = JSON.parse(response.data.body);
38
+ return versionList;
39
+ } catch (error) {
40
+ console.log(error);
41
+ }
42
+ };
43
+
44
+ const getRetailers = async () => {
45
+ const retailersResponse = await axios.get(
46
+ `${process.env.REACT_APP_RETAILER_ENDPOINT}`,
47
+ {
48
+ headers: {
49
+ Authorization: sessionStorage.getItem("jwt"),
50
+ },
51
+ }
52
+ );
53
+ setRetailers(JSON.parse(retailersResponse.data.body).data);
54
+ };
55
+
56
+ const loadProductsByStatus = async (orderByStatus) => {
57
+ const { orders, fullData } = await loadProductVersions(true, orderByStatus);
58
+ setMetricsData([
59
+ { label: "Productos totales", value: fullData?.total },
60
+ { label: "Productos sin asignar", value: fullData?.PA },
61
+ { label: "Productos en proceso", value: fullData?.CA },
62
+ { label: "Productos terminados", value: fullData?.AP },
63
+ ]);
64
+ setProductsByStatus(orders);
65
+ };
66
+
67
+ const loadRequiredProducts = async (orderByRequired) => {
68
+ const { dates } = await loadProductVersions(false, orderByRequired);
69
+ setRequiredProducts(dates);
70
+ };
71
+
72
+ useEffect(() => {
73
+ const today = new Date();
74
+ const firstWeekDay = today.getDate() - today.getDay();
75
+ const startDate = `${today.getFullYear()}-${
76
+ today.getMonth() + 1
77
+ }-${firstWeekDay}`;
78
+ const endDate = `${today.getFullYear()}-${
79
+ today.getMonth() + 1
80
+ }-${today.getDate()}`;
81
+ const queryObject = { retailerId: "58", startDate, endDate };
82
+ setOrderByStatus(queryObject);
83
+ setOrderByRequired(queryObject);
84
+ getRetailers();
85
+ }, []);
86
+
87
+ useEffect(() => {
88
+ loadProductsByStatus(orderByStatus);
89
+ }, [orderByStatus]);
90
+
91
+ useEffect(() => {
92
+ loadRequiredProducts(orderByRequired);
93
+ }, [orderByRequired]);
94
+
95
+ useEffect(() => {
96
+ orderByRequired?.retailerId &&
97
+ orderByStatus?.retailerId &&
98
+ metricsData.length > 0 &&
99
+ setLoading(false);
100
+ }, [orderByRequired, orderByStatus, metricsData]);
101
+
102
+ return loading ? (
103
+ <Loading />
104
+ ) : (
105
+ <Container>
106
+ <div className="metric-cards">
107
+ {metricsData.map((metric, index) => (
108
+ <MetricCard
109
+ key={`${index}-${metric.value}`}
110
+ label={metric.label}
111
+ number={metric.value}
112
+ />
113
+ ))}
114
+ </div>
115
+ <div className="metrics-main-container">
116
+ <DashboardMetric
117
+ label={"Productos por estatus"}
118
+ description={
119
+ "Revisa el avance individual de cada estatus, utiliza los filtros para encontrar información precisa."
120
+ }
121
+ dataObject={productsByStatus}
122
+ retailerSelected={orderByStatus.retailerId}
123
+ retailers={retailers}
124
+ queryObject={orderByStatus}
125
+ setQueryObject={setOrderByStatus}
126
+ />
127
+ <DashboardMetric
128
+ label={"Productos solicitados"}
129
+ description={
130
+ "Filtra los productos solicitados por fecha y alcance para revisar rápidamente el flujo de trabajo."
131
+ }
132
+ dataObject={requiredProducts}
133
+ type="line"
134
+ indexAxis="x"
135
+ scale="x"
136
+ displayScale={true}
137
+ retailers={retailers}
138
+ retailerSelected={orderByRequired.retailerId}
139
+ queryObject={orderByRequired}
140
+ setQueryObject={setOrderByRequired}
141
+ />
142
+ </div>
143
+ </Container>
144
+ );
145
+ };
@@ -0,0 +1,24 @@
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
+ `;
@@ -21,172 +21,106 @@ ProviderProductEditionDefault.args = {
21
21
  category: 846,
22
22
  version: 2,
23
23
  productSelected: {
24
- articleStatus: "ACA",
25
- version: 5,
26
- missing: {},
24
+ orderId: 2446,
25
+ article_status: "AP",
26
+ datasheet_status: "AP",
27
+ description_status: "AP",
28
+ images_status: "ACA",
29
+ prio: "none",
30
+ version: 2,
31
+ brand: null,
27
32
  article: {
28
33
  category:
29
- "Materiales de Construcción|Impermeabilizantes y Recubrimientos|Selladores",
30
- company_name: "SIKA MEXICANA S.A. DE C.V.",
31
- company_id: 383,
32
- id_category: "2249",
33
- id_article: 29457,
34
- name: "SIKA TECHO FRESCO SUPER 15",
35
- upc: "111187",
34
+ "Organizadores y Closets|Accesorios de Lavandería|Organizadores de Lavandería",
35
+ company_name: "WOMEX SA DE CV",
36
+ id_company: 424,
37
+ country: null,
38
+ id_category: "2522",
39
+ id_article: 78773,
40
+ name: "RACK PARA ROPA DOBLE NEGRO",
41
+ upc: "168462",
36
42
  },
37
- asignations: [],
38
43
  retailers: [
39
44
  {
40
45
  id: 58,
41
46
  name: "The Home Depot Golden",
42
- country: "México",
43
- id_region: 1,
44
- active: 1,
45
- },
46
- {
47
- id: 59,
48
- name: "The Home Depot Platinum",
49
- country: "México",
50
- id_region: 1,
51
- active: 1,
52
- },
53
- {
54
- id: 61,
55
- name: "Home Depot TAB",
56
- country: "México",
57
- id_region: 1,
58
- active: 1,
59
47
  },
60
48
  ],
61
- percentage: 33.35,
49
+ services: {
50
+ datasheets: 1,
51
+ descriptions: 1,
52
+ images: 1,
53
+ },
54
+ statusByRetailer: {
55
+ 58: {
56
+ datasheet: "AP",
57
+ description: "AP",
58
+ images: "ACA",
59
+ },
60
+ },
61
+ retailersWithService: ["58"],
62
+ id_article: 78773,
62
63
  retailersAvailable: [
63
64
  {
64
65
  id: 58,
65
66
  name: "The Home Depot Golden",
66
- country: "México",
67
- id_region: 1,
68
- active: 1,
69
- },
70
- {
71
- id: 59,
72
- name: "The Home Depot Platinum",
73
- country: "México",
74
- id_region: 1,
75
- active: 1,
76
- },
77
- {
78
- id: 61,
79
- name: "Home Depot TAB",
80
- country: "México",
81
- id_region: 1,
82
- active: 1,
83
- },
84
- ],
85
- upc: "111187",
86
- name: "SIKA TECHO FRESCO SUPER 15",
87
- categoryName:
88
- "Materiales de Construcción|Impermeabilizantes y Recubrimientos|Selladores",
89
- id_category: "2249",
90
- id_article: 29457,
91
- services: [
92
- {
93
- id_article: 29457,
94
- service: "datasheet",
95
- quantity: 1,
96
- price: 0,
97
- id_user: 1237,
98
- datasheet_common: null,
99
- discount: null,
100
67
  },
101
68
  ],
102
69
  },
103
70
  productToEdit: {
104
- idCategory: "2249",
105
- ArticleId: 29457,
106
- product: [
107
- {
108
- articleStatus: "ACA",
109
- version: 5,
110
- missing: {},
111
- article: {
112
- category:
113
- "Materiales de Construcción|Impermeabilizantes y Recubrimientos|Selladores",
114
- company_name: "SIKA MEXICANA S.A. DE C.V.",
115
- company_id: 383,
116
- id_category: "2249",
117
- id_article: 29457,
118
- name: "SIKA TECHO FRESCO SUPER 15",
119
- upc: "111187",
71
+ ArticleId: 78773,
72
+ idCategory: "2522",
73
+ product: {
74
+ orderId: 2446,
75
+ article_status: "AP",
76
+ datasheet_status: "AP",
77
+ description_status: "AP",
78
+ images_status: "ACA",
79
+ prio: "none",
80
+ version: 2,
81
+ brand: null,
82
+ article: {
83
+ category:
84
+ "Organizadores y Closets|Accesorios de Lavandería|Organizadores de Lavandería",
85
+ company_name: "WOMEX SA DE CV",
86
+ id_company: 424,
87
+ country: null,
88
+ id_category: "2522",
89
+ id_article: 78773,
90
+ name: "RACK PARA ROPA DOBLE NEGRO",
91
+ upc: "168462",
92
+ },
93
+ retailers: [
94
+ {
95
+ id: 58,
96
+ name: "The Home Depot Golden",
120
97
  },
121
- asignations: [],
122
- retailers: [
123
- {
124
- id: 58,
125
- name: "The Home Depot Golden",
126
- country: "México",
127
- id_region: 1,
128
- active: 1,
129
- },
130
- {
131
- id: 59,
132
- name: "The Home Depot Platinum",
133
- country: "México",
134
- id_region: 1,
135
- active: 1,
136
- },
137
- {
138
- id: 61,
139
- name: "Home Depot TAB",
140
- country: "México",
141
- id_region: 1,
142
- active: 1,
143
- },
144
- ],
145
- percentage: 33.35,
146
- retailersAvailable: [
147
- {
148
- id: 58,
149
- name: "The Home Depot Golden",
150
- country: "México",
151
- id_region: 1,
152
- active: 1,
153
- },
154
- {
155
- id: 59,
156
- name: "The Home Depot Platinum",
157
- country: "México",
158
- id_region: 1,
159
- active: 1,
160
- },
161
- {
162
- id: 61,
163
- name: "Home Depot TAB",
164
- country: "México",
165
- id_region: 1,
166
- active: 1,
167
- },
168
- ],
169
- upc: "111187",
170
- name: "SIKA TECHO FRESCO SUPER 15",
171
- categoryName:
172
- "Materiales de Construcción|Impermeabilizantes y Recubrimientos|Selladores",
173
- id_category: "2249",
174
- id_article: 29457,
175
- services: [
176
- {
177
- id_article: 29457,
178
- service: "datasheet",
179
- quantity: 1,
180
- price: 0,
181
- id_user: 1237,
182
- datasheet_common: null,
183
- discount: null,
184
- },
185
- ],
98
+ ],
99
+ services: {
100
+ datasheets: 1,
101
+ descriptions: 1,
102
+ images: 1,
186
103
  },
187
- ],
104
+ statusByRetailer: {
105
+ 58: {
106
+ datasheet: "AP",
107
+ description: "AP",
108
+ images: "ACA",
109
+ },
110
+ },
111
+ retailersWithService: ["58"],
112
+ id_article: 78773,
113
+ retailersAvailable: [
114
+ {
115
+ id: 58,
116
+ name: "The Home Depot Golden",
117
+ },
118
+ ],
119
+ },
120
+ },
121
+ location: {
122
+ state: { origin: "Contentoh" },
188
123
  },
189
- location: {},
190
124
  user: {
191
125
  id_user: 1237,
192
126
  name: "The Home",
package/src/index.js CHANGED
@@ -63,6 +63,7 @@ export * from "./components/organisms/ProductImageModal/index";
63
63
  export * from "./components/pages/ChangePasswordLogin";
64
64
  export * from "./components/pages/CustomerLogin";
65
65
  export * from "./components/pages/CustomerType";
66
+ export * from "./components/pages/Dashboard";
66
67
  export * from "./components/pages/EmailResetPassword";
67
68
  export * from "./components/pages/OnboardPlan";
68
69
  export * from "./components/pages/RegistrationLoginSecondStep";