contentoh-components-library 21.6.59 → 21.6.61
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.
- package/dist/components/organisms/ServicesNavigation/ServiceToolbar.js +210 -0
- package/dist/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +138 -0
- package/dist/components/organisms/ServicesNavigation/ServicesRail.js +705 -0
- package/dist/components/organisms/ServicesNavigation/catalog.js +505 -0
- package/dist/components/organisms/ServicesNavigation/index.js +337 -0
- package/dist/components/organisms/ServicesNavigation/model.js +167 -0
- package/dist/components/organisms/ServicesNavigation/ui.js +371 -0
- package/dist/components/organisms/ServicesNavigation/views.js +1237 -0
- package/dist/components/organisms/ServicesWorkspace/AssigneePicker.js +459 -0
- package/dist/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +119 -0
- package/dist/components/organisms/ServicesWorkspace/demo.js +137 -0
- package/dist/components/organisms/ServicesWorkspace/index.js +813 -0
- package/dist/components/organisms/ServicesWorkspace/servicesModel.js +351 -0
- package/dist/components/organisms/ServicesWorkspace/tooltipStyles.js +37 -0
- package/dist/components/pages/CreatorsProductEdition/mocks/mockApi.js +40 -0
- package/dist/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +387 -0
- package/dist/components/pages/CreatorsProductEdition/sections/StatusChip.js +13 -4
- package/dist/components/pages/ProductEdition/ProductEdition.stories.js +148 -0
- package/dist/components/pages/ProductEdition/ProductEditionView.js +1355 -0
- package/dist/components/pages/ProductEdition/ServiceHeader.js +142 -0
- package/dist/components/pages/ProductEdition/api.js +256 -0
- package/dist/components/pages/ProductEdition/index.js +37 -0
- package/dist/components/pages/ProductEdition/permissions.js +200 -0
- package/dist/components/pages/ProductEdition/permissions.test.js +320 -0
- package/dist/components/pages/ProductEdition/sections/CatalogServicePanel.js +237 -0
- package/dist/components/pages/ProductEdition/sections/EditionTopBar.js +174 -0
- package/dist/components/pages/ProductEdition/sections/ImagePanel.js +440 -0
- package/dist/components/pages/ProductEdition/sections/ServiceTeam.js +275 -0
- package/dist/components/pages/ProductEdition/sections/ServiceTools.js +186 -0
- package/dist/components/pages/ProductEdition/services.js +233 -0
- package/dist/components/pages/ProductEdition/services.test.js +195 -0
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +15 -2
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +2 -2
- package/dist/components/pages/RetailerProductEdition/index.js +57 -40
- package/dist/components/pages/RetailerProductEdition/utils.js +6 -2
- package/dist/index.js +13 -0
- package/package.json +1 -1
- package/src/components/organisms/ServicesNavigation/ServiceToolbar.jsx +143 -0
- package/src/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +101 -0
- package/src/components/organisms/ServicesNavigation/ServicesRail.jsx +591 -0
- package/src/components/organisms/ServicesNavigation/catalog.js +180 -0
- package/src/components/organisms/ServicesNavigation/index.jsx +232 -0
- package/src/components/organisms/ServicesNavigation/model.js +85 -0
- package/src/components/organisms/ServicesNavigation/ui.jsx +229 -0
- package/src/components/organisms/ServicesNavigation/views.jsx +705 -0
- package/src/components/organisms/ServicesWorkspace/AssigneePicker.js +348 -0
- package/src/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +61 -0
- package/src/components/organisms/ServicesWorkspace/demo.js +58 -0
- package/src/components/organisms/ServicesWorkspace/index.js +556 -0
- package/src/components/organisms/ServicesWorkspace/servicesModel.js +203 -0
- package/src/components/organisms/ServicesWorkspace/tooltipStyles.js +27 -0
- package/src/components/pages/CreatorsProductEdition/mocks/mockApi.js +17 -0
- package/src/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +175 -0
- package/src/components/pages/CreatorsProductEdition/sections/StatusChip.jsx +8 -4
- package/src/components/pages/ProductEdition/ProductEdition.stories.js +106 -0
- package/src/components/pages/ProductEdition/ProductEditionView.jsx +1142 -0
- package/src/components/pages/ProductEdition/ServiceHeader.jsx +104 -0
- package/src/components/pages/ProductEdition/api.js +84 -0
- package/src/components/pages/ProductEdition/index.js +21 -0
- package/src/components/pages/ProductEdition/permissions.js +128 -0
- package/src/components/pages/ProductEdition/permissions.test.js +249 -0
- package/src/components/pages/ProductEdition/sections/CatalogServicePanel.jsx +123 -0
- package/src/components/pages/ProductEdition/sections/EditionTopBar.jsx +134 -0
- package/src/components/pages/ProductEdition/sections/ImagePanel.jsx +342 -0
- package/src/components/pages/ProductEdition/sections/ServiceTeam.jsx +184 -0
- package/src/components/pages/ProductEdition/sections/ServiceTools.jsx +134 -0
- package/src/components/pages/ProductEdition/services.js +187 -0
- package/src/components/pages/ProductEdition/services.test.js +88 -0
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +12 -0
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +6 -2
- package/src/components/pages/RetailerProductEdition/index.js +28 -3
- package/src/components/pages/RetailerProductEdition/utils.js +5 -0
- package/src/index.js +1 -0
- package/.claude/settings.local.json +0 -7
- package/dist/ai/prompts/attribute.prompt.js +0 -28
- package/dist/ai/prompts/description.prompt.js +0 -33
- package/dist/ai/schemas/attribute.schema.js +0 -35
- package/dist/ai/schemas/description.schema.js +0 -27
|
@@ -0,0 +1,337 @@
|
|
|
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.default = exports.ServicesNavigation = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var _react = require("react");
|
|
15
|
+
|
|
16
|
+
var _material = require("@mui/material");
|
|
17
|
+
|
|
18
|
+
var _ImageOutlined = _interopRequireDefault(require("@mui/icons-material/ImageOutlined"));
|
|
19
|
+
|
|
20
|
+
var _ProductHeader = require("../../pages/CreatorsProductEdition/sections/ProductHeader");
|
|
21
|
+
|
|
22
|
+
var _ui = require("./ui");
|
|
23
|
+
|
|
24
|
+
var _ServicesRail = require("./ServicesRail");
|
|
25
|
+
|
|
26
|
+
var _ServiceToolbar = require("./ServiceToolbar");
|
|
27
|
+
|
|
28
|
+
var _views = require("./views");
|
|
29
|
+
|
|
30
|
+
var _model = require("./model");
|
|
31
|
+
|
|
32
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
PROTOTIPO: navegación por servicios en la edición de producto.
|
|
36
|
+
|
|
37
|
+
Responde a dos preguntas:
|
|
38
|
+
1. Si el producto solo lleva Traducción, ¿por qué ver Ficha técnica,
|
|
39
|
+
Descripción e Imágenes? → Solo aparecen los servicios contratados. Con
|
|
40
|
+
uno solo no hay lista: la edición abre directo en él.
|
|
41
|
+
2. Con 20 servicios, ¿cómo se navega sin perderse? → Lista lateral en lugar
|
|
42
|
+
de pestañas, filtrada por omisión a lo que la persona trabaja («Míos»),
|
|
43
|
+
con un Resumen y un punto rosa en lo que le toca a cada quien.
|
|
44
|
+
|
|
45
|
+
Usa la cabecera real de la edición de Creators (ProductHeader); la columna de
|
|
46
|
+
imagen es un marcador de lugar y las vistas de trabajo son de ejemplo. No está
|
|
47
|
+
conectado a la base: los servicios y sus estatus llegan por props.
|
|
48
|
+
*/
|
|
49
|
+
var ImagePanelPlaceholder = function ImagePanelPlaceholder() {
|
|
50
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
51
|
+
sx: {
|
|
52
|
+
display: {
|
|
53
|
+
xs: "none",
|
|
54
|
+
lg: "block"
|
|
55
|
+
},
|
|
56
|
+
flex: "0 0 clamp(240px, 22%, 320px)",
|
|
57
|
+
minWidth: 0
|
|
58
|
+
},
|
|
59
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
60
|
+
sx: {
|
|
61
|
+
aspectRatio: "1 / 1",
|
|
62
|
+
borderRadius: "8px",
|
|
63
|
+
border: "1px solid ".concat(_ui.COLORS.s2),
|
|
64
|
+
background: "linear-gradient(135deg, ".concat(_ui.COLORS.blue_light, ", ").concat(_ui.COLORS.s2, ")"),
|
|
65
|
+
display: "flex",
|
|
66
|
+
flexDirection: "column",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
gap: 1
|
|
70
|
+
},
|
|
71
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageOutlined.default, {
|
|
72
|
+
sx: {
|
|
73
|
+
fontSize: 56,
|
|
74
|
+
color: _ui.COLORS.s3
|
|
75
|
+
}
|
|
76
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
77
|
+
sx: _ui.captionSx,
|
|
78
|
+
children: "Imagen principal"
|
|
79
|
+
})]
|
|
80
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
81
|
+
direction: "row",
|
|
82
|
+
spacing: 1,
|
|
83
|
+
sx: {
|
|
84
|
+
mt: 1
|
|
85
|
+
},
|
|
86
|
+
children: [0, 1, 2, 3].map(function (index) {
|
|
87
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
88
|
+
sx: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
aspectRatio: "1 / 1",
|
|
91
|
+
borderRadius: "6px",
|
|
92
|
+
border: "1px solid ".concat(index === 0 ? _ui.COLORS.magenta_s2 : _ui.COLORS.s2),
|
|
93
|
+
bgcolor: _ui.COLORS.s1
|
|
94
|
+
}
|
|
95
|
+
}, index);
|
|
96
|
+
})
|
|
97
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
98
|
+
sx: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _ui.captionSx), {}, {
|
|
99
|
+
mt: 1.5
|
|
100
|
+
}),
|
|
101
|
+
children: "La columna de imagen de la edici\xF3n se queda como est\xE1."
|
|
102
|
+
})]
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
var TopBar = function TopBar(_ref) {
|
|
107
|
+
var currentUser = _ref.currentUser,
|
|
108
|
+
currentUserRole = _ref.currentUserRole;
|
|
109
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
110
|
+
direction: "row",
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
spacing: 1.5,
|
|
113
|
+
sx: {
|
|
114
|
+
px: 2,
|
|
115
|
+
py: 1.25,
|
|
116
|
+
borderBottom: "1px solid ".concat(_ui.COLORS.s2),
|
|
117
|
+
flexWrap: "wrap",
|
|
118
|
+
rowGap: 0.5
|
|
119
|
+
},
|
|
120
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
121
|
+
sx: {
|
|
122
|
+
fontFamily: _ui.TITLE_STACK,
|
|
123
|
+
fontWeight: 600,
|
|
124
|
+
fontSize: 18,
|
|
125
|
+
color: _ui.COLORS.s5
|
|
126
|
+
},
|
|
127
|
+
children: "Edici\xF3n de producto"
|
|
128
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
129
|
+
label: "Prototipo \xB7 datos de ejemplo",
|
|
130
|
+
size: "small",
|
|
131
|
+
sx: {
|
|
132
|
+
height: 22,
|
|
133
|
+
bgcolor: _ui.COLORS.s2,
|
|
134
|
+
color: _ui.COLORS.s4,
|
|
135
|
+
fontFamily: _ui.FONT_STACK,
|
|
136
|
+
fontWeight: 700,
|
|
137
|
+
fontSize: 11
|
|
138
|
+
}
|
|
139
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
140
|
+
sx: {
|
|
141
|
+
flex: 1
|
|
142
|
+
}
|
|
143
|
+
}), currentUser && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
144
|
+
sx: _ui.captionSx,
|
|
145
|
+
children: ["Viendo como ", /*#__PURE__*/(0, _jsxRuntime.jsx)("b", {
|
|
146
|
+
children: (0, _model.fullName)(currentUser)
|
|
147
|
+
}), currentUserRole ? " \xB7 ".concat(currentUserRole) : ""]
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
var ServicesNavigation = function ServicesNavigation(_ref2) {
|
|
153
|
+
var _product$categoryReta, _services$find;
|
|
154
|
+
|
|
155
|
+
var product = _ref2.product,
|
|
156
|
+
_ref2$services = _ref2.services,
|
|
157
|
+
services = _ref2$services === void 0 ? [] : _ref2$services,
|
|
158
|
+
currentUser = _ref2.currentUser,
|
|
159
|
+
currentUserRole = _ref2.currentUserRole,
|
|
160
|
+
initialService = _ref2.initialService,
|
|
161
|
+
_ref2$initialCollapse = _ref2.initialCollapsed,
|
|
162
|
+
initialCollapsed = _ref2$initialCollapse === void 0 ? false : _ref2$initialCollapse;
|
|
163
|
+
var userId = currentUser === null || currentUser === void 0 ? void 0 : currentUser.id_user;
|
|
164
|
+
var isDesktop = (0, _material.useMediaQuery)("(min-width:900px)");
|
|
165
|
+
var single = services.length === 1;
|
|
166
|
+
var showFilter = (0, _model.hasUsefulFilter)(services, userId);
|
|
167
|
+
|
|
168
|
+
var _useState = (0, _react.useState)(function () {
|
|
169
|
+
return initialService !== null && initialService !== void 0 ? initialService : (0, _model.initialSelection)(services, userId);
|
|
170
|
+
}),
|
|
171
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
172
|
+
selected = _useState2[0],
|
|
173
|
+
setSelected = _useState2[1];
|
|
174
|
+
|
|
175
|
+
var _useState3 = (0, _react.useState)(function () {
|
|
176
|
+
return (0, _model.defaultFilter)(services, userId);
|
|
177
|
+
}),
|
|
178
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
179
|
+
filter = _useState4[0],
|
|
180
|
+
setFilter = _useState4[1];
|
|
181
|
+
|
|
182
|
+
var _useState5 = (0, _react.useState)(initialCollapsed),
|
|
183
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
184
|
+
collapsed = _useState6[0],
|
|
185
|
+
setCollapsed = _useState6[1];
|
|
186
|
+
|
|
187
|
+
var _useState7 = (0, _react.useState)(false),
|
|
188
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
189
|
+
drawerOpen = _useState8[0],
|
|
190
|
+
setDrawerOpen = _useState8[1];
|
|
191
|
+
|
|
192
|
+
var retailers = (_product$categoryReta = product === null || product === void 0 ? void 0 : product.categoryRetailer) !== null && _product$categoryReta !== void 0 ? _product$categoryReta : [];
|
|
193
|
+
|
|
194
|
+
var _useState9 = (0, _react.useState)(function () {
|
|
195
|
+
var _retailers$, _retailers$2;
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
id: (_retailers$ = retailers[0]) === null || _retailers$ === void 0 ? void 0 : _retailers$.id_retailer,
|
|
199
|
+
name: (_retailers$2 = retailers[0]) === null || _retailers$2 === void 0 ? void 0 : _retailers$2.name
|
|
200
|
+
};
|
|
201
|
+
}),
|
|
202
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
203
|
+
activeRetailer = _useState10[0],
|
|
204
|
+
_setActiveRetailer = _useState10[1];
|
|
205
|
+
|
|
206
|
+
var service = (_services$find = services.find(function (item) {
|
|
207
|
+
return item.service_name === selected;
|
|
208
|
+
})) !== null && _services$find !== void 0 ? _services$find : null;
|
|
209
|
+
var isSummary = !single && (selected === _model.SUMMARY || !service);
|
|
210
|
+
|
|
211
|
+
var select = function select(name) {
|
|
212
|
+
var target = services.find(function (item) {
|
|
213
|
+
return item.service_name === name;
|
|
214
|
+
}); // Si se abre algo que no es suyo (desde el Resumen), se pasa a «Todos»
|
|
215
|
+
// para que el servicio abierto se vea marcado en la lista.
|
|
216
|
+
|
|
217
|
+
if (target && filter === "mine" && !(0, _model.isMine)(target, userId)) setFilter("all");
|
|
218
|
+
setSelected(name);
|
|
219
|
+
setDrawerOpen(false);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var renderRail = function renderRail(variant) {
|
|
223
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ServicesRail.ServicesRail, {
|
|
224
|
+
variant: variant,
|
|
225
|
+
services: services,
|
|
226
|
+
selected: isSummary ? _model.SUMMARY : selected,
|
|
227
|
+
onSelect: select,
|
|
228
|
+
userId: userId,
|
|
229
|
+
filter: filter,
|
|
230
|
+
onFilterChange: setFilter,
|
|
231
|
+
showFilter: showFilter,
|
|
232
|
+
collapsed: collapsed,
|
|
233
|
+
onToggleCollapsed: function onToggleCollapsed() {
|
|
234
|
+
return setCollapsed(function (value) {
|
|
235
|
+
return !value;
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
onClose: variant === "drawer" ? function () {
|
|
239
|
+
return setDrawerOpen(false);
|
|
240
|
+
} : undefined
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
245
|
+
sx: {
|
|
246
|
+
flex: 1,
|
|
247
|
+
minWidth: 0,
|
|
248
|
+
height: "100%",
|
|
249
|
+
display: "flex",
|
|
250
|
+
flexDirection: "column",
|
|
251
|
+
bgcolor: _ui.COLORS.white,
|
|
252
|
+
fontFamily: _ui.FONT_STACK,
|
|
253
|
+
textAlign: "left"
|
|
254
|
+
},
|
|
255
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(TopBar, {
|
|
256
|
+
currentUser: currentUser,
|
|
257
|
+
currentUserRole: currentUserRole
|
|
258
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
259
|
+
sx: {
|
|
260
|
+
flex: 1,
|
|
261
|
+
minHeight: 0,
|
|
262
|
+
display: "flex"
|
|
263
|
+
},
|
|
264
|
+
children: [!single && isDesktop && renderRail("rail"), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
265
|
+
sx: {
|
|
266
|
+
flex: 1,
|
|
267
|
+
minWidth: 0,
|
|
268
|
+
overflowY: "auto",
|
|
269
|
+
p: {
|
|
270
|
+
xs: 1.5,
|
|
271
|
+
md: 2.5
|
|
272
|
+
},
|
|
273
|
+
display: "flex",
|
|
274
|
+
gap: 2.5,
|
|
275
|
+
alignItems: "flex-start"
|
|
276
|
+
},
|
|
277
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ImagePanelPlaceholder, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
278
|
+
sx: {
|
|
279
|
+
flex: 1,
|
|
280
|
+
minWidth: 0
|
|
281
|
+
},
|
|
282
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductHeader.ProductHeader, {
|
|
283
|
+
headerData: product,
|
|
284
|
+
percent: 72,
|
|
285
|
+
activeRetailer: activeRetailer,
|
|
286
|
+
setActiveRetailer: function setActiveRetailer(retailer) {
|
|
287
|
+
var _retailer$id_retailer, _retailer$name;
|
|
288
|
+
|
|
289
|
+
return _setActiveRetailer({
|
|
290
|
+
id: (_retailer$id_retailer = retailer === null || retailer === void 0 ? void 0 : retailer.id_retailer) !== null && _retailer$id_retailer !== void 0 ? _retailer$id_retailer : retailer === null || retailer === void 0 ? void 0 : retailer.id,
|
|
291
|
+
name: (_retailer$name = retailer === null || retailer === void 0 ? void 0 : retailer.name) !== null && _retailer$name !== void 0 ? _retailer$name : retailer === null || retailer === void 0 ? void 0 : retailer.retailer
|
|
292
|
+
});
|
|
293
|
+
},
|
|
294
|
+
servicesData: null,
|
|
295
|
+
showValidationButtons: false
|
|
296
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ServiceToolbar.ServiceToolbar, {
|
|
297
|
+
service: service,
|
|
298
|
+
isSummary: isSummary,
|
|
299
|
+
summaryCounts: {
|
|
300
|
+
total: services.length,
|
|
301
|
+
pending: services.filter(function (item) {
|
|
302
|
+
return (0, _model.isPendingFor)(item, userId);
|
|
303
|
+
}).length
|
|
304
|
+
},
|
|
305
|
+
onOpenRail: !single && !isDesktop ? function () {
|
|
306
|
+
return setDrawerOpen(true);
|
|
307
|
+
} : undefined,
|
|
308
|
+
userId: userId
|
|
309
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_views.ServiceView, {
|
|
310
|
+
selected: isSummary ? _model.SUMMARY : selected,
|
|
311
|
+
service: service,
|
|
312
|
+
services: services,
|
|
313
|
+
userId: userId,
|
|
314
|
+
onSelect: select,
|
|
315
|
+
retailerName: activeRetailer.name
|
|
316
|
+
})]
|
|
317
|
+
})]
|
|
318
|
+
})]
|
|
319
|
+
}), !single && !isDesktop && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Drawer, {
|
|
320
|
+
anchor: "left",
|
|
321
|
+
open: drawerOpen,
|
|
322
|
+
onClose: function onClose() {
|
|
323
|
+
return setDrawerOpen(false);
|
|
324
|
+
},
|
|
325
|
+
PaperProps: {
|
|
326
|
+
sx: {
|
|
327
|
+
width: "min(320px, 88vw)"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
children: renderRail("drawer")
|
|
331
|
+
})]
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
exports.ServicesNavigation = ServicesNavigation;
|
|
336
|
+
var _default = ServicesNavigation;
|
|
337
|
+
exports.default = _default;
|
|
@@ -0,0 +1,167 @@
|
|
|
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.rolesOf = exports.railOrder = exports.isPendingFor = exports.isMine = exports.initials = exports.initialSelection = exports.hasUsefulFilter = exports.groupServices = exports.groupLabel = exports.fullName = exports.defaultFilter = exports.SUMMARY = exports.ROLE_LABELS = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _catalog = require("./catalog");
|
|
15
|
+
|
|
16
|
+
/** Identificador del elemento «Resumen» de la lista (no es un servicio). */
|
|
17
|
+
var SUMMARY = "__summary";
|
|
18
|
+
exports.SUMMARY = SUMMARY;
|
|
19
|
+
var ROLE_LABELS = {
|
|
20
|
+
especialist: "Especialista",
|
|
21
|
+
facilitator: "Coordinador",
|
|
22
|
+
auditor: "Auditor"
|
|
23
|
+
};
|
|
24
|
+
/*
|
|
25
|
+
Estatus en los que le toca actuar a cada rol. Un estatus compuesto como
|
|
26
|
+
«RA/AS» (rechazado por el auditor y de vuelta con el especialista) cuenta si
|
|
27
|
+
cualquiera de sus partes le toca al rol.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
exports.ROLE_LABELS = ROLE_LABELS;
|
|
31
|
+
var ACTIONABLE = {
|
|
32
|
+
especialist: ["AS", "CA", "RC", "RA"],
|
|
33
|
+
facilitator: ["PA", "IE"],
|
|
34
|
+
auditor: ["AC", "RP", "RCA", "SAC"]
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var statusParts = function statusParts(status) {
|
|
38
|
+
return String(status !== null && status !== void 0 ? status : "").split("/");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var fullName = function fullName(user) {
|
|
42
|
+
return user ? [user.name, user.last_name].filter(Boolean).join(" ") : "";
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.fullName = fullName;
|
|
46
|
+
|
|
47
|
+
var initials = function initials(user) {
|
|
48
|
+
var _user$name$, _user$name, _user$last_name$, _user$last_name;
|
|
49
|
+
|
|
50
|
+
return user ? "".concat((_user$name$ = (_user$name = user.name) === null || _user$name === void 0 ? void 0 : _user$name[0]) !== null && _user$name$ !== void 0 ? _user$name$ : "").concat((_user$last_name$ = (_user$last_name = user.last_name) === null || _user$last_name === void 0 ? void 0 : _user$last_name[0]) !== null && _user$last_name$ !== void 0 ? _user$last_name$ : "").toUpperCase() : "";
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.initials = initials;
|
|
54
|
+
|
|
55
|
+
var rolesOf = function rolesOf(service, userId) {
|
|
56
|
+
var _service$assignees;
|
|
57
|
+
|
|
58
|
+
return Object.entries((_service$assignees = service.assignees) !== null && _service$assignees !== void 0 ? _service$assignees : {}).filter(function (_ref) {
|
|
59
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
60
|
+
user = _ref2[1];
|
|
61
|
+
|
|
62
|
+
return user && user.id_user === userId;
|
|
63
|
+
}).map(function (_ref3) {
|
|
64
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref3, 1),
|
|
65
|
+
role = _ref4[0];
|
|
66
|
+
|
|
67
|
+
return role;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
/*
|
|
71
|
+
`mine` y `pending` pueden venir ya calculados en el servicio (la edición real
|
|
72
|
+
los saca de ProductEdition/permissions.js con las asignaciones del
|
|
73
|
+
producto). Si no vienen, se calculan aquí con `assignees`, como en el
|
|
74
|
+
prototipo.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
exports.rolesOf = rolesOf;
|
|
79
|
+
|
|
80
|
+
var isMine = function isMine(service, userId) {
|
|
81
|
+
return typeof service.mine === "boolean" ? service.mine : rolesOf(service, userId).length > 0;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.isMine = isMine;
|
|
85
|
+
|
|
86
|
+
var isPendingFor = function isPendingFor(service, userId) {
|
|
87
|
+
return typeof service.pending === "boolean" ? service.pending : rolesOf(service, userId).some(function (role) {
|
|
88
|
+
return statusParts(service.status).some(function (part) {
|
|
89
|
+
var _ACTIONABLE$role;
|
|
90
|
+
|
|
91
|
+
return (_ACTIONABLE$role = ACTIONABLE[role]) === null || _ACTIONABLE$role === void 0 ? void 0 : _ACTIONABLE$role.includes(part);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.isPendingFor = isPendingFor;
|
|
97
|
+
|
|
98
|
+
var groupLabel = function groupLabel(key) {
|
|
99
|
+
var _SERVICE_GROUPS$find$, _SERVICE_GROUPS$find;
|
|
100
|
+
|
|
101
|
+
return (_SERVICE_GROUPS$find$ = (_SERVICE_GROUPS$find = _catalog.SERVICE_GROUPS.find(function (group) {
|
|
102
|
+
return group.key === key;
|
|
103
|
+
})) === null || _SERVICE_GROUPS$find === void 0 ? void 0 : _SERVICE_GROUPS$find.label) !== null && _SERVICE_GROUPS$find$ !== void 0 ? _SERVICE_GROUPS$find$ : "";
|
|
104
|
+
};
|
|
105
|
+
/** Servicios en bloques fijos, en el orden del catálogo. */
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
exports.groupLabel = groupLabel;
|
|
109
|
+
|
|
110
|
+
var groupServices = function groupServices(services) {
|
|
111
|
+
return _catalog.SERVICE_GROUPS.map(function (group) {
|
|
112
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, group), {}, {
|
|
113
|
+
services: services.filter(function (service) {
|
|
114
|
+
return service.group === group.key;
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
}).filter(function (group) {
|
|
118
|
+
return group.services.length > 0;
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
/** El orden en que aparecen en la lista lateral. */
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
exports.groupServices = groupServices;
|
|
125
|
+
|
|
126
|
+
var railOrder = function railOrder(services) {
|
|
127
|
+
return groupServices(services).flatMap(function (group) {
|
|
128
|
+
return group.services;
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Qué se abre al entrar: con un solo servicio, ese; si a la persona le toca
|
|
133
|
+
* algo, lo primero que le toca; si no, el Resumen.
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
exports.railOrder = railOrder;
|
|
138
|
+
|
|
139
|
+
var initialSelection = function initialSelection(services, userId) {
|
|
140
|
+
if (services.length === 1) return services[0].service_name;
|
|
141
|
+
var pending = railOrder(services).find(function (service) {
|
|
142
|
+
return isPendingFor(service, userId);
|
|
143
|
+
});
|
|
144
|
+
return pending ? pending.service_name : SUMMARY;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* «Míos» solo tiene sentido si la persona trabaja algunos servicios del
|
|
148
|
+
* producto y no todos: con todos o con ninguno, el filtro no cambia nada.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
exports.initialSelection = initialSelection;
|
|
153
|
+
|
|
154
|
+
var hasUsefulFilter = function hasUsefulFilter(services, userId) {
|
|
155
|
+
var mine = services.filter(function (service) {
|
|
156
|
+
return isMine(service, userId);
|
|
157
|
+
}).length;
|
|
158
|
+
return mine > 0 && mine < services.length;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
exports.hasUsefulFilter = hasUsefulFilter;
|
|
162
|
+
|
|
163
|
+
var defaultFilter = function defaultFilter(services, userId) {
|
|
164
|
+
return hasUsefulFilter(services, userId) ? "mine" : "all";
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
exports.defaultFilter = defaultFilter;
|