contentoh-components-library 21.1.98 → 21.2.1

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 (49) 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 +254 -0
  22. package/dist/components/pages/Dashboard/styles.js +18 -0
  23. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +68 -120
  24. package/dist/components/pages/ProviderProductEdition/index.js +9 -6
  25. package/dist/index.js +13 -0
  26. package/package.json +1 -1
  27. package/src/components/atoms/FeatureTag/styles.js +6 -0
  28. package/src/components/atoms/Graphic/Graphic.stories.js +8 -0
  29. package/src/components/atoms/Graphic/index.js +3 -9
  30. package/src/components/atoms/Graphic/styles.js +1 -2
  31. package/src/components/atoms/MetricCard/MetricCard.stories.js +14 -0
  32. package/src/components/atoms/MetricCard/index.js +10 -0
  33. package/src/components/atoms/MetricCard/styles.js +30 -0
  34. package/src/components/atoms/MetricSelect/MetricSelect.stories.js +37 -0
  35. package/src/components/atoms/MetricSelect/index.js +22 -0
  36. package/src/components/atoms/MetricSelect/styles.js +20 -0
  37. package/src/components/organisms/Calendar/Calendar.stories.js +10 -0
  38. package/src/components/organisms/Calendar/index.js +17 -0
  39. package/src/components/organisms/Calendar/styles.js +851 -0
  40. package/src/components/organisms/DashboardMetric/DashboardMetric.stories.js +28 -0
  41. package/src/components/organisms/DashboardMetric/index.js +128 -0
  42. package/src/components/organisms/DashboardMetric/styles.js +60 -0
  43. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  44. package/src/components/pages/Dashboard/Dashboard.stories.js +10 -0
  45. package/src/components/pages/Dashboard/index.js +126 -0
  46. package/src/components/pages/Dashboard/styles.js +24 -0
  47. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +77 -145
  48. package/src/components/pages/ProviderProductEdition/index.js +7 -7
  49. 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,128 @@
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()}-${start.getDate()}-${
45
+ start.getMonth() + 1
46
+ }`,
47
+ endDate: `${end?.getFullYear()}-${end?.getDate()}-${
48
+ end?.getMonth() + 1
49
+ }`,
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
+ };
@@ -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,126 @@
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 axios from "axios";
6
+
7
+ export const Dashboard = () => {
8
+ const [metricsData, setMetricsData] = useState([]);
9
+ const [productsByStatus, setProductsByStatus] = useState({});
10
+ const [requiredProducts, setRequiredProducts] = useState([]);
11
+ const [orderByStatus, setOrderByStatus] = useState({});
12
+ const [orderByRequired, setOrderByRequired] = useState({});
13
+ const [retailers, setRetailers] = useState({});
14
+
15
+ const loadProductVersions = async (byStatus, queryObject) => {
16
+ const { retailerId, startDate, endDate, fullData } = queryObject;
17
+ const query = fullData
18
+ ? `fullData=true`
19
+ : `retailerId=${retailerId}&startDate=${startDate}&endDate=${endDate}`;
20
+ try {
21
+ const response = await axios.get(
22
+ byStatus
23
+ ? `${process.env.REACT_APP_READ_ORDERS_BY_STATUS}?${query}`
24
+ : `${process.env.REACT_APP_READ_REQUIRED_ORDERS}?retailerId=${retailerId}&startDate=${startDate}&endDate=${endDate}`
25
+ );
26
+
27
+ const versionList = JSON.parse(response.data.body);
28
+ return versionList;
29
+ } catch (error) {
30
+ console.log(error);
31
+ }
32
+ };
33
+
34
+ const getRetailers = async () => {
35
+ const retailersResponse = await axios.get(
36
+ `${process.env.REACT_APP_RETAILER_ENDPOINT}`,
37
+ {
38
+ headers: {
39
+ Authorization: sessionStorage.getItem("jwt"),
40
+ },
41
+ }
42
+ );
43
+ setRetailers(JSON.parse(retailersResponse.data.body).data);
44
+ };
45
+
46
+ const loadProductsByStatus = async (orderByStatus) => {
47
+ const { orders, fullData } = await loadProductVersions(true, orderByStatus);
48
+ setMetricsData([
49
+ { label: "Productos totales", value: fullData?.total },
50
+ { label: "Productos sin asignar", value: fullData?.PA },
51
+ { label: "Productos en proceso", value: fullData?.CA },
52
+ { label: "Productos terminados", value: fullData?.AP },
53
+ ]);
54
+ setProductsByStatus(orders);
55
+ };
56
+
57
+ const loadRequiredProducts = async (orderByRequired) => {
58
+ const { dates } = await loadProductVersions(false, orderByRequired);
59
+ setRequiredProducts(dates);
60
+ };
61
+
62
+ useEffect(() => {
63
+ const today = new Date();
64
+ const firstWeekDay = today.getDate() - today.getDay();
65
+ const startDate = `${today.getFullYear()}-${firstWeekDay}-${
66
+ today.getMonth() + 1
67
+ }`;
68
+ const endDate = `${today.getFullYear()}-${today.getDate()}-${
69
+ today.getMonth() + 1
70
+ }`;
71
+ const queryObject = { retailerId: "58", startDate, endDate };
72
+ setOrderByStatus(queryObject);
73
+ setOrderByRequired(queryObject);
74
+ getRetailers();
75
+ }, []);
76
+
77
+ useEffect(() => {
78
+ loadProductsByStatus(orderByStatus);
79
+ }, [orderByStatus]);
80
+
81
+ useEffect(() => {
82
+ loadRequiredProducts(orderByRequired);
83
+ }, [orderByRequired]);
84
+
85
+ return (
86
+ <Container>
87
+ <div className="metric-cards">
88
+ {metricsData.map((metric, index) => (
89
+ <MetricCard
90
+ key={`${index}-${metric.value}`}
91
+ label={metric.label}
92
+ number={metric.value}
93
+ />
94
+ ))}
95
+ </div>
96
+ <div className="metrics-main-container">
97
+ <DashboardMetric
98
+ label={"Productos por estatus"}
99
+ description={
100
+ "Revisa el avance individual de cada estatus, utiliza los filtros para encontrar información precisa."
101
+ }
102
+ dataObject={productsByStatus}
103
+ retailerSelected={orderByStatus.retailerId}
104
+ retailers={retailers}
105
+ queryObject={orderByStatus}
106
+ setQueryObject={setOrderByStatus}
107
+ />
108
+ <DashboardMetric
109
+ label={"Productos solicitados"}
110
+ description={
111
+ "Filtra los productos solicitados por fecha y alcance para revisar rápidamente el flujo de trabajo."
112
+ }
113
+ dataObject={requiredProducts}
114
+ type="line"
115
+ indexAxis="x"
116
+ scale="x"
117
+ displayScale={true}
118
+ retailers={retailers}
119
+ retailerSelected={orderByRequired.retailerId}
120
+ queryObject={orderByRequired}
121
+ setQueryObject={setOrderByRequired}
122
+ />
123
+ </div>
124
+ </Container>
125
+ );
126
+ };
@@ -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,170 +21,102 @@ 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
+ },
188
120
  },
189
121
  location: {
190
122
  state: { origin: "Contentoh" },
@@ -271,13 +271,13 @@ export const ProviderProductEdition = ({
271
271
  setServices(services);
272
272
  await getServices();
273
273
 
274
- if (!originProp) {
275
- setActiveRetailer(
276
- product?.retailers
277
- ? product?.retailers[0]
278
- : product?.retailersAvailable[0]
279
- );
280
- }
274
+ // if (!originProp) {
275
+ // setActiveRetailer(
276
+ // product?.retailers
277
+ // ? product?.retailers[0]
278
+ // : product?.retailersAvailable[0]
279
+ // );
280
+ // }
281
281
 
282
282
  // setActiveRetailer(product?.retailers[0]);
283
283
  setImages({ action: "init", init: services[2] });
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";