contentoh-components-library 21.6.61 → 21.6.63

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 (102) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/dist/ai/prompts/attribute.prompt.js +28 -0
  3. package/dist/ai/prompts/description.prompt.js +33 -0
  4. package/dist/ai/schemas/attribute.schema.js +35 -0
  5. package/dist/ai/schemas/description.schema.js +27 -0
  6. package/dist/components/atoms/MetricCard/index.js +3 -1
  7. package/dist/components/organisms/DashboardMetric/DashboardMetric.stories.js +12 -2
  8. package/dist/components/organisms/DashboardMetric/index.js +24 -1
  9. package/dist/components/organisms/DashboardMetric/styles.js +1 -1
  10. package/dist/components/pages/CreatorsProductEdition/CreatorsProductEditionView.js +11 -5
  11. package/dist/components/pages/CreatorsProductEdition/hooks/useCreatorsProductEdition.js +58 -31
  12. package/dist/components/pages/CreatorsProductEdition/mocks/api.fixtures.js +5 -1
  13. package/dist/components/pages/CreatorsProductEdition/mocks/mockApi.js +3 -40
  14. package/dist/components/pages/CreatorsProductEdition/sections/ImagesSection.js +18 -3
  15. package/dist/components/pages/CreatorsProductEdition/sections/StatusChip.js +4 -13
  16. package/dist/components/pages/CreatorsProductEdition/sections/TabsBar.js +10 -0
  17. package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEdition.stories.js +10 -2
  18. package/dist/components/pages/Dashboard/dashboardUtils.js +3 -3
  19. package/dist/components/pages/Dashboard/index.js +102 -88
  20. package/dist/components/pages/Dashboard/styles.js +1 -1
  21. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +2 -15
  22. package/dist/components/pages/RetailerProductEdition/index.js +40 -57
  23. package/dist/components/pages/RetailerProductEdition/utils.js +2 -6
  24. package/dist/index.js +0 -13
  25. package/package.json +1 -1
  26. package/src/components/atoms/MetricCard/index.js +2 -2
  27. package/src/components/organisms/DashboardMetric/DashboardMetric.stories.js +11 -0
  28. package/src/components/organisms/DashboardMetric/index.js +13 -1
  29. package/src/components/organisms/DashboardMetric/styles.js +13 -0
  30. package/src/components/pages/CreatorsProductEdition/CreatorsProductEditionView.jsx +22 -3
  31. package/src/components/pages/CreatorsProductEdition/hooks/useCreatorsProductEdition.js +36 -1
  32. package/src/components/pages/CreatorsProductEdition/mocks/api.fixtures.js +15 -3
  33. package/src/components/pages/CreatorsProductEdition/mocks/mockApi.js +8 -18
  34. package/src/components/pages/CreatorsProductEdition/sections/ImagesSection.jsx +24 -2
  35. package/src/components/pages/CreatorsProductEdition/sections/StatusChip.jsx +4 -8
  36. package/src/components/pages/CreatorsProductEdition/sections/TabsBar.jsx +9 -0
  37. package/src/components/pages/CreatorsProductEdition/stories/CreatorsProductEdition.stories.js +6 -0
  38. package/src/components/pages/Dashboard/dashboardUtils.js +3 -3
  39. package/src/components/pages/Dashboard/index.js +62 -106
  40. package/src/components/pages/Dashboard/styles.js +17 -12
  41. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +0 -12
  42. package/src/components/pages/RetailerProductEdition/index.js +3 -28
  43. package/src/components/pages/RetailerProductEdition/utils.js +0 -5
  44. package/src/index.js +0 -1
  45. package/dist/components/organisms/ServicesNavigation/ServiceToolbar.js +0 -210
  46. package/dist/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +0 -138
  47. package/dist/components/organisms/ServicesNavigation/ServicesRail.js +0 -705
  48. package/dist/components/organisms/ServicesNavigation/catalog.js +0 -505
  49. package/dist/components/organisms/ServicesNavigation/index.js +0 -337
  50. package/dist/components/organisms/ServicesNavigation/model.js +0 -167
  51. package/dist/components/organisms/ServicesNavigation/ui.js +0 -371
  52. package/dist/components/organisms/ServicesNavigation/views.js +0 -1237
  53. package/dist/components/organisms/ServicesWorkspace/AssigneePicker.js +0 -459
  54. package/dist/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +0 -119
  55. package/dist/components/organisms/ServicesWorkspace/demo.js +0 -137
  56. package/dist/components/organisms/ServicesWorkspace/index.js +0 -813
  57. package/dist/components/organisms/ServicesWorkspace/servicesModel.js +0 -351
  58. package/dist/components/organisms/ServicesWorkspace/tooltipStyles.js +0 -37
  59. package/dist/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +0 -387
  60. package/dist/components/pages/ProductEdition/ProductEdition.stories.js +0 -148
  61. package/dist/components/pages/ProductEdition/ProductEditionView.js +0 -1355
  62. package/dist/components/pages/ProductEdition/ServiceHeader.js +0 -142
  63. package/dist/components/pages/ProductEdition/api.js +0 -256
  64. package/dist/components/pages/ProductEdition/index.js +0 -37
  65. package/dist/components/pages/ProductEdition/permissions.js +0 -200
  66. package/dist/components/pages/ProductEdition/permissions.test.js +0 -320
  67. package/dist/components/pages/ProductEdition/sections/CatalogServicePanel.js +0 -237
  68. package/dist/components/pages/ProductEdition/sections/EditionTopBar.js +0 -174
  69. package/dist/components/pages/ProductEdition/sections/ImagePanel.js +0 -440
  70. package/dist/components/pages/ProductEdition/sections/ServiceTeam.js +0 -275
  71. package/dist/components/pages/ProductEdition/sections/ServiceTools.js +0 -186
  72. package/dist/components/pages/ProductEdition/services.js +0 -233
  73. package/dist/components/pages/ProductEdition/services.test.js +0 -195
  74. package/src/components/organisms/ServicesNavigation/ServiceToolbar.jsx +0 -143
  75. package/src/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +0 -101
  76. package/src/components/organisms/ServicesNavigation/ServicesRail.jsx +0 -591
  77. package/src/components/organisms/ServicesNavigation/catalog.js +0 -180
  78. package/src/components/organisms/ServicesNavigation/index.jsx +0 -232
  79. package/src/components/organisms/ServicesNavigation/model.js +0 -85
  80. package/src/components/organisms/ServicesNavigation/ui.jsx +0 -229
  81. package/src/components/organisms/ServicesNavigation/views.jsx +0 -705
  82. package/src/components/organisms/ServicesWorkspace/AssigneePicker.js +0 -348
  83. package/src/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +0 -61
  84. package/src/components/organisms/ServicesWorkspace/demo.js +0 -58
  85. package/src/components/organisms/ServicesWorkspace/index.js +0 -556
  86. package/src/components/organisms/ServicesWorkspace/servicesModel.js +0 -203
  87. package/src/components/organisms/ServicesWorkspace/tooltipStyles.js +0 -27
  88. package/src/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +0 -175
  89. package/src/components/pages/ProductEdition/ProductEdition.stories.js +0 -106
  90. package/src/components/pages/ProductEdition/ProductEditionView.jsx +0 -1142
  91. package/src/components/pages/ProductEdition/ServiceHeader.jsx +0 -104
  92. package/src/components/pages/ProductEdition/api.js +0 -84
  93. package/src/components/pages/ProductEdition/index.js +0 -21
  94. package/src/components/pages/ProductEdition/permissions.js +0 -128
  95. package/src/components/pages/ProductEdition/permissions.test.js +0 -249
  96. package/src/components/pages/ProductEdition/sections/CatalogServicePanel.jsx +0 -123
  97. package/src/components/pages/ProductEdition/sections/EditionTopBar.jsx +0 -134
  98. package/src/components/pages/ProductEdition/sections/ImagePanel.jsx +0 -342
  99. package/src/components/pages/ProductEdition/sections/ServiceTeam.jsx +0 -184
  100. package/src/components/pages/ProductEdition/sections/ServiceTools.jsx +0 -134
  101. package/src/components/pages/ProductEdition/services.js +0 -187
  102. package/src/components/pages/ProductEdition/services.test.js +0 -88
