contentoh-components-library 21.3.41 → 21.3.42
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/pages/ProviderProductEdition/ProviderProductEdition.stories.js +43 -57
- package/dist/components/pages/ProviderProductEdition/index.js +453 -205
- package/package.json +1 -1
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +43 -63
- package/src/components/pages/ProviderProductEdition/index.js +138 -23
package/package.json
CHANGED
|
@@ -21,13 +21,13 @@ ProviderProductEditionDefault.args = {
|
|
|
21
21
|
category: 846,
|
|
22
22
|
version: 2,
|
|
23
23
|
productSelected: {
|
|
24
|
-
orderId:
|
|
24
|
+
orderId: 15158,
|
|
25
25
|
article_status: "RAC",
|
|
26
|
-
datasheet_status: "
|
|
26
|
+
datasheet_status: "RAC",
|
|
27
27
|
description_status: "RAC",
|
|
28
|
-
images_status: "
|
|
28
|
+
images_status: "RAC",
|
|
29
29
|
prio: "none",
|
|
30
|
-
version:
|
|
30
|
+
version: 5,
|
|
31
31
|
brand: null,
|
|
32
32
|
article: {
|
|
33
33
|
category: "Puertas y Ventanas|Molduras|Molduras Madera Blanda",
|
|
@@ -56,9 +56,9 @@ ProviderProductEditionDefault.args = {
|
|
|
56
56
|
},
|
|
57
57
|
statusByRetailer: {
|
|
58
58
|
58: {
|
|
59
|
-
datasheet: "
|
|
59
|
+
datasheet: "RAC",
|
|
60
60
|
description: "RAC",
|
|
61
|
-
images: "
|
|
61
|
+
images: "RAC",
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
retailersWithService: ["58"],
|
|
@@ -78,13 +78,13 @@ ProviderProductEditionDefault.args = {
|
|
|
78
78
|
ArticleId: 39290,
|
|
79
79
|
idCategory: "2366",
|
|
80
80
|
product: {
|
|
81
|
-
orderId:
|
|
81
|
+
orderId: 15158,
|
|
82
82
|
article_status: "RAC",
|
|
83
|
-
datasheet_status: "
|
|
83
|
+
datasheet_status: "RAC",
|
|
84
84
|
description_status: "RAC",
|
|
85
|
-
images_status: "
|
|
85
|
+
images_status: "RAC",
|
|
86
86
|
prio: "none",
|
|
87
|
-
version:
|
|
87
|
+
version: 5,
|
|
88
88
|
brand: null,
|
|
89
89
|
article: {
|
|
90
90
|
category: "Puertas y Ventanas|Molduras|Molduras Madera Blanda",
|
|
@@ -113,9 +113,9 @@ ProviderProductEditionDefault.args = {
|
|
|
113
113
|
},
|
|
114
114
|
statusByRetailer: {
|
|
115
115
|
58: {
|
|
116
|
-
datasheet: "
|
|
116
|
+
datasheet: "RAC",
|
|
117
117
|
description: "RAC",
|
|
118
|
-
images: "
|
|
118
|
+
images: "RAC",
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
121
|
retailersWithService: ["58"],
|
|
@@ -142,58 +142,38 @@ ProviderProductEditionDefault.args = {
|
|
|
142
142
|
key: "24vwut",
|
|
143
143
|
},
|
|
144
144
|
user: {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
descriptions: 1,
|
|
176
|
-
images: 1,
|
|
177
|
-
},
|
|
178
|
-
statusByRetailer: {
|
|
179
|
-
58: {
|
|
180
|
-
datasheet: "AAC",
|
|
181
|
-
description: "RAC",
|
|
182
|
-
images: "AAC",
|
|
183
|
-
},
|
|
145
|
+
id_user: 59,
|
|
146
|
+
name: "Cadena",
|
|
147
|
+
last_name: "Comercial",
|
|
148
|
+
email: "cadena.ismael@allfreemail.net",
|
|
149
|
+
position: "Admin",
|
|
150
|
+
telephone: "+523111366336",
|
|
151
|
+
country: "México",
|
|
152
|
+
id_company: 817,
|
|
153
|
+
id_cognito: "5884ae34-59d6-4454-b98e-821518bcc3a7",
|
|
154
|
+
birth_Date: null,
|
|
155
|
+
about_me: "",
|
|
156
|
+
zip_code: "",
|
|
157
|
+
address: "",
|
|
158
|
+
job: "",
|
|
159
|
+
id_stripe: "",
|
|
160
|
+
id_role: 0,
|
|
161
|
+
active: 1,
|
|
162
|
+
is_retailer: 1,
|
|
163
|
+
email_notify: 0,
|
|
164
|
+
is_user_tech: null,
|
|
165
|
+
membership: {
|
|
166
|
+
id: 47,
|
|
167
|
+
start_date: "2022-05-25T14:31:12.000Z",
|
|
168
|
+
end_date: "2023-05-25T14:31:12.000Z",
|
|
169
|
+
planID: 5,
|
|
170
|
+
plan: "prod_Ktl6B5Ou2gqTB2",
|
|
171
|
+
name: "Plan Pro",
|
|
172
|
+
user_limit: "5",
|
|
173
|
+
products_limit: "500",
|
|
174
|
+
type: "PyMES",
|
|
184
175
|
},
|
|
185
|
-
|
|
186
|
-
id_article: 39290,
|
|
187
|
-
retailersAvailable: [
|
|
188
|
-
{
|
|
189
|
-
id: 58,
|
|
190
|
-
name: "The Home Depot Golden",
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
id: 68,
|
|
194
|
-
name: "The Home Depot Merchants",
|
|
195
|
-
},
|
|
196
|
-
],
|
|
176
|
+
src: "https://content-management-profile.s3.amazonaws.com/id-59/59.png?1682103877593",
|
|
197
177
|
},
|
|
198
178
|
company: {
|
|
199
179
|
id_company: 817,
|
|
@@ -19,9 +19,6 @@ import { useDropzone } from "react-dropzone";
|
|
|
19
19
|
import axios from "axios";
|
|
20
20
|
import { v4 as uuidv4 } from "uuid";
|
|
21
21
|
import AWS from "aws-sdk";
|
|
22
|
-
import attributesSent from "../../../assets/images/modalsSVGs/attributesSent.svg";
|
|
23
|
-
import descriptionSent from "../../../assets/images/modalsSVGs/descriptionSent.svg";
|
|
24
|
-
import imagesSent from "../../../assets/images/modalsSVGs/uploadingImages.svg";
|
|
25
22
|
import { TagAndInput } from "../../molecules/TagAndInput/index";
|
|
26
23
|
import { Button } from "../../atoms/GeneralButton";
|
|
27
24
|
import { Commentary } from "../../atoms/Commentary";
|
|
@@ -133,6 +130,7 @@ export const ProviderProductEdition = ({
|
|
|
133
130
|
setShowContentohRequestModal,
|
|
134
131
|
showSurvey,
|
|
135
132
|
company,
|
|
133
|
+
addToCart,
|
|
136
134
|
}) => {
|
|
137
135
|
const [activeTab, setActiveTab] = useState("Descripción");
|
|
138
136
|
const [activeImage, setActiveImage] = useState();
|
|
@@ -233,7 +231,7 @@ export const ProviderProductEdition = ({
|
|
|
233
231
|
}`,
|
|
234
232
|
button1: {
|
|
235
233
|
name: "Cerrar",
|
|
236
|
-
action:
|
|
234
|
+
action: closeGlobalModal,
|
|
237
235
|
},
|
|
238
236
|
button2: {
|
|
239
237
|
name: "Continuar",
|
|
@@ -250,6 +248,97 @@ export const ProviderProductEdition = ({
|
|
|
250
248
|
useCloseModal("version-selector");
|
|
251
249
|
const [globalModal, setGlobalModal] = useState();
|
|
252
250
|
|
|
251
|
+
const updateAuditStatus = async (status) => {
|
|
252
|
+
const productTemp = product;
|
|
253
|
+
productTemp.article_status = status;
|
|
254
|
+
productTemp.datasheet_status = status;
|
|
255
|
+
productTemp.description_status = status;
|
|
256
|
+
productTemp.images_status = status;
|
|
257
|
+
|
|
258
|
+
const retailerStatusCopy = { ...retailerStatus };
|
|
259
|
+
const conceptArray = ["description", "datasheet", "images"];
|
|
260
|
+
Object.keys(retailerStatusCopy).forEach((key) => {
|
|
261
|
+
conceptArray.forEach((concept) => {
|
|
262
|
+
if (retailerStatusCopy[key][concept]) {
|
|
263
|
+
retailerStatusCopy[key][concept] = status;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
setRetailerStatus(retailerStatusCopy);
|
|
268
|
+
productTemp.statusByRetailer = retailerStatusCopy;
|
|
269
|
+
setProduct(productTemp);
|
|
270
|
+
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
271
|
+
setProductEdit({
|
|
272
|
+
ArticleId: productTemp.id_article,
|
|
273
|
+
idCategory: productTemp.article.id_category,
|
|
274
|
+
product: productTemp,
|
|
275
|
+
});
|
|
276
|
+
sessionStorage.setItem(
|
|
277
|
+
"productEdit",
|
|
278
|
+
JSON.stringify({
|
|
279
|
+
ArticleId: productTemp.id_article,
|
|
280
|
+
idCategory: productTemp.article.id_category,
|
|
281
|
+
product: productTemp,
|
|
282
|
+
})
|
|
283
|
+
);
|
|
284
|
+
await loadData();
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const addCart = async (retailers) => {
|
|
288
|
+
const { article, version } = product;
|
|
289
|
+
const articleToOrder = [
|
|
290
|
+
{
|
|
291
|
+
articleId: article.id_article,
|
|
292
|
+
version,
|
|
293
|
+
userId: user.id_user,
|
|
294
|
+
discount: 0,
|
|
295
|
+
subtotal: 0,
|
|
296
|
+
companyId: user.id_company,
|
|
297
|
+
datasheet: retailers,
|
|
298
|
+
description: retailers,
|
|
299
|
+
image: retailers,
|
|
300
|
+
attributeTranslations: false,
|
|
301
|
+
descriptionTranslations: false,
|
|
302
|
+
build: "[]",
|
|
303
|
+
manual: "[]",
|
|
304
|
+
userCreated: user.id_user,
|
|
305
|
+
},
|
|
306
|
+
];
|
|
307
|
+
let modatlType = "addedToCartError";
|
|
308
|
+
if (addToCart) {
|
|
309
|
+
const resCart = await addToCart({ data: articleToOrder });
|
|
310
|
+
if (resCart.data.statusCode === 200) {
|
|
311
|
+
modatlType = "addedToCart";
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
showGlobalModal(modatlType);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const closeGlobalModal = () => setGlobalModal();
|
|
318
|
+
|
|
319
|
+
const seenByProvider = async () => {
|
|
320
|
+
const productTemp = product;
|
|
321
|
+
const articleId = productTemp.id_article;
|
|
322
|
+
const orderId = productTemp.id_order ?? productTemp.orderId;
|
|
323
|
+
const sectionStatusKey = `${getConcept(activeTab)}_status`;
|
|
324
|
+
const evalStatus = product[sectionStatusKey] || product?.version_status;
|
|
325
|
+
const promises = [];
|
|
326
|
+
const conceptArray = ["description", "datasheet", "images"];
|
|
327
|
+
conceptArray.forEach((concept) => {
|
|
328
|
+
const data = { articleId, orderId, concept, evalStatus };
|
|
329
|
+
promises.push(
|
|
330
|
+
axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
|
|
331
|
+
headers: {
|
|
332
|
+
Authorization: token,
|
|
333
|
+
},
|
|
334
|
+
})
|
|
335
|
+
);
|
|
336
|
+
});
|
|
337
|
+
await Promise.all(promises);
|
|
338
|
+
closeGlobalModal();
|
|
339
|
+
await updateAuditStatus("FAP");
|
|
340
|
+
};
|
|
341
|
+
|
|
253
342
|
const showGlobalModal = useCallback(
|
|
254
343
|
(type) => {
|
|
255
344
|
const formatter = new Intl.ListFormat("es", { type: "conjunction" });
|
|
@@ -285,7 +374,7 @@ export const ProviderProductEdition = ({
|
|
|
285
374
|
detail: "Trabajaremos en conjunto para resolverlo.",
|
|
286
375
|
button1: {
|
|
287
376
|
name: "Cerrar",
|
|
288
|
-
action:
|
|
377
|
+
action: closeGlobalModal,
|
|
289
378
|
},
|
|
290
379
|
img: face,
|
|
291
380
|
textArea: false,
|
|
@@ -294,9 +383,9 @@ export const ProviderProductEdition = ({
|
|
|
294
383
|
case "RAC":
|
|
295
384
|
const servicesRejected = [];
|
|
296
385
|
const translateServices = {
|
|
297
|
-
datasheet:
|
|
298
|
-
description:
|
|
299
|
-
images:
|
|
386
|
+
datasheet: "ficha técnica",
|
|
387
|
+
description: "descripción",
|
|
388
|
+
images: "imágenes",
|
|
300
389
|
};
|
|
301
390
|
Object.keys(translateServices).forEach((service) => {
|
|
302
391
|
if (product[`${service}_status`] === "RAC") {
|
|
@@ -309,6 +398,9 @@ export const ProviderProductEdition = ({
|
|
|
309
398
|
const formatted = formatter.format(servicesRejected);
|
|
310
399
|
const text1 = `${grammar[0]} de ${formatted} no ${grammar[1]} con lo que la cadena necesita.`;
|
|
311
400
|
const text2 = `¡Solicita el servicio de Content-oh! para completarlo!`;
|
|
401
|
+
const retailers = product.retailersWithService.map((retailer) =>
|
|
402
|
+
Number(retailer)
|
|
403
|
+
);
|
|
312
404
|
setGlobalModal({
|
|
313
405
|
message:
|
|
314
406
|
"Tu producto no cumple con los requerimientos de la cadena",
|
|
@@ -324,13 +416,16 @@ export const ProviderProductEdition = ({
|
|
|
324
416
|
),
|
|
325
417
|
button1: {
|
|
326
418
|
name: "Continuar",
|
|
327
|
-
action: () =>
|
|
419
|
+
action: async () => await seenByProvider(),
|
|
328
420
|
},
|
|
329
421
|
button2: {
|
|
330
422
|
name: "Solicitar a Content-oh!",
|
|
331
|
-
action: () =>
|
|
423
|
+
action: async () => {
|
|
424
|
+
await addCart(retailers);
|
|
425
|
+
await seenByProvider();
|
|
426
|
+
},
|
|
332
427
|
},
|
|
333
|
-
img:
|
|
428
|
+
img: errorModal,
|
|
334
429
|
});
|
|
335
430
|
break;
|
|
336
431
|
case "AAC":
|
|
@@ -339,17 +434,38 @@ export const ProviderProductEdition = ({
|
|
|
339
434
|
detail: "Tu producto cumple con los requerimientos de la cadena.",
|
|
340
435
|
button1: {
|
|
341
436
|
name: "Continuar",
|
|
342
|
-
action: () =>
|
|
437
|
+
action: async () => await seenByProvider(),
|
|
438
|
+
},
|
|
439
|
+
img: face,
|
|
440
|
+
});
|
|
441
|
+
break;
|
|
442
|
+
case "addedToCartError":
|
|
443
|
+
setGlobalModal({
|
|
444
|
+
detail:
|
|
445
|
+
"Parece que algo salió mal al intentar añadir tu producto a tu carrito.",
|
|
446
|
+
button1: {
|
|
447
|
+
name: "Continuar",
|
|
448
|
+
action: closeGlobalModal,
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
break;
|
|
452
|
+
case "addedToCart":
|
|
453
|
+
setGlobalModal({
|
|
454
|
+
message: "Producto añadido",
|
|
455
|
+
detail: "Tu producto se añadió al carrito de compras.",
|
|
456
|
+
button1: {
|
|
457
|
+
name: "Continuar",
|
|
458
|
+
action: closeGlobalModal,
|
|
343
459
|
},
|
|
344
460
|
img: face,
|
|
345
461
|
});
|
|
346
462
|
break;
|
|
347
463
|
default:
|
|
348
|
-
|
|
464
|
+
closeGlobalModal();
|
|
349
465
|
break;
|
|
350
466
|
}
|
|
351
467
|
},
|
|
352
|
-
[activeTab, dataGenericModal]
|
|
468
|
+
[activeTab, dataGenericModal, product]
|
|
353
469
|
);
|
|
354
470
|
|
|
355
471
|
useEffect(() => {
|
|
@@ -990,23 +1106,24 @@ export const ProviderProductEdition = ({
|
|
|
990
1106
|
})
|
|
991
1107
|
);
|
|
992
1108
|
});
|
|
993
|
-
|
|
1109
|
+
await Promise.all(evaluationArray);
|
|
994
1110
|
const userType = user.is_retailer === 1 ? "CA" : "P";
|
|
995
1111
|
|
|
996
1112
|
const productTemp = product;
|
|
997
|
-
|
|
1113
|
+
const status = `${result}${userType}`;
|
|
1114
|
+
productTemp.article_status = status;
|
|
998
1115
|
productTemp.datasheet_status =
|
|
999
|
-
productTemp.datasheet_status === "NA" ? "NA" :
|
|
1116
|
+
productTemp.datasheet_status === "NA" ? "NA" : status;
|
|
1000
1117
|
productTemp.description_status =
|
|
1001
|
-
productTemp.description_status === "NA" ? "NA" :
|
|
1118
|
+
productTemp.description_status === "NA" ? "NA" : status;
|
|
1002
1119
|
productTemp.images_status =
|
|
1003
|
-
productTemp.images_status === "NA" ? "NA" :
|
|
1120
|
+
productTemp.images_status === "NA" ? "NA" : status;
|
|
1004
1121
|
|
|
1005
1122
|
const retailerStatusCopy = { ...retailerStatus };
|
|
1006
1123
|
Object.keys(retailerStatusCopy).forEach((key) => {
|
|
1007
1124
|
conceptArray.forEach((concept) => {
|
|
1008
1125
|
if (retailerStatusCopy[key][concept]) {
|
|
1009
|
-
retailerStatusCopy[key][concept] =
|
|
1126
|
+
retailerStatusCopy[key][concept] = status;
|
|
1010
1127
|
}
|
|
1011
1128
|
});
|
|
1012
1129
|
});
|
|
@@ -1495,9 +1612,7 @@ export const ProviderProductEdition = ({
|
|
|
1495
1612
|
onClick={() => setMessage("")}
|
|
1496
1613
|
/>
|
|
1497
1614
|
)}
|
|
1498
|
-
{globalModal &&
|
|
1499
|
-
<GlobalModal close={() => setGlobalModal()} {...globalModal} />
|
|
1500
|
-
)}
|
|
1615
|
+
{globalModal && <GlobalModal close={closeGlobalModal} {...globalModal} />}
|
|
1501
1616
|
{showVersionSelector && (
|
|
1502
1617
|
<VersionSelector
|
|
1503
1618
|
modalId={"version-selector"}
|