contentoh-components-library 21.6.55 → 21.6.57
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/.claude/launch.json +14 -0
- package/.env.test +1 -0
- package/dist/ai/prompts/attribute.prompt.js +28 -0
- package/dist/ai/prompts/description.prompt.js +33 -0
- package/dist/ai/schemas/attribute.schema.js +35 -0
- package/dist/ai/schemas/description.schema.js +27 -0
- package/dist/components/atoms/AsignationOption/index.js +1 -0
- package/dist/components/atoms/AsignationOption/styles.js +1 -1
- package/dist/components/atoms/AssetPreview/AssetPreview.stories.js +118 -0
- package/dist/components/atoms/AssetPreview/index.js +150 -0
- package/dist/components/atoms/AssetPreview/styles.js +28 -0
- package/dist/components/atoms/IconFile/index.js +85 -2
- package/dist/components/atoms/IconFile/styles.js +1 -1
- package/dist/components/atoms/ProductImage/ProductImage.stories.js +70 -2
- package/dist/components/atoms/ProductImage/index.js +100 -27
- package/dist/components/atoms/ProductImage/styles.js +3 -1
- package/dist/components/molecules/EditionActiveImage/index.js +4 -2
- package/dist/components/molecules/GalleryAssetElement/GalleryAssetElement.stories.js +147 -0
- package/dist/components/molecules/GalleryAssetElement/index.js +178 -0
- package/dist/components/molecules/GalleryAssetElement/styles.js +26 -0
- package/dist/components/molecules/GalleryElement/index.js +13 -4
- package/dist/components/molecules/GalleryHeader/index.js +96 -24
- package/dist/components/molecules/GalleryHeader/styles.js +4 -1
- package/dist/components/molecules/GalleryTrayTabs/GalleryTrayTabs.stories.js +56 -0
- package/dist/components/molecules/GalleryTrayTabs/index.js +60 -0
- package/dist/components/molecules/GalleryTrayTabs/styles.js +20 -0
- package/dist/components/molecules/ImageSelector/index.js +1 -0
- package/dist/components/molecules/RetailerSelector/RetailerSelector.stories.js +23 -2
- package/dist/components/molecules/RetailerSelector/index.js +7 -2
- package/dist/components/molecules/RetailerSelectorv2/index.js +6 -2
- package/dist/components/organisms/DigitalAssetsTray/DigitalAssetsTray.stories.js +235 -0
- package/dist/components/organisms/DigitalAssetsTray/index.js +219 -0
- package/dist/components/organisms/DigitalAssetsTray/styles.js +22 -0
- package/dist/components/organisms/ImagePreviewer/index.js +1 -0
- package/dist/components/organisms/ProductImageModal/index.js +3 -2
- package/dist/components/pages/CreatorsProductEdition/CreatorsProductEditionView.js +905 -0
- package/dist/components/pages/CreatorsProductEdition/constants.js +19 -0
- package/dist/components/pages/CreatorsProductEdition/hooks/useCreatorsProductEdition.js +2967 -0
- package/dist/components/pages/CreatorsProductEdition/index.js +33 -0
- package/dist/components/pages/CreatorsProductEdition/mocks/api.fixtures.js +537 -0
- package/dist/components/pages/CreatorsProductEdition/mocks/mockApi.js +251 -0
- package/dist/components/pages/CreatorsProductEdition/sections/CommentBox.js +311 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ImagePanel.js +421 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ImagesSection.js +473 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ProductHeader.js +379 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ProductMedia.js +138 -0
- package/dist/components/pages/CreatorsProductEdition/sections/RetailerMenu.js +162 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ServiceActions.js +542 -0
- package/dist/components/pages/CreatorsProductEdition/sections/StatusChip.js +50 -0
- package/dist/components/pages/CreatorsProductEdition/sections/TabsBar.js +247 -0
- package/dist/components/pages/CreatorsProductEdition/sections/VariantsPanel.js +389 -0
- package/dist/components/pages/CreatorsProductEdition/sections/tokens.js +90 -0
- package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEdition.stories.js +168 -0
- package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEditionAPI.stories.js +74 -0
- package/dist/components/pages/CreatorsProductEdition/styles.js +46 -0
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +330 -15
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +12 -2
- package/dist/components/pages/RetailerProductEdition/index.js +606 -425
- package/dist/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +1 -0
- package/dist/global-files/data.js +16 -3
- package/dist/global-files/digital-assets/assetTypes.js +517 -0
- package/dist/global-files/digital-assets/assets.actions.js +64 -0
- package/dist/global-files/digital-assets/assets.adapter.js +304 -0
- package/dist/global-files/digital-assets/assets.mock.js +136 -0
- package/dist/global-files/digital-assets/assets.reducer.js +220 -0
- package/dist/global-files/digital-assets/uploadAssets.js +202 -0
- package/dist/global-files/digital-assets/useDigitalAssets.js +535 -0
- package/dist/index.js +142 -90
- package/docs/activos-digitales.md +273 -0
- package/package.json +1 -1
- package/src/components/atoms/AsignationOption/index.js +1 -1
- package/src/components/atoms/AsignationOption/styles.js +9 -0
- package/src/components/atoms/AssetPreview/AssetPreview.stories.js +78 -0
- package/src/components/atoms/AssetPreview/index.js +119 -0
- package/src/components/atoms/AssetPreview/styles.js +190 -0
- package/src/components/atoms/IconFile/index.js +28 -1
- package/src/components/atoms/IconFile/styles.js +8 -0
- package/src/components/atoms/ProductImage/ProductImage.stories.js +38 -0
- package/src/components/atoms/ProductImage/index.js +95 -20
- package/src/components/atoms/ProductImage/styles.js +92 -7
- package/src/components/molecules/EditionActiveImage/index.js +2 -2
- package/src/components/molecules/GalleryAssetElement/GalleryAssetElement.stories.js +102 -0
- package/src/components/molecules/GalleryAssetElement/index.js +162 -0
- package/src/components/molecules/GalleryAssetElement/styles.js +163 -0
- package/src/components/molecules/GalleryElement/index.js +9 -0
- package/src/components/molecules/GalleryHeader/index.js +65 -13
- package/src/components/molecules/GalleryHeader/styles.js +2 -1
- package/src/components/molecules/GalleryTrayTabs/GalleryTrayTabs.stories.js +32 -0
- package/src/components/molecules/GalleryTrayTabs/index.js +41 -0
- package/src/components/molecules/GalleryTrayTabs/styles.js +52 -0
- package/src/components/molecules/ImageSelector/index.js +1 -0
- package/src/components/molecules/RetailerSelector/RetailerSelector.stories.js +15 -1
- package/src/components/molecules/RetailerSelector/index.js +8 -1
- package/src/components/molecules/RetailerSelectorv2/index.js +7 -1
- package/src/components/organisms/DigitalAssetsTray/DigitalAssetsTray.stories.js +164 -0
- package/src/components/organisms/DigitalAssetsTray/index.js +193 -0
- package/src/components/organisms/DigitalAssetsTray/styles.js +183 -0
- package/src/components/organisms/ImagePreviewer/index.js +1 -0
- package/src/components/organisms/ProductImageModal/index.js +1 -0
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +201 -0
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +12 -0
- package/src/components/pages/RetailerProductEdition/index.js +356 -139
- package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +1 -0
- package/src/global-files/data.js +17 -2
- package/src/global-files/digital-assets/assetTypes.js +451 -0
- package/src/global-files/digital-assets/assets.actions.js +50 -0
- package/src/global-files/digital-assets/assets.adapter.js +229 -0
- package/src/global-files/digital-assets/assets.mock.js +122 -0
- package/src/global-files/digital-assets/assets.reducer.js +197 -0
- package/src/global-files/digital-assets/uploadAssets.js +124 -0
- package/src/global-files/digital-assets/useDigitalAssets.js +340 -0
- package/src/index.js +4 -0
|
@@ -0,0 +1,251 @@
|
|
|
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.withRealApi = exports.withMockApi = exports.createMockAdapter = 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 _axios = _interopRequireDefault(require("axios"));
|
|
17
|
+
|
|
18
|
+
var _api = require("./api.fixtures");
|
|
19
|
+
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
API falsa para las historias: reemplaza el adaptador de axios mientras la
|
|
24
|
+
historia está montada. Toda la pantalla (contexto, utils, modales) usa la
|
|
25
|
+
instancia por omisión de axios y nadie usa `fetch`, así que con esto basta y
|
|
26
|
+
no hace falta ninguna dependencia nueva.
|
|
27
|
+
|
|
28
|
+
Lo que no reconoce responde 200 vacío y lo avisa en la consola: así una
|
|
29
|
+
llamada nueva no rompe la historia y se nota qué falta simular.
|
|
30
|
+
*/
|
|
31
|
+
var reply = function reply(config, data) {
|
|
32
|
+
var status = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
|
|
33
|
+
return new Promise(function (resolve) {
|
|
34
|
+
return (// Un poco de latencia para ver el skeleton y los estados de carga.
|
|
35
|
+
setTimeout(function () {
|
|
36
|
+
return resolve({
|
|
37
|
+
data: data,
|
|
38
|
+
status: status,
|
|
39
|
+
statusText: "OK",
|
|
40
|
+
headers: {},
|
|
41
|
+
config: config,
|
|
42
|
+
request: {}
|
|
43
|
+
});
|
|
44
|
+
}, 150)
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var pathOf = function pathOf() {
|
|
50
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
var _URL = new URL(url, "http://mock"),
|
|
54
|
+
pathname = _URL.pathname,
|
|
55
|
+
searchParams = _URL.searchParams; // `/dev/articles-data/images` → `articles-data/images`
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
path: pathname.replace(/^\/[^/]+\//, ""),
|
|
60
|
+
params: searchParams
|
|
61
|
+
};
|
|
62
|
+
} catch (_unused) {
|
|
63
|
+
return {
|
|
64
|
+
path: url,
|
|
65
|
+
params: new URLSearchParams()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var ok = {
|
|
71
|
+
statusCode: 200,
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
message: "OK"
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var createMockAdapter = function createMockAdapter() {
|
|
78
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
79
|
+
_ref$images = _ref.images,
|
|
80
|
+
images = _ref$images === void 0 ? true : _ref$images,
|
|
81
|
+
_ref$failLoad = _ref.failLoad,
|
|
82
|
+
failLoad = _ref$failLoad === void 0 ? false : _ref$failLoad,
|
|
83
|
+
delSolStatus = _ref.delSolStatus,
|
|
84
|
+
familia = _ref.familia,
|
|
85
|
+
grupo = _ref.grupo;
|
|
86
|
+
|
|
87
|
+
var fx = (0, _api.buildFixtures)({
|
|
88
|
+
images: images,
|
|
89
|
+
delSolStatus: delSolStatus,
|
|
90
|
+
familia: familia,
|
|
91
|
+
grupo: grupo
|
|
92
|
+
});
|
|
93
|
+
return function (config) {
|
|
94
|
+
var _fx$comments$query$co, _fx$users$query$fetch;
|
|
95
|
+
|
|
96
|
+
var method = (config.method || "get").toUpperCase();
|
|
97
|
+
|
|
98
|
+
var _pathOf = pathOf(config.url),
|
|
99
|
+
path = _pathOf.path,
|
|
100
|
+
params = _pathOf.params;
|
|
101
|
+
|
|
102
|
+
var query = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, Object.fromEntries(params)), config.params || {});
|
|
103
|
+
|
|
104
|
+
if (failLoad && path === "services") {
|
|
105
|
+
return reply(config, {
|
|
106
|
+
statusCode: 500,
|
|
107
|
+
body: JSON.stringify({
|
|
108
|
+
message: "Error simulado"
|
|
109
|
+
})
|
|
110
|
+
}, 500).then(function (response) {
|
|
111
|
+
return Promise.reject(Object.assign(new Error("Request failed with status code 500"), {
|
|
112
|
+
response: response
|
|
113
|
+
}));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (method === "GET" && path === "comments") return reply(config, (_fx$comments$query$co = fx.comments[query.concept]) !== null && _fx$comments$query$co !== void 0 ? _fx$comments$query$co : fx.comments.images);
|
|
118
|
+
if (path === "articles-data/datasheets") return reply(config, fx.datasheets);
|
|
119
|
+
if (method === "GET" && path === "articles-data/descriptions") return reply(config, fx.descriptions);
|
|
120
|
+
if (path === "articles-data/images") return reply(config, fx.images);
|
|
121
|
+
if (method === "GET" && path === "users") return reply(config, (_fx$users$query$fetch = fx.users[query.fetchRole]) !== null && _fx$users$query$fetch !== void 0 ? _fx$users$query$fetch : {
|
|
122
|
+
data: []
|
|
123
|
+
});
|
|
124
|
+
if (path === "variants/family") return reply(config, fx.family);
|
|
125
|
+
if (path === "variants/group") return reply(config, fx.group);
|
|
126
|
+
if (method === "GET" && path === "services") return reply(config, fx.services);
|
|
127
|
+
if (path === "percentages") return reply(config, fx.percentages); // Sin versión auditable ni observación: con la API real de dev estas dos
|
|
128
|
+
// fallan por CORS, así que la pantalla ya sabe vivir sin ellas.
|
|
129
|
+
|
|
130
|
+
if (method === "GET" && path === "version-manager") {
|
|
131
|
+
return reply(config, {
|
|
132
|
+
statusCode: 200,
|
|
133
|
+
body: JSON.stringify({
|
|
134
|
+
data: null
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (method === "GET" && path === "articles-observations/read-observation") {
|
|
140
|
+
return reply(config, {
|
|
141
|
+
statusCode: 200,
|
|
142
|
+
body: JSON.stringify({
|
|
143
|
+
data: [{
|
|
144
|
+
observations: ""
|
|
145
|
+
}]
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
} // Guardados, evaluaciones y demás escrituras: se aceptan sin hacer nada.
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if (method !== "GET") {
|
|
152
|
+
console.info("[mock API] ".concat(method, " ").concat(path), config.data);
|
|
153
|
+
return reply(config, ok);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
console.warn("[mock API] sin simular: ".concat(method, " ").concat(path), query);
|
|
157
|
+
return reply(config, {
|
|
158
|
+
statusCode: 200,
|
|
159
|
+
body: JSON.stringify({
|
|
160
|
+
message: "OK",
|
|
161
|
+
data: []
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
exports.createMockAdapter = createMockAdapter;
|
|
168
|
+
|
|
169
|
+
var realAdapter = function realAdapter() {
|
|
170
|
+
if (!_axios.default.defaults.__realAdapter) _axios.default.defaults.__realAdapter = _axios.default.defaults.adapter;
|
|
171
|
+
return _axios.default.defaults.__realAdapter;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var activeMock = null;
|
|
175
|
+
/*
|
|
176
|
+
Monta la API falsa ANTES que la pantalla: el adaptador se cambia durante el
|
|
177
|
+
render, y los efectos de los hijos —que son los que piden los datos— corren
|
|
178
|
+
después.
|
|
179
|
+
|
|
180
|
+
Dos detalles que no son adorno:
|
|
181
|
+
- Se aplica en CADA render, no solo al montar. Al cambiar de historia desde
|
|
182
|
+
el menú, React reutiliza este mismo componente con otras `options` (por
|
|
183
|
+
ejemplo, de "Error al cargar" a otra): si solo se aplicara al montar, la
|
|
184
|
+
historia nueva seguiría con la API de la anterior.
|
|
185
|
+
- Al desmontarse solo restaura si nadie más tomó el relevo. El render de la
|
|
186
|
+
historia nueva ocurre ANTES que la limpieza de la vieja; restaurar a ciegas
|
|
187
|
+
le quitaría la API falsa a la historia que acaba de entrar.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
var MockApi = function MockApi(_ref2) {
|
|
191
|
+
var _activeMock;
|
|
192
|
+
|
|
193
|
+
var options = _ref2.options,
|
|
194
|
+
children = _ref2.children;
|
|
195
|
+
|
|
196
|
+
var _useState = (0, _react.useState)(function () {
|
|
197
|
+
return Symbol("mock-api");
|
|
198
|
+
}),
|
|
199
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
|
200
|
+
id = _useState2[0];
|
|
201
|
+
|
|
202
|
+
var key = JSON.stringify(options !== null && options !== void 0 ? options : {});
|
|
203
|
+
realAdapter();
|
|
204
|
+
|
|
205
|
+
if (((_activeMock = activeMock) === null || _activeMock === void 0 ? void 0 : _activeMock.id) !== id || activeMock.key !== key) {
|
|
206
|
+
_axios.default.defaults.adapter = createMockAdapter(options);
|
|
207
|
+
activeMock = {
|
|
208
|
+
id: id,
|
|
209
|
+
key: key
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
(0, _react.useEffect)(function () {
|
|
214
|
+
return function () {
|
|
215
|
+
var _activeMock2;
|
|
216
|
+
|
|
217
|
+
if (((_activeMock2 = activeMock) === null || _activeMock2 === void 0 ? void 0 : _activeMock2.id) === id) {
|
|
218
|
+
_axios.default.defaults.adapter = realAdapter();
|
|
219
|
+
activeMock = null;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}, [id]);
|
|
223
|
+
return children;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Decorador de Storybook que envuelve la historia en la API falsa. La `key`
|
|
227
|
+
* obliga a remontar la pantalla cuando cambian las opciones, para que vuelva a
|
|
228
|
+
* pedir los datos con la API nueva.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
var withMockApi = function withMockApi(options) {
|
|
233
|
+
return function (Story) {
|
|
234
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MockApi, {
|
|
235
|
+
options: options,
|
|
236
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Story, {})
|
|
237
|
+
}, JSON.stringify(options !== null && options !== void 0 ? options : {}));
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
/** Decorador para las historias contra dev: garantiza el adaptador real. */
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
exports.withMockApi = withMockApi;
|
|
244
|
+
|
|
245
|
+
var withRealApi = function withRealApi(Story) {
|
|
246
|
+
_axios.default.defaults.adapter = realAdapter();
|
|
247
|
+
activeMock = null;
|
|
248
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Story, {});
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
exports.withRealApi = withRealApi;
|
|
@@ -0,0 +1,311 @@
|
|
|
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.CommentBox = 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 _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
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 _genericModalCheck = _interopRequireDefault(require("../../../../assets/images/genericModal/genericModalCheck.svg"));
|
|
23
|
+
|
|
24
|
+
var _errorModal = _interopRequireDefault(require("../../../../assets/images/genericModal/errorModal.svg"));
|
|
25
|
+
|
|
26
|
+
var _tokens = require("./tokens");
|
|
27
|
+
|
|
28
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
Caja de comentario y botones de acción ("Cambio de Estatus", "Enviar
|
|
32
|
+
evaluación").
|
|
33
|
+
|
|
34
|
+
Reemplaza a TagAndInput (Quill) + Commentary + los botones de la vista
|
|
35
|
+
original. El comentario se guarda con el mismo `createComment` y los mismos
|
|
36
|
+
avisos que `handleOnSubmitComment`, pero leyendo el campo controlado en lugar
|
|
37
|
+
del DOM de Quill. Con eso se va un defecto del original: solo guardaba el
|
|
38
|
+
primer párrafo (`.ql-editor > p`), así que un comentario de dos párrafos
|
|
39
|
+
perdía el segundo.
|
|
40
|
+
*/
|
|
41
|
+
var MAX_CHARS = 999;
|
|
42
|
+
/*
|
|
43
|
+
Se guarda el texto tal cual, con sus saltos de línea: los comentarios se
|
|
44
|
+
pintan como texto (`white-space: pre-wrap`), no como HTML, y es el mismo
|
|
45
|
+
formato que ya usa el mensaje de rechazo (convierte los <br> de Quill a \n).
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
var toCommentText = function toCommentText(text) {
|
|
49
|
+
return text.trim();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var pill = {
|
|
53
|
+
borderRadius: "30px",
|
|
54
|
+
px: "25px",
|
|
55
|
+
py: "10px",
|
|
56
|
+
minHeight: 40,
|
|
57
|
+
textTransform: "none",
|
|
58
|
+
fontSize: 18,
|
|
59
|
+
lineHeight: "22px",
|
|
60
|
+
boxShadow: "none",
|
|
61
|
+
whiteSpace: "nowrap",
|
|
62
|
+
"&:hover": {
|
|
63
|
+
boxShadow: "none",
|
|
64
|
+
opacity: 0.7
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var CommentBox = function CommentBox(_ref) {
|
|
69
|
+
var comment = _ref.comment,
|
|
70
|
+
crossComment = _ref.crossComment,
|
|
71
|
+
createComment = _ref.createComment,
|
|
72
|
+
token = _ref.token,
|
|
73
|
+
dispatch = _ref.dispatch,
|
|
74
|
+
showChangeStatus = _ref.showChangeStatus,
|
|
75
|
+
onOpenChangeStatus = _ref.onOpenChangeStatus,
|
|
76
|
+
showSendEvaluation = _ref.showSendEvaluation,
|
|
77
|
+
canSendEvaluation = _ref.canSendEvaluation,
|
|
78
|
+
onSendEvaluation = _ref.onSendEvaluation;
|
|
79
|
+
|
|
80
|
+
var _useState = (0, _react.useState)(""),
|
|
81
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
82
|
+
text = _useState2[0],
|
|
83
|
+
setText = _useState2[1];
|
|
84
|
+
|
|
85
|
+
var _useState3 = (0, _react.useState)(false),
|
|
86
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
87
|
+
sending = _useState4[0],
|
|
88
|
+
setSending = _useState4[1];
|
|
89
|
+
|
|
90
|
+
var notify = function notify(payload) {
|
|
91
|
+
return dispatch({
|
|
92
|
+
type: "SET_MODAL",
|
|
93
|
+
payload: (0, _objectSpread2.default)({
|
|
94
|
+
show: true
|
|
95
|
+
}, payload)
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var submit = /*#__PURE__*/function () {
|
|
100
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
101
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
102
|
+
while (1) {
|
|
103
|
+
switch (_context.prev = _context.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (text.trim()) {
|
|
106
|
+
_context.next = 2;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return _context.abrupt("return");
|
|
111
|
+
|
|
112
|
+
case 2:
|
|
113
|
+
setSending(true);
|
|
114
|
+
_context.prev = 3;
|
|
115
|
+
_context.next = 6;
|
|
116
|
+
return createComment(toCommentText(text), token);
|
|
117
|
+
|
|
118
|
+
case 6:
|
|
119
|
+
setText("");
|
|
120
|
+
notify({
|
|
121
|
+
title: "",
|
|
122
|
+
message: "Comentario guardado con éxito",
|
|
123
|
+
image: _genericModalCheck.default
|
|
124
|
+
});
|
|
125
|
+
_context.next = 14;
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case 10:
|
|
129
|
+
_context.prev = 10;
|
|
130
|
+
_context.t0 = _context["catch"](3);
|
|
131
|
+
console.error("Error saving comment:", _context.t0);
|
|
132
|
+
notify({
|
|
133
|
+
title: "Error",
|
|
134
|
+
message: "Hubo un error al guardar el comentario",
|
|
135
|
+
image: _errorModal.default
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
case 14:
|
|
139
|
+
_context.prev = 14;
|
|
140
|
+
setSending(false);
|
|
141
|
+
return _context.finish(14);
|
|
142
|
+
|
|
143
|
+
case 17:
|
|
144
|
+
case "end":
|
|
145
|
+
return _context.stop();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, _callee, null, [[3, 10, 14, 17]]);
|
|
149
|
+
}));
|
|
150
|
+
|
|
151
|
+
return function submit() {
|
|
152
|
+
return _ref2.apply(this, arguments);
|
|
153
|
+
};
|
|
154
|
+
}();
|
|
155
|
+
|
|
156
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
157
|
+
direction: {
|
|
158
|
+
xs: "column",
|
|
159
|
+
sm: "row"
|
|
160
|
+
},
|
|
161
|
+
alignItems: {
|
|
162
|
+
xs: "stretch",
|
|
163
|
+
sm: "flex-end"
|
|
164
|
+
},
|
|
165
|
+
justifyContent: "space-between",
|
|
166
|
+
flexWrap: "wrap",
|
|
167
|
+
gap: 1.5,
|
|
168
|
+
sx: {
|
|
169
|
+
py: "10px",
|
|
170
|
+
minWidth: 0
|
|
171
|
+
},
|
|
172
|
+
children: [!comment ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
173
|
+
direction: {
|
|
174
|
+
xs: "column",
|
|
175
|
+
md: "row"
|
|
176
|
+
},
|
|
177
|
+
alignItems: {
|
|
178
|
+
xs: "stretch",
|
|
179
|
+
md: "flex-end"
|
|
180
|
+
},
|
|
181
|
+
gap: 1,
|
|
182
|
+
sx: {
|
|
183
|
+
flex: 1,
|
|
184
|
+
minWidth: 0
|
|
185
|
+
},
|
|
186
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
187
|
+
sx: {
|
|
188
|
+
width: {
|
|
189
|
+
xs: "100%",
|
|
190
|
+
md: "min(500px, 100%)"
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
194
|
+
component: "label",
|
|
195
|
+
htmlFor: "commentary-box-input",
|
|
196
|
+
sx: {
|
|
197
|
+
display: "block",
|
|
198
|
+
mb: 0.5,
|
|
199
|
+
fontFamily: _tokens.FONTS.Raleway,
|
|
200
|
+
fontSize: 14,
|
|
201
|
+
color: _tokens.COLORS.color_gray
|
|
202
|
+
},
|
|
203
|
+
children: "Caja de Comentario"
|
|
204
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
205
|
+
id: "commentary-box-input",
|
|
206
|
+
multiline: true,
|
|
207
|
+
minRows: 4,
|
|
208
|
+
maxRows: 8,
|
|
209
|
+
fullWidth: true,
|
|
210
|
+
value: text,
|
|
211
|
+
onChange: function onChange(e) {
|
|
212
|
+
return setText(e.target.value.slice(0, MAX_CHARS));
|
|
213
|
+
},
|
|
214
|
+
helperText: "".concat(text.length, "/").concat(MAX_CHARS),
|
|
215
|
+
FormHelperTextProps: {
|
|
216
|
+
sx: {
|
|
217
|
+
textAlign: "right",
|
|
218
|
+
mx: 0
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
InputProps: {
|
|
222
|
+
sx: {
|
|
223
|
+
fontFamily: _tokens.FONTS.AvenirNext,
|
|
224
|
+
fontSize: 13,
|
|
225
|
+
borderRadius: "3px"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
})]
|
|
229
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
230
|
+
variant: "outlined",
|
|
231
|
+
disabled: !text.trim() || sending,
|
|
232
|
+
onClick: submit,
|
|
233
|
+
sx: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pill), {}, {
|
|
234
|
+
mb: {
|
|
235
|
+
md: "23px"
|
|
236
|
+
},
|
|
237
|
+
fontSize: 16,
|
|
238
|
+
borderColor: _tokens.COLORS.s5,
|
|
239
|
+
color: _tokens.COLORS.s5,
|
|
240
|
+
"&:hover": (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pill["&:hover"]), {}, {
|
|
241
|
+
borderColor: _tokens.COLORS.s5
|
|
242
|
+
})
|
|
243
|
+
}),
|
|
244
|
+
children: sending ? "Enviando…" : "Enviar comentario"
|
|
245
|
+
})]
|
|
246
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Paper, {
|
|
247
|
+
variant: "outlined",
|
|
248
|
+
sx: {
|
|
249
|
+
flex: 1,
|
|
250
|
+
minWidth: 0,
|
|
251
|
+
maxWidth: {
|
|
252
|
+
md: 500
|
|
253
|
+
},
|
|
254
|
+
minHeight: 80,
|
|
255
|
+
p: "10px",
|
|
256
|
+
borderColor: _tokens.COLORS.s2
|
|
257
|
+
},
|
|
258
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
259
|
+
sx: {
|
|
260
|
+
whiteSpace: "pre-wrap",
|
|
261
|
+
overflowWrap: "anywhere",
|
|
262
|
+
fontFamily: _tokens.FONTS.AvenirNext,
|
|
263
|
+
fontSize: 12,
|
|
264
|
+
lineHeight: "15px",
|
|
265
|
+
color: _tokens.COLORS.deep_gray,
|
|
266
|
+
textDecoration: crossComment ? "line-through" : "none"
|
|
267
|
+
},
|
|
268
|
+
children: comment === null || comment === void 0 ? void 0 : comment.message
|
|
269
|
+
})
|
|
270
|
+
}), (showChangeStatus || showSendEvaluation) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
271
|
+
gap: 2,
|
|
272
|
+
sx: {
|
|
273
|
+
flexShrink: 0
|
|
274
|
+
},
|
|
275
|
+
children: [showChangeStatus && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
276
|
+
id: "button-change-status",
|
|
277
|
+
variant: "contained",
|
|
278
|
+
onClick: onOpenChangeStatus,
|
|
279
|
+
sx: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pill), {}, {
|
|
280
|
+
bgcolor: "#E33AA9",
|
|
281
|
+
"&:hover": (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pill["&:hover"]), {}, {
|
|
282
|
+
bgcolor: "#E33AA9"
|
|
283
|
+
})
|
|
284
|
+
}),
|
|
285
|
+
children: "Cambio de Estatus"
|
|
286
|
+
}), showSendEvaluation &&
|
|
287
|
+
/*#__PURE__*/
|
|
288
|
+
// Igual que el original: gris y deshabilitado mientras no se pueda
|
|
289
|
+
// enviar (evaluación sin terminar o faltan requeridos).
|
|
290
|
+
(0, _jsxRuntime.jsx)(_material.Button, {
|
|
291
|
+
variant: "contained",
|
|
292
|
+
disabled: !canSendEvaluation,
|
|
293
|
+
onClick: onSendEvaluation,
|
|
294
|
+
sx: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pill), {}, {
|
|
295
|
+
bgcolor: "#71de56",
|
|
296
|
+
color: _tokens.COLORS.white,
|
|
297
|
+
"&:hover": (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pill["&:hover"]), {}, {
|
|
298
|
+
bgcolor: "#71de56"
|
|
299
|
+
}),
|
|
300
|
+
"&.Mui-disabled": {
|
|
301
|
+
bgcolor: "grey",
|
|
302
|
+
color: _tokens.COLORS.white
|
|
303
|
+
}
|
|
304
|
+
}),
|
|
305
|
+
children: "Enviar evaluaci\xF3n"
|
|
306
|
+
})]
|
|
307
|
+
})]
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
exports.CommentBox = CommentBox;
|