@@ -1,320 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
6
-
7
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
8
-
9
- var _vitest = require("vitest");
10
-
11
- var _permissions = require("./permissions");
12
-
13
- var _services = require("./services");
14
-
15
- /**
16
- * Matriz de permisos de la edición (fase 1, app «creators»).
17
- *
18
- * La librería no tiene corredor de pruebas propio; se corre con
19
- * npx vitest run src/components/pages/ProductEdition
20
- *
21
- * Cada caso fija una regla tal como funciona hoy en
22
- * `useCreatorsProductEdition`: si una prueba falla, cambió quién puede hacer
23
- * qué, y eso hay que decidirlo a propósito.
24
- */
25
- var product = {
26
- datasheet_status: "AS",
27
- description_status: "RA/AS",
28
- images_status: "NS",
29
- id_datasheet_especialist: 426,
30
- id_datasheet_facilitator: 430,
31
- id_description_especialist: 426,
32
- id_description_facilitator: 430,
33
- id_images_especialist: 427,
34
- id_auditor: 425
35
- };
36
-
37
- var user = function user(id_user, id_role) {
38
- var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
39
- return (0, _objectSpread2.default)({
40
- id_user: id_user,
41
- id_role: id_role
42
- }, extra);
43
- };
44
-
45
- var admin = user(1, 1);
46
- var textSpecialist = user(426, 7);
47
- var imageSpecialist = user(427, 8);
48
- var coordinator = user(430, 4);
49
- var unassignedCoordinator = user(431, 5);
50
- var auditor = user(425, 6);
51
- var unassignedAuditor = user(432, 6);
52
- (0, _vitest.describe)("pestañas y estatus", function () {
53
- (0, _vitest.it)("relaciona servicio y pestaña en los dos sentidos", function () {
54
- (0, _vitest.expect)((0, _permissions.tabOf)("datasheet")).toBe("Ficha técnica");
55
- (0, _vitest.expect)((0, _permissions.serviceOfTab)("Imágenes")).toBe("images");
56
- (0, _vitest.expect)((0, _permissions.tabOf)("translation")).toBeNull();
57
- });
58
- (0, _vitest.it)("toma la parte vigente de un estatus compuesto", function () {
59
- (0, _vitest.expect)((0, _permissions.currentStatus)("RA/AS")).toBe("AS");
60
- (0, _vitest.expect)((0, _permissions.currentStatus)("AC")).toBe("AC");
61
- (0, _vitest.expect)((0, _permissions.currentStatus)(null)).toBe("");
62
- });
63
- });
64
- (0, _vitest.describe)("trabajar y guardar un servicio", function () {
65
- (0, _vitest.it)("el administrador puede en todos", function () {
66
- (0, _vitest.expect)((0, _permissions.canSave)(product, admin, "images")).toBe(true);
67
- });
68
- (0, _vitest.it)("el especialista solo en los servicios que tiene asignados", function () {
69
- (0, _vitest.expect)((0, _permissions.canSave)(product, textSpecialist, "datasheet")).toBe(true);
70
- (0, _vitest.expect)((0, _permissions.canSave)(product, textSpecialist, "images")).toBe(false);
71
- (0, _vitest.expect)((0, _permissions.canSave)(product, imageSpecialist, "images")).toBe(true);
72
- });
73
- (0, _vitest.it)("el coordinador asignado puede; el que no está asignado, no", function () {
74
- (0, _vitest.expect)((0, _permissions.canSave)(product, coordinator, "description")).toBe(true);
75
- (0, _vitest.expect)((0, _permissions.canSave)(product, unassignedCoordinator, "description")).toBe(false);
76
- });
77
- (0, _vitest.it)("el auditor asignado al producto puede en todos sus servicios", function () {
78
- (0, _vitest.expect)((0, _permissions.canSave)(product, auditor, "images")).toBe(true);
79
- (0, _vitest.expect)((0, _permissions.canSave)(product, unassignedAuditor, "images")).toBe(false);
80
- });
81
- (0, _vitest.it)("un rol fuera del equipo no trabaja servicios aunque coincida el id", function () {
82
- (0, _vitest.expect)((0, _permissions.isAssignedToService)(product, user(426, 3), "datasheet")).toBe(false);
83
- });
84
- });
85
- (0, _vitest.describe)("asignar, enviar al coordinador y cambiar estatus", function () {
86
- (0, _vitest.it)("asignan todos menos los especialistas", function () {
87
- (0, _vitest.expect)((0, _permissions.canAssign)(admin)).toBe(true);
88
- (0, _vitest.expect)((0, _permissions.canAssign)(coordinator)).toBe(true);
89
- (0, _vitest.expect)((0, _permissions.canAssign)(auditor)).toBe(true);
90
- (0, _vitest.expect)((0, _permissions.canAssign)(textSpecialist)).toBe(false);
91
- (0, _vitest.expect)((0, _permissions.canAssign)(imageSpecialist)).toBe(false);
92
- });
93
- (0, _vitest.it)("envían al coordinador solo los especialistas", function () {
94
- (0, _vitest.expect)((0, _permissions.canSendToFacilitator)(textSpecialist)).toBe(true);
95
- (0, _vitest.expect)((0, _permissions.canSendToFacilitator)(coordinator)).toBe(false);
96
- });
97
- (0, _vitest.it)("«Cambio de estatus» depende de la lista de cuentas", function () {
98
- var allowed = ["oserna@contentoh.com"];
99
- (0, _vitest.expect)((0, _permissions.canChangeStatus)(user(1, 1, {
100
- email: "oserna@contentoh.com"
101
- }), allowed)).toBe(true);
102
- (0, _vitest.expect)((0, _permissions.canChangeStatus)(user(1, 1, {
103
- email: "otra@contentoh.com"
104
- }), allowed)).toBe(false);
105
- });
106
- });
107
- (0, _vitest.describe)("validar o rechazar en la cadena activa", function () {
108
- (0, _vitest.it)("IE: coordinadores por rol o el coordinador asignado", function () {
109
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, unassignedCoordinator, "datasheet", "IE")).toBe(true);
110
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, admin, "datasheet", "IE")).toBe(true);
111
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, auditor, "datasheet", "IE")).toBe(false);
112
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, textSpecialist, "datasheet", "IE")).toBe(false);
113
- });
114
- (0, _vitest.it)("AC, RP, RCA y SAC: auditor por rol o asignado", function () {
115
- ["AC", "RP", "RCA", "SAC"].forEach(function (status) {
116
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, unassignedAuditor, "images", status)).toBe(true);
117
- });
118
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, coordinator, "images", "RP")).toBe(false);
119
- });
120
- (0, _vitest.it)("AC: también los especialistas", function () {
121
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, textSpecialist, "datasheet", "AC")).toBe(true);
122
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, imageSpecialist, "images", "AC")).toBe(true);
123
- });
124
- (0, _vitest.it)("en captura nadie evalúa, salvo que la parte vigente lo permita", function () {
125
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, admin, "datasheet", "CA")).toBe(false);
126
- (0, _vitest.expect)((0, _permissions.canEvaluate)(product, auditor, "datasheet", "RA/AC")).toBe(true);
127
- });
128
- });
129
- (0, _vitest.describe)("«te toca a ti» en la lista lateral", function () {
130
- (0, _vitest.it)("al especialista le toca lo asignado, en captura o rechazado", function () {
131
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, textSpecialist, "datasheet", "AS")).toBe(true);
132
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, textSpecialist, "description", "RA/AS")).toBe(true);
133
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, textSpecialist, "datasheet", "AC")).toBe(false);
134
- });
135
- (0, _vitest.it)("al coordinador asignado, lo que está por asignar o en IE", function () {
136
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, coordinator, "datasheet", "IE")).toBe(true);
137
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, coordinator, "datasheet", "CA")).toBe(false);
138
- });
139
- (0, _vitest.it)("al auditor asignado, lo que puede evaluar", function () {
140
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, auditor, "images", "AC")).toBe(true);
141
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, auditor, "images", "AS")).toBe(false);
142
- });
143
- (0, _vitest.it)("a quien no está asignado nunca le toca, aunque su rol pueda evaluar", function () {
144
- (0, _vitest.expect)((0, _permissions.isPendingFor)(product, unassignedAuditor, "images", "AC")).toBe(false);
145
- });
146
- });
147
- (0, _vitest.describe)("servicios de la lista lateral", function () {
148
- var servicesData = [{
149
- service: "datasheet",
150
- id_retailer: 4,
151
- status: "CA"
152
- }, {
153
- service: "datasheet",
154
- id_retailer: 9,
155
- status: "AC"
156
- }];
157
- (0, _vitest.it)("solo aparecen los servicios contratados", function () {
158
- var services = (0, _services.buildEditionServices)({
159
- product: product,
160
- user: textSpecialist,
161
- servicesData: servicesData,
162
- activeRetailerId: 4
163
- });
164
- (0, _vitest.expect)(services.map(function (item) {
165
- return item.service_name;
166
- })).toEqual(["datasheet", "description"]);
167
- });
168
- (0, _vitest.it)("el estatus es el de la cadena activa, con el del producto de respaldo", function () {
169
- var at4 = (0, _services.buildEditionServices)({
170
- product: product,
171
- user: textSpecialist,
172
- servicesData: servicesData,
173
- activeRetailerId: 4
174
- });
175
- var at9 = (0, _services.buildEditionServices)({
176
- product: product,
177
- user: textSpecialist,
178
- servicesData: servicesData,
179
- activeRetailerId: 9
180
- });
181
- (0, _vitest.expect)(at4[0].status).toBe("CA");
182
- (0, _vitest.expect)(at9[0].status).toBe("AC");
183
- (0, _vitest.expect)(at4[1].status).toBe("RA/AS");
184
- });
185
- (0, _vitest.it)("marca los servicios de la persona y lo que le toca", function () {
186
- var services = (0, _services.buildEditionServices)({
187
- product: product,
188
- user: imageSpecialist,
189
- servicesData: servicesData,
190
- activeRetailerId: 4
191
- });
192
- (0, _vitest.expect)(services.every(function (item) {
193
- return item.mine === false;
194
- })).toBe(true);
195
- var mine = (0, _services.buildEditionServices)({
196
- product: product,
197
- user: textSpecialist,
198
- servicesData: servicesData,
199
- activeRetailerId: 4
200
- });
201
- (0, _vitest.expect)(mine.map(function (item) {
202
- return [item.mine, item.pending];
203
- })).toEqual([[true, true], [true, true]]);
204
- });
205
- (0, _vitest.it)("agrega los servicios de ejemplo al final, marcados como tales", function () {
206
- var services = (0, _services.buildEditionServices)({
207
- product: product,
208
- user: admin,
209
- servicesData: servicesData,
210
- activeRetailerId: 4,
211
- demoServices: [{
212
- service_name: "translation",
213
- status: "CA"
214
- }]
215
- });
216
- var demo = services[services.length - 1];
217
- (0, _vitest.expect)(demo).toMatchObject({
218
- service_name: "translation",
219
- display_name: "Traducción",
220
- is_demo: true,
221
- tab: null
222
- });
223
- });
224
- (0, _vitest.it)("ignora los servicios de muestra que traiga el producto (?demoServicios=1)", function () {
225
- var services = (0, _services.buildEditionServices)({
226
- product: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, product), {}, {
227
- demo_services: [{
228
- service_name: "seo",
229
- status: "AS"
230
- }]
231
- }),
232
- user: admin,
233
- servicesData: servicesData,
234
- activeRetailerId: 4
235
- });
236
- (0, _vitest.expect)(services.some(function (item) {
237
- return item.is_demo;
238
- })).toBe(false);
239
- });
240
- (0, _vitest.it)("los de ejemplo son del auditor del producto y de nadie más", function () {
241
- var demoServices = [{
242
- service_name: "seo",
243
- status: "AS"
244
- }];
245
- var forAuditor = (0, _services.buildEditionServices)({
246
- product: product,
247
- user: auditor,
248
- servicesData: servicesData,
249
- demoServices: demoServices
250
- });
251
- var forSpecialist = (0, _services.buildEditionServices)({
252
- product: product,
253
- user: textSpecialist,
254
- servicesData: servicesData,
255
- demoServices: demoServices
256
- });
257
- (0, _vitest.expect)(forAuditor.every(function (item) {
258
- return item.mine;
259
- })).toBe(true);
260
- (0, _vitest.expect)(forAuditor.at(-1).assignees.auditor).toMatchObject({
261
- id_user: 425
262
- });
263
- (0, _vitest.expect)(forSpecialist.at(-1).mine).toBe(false);
264
- });
265
- (0, _vitest.it)("sin producto no hay servicios", function () {
266
- (0, _vitest.expect)((0, _services.buildEditionServices)({
267
- product: null,
268
- user: admin
269
- })).toEqual([]);
270
- });
271
- });
272
- (0, _vitest.describe)("servicios mientras carga la edición", function () {
273
- (0, _vitest.it)("no truena con services_data y asignaciones en null", function () {
274
- var services = (0, _services.buildEditionServices)({
275
- product: product,
276
- user: textSpecialist,
277
- servicesData: null,
278
- activeRetailerId: undefined,
279
- collaboratorAssignations: null
280
- });
281
- (0, _vitest.expect)(services.map(function (item) {
282
- return item.status;
283
- })).toEqual(["AS", "RA/AS"]);
284
- });
285
- });
286
- (0, _vitest.describe)("equipo del servicio", function () {
287
- (0, _vitest.it)("le pone nombre al auditor con la lista de auditores", function () {
288
- var _buildEditionServices = (0, _services.buildEditionServices)({
289
- product: product,
290
- user: textSpecialist,
291
- servicesData: [],
292
- auditors: [{
293
- id_user: 425,
294
- name: "Auditor QA",
295
- last_name: null
296
- }]
297
- }),
298
- _buildEditionServices2 = (0, _slicedToArray2.default)(_buildEditionServices, 1),
299
- first = _buildEditionServices2[0];
300
-
301
- (0, _vitest.expect)(first.assignees.auditor).toMatchObject({
302
- id_user: 425,
303
- name: "Auditor QA"
304
- });
305
- });
306
- (0, _vitest.it)("sin la lista, el auditor queda como «Asignado»", function () {
307
- var _buildEditionServices3 = (0, _services.buildEditionServices)({
308
- product: product,
309
- user: textSpecialist,
310
- servicesData: []
311
- }),
312
- _buildEditionServices4 = (0, _slicedToArray2.default)(_buildEditionServices3, 1),
313
- first = _buildEditionServices4[0];
314
-
315
- (0, _vitest.expect)(first.assignees.auditor).toMatchObject({
316
- id_user: 425,
317
- name: "Asignado"
318
- });
319
- });
320
- });
@@ -1,237 +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.CatalogServicePanel = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
13
-
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
17
-
18
- var _react = require("react");
19
-
20
- var _material = require("@mui/material");
21
-
22
- var _StatusChip = require("../../CreatorsProductEdition/sections/StatusChip");
23
-
24
- var _tokens = require("../../CreatorsProductEdition/sections/tokens");
25
-
26
- var _jsxRuntime = require("react/jsx-runtime");
27
-
28
- /*
29
- Panel de un servicio del catálogo en la edición (los que no tienen editor):
30
- su estatus en cada cadena y, si la persona puede, el selector para cambiarlo.
31
-
32
- Sale de GET /product-services (`service.api`):
33
- - Flujo simple (casilla, avance): se elige el estatus de `status_options`
34
- con PUT /product-services/set-status, por cadena.
35
- - Flujo completo: solo se ve; lo moverá el motor de estatus.
36
- - De registro: solo se ve.
37
- Los servicios de los uno por producto aparecen como «Producto» (cadena 0).
38
- */
39
- var FLOW_NOTE = {
40
- workflow: "Este servicio sigue el flujo de aprobación (especialista, coordinador y auditor). " + "Su estatus todavía no se cambia desde aquí: lo moverá el motor de estatus.",
41
- flag: "Este servicio solo se registra en el producto: no cambia de estatus."
42
- };
43
-
44
- var chipProps = function chipProps(status) {
45
- var _status$display_name, _status$color;
46
-
47
- return status ? {
48
- status: status.status_name,
49
- label: (_status$display_name = status.display_name) !== null && _status$display_name !== void 0 ? _status$display_name : status.status_name,
50
- color: (_status$color = status.color) !== null && _status$color !== void 0 ? _status$color : undefined
51
- } : {
52
- status: null,
53
- label: "Sin estatus"
54
- };
55
- };
56
-
57
- var CatalogServicePanel = function CatalogServicePanel(_ref) {
58
- var _api$status_flow$flow, _api$status_flow, _api$actions, _api$status_options, _api$retailers;
59
-
60
- var service = _ref.service,
61
- onSetStatus = _ref.onSetStatus;
62
- var api = service === null || service === void 0 ? void 0 : service.api;
63
-
64
- var _useState = (0, _react.useState)(null),
65
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
66
- savingRetailer = _useState2[0],
67
- setSavingRetailer = _useState2[1];
68
-
69
- var _useState3 = (0, _react.useState)(null),
70
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
71
- error = _useState4[0],
72
- setError = _useState4[1];
73
-
74
- if (!api) return null;
75
- var flowType = (_api$status_flow$flow = (_api$status_flow = api.status_flow) === null || _api$status_flow === void 0 ? void 0 : _api$status_flow.flow_type) !== null && _api$status_flow$flow !== void 0 ? _api$status_flow$flow : "workflow";
76
- var canSet = Boolean((_api$actions = api.actions) === null || _api$actions === void 0 ? void 0 : _api$actions.set_status) && flowType === "simple";
77
- var options = (_api$status_options = api.status_options) !== null && _api$status_options !== void 0 ? _api$status_options : [];
78
-
79
- var change = /*#__PURE__*/function () {
80
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(retailerId, statusName) {
81
- var _err$message;
82
-
83
- return _regenerator.default.wrap(function _callee$(_context) {
84
- while (1) {
85
- switch (_context.prev = _context.next) {
86
- case 0:
87
- setError(null);
88
- setSavingRetailer(retailerId);
89
- _context.prev = 2;
90
- _context.next = 5;
91
- return onSetStatus(statusName, [retailerId]);
92
-
93
- case 5:
94
- _context.next = 10;
95
- break;
96
-
97
- case 7:
98
- _context.prev = 7;
99
- _context.t0 = _context["catch"](2);
100
- setError((_err$message = _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) !== null && _err$message !== void 0 ? _err$message : "No se pudo cambiar el estatus.");
101
-
102
- case 10:
103
- _context.prev = 10;
104
- setSavingRetailer(null);
105
- return _context.finish(10);
106
-
107
- case 13:
108
- case "end":
109
- return _context.stop();
110
- }
111
- }
112
- }, _callee, null, [[2, 7, 10, 13]]);
113
- }));
114
-
115
- return function change(_x, _x2) {
116
- return _ref2.apply(this, arguments);
117
- };
118
- }();
119
-
120
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
121
- sx: {
122
- p: 2,
123
- borderRadius: "10px",
124
- border: "1px solid ".concat(_tokens.COLORS.s2),
125
- bgcolor: _tokens.COLORS.white,
126
- maxWidth: 720
127
- },
128
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
129
- sx: {
130
- fontFamily: _tokens.FONTS.Lato,
131
- fontSize: 14,
132
- fontWeight: 700,
133
- color: _tokens.COLORS.s5,
134
- mb: 0.5
135
- },
136
- children: ["Estatus ", api.per_retailer ? "por cadena" : "del producto"]
137
- }), FLOW_NOTE[flowType] && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
138
- sx: {
139
- fontFamily: _tokens.FONTS.Lato,
140
- fontSize: 13,
141
- color: _tokens.COLORS.s4,
142
- mb: 1.5
143
- },
144
- children: FLOW_NOTE[flowType]
145
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Stack, {
146
- spacing: 1,
147
- children: ((_api$retailers = api.retailers) !== null && _api$retailers !== void 0 ? _api$retailers : []).map(function (retailer) {
148
- var _retailer$retailer_na, _retailer$status$stat, _retailer$status;
149
-
150
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
151
- direction: "row",
152
- alignItems: "center",
153
- spacing: 1.5,
154
- sx: {
155
- py: 0.75,
156
- borderTop: "1px solid ".concat(_tokens.COLORS.s2),
157
- "&:first-of-type": {
158
- borderTop: "none"
159
- }
160
- },
161
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
162
- sx: {
163
- fontFamily: _tokens.FONTS.Lato,
164
- fontSize: 13,
165
- color: _tokens.COLORS.s5,
166
- flex: "1 1 auto",
167
- minWidth: 0
168
- },
169
- noWrap: true,
170
- children: api.per_retailer ? (_retailer$retailer_na = retailer.retailer_name) !== null && _retailer$retailer_na !== void 0 ? _retailer$retailer_na : "Cadena ".concat(retailer.id_retailer) : "Producto"
171
- }), canSet ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
172
- size: "small",
173
- value: (_retailer$status$stat = (_retailer$status = retailer.status) === null || _retailer$status === void 0 ? void 0 : _retailer$status.status_name) !== null && _retailer$status$stat !== void 0 ? _retailer$status$stat : "",
174
- disabled: savingRetailer !== null,
175
- onChange: function onChange(event) {
176
- return change(retailer.id_retailer, event.target.value);
177
- },
178
- renderValue: function renderValue(value) {
179
- var _options$find;
180
-
181
- var option = (_options$find = options.find(function (item) {
182
- return item.status_name === value;
183
- })) !== null && _options$find !== void 0 ? _options$find : retailer.status;
184
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StatusChip.StatusChip, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, chipProps(option)), {}, {
185
- oval: true
186
- }));
187
- },
188
- sx: {
189
- minWidth: 170,
190
- fontFamily: _tokens.FONTS.Lato,
191
- fontSize: 13
192
- },
193
- inputProps: {
194
- "aria-label": "Estatus de ".concat(service.display_name)
195
- },
196
- children: options.map(function (option) {
197
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
198
- value: option.status_name,
199
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_StatusChip.StatusChip, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, chipProps(option)), {}, {
200
- oval: true
201
- }))
202
- }, option.status_name);
203
- })
204
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_StatusChip.StatusChip, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, chipProps(retailer.status)), {}, {
205
- oval: true
206
- })), savingRetailer === retailer.id_retailer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
207
- size: 16,
208
- sx: {
209
- color: _tokens.COLORS.magenta_s2
210
- }
211
- })]
212
- }, retailer.id_retailer);
213
- })
214
- }), flowType === "simple" && !canSet && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
215
- sx: {
216
- fontFamily: _tokens.FONTS.Lato,
217
- fontSize: 12,
218
- color: _tokens.COLORS.s4,
219
- mt: 1.5
220
- },
221
- children: "Lo cambia quien est\xE1 asignado al servicio, un administrador o un coordinador."
222
- }), error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Alert, {
223
- severity: "error",
224
- sx: {
225
- mt: 1.5,
226
- fontFamily: _tokens.FONTS.Lato,
227
- fontSize: 13
228
- },
229
- onClose: function onClose() {
230
- return setError(null);
231
- },
232
- children: error
233
- })]
234
- });
235
- };
236
-
237
- exports.CatalogServicePanel = CatalogServicePanel;