contentoh-components-library 21.6.60 → 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.
Files changed (76) hide show
  1. package/dist/components/organisms/ServicesNavigation/ServiceToolbar.js +210 -0
  2. package/dist/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +138 -0
  3. package/dist/components/organisms/ServicesNavigation/ServicesRail.js +705 -0
  4. package/dist/components/organisms/ServicesNavigation/catalog.js +505 -0
  5. package/dist/components/organisms/ServicesNavigation/index.js +337 -0
  6. package/dist/components/organisms/ServicesNavigation/model.js +167 -0
  7. package/dist/components/organisms/ServicesNavigation/ui.js +371 -0
  8. package/dist/components/organisms/ServicesNavigation/views.js +1237 -0
  9. package/dist/components/organisms/ServicesWorkspace/AssigneePicker.js +459 -0
  10. package/dist/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +119 -0
  11. package/dist/components/organisms/ServicesWorkspace/demo.js +137 -0
  12. package/dist/components/organisms/ServicesWorkspace/index.js +813 -0
  13. package/dist/components/organisms/ServicesWorkspace/servicesModel.js +351 -0
  14. package/dist/components/organisms/ServicesWorkspace/tooltipStyles.js +37 -0
  15. package/dist/components/pages/CreatorsProductEdition/mocks/mockApi.js +40 -0
  16. package/dist/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +387 -0
  17. package/dist/components/pages/CreatorsProductEdition/sections/StatusChip.js +13 -4
  18. package/dist/components/pages/ProductEdition/ProductEdition.stories.js +148 -0
  19. package/dist/components/pages/ProductEdition/ProductEditionView.js +1355 -0
  20. package/dist/components/pages/ProductEdition/ServiceHeader.js +142 -0
  21. package/dist/components/pages/ProductEdition/api.js +256 -0
  22. package/dist/components/pages/ProductEdition/index.js +37 -0
  23. package/dist/components/pages/ProductEdition/permissions.js +200 -0
  24. package/dist/components/pages/ProductEdition/permissions.test.js +320 -0
  25. package/dist/components/pages/ProductEdition/sections/CatalogServicePanel.js +237 -0
  26. package/dist/components/pages/ProductEdition/sections/EditionTopBar.js +174 -0
  27. package/dist/components/pages/ProductEdition/sections/ImagePanel.js +440 -0
  28. package/dist/components/pages/ProductEdition/sections/ServiceTeam.js +275 -0
  29. package/dist/components/pages/ProductEdition/sections/ServiceTools.js +186 -0
  30. package/dist/components/pages/ProductEdition/services.js +233 -0
  31. package/dist/components/pages/ProductEdition/services.test.js +195 -0
  32. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +15 -2
  33. package/dist/components/pages/RetailerProductEdition/index.js +57 -40
  34. package/dist/components/pages/RetailerProductEdition/utils.js +6 -2
  35. package/dist/index.js +13 -0
  36. package/package.json +1 -1
  37. package/src/components/organisms/ServicesNavigation/ServiceToolbar.jsx +143 -0
  38. package/src/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +101 -0
  39. package/src/components/organisms/ServicesNavigation/ServicesRail.jsx +591 -0
  40. package/src/components/organisms/ServicesNavigation/catalog.js +180 -0
  41. package/src/components/organisms/ServicesNavigation/index.jsx +232 -0
  42. package/src/components/organisms/ServicesNavigation/model.js +85 -0
  43. package/src/components/organisms/ServicesNavigation/ui.jsx +229 -0
  44. package/src/components/organisms/ServicesNavigation/views.jsx +705 -0
  45. package/src/components/organisms/ServicesWorkspace/AssigneePicker.js +348 -0
  46. package/src/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +61 -0
  47. package/src/components/organisms/ServicesWorkspace/demo.js +58 -0
  48. package/src/components/organisms/ServicesWorkspace/index.js +556 -0
  49. package/src/components/organisms/ServicesWorkspace/servicesModel.js +203 -0
  50. package/src/components/organisms/ServicesWorkspace/tooltipStyles.js +27 -0
  51. package/src/components/pages/CreatorsProductEdition/mocks/mockApi.js +17 -0
  52. package/src/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +175 -0
  53. package/src/components/pages/CreatorsProductEdition/sections/StatusChip.jsx +8 -4
  54. package/src/components/pages/ProductEdition/ProductEdition.stories.js +106 -0
  55. package/src/components/pages/ProductEdition/ProductEditionView.jsx +1142 -0
  56. package/src/components/pages/ProductEdition/ServiceHeader.jsx +104 -0
  57. package/src/components/pages/ProductEdition/api.js +84 -0
  58. package/src/components/pages/ProductEdition/index.js +21 -0
  59. package/src/components/pages/ProductEdition/permissions.js +128 -0
  60. package/src/components/pages/ProductEdition/permissions.test.js +249 -0
  61. package/src/components/pages/ProductEdition/sections/CatalogServicePanel.jsx +123 -0
  62. package/src/components/pages/ProductEdition/sections/EditionTopBar.jsx +134 -0
  63. package/src/components/pages/ProductEdition/sections/ImagePanel.jsx +342 -0
  64. package/src/components/pages/ProductEdition/sections/ServiceTeam.jsx +184 -0
  65. package/src/components/pages/ProductEdition/sections/ServiceTools.jsx +134 -0
  66. package/src/components/pages/ProductEdition/services.js +187 -0
  67. package/src/components/pages/ProductEdition/services.test.js +88 -0
  68. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +12 -0
  69. package/src/components/pages/RetailerProductEdition/index.js +28 -3
  70. package/src/components/pages/RetailerProductEdition/utils.js +5 -0
  71. package/src/index.js +1 -0
  72. package/.claude/settings.local.json +0 -7
  73. package/dist/ai/prompts/attribute.prompt.js +0 -28
  74. package/dist/ai/prompts/description.prompt.js +0 -33
  75. package/dist/ai/schemas/attribute.schema.js +0 -35
  76. package/dist/ai/schemas/description.schema.js +0 -27
