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,292 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.Dashboard = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
13
-
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
15
-
16
- var _styles = require("./styles");
17
-
18
- var _MetricCard = require("../../atoms/MetricCard");
19
-
20
- var _DashboardMetric = require("../../organisms/DashboardMetric");
21
-
22
- var _react = require("react");
23
-
24
- var _Loading = require("../../atoms/Loading");
25
-
26
- var _axios = _interopRequireDefault(require("axios"));
27
-
28
- var _jsxRuntime = require("react/jsx-runtime");
29
-
30
- var Dashboard = function Dashboard() {
31
- var _useState = (0, _react.useState)([]),
32
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
33
- metricsData = _useState2[0],
34
- setMetricsData = _useState2[1];
35
-
36
- var _useState3 = (0, _react.useState)({}),
37
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
38
- productsByStatus = _useState4[0],
39
- setProductsByStatus = _useState4[1];
40
-
41
- var _useState5 = (0, _react.useState)([]),
42
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
43
- requiredProducts = _useState6[0],
44
- setRequiredProducts = _useState6[1];
45
-
46
- var _useState7 = (0, _react.useState)({
47
- retailerId: null,
48
- startDate: null,
49
- endDate: null
50
- }),
51
- _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
52
- orderByStatus = _useState8[0],
53
- setOrderByStatus = _useState8[1];
54
-
55
- var _useState9 = (0, _react.useState)({
56
- retailerId: null,
57
- startDate: null,
58
- endDate: null
59
- }),
60
- _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
61
- orderByRequired = _useState10[0],
62
- setOrderByRequired = _useState10[1];
63
-
64
- var _useState11 = (0, _react.useState)({}),
65
- _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
66
- retailers = _useState12[0],
67
- setRetailers = _useState12[1];
68
-
69
- var _useState13 = (0, _react.useState)(true),
70
- _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
71
- loading = _useState14[0],
72
- setLoading = _useState14[1];
73
-
74
- var loadProductVersions = /*#__PURE__*/function () {
75
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(queryObject) {
76
- var byStatus,
77
- retailerId,
78
- startDate,
79
- endDate,
80
- query,
81
- endpoint,
82
- response,
83
- _args = arguments;
84
- return _regenerator.default.wrap(function _callee$(_context) {
85
- while (1) {
86
- switch (_context.prev = _context.next) {
87
- case 0:
88
- byStatus = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
89
- retailerId = queryObject.retailerId, startDate = queryObject.startDate, endDate = queryObject.endDate;
90
- query = "retailerId=".concat(retailerId, "&startDate=").concat(startDate, "&endDate=").concat(endDate);
91
- endpoint = byStatus ? process.env.REACT_APP_READ_ORDERS_BY_STATUS : process.env.REACT_APP_READ_REQUIRED_ORDERS;
92
- _context.prev = 4;
93
- _context.next = 7;
94
- return _axios.default.get("".concat(endpoint, "?").concat(query));
95
-
96
- case 7:
97
- response = _context.sent;
98
- return _context.abrupt("return", JSON.parse(response.data.body));
99
-
100
- case 11:
101
- _context.prev = 11;
102
- _context.t0 = _context["catch"](4);
103
- console.log(_context.t0);
104
-
105
- case 14:
106
- case "end":
107
- return _context.stop();
108
- }
109
- }
110
- }, _callee, null, [[4, 11]]);
111
- }));
112
-
113
- return function loadProductVersions(_x) {
114
- return _ref.apply(this, arguments);
115
- };
116
- }();
117
-
118
- var getRetailers = /*#__PURE__*/function () {
119
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
120
- var retailersResponse, parsed, retailers;
121
- return _regenerator.default.wrap(function _callee2$(_context2) {
122
- while (1) {
123
- switch (_context2.prev = _context2.next) {
124
- case 0:
125
- _context2.next = 2;
126
- return _axios.default.get("".concat(process.env.REACT_APP_RETAILER_ENDPOINT), {
127
- headers: {
128
- Authorization: sessionStorage.getItem("jwt")
129
- }
130
- });
131
-
132
- case 2:
133
- retailersResponse = _context2.sent;
134
- parsed = JSON.parse(retailersResponse.data.body).data;
135
- retailers = Object.keys(parsed).map(function (key) {
136
- if (key.includes('The Home Depot')) return parsed[key];
137
- }).filter(function (f) {
138
- return f;
139
- });
140
- setRetailers(retailers);
141
-
142
- case 6:
143
- case "end":
144
- return _context2.stop();
145
- }
146
- }
147
- }, _callee2);
148
- }));
149
-
150
- return function getRetailers() {
151
- return _ref2.apply(this, arguments);
152
- };
153
- }();
154
-
155
- var loadProductsByStatus = /*#__PURE__*/function () {
156
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(orderByStatus) {
157
- var _yield$loadProductVer, orders, fullData, total, R, ACA, PA, inProcess;
158
-
159
- return _regenerator.default.wrap(function _callee3$(_context3) {
160
- while (1) {
161
- switch (_context3.prev = _context3.next) {
162
- case 0:
163
- _context3.next = 2;
164
- return loadProductVersions(orderByStatus, true);
165
-
166
- case 2:
167
- _yield$loadProductVer = _context3.sent;
168
- orders = _yield$loadProductVer.orders;
169
- fullData = _yield$loadProductVer.fullData;
170
- total = fullData.total, R = fullData.R, ACA = fullData.ACA, PA = fullData.PA;
171
- inProcess = Object.keys(fullData).reduce(function (prev, curr) {
172
- return !['total', 'ACA', 'PA', 'R'].includes(curr) ? prev + fullData[curr] : prev;
173
- }, 0);
174
- setMetricsData([{
175
- label: "Productos totales",
176
- value: total
177
- }, {
178
- label: "Productos sin asignar",
179
- value: PA + R
180
- }, {
181
- label: "Productos en proceso",
182
- value: inProcess
183
- }, {
184
- label: "Productos terminados",
185
- value: ACA
186
- }]);
187
- setProductsByStatus(orders);
188
-
189
- case 9:
190
- case "end":
191
- return _context3.stop();
192
- }
193
- }
194
- }, _callee3);
195
- }));
196
-
197
- return function loadProductsByStatus(_x2) {
198
- return _ref3.apply(this, arguments);
199
- };
200
- }();
201
-
202
- var loadRequiredProducts = /*#__PURE__*/function () {
203
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(orderByRequired) {
204
- var _yield$loadProductVer2, dates;
205
-
206
- return _regenerator.default.wrap(function _callee4$(_context4) {
207
- while (1) {
208
- switch (_context4.prev = _context4.next) {
209
- case 0:
210
- _context4.next = 2;
211
- return loadProductVersions(orderByRequired);
212
-
213
- case 2:
214
- _yield$loadProductVer2 = _context4.sent;
215
- dates = _yield$loadProductVer2.dates;
216
- setRequiredProducts(dates);
217
-
218
- case 5:
219
- case "end":
220
- return _context4.stop();
221
- }
222
- }
223
- }, _callee4);
224
- }));
225
-
226
- return function loadRequiredProducts(_x3) {
227
- return _ref4.apply(this, arguments);
228
- };
229
- }();
230
-
231
- (0, _react.useEffect)(function () {
232
- var today = new Date();
233
- var firstWeekDay = today.getDate() - today.getDay();
234
- var startDate = "".concat(today.getFullYear(), "-").concat(today.getMonth() + 1, "-").concat(firstWeekDay);
235
- var endDate = "".concat(today.getFullYear(), "-").concat(today.getMonth() + 1, "-").concat(today.getDate());
236
- var queryObject = {
237
- retailerId: "58",
238
- startDate: startDate,
239
- endDate: endDate
240
- };
241
- setOrderByStatus(queryObject);
242
- setOrderByRequired(queryObject);
243
- getRetailers();
244
- loadProductsByStatus(queryObject);
245
- loadRequiredProducts(queryObject);
246
- }, []);
247
- (0, _react.useEffect)(function () {
248
- (orderByRequired === null || orderByRequired === void 0 ? void 0 : orderByRequired.retailerId) && (orderByStatus === null || orderByStatus === void 0 ? void 0 : orderByStatus.retailerId) && metricsData.length > 0 && setLoading(false);
249
- }, [orderByRequired, orderByStatus, metricsData]);
250
- return loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
251
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
252
- className: "metric-cards",
253
- children: metricsData.map(function (metric, index) {
254
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MetricCard.MetricCard, {
255
- label: metric.label,
256
- number: metric.value
257
- }, "".concat(index, "-").concat(metric.value));
258
- })
259
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
260
- className: "metrics-main-container",
261
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DashboardMetric.DashboardMetric, {
262
- label: "Productos por estatus",
263
- description: "Revisa el avance individual de cada estatus, utiliza los filtros para encontrar información precisa.",
264
- dataObject: productsByStatus,
265
- retailerSelected: orderByStatus.retailerId,
266
- retailers: retailers,
267
- queryObject: orderByStatus,
268
- setQueryObject: function setQueryObject(evt) {
269
- loadProductsByStatus(evt);
270
- setOrderByStatus(evt);
271
- }
272
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DashboardMetric.DashboardMetric, {
273
- label: "Productos solicitados",
274
- description: "Filtra los productos solicitados por fecha y alcance para revisar rápidamente el flujo de trabajo.",
275
- dataObject: requiredProducts,
276
- type: "line",
277
- indexAxis: "x",
278
- scale: "x",
279
- displayScale: true,
280
- retailers: retailers,
281
- retailerSelected: orderByRequired.retailerId,
282
- queryObject: orderByRequired,
283
- setQueryObject: function setQueryObject(evt) {
284
- loadRequiredProducts(evt);
285
- setOrderByRequired(evt);
286
- }
287
- })]
288
- })]
289
- });
290
- };
291
-
292
- exports.Dashboard = Dashboard;
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.Container = void 0;
9
-
10
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
11
-
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
- var _templateObject;
15
-
16
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: 30px;\n .metric-cards {\n display: flex;\n\n > * + * {\n margin-left: 10px;\n }\n\n & + * {\n margin-top: 10px;\n }\n }\n\n .metrics-main-container {\n display: flex;\n\n > * + * {\n margin-left: 10px;\n }\n }\n"])));
17
-
18
- exports.Container = Container;
@@ -1,14 +0,0 @@
1
- import { MetricCard } from "./index";
2
-
3
- export default {
4
- title: "Components/atoms/MetricCard",
5
- component: MetricCard,
6
- };
7
-
8
- const Template = (args) => <MetricCard {...args} />;
9
- export const MetricCardDefault = Template.bind({});
10
-
11
- MetricCardDefault.args = {
12
- label: "Productos Totales",
13
- number: 2367,
14
- };
@@ -1,10 +0,0 @@
1
- import { Container } from "./styles";
2
-
3
- export const MetricCard = ({ label, number }) => {
4
- return (
5
- <Container>
6
- <p>{label}</p>
7
- <p>{number}</p>
8
- </Container>
9
- );
10
- };
@@ -1,30 +0,0 @@
1
- import styled from "styled-components";
2
- import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
-
4
- export const Container = styled.div`
5
- padding: 10px 20px;
6
- border: 1px solid ${GlobalColors.s3};
7
- width: fit-content;
8
- text-align: center;
9
- border-radius: 10px;
10
-
11
- p {
12
- color: #000;
13
- font-size: 25px;
14
- font-family: ${FontFamily.Raleway_600};
15
- font-size: 25px;
16
- font-feature-settings: "pnum", "lnum";
17
-
18
- &:first-of-type {
19
- color: ${GlobalColors.s3};
20
- font-family: ${FontFamily.Raleway};
21
- font-weight: 500;
22
- font-size: 13px;
23
- line-height: 13px;
24
- }
25
-
26
- & + * {
27
- margin-top: 3px;
28
- }
29
- }
30
- `;
@@ -1,37 +0,0 @@
1
- import { useState } from "react";
2
- import { MetricSelect } from ".";
3
-
4
- export default {
5
- title: "Components/atoms/MetricSelect",
6
- component: MetricSelect,
7
- };
8
-
9
- const Template = (args) => {
10
- const [optionSelected, setSelectedOption] = useState("Semana actual");
11
- const onChange = (e) => {
12
- setSelectedOption(e.target.value);
13
- };
14
- return (
15
- <MetricSelect
16
- {...args}
17
- optionSelected={optionSelected}
18
- onChange={onChange}
19
- />
20
- );
21
- };
22
- export const MetricSelectDefault = Template.bind({});
23
- MetricSelectDefault.args = {
24
- options: [
25
- "12/12/12",
26
- "12/12/13",
27
- "12/12/14",
28
- "12/12/15",
29
- "12/12/16",
30
- "12/12/17",
31
- "12/12/18",
32
- "12/12/19",
33
- "12/12/20",
34
- "12/12/21",
35
- "12/12/22",
36
- ],
37
- };
@@ -1,22 +0,0 @@
1
- import { Container } from "./styles";
2
-
3
- export const MetricSelect = ({
4
- options,
5
- optionSelected,
6
- onChange,
7
- label,
8
- className,
9
- }) => {
10
- return (
11
- <Container className={className}>
12
- <select value={optionSelected} onChange={onChange}>
13
- <option value="" disabled>{label}</option>
14
- {options?.map((option) => (
15
- <option key={option.name} value={option.id}>
16
- {option.name}
17
- </option>
18
- ))}
19
- </select>
20
- </Container>
21
- );
22
- };
@@ -1,20 +0,0 @@
1
- import styled from "styled-components";
2
- import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
-
4
- export const Container = styled.div`
5
- background-color: ${GlobalColors.s2};
6
- width: fit-content;
7
- display: block;
8
- padding-right: 10px;
9
- border-radius: 5px;
10
-
11
- select {
12
- color: ${GlobalColors.s4};
13
- outline: none;
14
- padding: 10px;
15
- background-color: transparent;
16
- border: none;
17
- option:first-of-type {
18
- }
19
- }
20
- `;
@@ -1,10 +0,0 @@
1
- import { Calendar } from ".";
2
-
3
- export default {
4
- title: "Components/organisms/Calendar",
5
- component: Calendar,
6
- };
7
-
8
- const Template = (args) => <Calendar {...args} />;
9
- export const CalendarDefault = Template.bind({});
10
- CalendarDefault.args = {};
@@ -1,17 +0,0 @@
1
- import { Container } from "./styles";
2
- import DatePicker from "react-datepicker";
3
- import { useState } from "react";
4
-
5
- export const Calendar = ({ onChange, startDate, endDate }) => {
6
- return (
7
- <Container>
8
- <DatePicker
9
- selected={startDate}
10
- onChange={onChange}
11
- startDate={startDate}
12
- endDate={endDate}
13
- selectsRange
14
- />
15
- </Container>
16
- );
17
- };