@@ -0,0 +1,142 @@
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.ServiceHeader = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
11
+
12
+ var _material = require("@mui/material");
13
+
14
+ var _Menu = _interopRequireDefault(require("@mui/icons-material/Menu"));
15
+
16
+ var _ui = require("../../organisms/ServicesNavigation/ui");
17
+
18
+ var _model = require("../../organisms/ServicesNavigation/model");
19
+
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+
22
+ /*
23
+ Encabezado del servicio abierto. Ocupa el lugar de la barra de pestañas,
24
+ con el diseño de la propuesta de navegación por servicios:
25
+
26
+ [ícono] GRUPO [equipo] [herramientas]
27
+ Nombre del servicio [estatus]
28
+
29
+ - `team`: especialista, coordinador y auditor (sections/ServiceTeam).
30
+ - `children`: versión, guardar e imágenes (sections/ServiceTools).
31
+ */
32
+ var ServiceHeader = function ServiceHeader(_ref) {
33
+ var service = _ref.service,
34
+ isSummary = _ref.isSummary,
35
+ subtitle = _ref.subtitle,
36
+ onOpenRail = _ref.onOpenRail,
37
+ team = _ref.team,
38
+ children = _ref.children;
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
40
+ sx: {
41
+ display: "flex",
42
+ flexWrap: "wrap",
43
+ alignItems: "center",
44
+ columnGap: 2.5,
45
+ rowGap: 1.25,
46
+ pb: 1.5,
47
+ mb: 2,
48
+ borderBottom: "2px solid ".concat(_ui.COLORS.s2),
49
+ minWidth: 0
50
+ },
51
+ children: [onOpenRail && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
52
+ onClick: onOpenRail,
53
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.default, {
54
+ sx: {
55
+ fontSize: 18
56
+ }
57
+ }),
58
+ sx: _ui.outlineButtonSx,
59
+ children: "Servicios"
60
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
61
+ direction: "row",
62
+ alignItems: "center",
63
+ spacing: 1.25,
64
+ sx: {
65
+ minWidth: 0,
66
+ flex: "1 1 200px"
67
+ },
68
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
69
+ sx: {
70
+ width: 40,
71
+ height: 40,
72
+ borderRadius: "10px",
73
+ bgcolor: _ui.COLORS.s2,
74
+ display: "flex",
75
+ alignItems: "center",
76
+ justifyContent: "center",
77
+ flexShrink: 0
78
+ },
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.ServiceIcon, {
80
+ icon: isSummary ? "summary" : service === null || service === void 0 ? void 0 : service.icon,
81
+ sx: {
82
+ fontSize: 22,
83
+ color: _ui.COLORS.magenta_s2
84
+ }
85
+ })
86
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
87
+ sx: {
88
+ minWidth: 0
89
+ },
90
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
91
+ sx: {
92
+ fontFamily: _ui.FONT_STACK,
93
+ fontSize: 11,
94
+ fontWeight: 700,
95
+ letterSpacing: "0.06em",
96
+ textTransform: "uppercase",
97
+ color: _ui.COLORS.s4
98
+ },
99
+ children: isSummary ? "Todos los servicios" : (0, _model.groupLabel)(service === null || service === void 0 ? void 0 : service.group)
100
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
101
+ direction: "row",
102
+ alignItems: "center",
103
+ spacing: 1,
104
+ sx: {
105
+ minWidth: 0
106
+ },
107
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
108
+ component: "h3",
109
+ sx: {
110
+ fontFamily: _ui.TITLE_STACK,
111
+ fontWeight: 500,
112
+ fontSize: 20,
113
+ lineHeight: "26px",
114
+ color: _ui.COLORS.s5,
115
+ overflow: "hidden",
116
+ textOverflow: "ellipsis",
117
+ whiteSpace: "nowrap"
118
+ },
119
+ children: isSummary ? "Resumen" : service === null || service === void 0 ? void 0 : service.display_name
120
+ }), !isSummary && (service === null || service === void 0 ? void 0 : service.status) && service.status !== "-" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.StatusChip, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _ui.serviceStatusProps)(service)), {}, {
121
+ oval: true
122
+ }))]
123
+ })]
124
+ })]
125
+ }), subtitle && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
126
+ sx: {
127
+ fontFamily: _ui.FONT_STACK,
128
+ fontSize: 13,
129
+ color: _ui.COLORS.s4
130
+ },
131
+ children: subtitle
132
+ }), team, children && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
133
+ sx: {
134
+ ml: "auto",
135
+ flexShrink: 0
136
+ },
137
+ children: children
138
+ })]
139
+ });
140
+ };
141
+
142
+ exports.ServiceHeader = ServiceHeader;
@@ -0,0 +1,256 @@
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.setServiceStatus = exports.productServicesUrl = exports.fetchProductServices = exports.fetchAssignables = exports.assignService = exports.ProductServicesError = 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 _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createClass"));
15
+
16
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classCallCheck"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/inherits"));
19
+
20
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createSuper"));
21
+
22
+ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/wrapNativeSuper"));
23
+
24
+ var _axios = _interopRequireDefault(require("axios"));
25
+
26
+ /*
27
+ Servicios del producto en el backend (Lambda `product-services`, ver
28
+ CRUD/services/docs/product-services.md en content-management-backend):
29
+
30
+ GET /product-services?articleId=&orderId= servicios, estatus, equipo y acciones
31
+ PUT /product-services/set-status estatus de un servicio de flujo simple
32
+ PUT /product-services/assign especialista o coordinador
33
+ GET /service-catalog?view=assignables a quién se puede asignar un rol
34
+
35
+ Las URL salen de REACT_APP_PRODUCT_SERVICES_ENDPOINT y
36
+ REACT_APP_SERVICE_CATALOG_ENDPOINT o, si no están, de
37
+ REACT_APP_SERVICES_ENDPOINT cambiando /services por la ruta nueva (mismo
38
+ API Gateway).
39
+ */
40
+ var fromServicesEndpoint = function fromServicesEndpoint(path) {
41
+ var services = process.env.REACT_APP_SERVICES_ENDPOINT;
42
+ return services ? services.replace(/\/services\/?$/, path) : null;
43
+ };
44
+
45
+ var productServicesUrl = function productServicesUrl() {
46
+ return process.env.REACT_APP_PRODUCT_SERVICES_ENDPOINT || fromServicesEndpoint("/product-services");
47
+ };
48
+
49
+ exports.productServicesUrl = productServicesUrl;
50
+
51
+ var serviceCatalogUrl = function serviceCatalogUrl() {
52
+ return process.env.REACT_APP_SERVICE_CATALOG_ENDPOINT || fromServicesEndpoint("/service-catalog");
53
+ };
54
+ /** Error con el mensaje del backend, para mostrarlo tal cual. */
55
+
56
+
57
+ var ProductServicesError = /*#__PURE__*/function (_Error) {
58
+ (0, _inherits2.default)(ProductServicesError, _Error);
59
+
60
+ var _super = (0, _createSuper2.default)(ProductServicesError);
61
+
62
+ function ProductServicesError(message, status, detail) {
63
+ var _this;
64
+
65
+ (0, _classCallCheck2.default)(this, ProductServicesError);
66
+ _this = _super.call(this, message);
67
+ _this.name = "ProductServicesError";
68
+ _this.status = status;
69
+ _this.detail = detail;
70
+ return _this;
71
+ }
72
+
73
+ return (0, _createClass2.default)(ProductServicesError);
74
+ }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
75
+ /*
76
+ Las Lambdas usan `integration: lambda`: API Gateway responde 200 y el
77
+ código real viene en `data.statusCode`, con el cuerpo como texto en
78
+ `data.body`.
79
+ */
80
+
81
+
82
+ exports.ProductServicesError = ProductServicesError;
83
+
84
+ var unwrap = function unwrap(response) {
85
+ var _response$data, _data$body, _ref, _data$statusCode;
86
+
87
+ var data = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : {};
88
+ var body = typeof data.body === "string" ? JSON.parse(data.body) : (_data$body = data.body) !== null && _data$body !== void 0 ? _data$body : data;
89
+ var status = Number((_ref = (_data$statusCode = data.statusCode) !== null && _data$statusCode !== void 0 ? _data$statusCode : response === null || response === void 0 ? void 0 : response.status) !== null && _ref !== void 0 ? _ref : 200);
90
+
91
+ if (status >= 400) {
92
+ var _body$message;
93
+
94
+ throw new ProductServicesError((_body$message = body === null || body === void 0 ? void 0 : body.message) !== null && _body$message !== void 0 ? _body$message : "Error en los servicios del producto", status, body === null || body === void 0 ? void 0 : body.detail);
95
+ }
96
+
97
+ return body;
98
+ };
99
+
100
+ var fetchProductServices = /*#__PURE__*/function () {
101
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
102
+ var articleId, orderId, token, url, response;
103
+ return _regenerator.default.wrap(function _callee$(_context) {
104
+ while (1) {
105
+ switch (_context.prev = _context.next) {
106
+ case 0:
107
+ articleId = _ref2.articleId, orderId = _ref2.orderId, token = _ref2.token;
108
+ url = productServicesUrl();
109
+
110
+ if (url) {
111
+ _context.next = 4;
112
+ break;
113
+ }
114
+
115
+ throw new ProductServicesError("Falta REACT_APP_SERVICES_ENDPOINT", 0);
116
+
117
+ case 4:
118
+ _context.next = 6;
119
+ return _axios.default.get(url, {
120
+ params: {
121
+ articleId: articleId,
122
+ orderId: orderId
123
+ },
124
+ headers: {
125
+ Authorization: token
126
+ }
127
+ });
128
+
129
+ case 6:
130
+ response = _context.sent;
131
+ return _context.abrupt("return", unwrap(response));
132
+
133
+ case 8:
134
+ case "end":
135
+ return _context.stop();
136
+ }
137
+ }
138
+ }, _callee);
139
+ }));
140
+
141
+ return function fetchProductServices(_x) {
142
+ return _ref3.apply(this, arguments);
143
+ };
144
+ }();
145
+
146
+ exports.fetchProductServices = fetchProductServices;
147
+
148
+ var putAction = /*#__PURE__*/function () {
149
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(action, data, token) {
150
+ var response;
151
+ return _regenerator.default.wrap(function _callee2$(_context2) {
152
+ while (1) {
153
+ switch (_context2.prev = _context2.next) {
154
+ case 0:
155
+ _context2.next = 2;
156
+ return _axios.default.put("".concat(productServicesUrl(), "/").concat(action), data, {
157
+ headers: {
158
+ Authorization: token
159
+ }
160
+ });
161
+
162
+ case 2:
163
+ response = _context2.sent;
164
+ return _context2.abrupt("return", unwrap(response));
165
+
166
+ case 4:
167
+ case "end":
168
+ return _context2.stop();
169
+ }
170
+ }
171
+ }, _callee2);
172
+ }));
173
+
174
+ return function putAction(_x2, _x3, _x4) {
175
+ return _ref4.apply(this, arguments);
176
+ };
177
+ }();
178
+
179
+ var setServiceStatus = function setServiceStatus(_ref5) {
180
+ var articleId = _ref5.articleId,
181
+ orderId = _ref5.orderId,
182
+ serviceName = _ref5.serviceName,
183
+ statusName = _ref5.statusName,
184
+ retailerIds = _ref5.retailerIds,
185
+ token = _ref5.token;
186
+ return putAction("set-status", {
187
+ articleId: articleId,
188
+ orderId: orderId,
189
+ serviceName: serviceName,
190
+ statusName: statusName,
191
+ retailerIds: retailerIds
192
+ }, token);
193
+ };
194
+
195
+ exports.setServiceStatus = setServiceStatus;
196
+
197
+ var assignService = function assignService(_ref6) {
198
+ var articleId = _ref6.articleId,
199
+ orderId = _ref6.orderId,
200
+ serviceName = _ref6.serviceName,
201
+ role = _ref6.role,
202
+ userId = _ref6.userId,
203
+ token = _ref6.token;
204
+ return putAction("assign", {
205
+ articleId: articleId,
206
+ orderId: orderId,
207
+ serviceName: serviceName,
208
+ role: role,
209
+ userId: userId
210
+ }, token);
211
+ };
212
+ /** Personas que pueden ocupar el rol del servicio. */
213
+
214
+
215
+ exports.assignService = assignService;
216
+
217
+ var fetchAssignables = /*#__PURE__*/function () {
218
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref7) {
219
+ var _unwrap$users, _unwrap;
220
+
221
+ var serviceName, role, token, response;
222
+ return _regenerator.default.wrap(function _callee3$(_context3) {
223
+ while (1) {
224
+ switch (_context3.prev = _context3.next) {
225
+ case 0:
226
+ serviceName = _ref7.serviceName, role = _ref7.role, token = _ref7.token;
227
+ _context3.next = 3;
228
+ return _axios.default.get(serviceCatalogUrl(), {
229
+ params: {
230
+ view: "assignables",
231
+ service_name: serviceName,
232
+ assignment_role: role
233
+ },
234
+ headers: {
235
+ Authorization: token
236
+ }
237
+ });
238
+
239
+ case 3:
240
+ response = _context3.sent;
241
+ return _context3.abrupt("return", (_unwrap$users = (_unwrap = unwrap(response)) === null || _unwrap === void 0 ? void 0 : _unwrap.users) !== null && _unwrap$users !== void 0 ? _unwrap$users : []);
242
+
243
+ case 5:
244
+ case "end":
245
+ return _context3.stop();
246
+ }
247
+ }
248
+ }, _callee3);
249
+ }));
250
+
251
+ return function fetchAssignables(_x5) {
252
+ return _ref8.apply(this, arguments);
253
+ };
254
+ }();
255
+
256
+ exports.fetchAssignables = fetchAssignables;
@@ -0,0 +1,37 @@
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.ProductEdition = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
11
+
12
+ var _providerProductEdition = require("../RetailerProductEdition/context/provider-product-edition.context");
13
+
14
+ var _ProductEditionView = require("./ProductEditionView");
15
+
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+
18
+ /**
19
+ * Edición de producto unificada: una sola pantalla para Creators y para
20
+ * Content Management, con la lista lateral de servicios. Lo que cambia entre
21
+ * aplicaciones son los permisos (`permissions.js`).
22
+ *
23
+ * Props: las de CreatorsProductEdition (`tabsSections`, `productSelected`,
24
+ * `user`, `token`, `location`, `enableDigitalAssets`) y además:
25
+ * - `app`: "creators" (fase 1). "management" llega en la fase 2.
26
+ * - `demoServices`: solo para historias de Storybook.
27
+ *
28
+ * Los servicios salen de GET /product-services; si no responde, la lista
29
+ * muestra los servicios de siempre del producto.
30
+ */
31
+ var ProductEdition = function ProductEdition(props) {
32
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_providerProductEdition.ProviderProductEditionProvider, {
33
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductEditionView.ProductEditionView, (0, _objectSpread2.default)({}, props))
34
+ });
35
+ };
36
+
37
+ exports.ProductEdition = ProductEdition;
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tabOf = exports.serviceOfTab = exports.rolesInService = exports.isPendingFor = exports.isAuditorAssigned = exports.isAssignedToService = exports.isAssignedAs = exports.isAdmin = exports.currentStatus = exports.canSendToFacilitator = exports.canSave = exports.canEvaluate = exports.canChangeStatus = exports.canAssign = exports.CLASSIC_SERVICES = void 0;
7
+
8
+ /*
9
+ Permisos de la edición de producto, en un solo lugar.
10
+
11
+ Antes estas reglas vivían repartidas en `if` dentro de cada vista
12
+ (RetailerProductEdition, ProviderProductEdition y la copia del hook de
13
+ CreatorsProductEdition). Aquí son funciones puras: reciben el producto, la
14
+ persona y el servicio, y responden sí o no. Así se pueden leer como una tabla
15
+ y probar sin montar la pantalla.
16
+
17
+ FASE 1 — app «creators» (equipo Content-oh). Las reglas son las mismas que
18
+ usa hoy `useCreatorsProductEdition`, copiadas tal cual:
19
+
20
+ Rol 1 Administrador todo
21
+ Rol 4 Coordinador de textos evalúa lo que está en IE (información enviada)
22
+ Rol 5 Coordinador de imágenes evalúa lo que está en IE
23
+ Rol 6 Auditor evalúa lo que está en AC, RP, RCA, SAC
24
+ Rol 7 Especialista de textos produce; también valida lo que está en AC
25
+ Rol 8 Especialista de imágenes produce; también valida lo que está en AC
26
+
27
+ Además del rol cuenta la ASIGNACIÓN del producto: `id_<servicio>_especialist`,
28
+ `id_<servicio>_facilitator` (coordinador) e `id_auditor`. Quien está asignado
29
+ a un servicio puede trabajarlo aunque su rol sea otro.
30
+
31
+ FASE 2 — app «management» (proveedor y cadena) se agrega aquí mismo.
32
+ */
33
+
34
+ /** Servicios que hoy tienen editor y su pestaña en la edición. */
35
+ var CLASSIC_SERVICES = [{
36
+ service_name: "datasheet",
37
+ tab: "Ficha técnica"
38
+ }, {
39
+ service_name: "description",
40
+ tab: "Descripción"
41
+ }, {
42
+ service_name: "images",
43
+ tab: "Imágenes"
44
+ }];
45
+ exports.CLASSIC_SERVICES = CLASSIC_SERVICES;
46
+
47
+ var tabOf = function tabOf(serviceName) {
48
+ var _CLASSIC_SERVICES$fin, _CLASSIC_SERVICES$fin2;
49
+
50
+ return (_CLASSIC_SERVICES$fin = (_CLASSIC_SERVICES$fin2 = CLASSIC_SERVICES.find(function (item) {
51
+ return item.service_name === serviceName;
52
+ })) === null || _CLASSIC_SERVICES$fin2 === void 0 ? void 0 : _CLASSIC_SERVICES$fin2.tab) !== null && _CLASSIC_SERVICES$fin !== void 0 ? _CLASSIC_SERVICES$fin : null;
53
+ };
54
+
55
+ exports.tabOf = tabOf;
56
+
57
+ var serviceOfTab = function serviceOfTab(tab) {
58
+ var _CLASSIC_SERVICES$fin3, _CLASSIC_SERVICES$fin4;
59
+
60
+ return (_CLASSIC_SERVICES$fin3 = (_CLASSIC_SERVICES$fin4 = CLASSIC_SERVICES.find(function (item) {
61
+ return item.tab === tab;
62
+ })) === null || _CLASSIC_SERVICES$fin4 === void 0 ? void 0 : _CLASSIC_SERVICES$fin4.service_name) !== null && _CLASSIC_SERVICES$fin3 !== void 0 ? _CLASSIC_SERVICES$fin3 : null;
63
+ };
64
+ /** Estatus base: «RA/AS» → «AS» (la parte vigente es la última). */
65
+
66
+
67
+ exports.serviceOfTab = serviceOfTab;
68
+
69
+ var currentStatus = function currentStatus(status) {
70
+ return String(status !== null && status !== void 0 ? status : "").replace(/.*\//, "");
71
+ };
72
+
73
+ exports.currentStatus = currentStatus;
74
+
75
+ var roleOf = function roleOf(user) {
76
+ return Number(user === null || user === void 0 ? void 0 : user.id_role);
77
+ };
78
+
79
+ var isAdmin = function isAdmin(user) {
80
+ return roleOf(user) === 1;
81
+ };
82
+
83
+ exports.isAdmin = isAdmin;
84
+
85
+ var isAssignedAs = function isAssignedAs(product, user, role, serviceName) {
86
+ var assigned = product === null || product === void 0 ? void 0 : product["id_".concat(serviceName, "_").concat(role)];
87
+ return Boolean(assigned) && assigned === (user === null || user === void 0 ? void 0 : user.id_user);
88
+ };
89
+
90
+ exports.isAssignedAs = isAssignedAs;
91
+
92
+ var isAuditorAssigned = function isAuditorAssigned(product, user) {
93
+ return Boolean(product === null || product === void 0 ? void 0 : product.id_auditor) && product.id_auditor === (user === null || user === void 0 ? void 0 : user.id_user);
94
+ };
95
+ /**
96
+ * Trabaja el servicio: administrador, o especialista/coordinador asignado con
97
+ * un rol del equipo. Igual que `isUserAssignedToService` del hook.
98
+ */
99
+
100
+
101
+ exports.isAuditorAssigned = isAuditorAssigned;
102
+
103
+ var isAssignedToService = function isAssignedToService(product, user, serviceName, role) {
104
+ if (![1, 4, 5, 6, 7, 8].includes(roleOf(user))) return false;
105
+ if (isAdmin(user)) return true;
106
+ return role ? isAssignedAs(product, user, role, serviceName) : isAssignedAs(product, user, "especialist", serviceName) || isAssignedAs(product, user, "facilitator", serviceName);
107
+ };
108
+ /** Ve el botón de guardar: el auditor asignado o quien trabaja el servicio. */
109
+
110
+
111
+ exports.isAssignedToService = isAssignedToService;
112
+
113
+ var canSave = function canSave(product, user, serviceName) {
114
+ return isAuditorAssigned(product, user) || isAssignedToService(product, user, serviceName);
115
+ };
116
+ /** Puede asignar personas: todos menos los especialistas (roles 7 y 8). */
117
+
118
+
119
+ exports.canSave = canSave;
120
+
121
+ var canAssign = function canAssign(user) {
122
+ return ![7, 8].includes(roleOf(user));
123
+ };
124
+ /** Envía su trabajo al coordinador: los especialistas. */
125
+
126
+
127
+ exports.canAssign = canAssign;
128
+
129
+ var canSendToFacilitator = function canSendToFacilitator(user) {
130
+ return [7, 8].includes(roleOf(user));
131
+ };
132
+ /** Ve «Cambio de estatus»: una lista fija de cuentas (constants.js). */
133
+
134
+
135
+ exports.canSendToFacilitator = canSendToFacilitator;
136
+
137
+ var canChangeStatus = function canChangeStatus(user) {
138
+ var allowedAccounts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
139
+ return allowedAccounts.includes(user === null || user === void 0 ? void 0 : user.email);
140
+ };
141
+ /**
142
+ * Puede validar o rechazar el servicio en la cadena activa. Misma regla que
143
+ * `canShowSingleEvaluationButtons` del hook.
144
+ */
145
+
146
+
147
+ exports.canChangeStatus = canChangeStatus;
148
+
149
+ var canEvaluate = function canEvaluate(product, user, serviceName, retailerStatus) {
150
+ var status = currentStatus(retailerStatus);
151
+ var role = roleOf(user);
152
+ var asFacilitator = status === "IE" && ([1, 4, 5].includes(role) || isAssignedAs(product, user, "facilitator", serviceName));
153
+ var asAuditor = ["AC", "RP", "RCA", "SAC"].includes(status) && ([1, 6].includes(role) || isAuditorAssigned(product, user));
154
+ var asSpecialist = status === "AC" && [7, 8].includes(role);
155
+ return asFacilitator || asAuditor || asSpecialist;
156
+ };
157
+ /* ------------------------------------------------------------------------ */
158
+
159
+ /* Lista lateral */
160
+
161
+ /* ------------------------------------------------------------------------ */
162
+
163
+ /*
164
+ «Te toca a ti»: el estatus del servicio está en una etapa que le
165
+ corresponde a alguno de los papeles que la persona tiene asignados en él.
166
+ Un estatus compuesto («RA/AS») cuenta por cualquiera de sus partes.
167
+
168
+ especialista asignado, capturando o rechazado por coordinador/auditor
169
+ coordinador por asignar o con información enviada (IE) para revisar
170
+ auditor lo mismo que puede evaluar: AC, RP, RCA, SAC
171
+ */
172
+
173
+
174
+ exports.canEvaluate = canEvaluate;
175
+ var ACTIONABLE = {
176
+ especialist: ["AS", "CA", "RC", "RA"],
177
+ facilitator: ["PA", "IE"],
178
+ auditor: ["AC", "RP", "RCA", "SAC"]
179
+ };
180
+
181
+ var rolesInService = function rolesInService(product, user, serviceName) {
182
+ var roles = [];
183
+ if (isAssignedAs(product, user, "especialist", serviceName)) roles.push("especialist");
184
+ if (isAssignedAs(product, user, "facilitator", serviceName)) roles.push("facilitator");
185
+ if (isAuditorAssigned(product, user)) roles.push("auditor");
186
+ return roles;
187
+ };
188
+
189
+ exports.rolesInService = rolesInService;
190
+
191
+ var isPendingFor = function isPendingFor(product, user, serviceName, status) {
192
+ var parts = String(status !== null && status !== void 0 ? status : "").split("/");
193
+ return rolesInService(product, user, serviceName).some(function (role) {
194
+ return parts.some(function (part) {
195
+ return ACTIONABLE[role].includes(part);
196
+ });
197
+ });
198
+ };
199
+
200
+ exports.isPendingFor = isPendingFor;