contentoh-components-library 13.0.0 → 16.0.0
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/atoms/CheckBox/index.js +4 -2
- package/dist/components/atoms/GeneralButton/styles.js +4 -2
- package/dist/components/atoms/GeneralInput/index.js +14 -27
- package/dist/components/atoms/GenericModal/index.js +4 -2
- package/dist/components/atoms/GenericModal/styles.js +1 -1
- package/dist/components/atoms/Input/index.js +1 -1
- package/dist/components/atoms/Input/style.js +4 -4
- package/dist/components/atoms/InputFormatter/Wysiwyg.stories.js +30 -0
- package/dist/components/atoms/InputFormatter/index.js +119 -0
- package/dist/components/atoms/InputFormatter/styles.js +33 -0
- package/dist/components/atoms/LabelToInput/style.js +3 -3
- package/dist/components/atoms/ProductPercentCard/Percent.stories.js +41 -0
- package/dist/components/atoms/ProductPercentCard/index.js +45 -0
- package/dist/components/atoms/ProductPercentCard/styles.js +20 -0
- package/dist/components/molecules/GalleryElement/index.js +24 -2
- package/dist/components/molecules/GalleryHeader/index.js +19 -2
- package/dist/components/molecules/StatusAsignationInfo/index.js +12 -27
- package/dist/components/molecules/TableHeader/index.js +4 -2
- package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
- package/dist/components/organisms/FullTabsMenu/index.js +8 -10
- package/dist/components/organisms/ImageDataTable/index.js +4 -2
- package/dist/components/organisms/ProductImageModal/index.js +2 -3
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +4 -14
- package/dist/components/pages/RetailerProductEdition/index.js +331 -172
- package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
- package/package.json +5 -1
- package/src/assets/images/generalButton/downloadIcon.svg +3 -0
- package/src/components/atoms/CheckBox/index.js +8 -2
- package/src/components/atoms/GeneralButton/styles.js +14 -0
- package/src/components/atoms/GeneralInput/index.js +12 -29
- package/src/components/atoms/GenericModal/index.js +2 -2
- package/src/components/atoms/GenericModal/styles.js +1 -0
- package/src/components/atoms/Input/index.js +2 -1
- package/src/components/atoms/Input/style.js +9 -5
- package/src/components/atoms/InputFormatter/Wysiwyg.stories.js +12 -0
- package/src/components/atoms/InputFormatter/index.js +76 -0
- package/src/components/atoms/InputFormatter/styles.js +34 -0
- package/src/components/atoms/LabelToInput/style.js +10 -2
- package/src/components/atoms/ProductPercentCard/Percent.stories.js +41 -0
- package/src/components/atoms/ProductPercentCard/index.js +23 -0
- package/src/components/atoms/{Percent → ProductPercentCard}/styles.js +11 -7
- package/src/components/molecules/GalleryElement/index.js +18 -1
- package/src/components/molecules/GalleryHeader/index.js +8 -2
- package/src/components/molecules/StatusAsignationInfo/index.js +12 -24
- package/src/components/molecules/TableHeader/index.js +2 -0
- package/src/components/organisms/FullProductNameHeader/index.js +1 -1
- package/src/components/organisms/FullTabsMenu/index.js +6 -8
- package/src/components/organisms/ImageDataTable/index.js +2 -0
- package/src/components/organisms/ProductImageModal/index.js +8 -2
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +4 -14
- package/src/components/pages/RetailerProductEdition/index.js +252 -92
- package/src/components/pages/RetailerProductEdition/styles.js +13 -3
- package/src/components/atoms/Percent/Percent.stories.js +0 -38
- package/src/components/atoms/Percent/index.js +0 -15
|
@@ -7,6 +7,7 @@ import { FullTabsMenu } from "../../organisms/FullTabsMenu";
|
|
|
7
7
|
import { InputGroup } from "../../organisms/InputGroup";
|
|
8
8
|
import { useEffect, useReducer, useState, useCallback } from "react";
|
|
9
9
|
import { GalleryElement } from "../../molecules/GalleryElement";
|
|
10
|
+
import { saveAs } from "file-saver";
|
|
10
11
|
import {
|
|
11
12
|
getRetailerServices,
|
|
12
13
|
getPercentage,
|
|
@@ -24,6 +25,8 @@ import imagesSent from "../../../assets/images/modalsSVGs/uploadingImages.svg";
|
|
|
24
25
|
import { TagAndInput } from "../../molecules/TagAndInput/index";
|
|
25
26
|
import { Button } from "../../atoms/GeneralButton";
|
|
26
27
|
import { Commentary } from "../../atoms/Commentary";
|
|
28
|
+
import { GenericModal } from "../../atoms/GenericModal";
|
|
29
|
+
import { ScreenHeader } from "../../atoms/ScreenHeader";
|
|
27
30
|
|
|
28
31
|
const reducerImages = (state, action) => {
|
|
29
32
|
let { values, attrForImgs } = state;
|
|
@@ -58,22 +61,19 @@ const myBucket = new AWS.S3({
|
|
|
58
61
|
});
|
|
59
62
|
|
|
60
63
|
export const RetailerProductEdition = ({
|
|
61
|
-
productData,
|
|
62
64
|
tabsSections,
|
|
63
|
-
articleId,
|
|
64
65
|
productSelected = {},
|
|
65
66
|
user = {},
|
|
66
67
|
token,
|
|
67
68
|
}) => {
|
|
68
69
|
const [activeTab, setActiveTab] = useState("Descripción");
|
|
69
70
|
const [activeImage, setActiveImage] = useState();
|
|
70
|
-
const [imageLayout, setImageLayout] = useState(
|
|
71
|
+
const [imageLayout, setImageLayout] = useState(false);
|
|
71
72
|
const [headerTop, setHeaderTop] = useState(0);
|
|
72
73
|
const [descriptions, setDescriptions] = useState([]);
|
|
73
74
|
const [datasheets, setDatasheets] = useState([]);
|
|
74
75
|
const [images, setImages] = useReducer(reducerImages, {});
|
|
75
76
|
const [showModal, setShowModal] = useState(false);
|
|
76
|
-
const [retailerSelected, setRetailerSelected] = useState(54); // revisar después como trabajar esto de mejor forma
|
|
77
77
|
const { getRootProps, getInputProps } = useDropzone({
|
|
78
78
|
accept: "image/*",
|
|
79
79
|
noKeyboard: true,
|
|
@@ -115,7 +115,7 @@ export const RetailerProductEdition = ({
|
|
|
115
115
|
const [imagesUploaded, setImagesUploaded] = useState(false);
|
|
116
116
|
const [dataImages, setDataImages] = useState();
|
|
117
117
|
const [percentages, setPercentages] = useState(
|
|
118
|
-
new Array(productSelected
|
|
118
|
+
new Array(productSelected?.retailers?.length).fill({ percentage: 0 })
|
|
119
119
|
);
|
|
120
120
|
const [activePercentage, setActivePercentage] = useState(0);
|
|
121
121
|
const [activeRetailer, setActiveRetailer] = useState({});
|
|
@@ -131,13 +131,19 @@ export const RetailerProductEdition = ({
|
|
|
131
131
|
const [crossComment, setCrossComment] = useState(false);
|
|
132
132
|
const [userGroups, setUserGroups] = useState([]);
|
|
133
133
|
const [assig, setAssig] = useState({});
|
|
134
|
+
const [selectedImages, setSelectedImages] = useState([]);
|
|
135
|
+
const [componentsArray, setComponentsArray] = useState([]);
|
|
136
|
+
const [checkAll, setCheckAll] = useState(false);
|
|
134
137
|
const isRetailer = user?.is_retailer;
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
checkAll && setSelectedImages(images.values);
|
|
140
|
+
}, [checkAll]);
|
|
135
141
|
|
|
136
142
|
const loadData = async () => {
|
|
137
143
|
const services = await getRetailerServices(
|
|
138
|
-
productSelected
|
|
139
|
-
parseInt(productSelected
|
|
140
|
-
productSelected
|
|
144
|
+
productSelected?.article?.id_article,
|
|
145
|
+
parseInt(productSelected?.article?.id_category),
|
|
146
|
+
productSelected?.version
|
|
141
147
|
);
|
|
142
148
|
|
|
143
149
|
//Converts the data inside the datasheets object to array
|
|
@@ -166,10 +172,9 @@ export const RetailerProductEdition = ({
|
|
|
166
172
|
}
|
|
167
173
|
const selected = productSelected;
|
|
168
174
|
const servicesResponse = await axios.get(
|
|
169
|
-
`${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${selected
|
|
175
|
+
`${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${selected?.article?.id_article}&orderId=${selected?.article?.id_order}&end=true`
|
|
170
176
|
);
|
|
171
|
-
const parsedResponse = JSON.parse(servicesResponse
|
|
172
|
-
|
|
177
|
+
const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
|
|
173
178
|
setServicesData(parsedResponse);
|
|
174
179
|
};
|
|
175
180
|
|
|
@@ -201,10 +206,10 @@ export const RetailerProductEdition = ({
|
|
|
201
206
|
let comments = {};
|
|
202
207
|
commentsResponse.forEach(
|
|
203
208
|
(comment) =>
|
|
204
|
-
JSON.parse(comment
|
|
209
|
+
JSON.parse(comment?.data?.body).data[0] &&
|
|
205
210
|
(comments[
|
|
206
|
-
translateConcept(JSON.parse(comment
|
|
207
|
-
] = JSON.parse(comment
|
|
211
|
+
translateConcept(JSON.parse(comment?.data?.body)?.data[0]?.concept)
|
|
212
|
+
] = JSON.parse(comment?.data?.body).data[0])
|
|
208
213
|
);
|
|
209
214
|
setComment(comments[tab]);
|
|
210
215
|
setComments(comments);
|
|
@@ -278,42 +283,48 @@ export const RetailerProductEdition = ({
|
|
|
278
283
|
}, [userGroups]);
|
|
279
284
|
|
|
280
285
|
useEffect(() => {
|
|
281
|
-
productSelected
|
|
282
|
-
retailer["percentage"] = percentages
|
|
283
|
-
(percent) => retailer
|
|
286
|
+
productSelected?.retailers?.forEach((retailer) => {
|
|
287
|
+
retailer["percentage"] = percentages?.filter(
|
|
288
|
+
(percent) => retailer?.id === percent?.id_retailer
|
|
284
289
|
)[0]?.percentage;
|
|
285
290
|
});
|
|
286
291
|
setActivePercentage(productSelected?.retailers[0]?.percentage);
|
|
287
292
|
}, [percentages]);
|
|
288
293
|
|
|
289
294
|
useEffect(() => {
|
|
295
|
+
const required = {};
|
|
290
296
|
if (services.length > 0) {
|
|
291
|
-
services[0][activeRetailer
|
|
292
|
-
services[0][activeRetailer
|
|
297
|
+
services[0][activeRetailer.id].data = Object.values(
|
|
298
|
+
services[0][activeRetailer.id].data
|
|
293
299
|
);
|
|
294
|
-
setActivePercentage(Math.round(activeRetailer
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
setActivePercentage(Math.round(activeRetailer?.percentage, 0));
|
|
301
|
+
const datagroups = services[0][activeRetailer?.id];
|
|
302
|
+
const inputs = services[0]?.inputs;
|
|
303
|
+
const descriptions = services[1]?.filter(
|
|
304
|
+
(service) => service?.id === activeRetailer?.id
|
|
298
305
|
);
|
|
306
|
+
setRequiredNull(required);
|
|
307
|
+
setDatasheets([datagroups, inputs]);
|
|
308
|
+
setDescriptions(descriptions);
|
|
299
309
|
}
|
|
300
310
|
}, [activeRetailer]);
|
|
301
311
|
|
|
302
312
|
const thumbs = () => {
|
|
303
|
-
const imageInputs = images
|
|
304
|
-
value: e
|
|
305
|
-
name: e
|
|
313
|
+
const imageInputs = images?.inputs?.map((e) => ({
|
|
314
|
+
value: e?.id,
|
|
315
|
+
name: e?.name,
|
|
306
316
|
}));
|
|
307
|
-
const imageType = images
|
|
308
|
-
value: e
|
|
309
|
-
name: e
|
|
317
|
+
const imageType = images?.imageType?.map((e) => ({
|
|
318
|
+
value: e?.id,
|
|
319
|
+
name: e?.name,
|
|
310
320
|
}));
|
|
311
|
-
const imagePackagingType = images
|
|
312
|
-
value: e
|
|
313
|
-
name: e
|
|
321
|
+
const imagePackagingType = images?.imagePackagingType?.map((e) => ({
|
|
322
|
+
value: e?.id,
|
|
323
|
+
name: e?.name,
|
|
314
324
|
}));
|
|
315
325
|
return images?.values?.map((image, index) => (
|
|
316
326
|
<GalleryElement
|
|
327
|
+
setCheckAll={setCheckAll}
|
|
317
328
|
key={index}
|
|
318
329
|
image={image}
|
|
319
330
|
gridLayout={imageLayout}
|
|
@@ -323,6 +334,8 @@ export const RetailerProductEdition = ({
|
|
|
323
334
|
imagePackagingType={imagePackagingType}
|
|
324
335
|
imageInputs={imageInputs}
|
|
325
336
|
changeImage={setImages}
|
|
337
|
+
selectedImages={selectedImages}
|
|
338
|
+
setSelectedImages={setSelectedImages}
|
|
326
339
|
/>
|
|
327
340
|
));
|
|
328
341
|
};
|
|
@@ -362,7 +375,6 @@ export const RetailerProductEdition = ({
|
|
|
362
375
|
},
|
|
363
376
|
}
|
|
364
377
|
);
|
|
365
|
-
console.log("saved");
|
|
366
378
|
} catch (error) {
|
|
367
379
|
console.log(error);
|
|
368
380
|
}
|
|
@@ -370,53 +382,53 @@ export const RetailerProductEdition = ({
|
|
|
370
382
|
|
|
371
383
|
const updateImages = useCallback(async () => {
|
|
372
384
|
const imagesList = images?.values?.slice();
|
|
373
|
-
const imagesListTemp = imagesList
|
|
374
|
-
acc[image
|
|
385
|
+
const imagesListTemp = imagesList?.reduce((acc, image) => {
|
|
386
|
+
acc[image?.image_id] = ++acc[image?.image_id] || 0;
|
|
375
387
|
return acc;
|
|
376
388
|
}, {});
|
|
377
389
|
|
|
378
|
-
const duplicated = imagesList
|
|
379
|
-
return imagesListTemp[image
|
|
390
|
+
const duplicated = imagesList?.filter((image) => {
|
|
391
|
+
return imagesListTemp[image?.image_id];
|
|
380
392
|
});
|
|
381
393
|
|
|
382
394
|
const attrForImgs = Object.values(images?.attrForImgs);
|
|
383
395
|
attrForImgs.pop();
|
|
384
396
|
const data = {
|
|
385
|
-
articleId,
|
|
386
|
-
attrReqImgs: attrForImgs
|
|
387
|
-
attrId: e[0]
|
|
388
|
-
value: e[0]
|
|
397
|
+
articleId: product?.article?.id_article,
|
|
398
|
+
attrReqImgs: attrForImgs?.map((e) => ({
|
|
399
|
+
attrId: e[0]?.id,
|
|
400
|
+
value: e[0]?.value,
|
|
389
401
|
})),
|
|
390
|
-
articleData: imagesList
|
|
391
|
-
updateImages: imagesList
|
|
402
|
+
articleData: imagesList?.filter((e) => !e.id),
|
|
403
|
+
updateImages: imagesList?.filter((e) => e.id),
|
|
392
404
|
};
|
|
393
405
|
let valid =
|
|
394
|
-
data
|
|
406
|
+
data?.articleData?.length === 0
|
|
395
407
|
? true
|
|
396
|
-
: data
|
|
397
|
-
if (e
|
|
408
|
+
: data?.articleData?.every((e, i) => {
|
|
409
|
+
if (e?.image_id && e?.packing_type && e?.image_type) {
|
|
398
410
|
return true;
|
|
399
411
|
}
|
|
400
412
|
return false;
|
|
401
413
|
});
|
|
402
|
-
if (valid && data
|
|
403
|
-
valid = data
|
|
404
|
-
if (e
|
|
414
|
+
if (valid && data?.updateImages?.length > 0 && duplicated?.length === 0) {
|
|
415
|
+
valid = data?.updateImages?.every((e, i) => {
|
|
416
|
+
if (e?.image_id && e?.packing_type && e?.image_type) {
|
|
405
417
|
return true;
|
|
406
418
|
}
|
|
407
419
|
return false;
|
|
408
420
|
});
|
|
409
421
|
}
|
|
410
|
-
if (valid && duplicated
|
|
422
|
+
if (valid && duplicated?.length === 0) {
|
|
411
423
|
try {
|
|
412
|
-
data
|
|
424
|
+
data?.articleData?.forEach((e) => {
|
|
413
425
|
e.uuid = uuidv4();
|
|
414
426
|
});
|
|
415
427
|
setDataImages(data);
|
|
416
|
-
if (data
|
|
428
|
+
if (data?.articleData?.length > 0) {
|
|
417
429
|
setImagesUploaded(false);
|
|
418
430
|
const promiseArray = [];
|
|
419
|
-
data
|
|
431
|
+
data?.articleData?.forEach((e) => {
|
|
420
432
|
const file = Buffer.from(
|
|
421
433
|
e.src.replace(/^data:image\/\w+;base64,/, ""),
|
|
422
434
|
"base64"
|
|
@@ -425,7 +437,7 @@ export const RetailerProductEdition = ({
|
|
|
425
437
|
ACL: "public-read",
|
|
426
438
|
Body: file,
|
|
427
439
|
Bucket: S3_BUCKET,
|
|
428
|
-
Key: `id-${data.articleId}/${version}/${e
|
|
440
|
+
Key: `id-${data.articleId}/${version}/${e?.image_id}-${e?.uuid}.${e?.ext}`,
|
|
429
441
|
};
|
|
430
442
|
promiseArray.push(myBucket.putObject(params).promise());
|
|
431
443
|
});
|
|
@@ -440,25 +452,16 @@ export const RetailerProductEdition = ({
|
|
|
440
452
|
}
|
|
441
453
|
} else {
|
|
442
454
|
// setMainLoading(false);
|
|
443
|
-
|
|
444
|
-
"Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma."
|
|
445
|
-
"Recuerda hay campos obligatorios y no podras avanzar si no estan completos."
|
|
455
|
+
setMessage(
|
|
456
|
+
"Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma.<br>Recuerda hay campos obligatorios y no podras avanzar si no estan completos."
|
|
446
457
|
);
|
|
447
|
-
// setAlertList((prev) => [
|
|
448
|
-
// ...prev,
|
|
449
|
-
// {
|
|
450
|
-
// titleMsg: "Completa los campos que solicita cada una de la imágenes",
|
|
451
|
-
// alertMsg:
|
|
452
|
-
// "Recuerda hay campos obligatorios y no podras avanzar si no estan completos.",
|
|
453
|
-
// },
|
|
454
|
-
// ]);
|
|
455
458
|
}
|
|
456
459
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
457
460
|
}, [images, imagesUploaded]);
|
|
458
461
|
|
|
459
462
|
useEffect(async () => {
|
|
460
463
|
if (imagesUploaded) {
|
|
461
|
-
dataImages.articleData = dataImages
|
|
464
|
+
dataImages.articleData = dataImages?.articleData.map((e) => {
|
|
462
465
|
delete e.src;
|
|
463
466
|
e.imageID = e.image_id;
|
|
464
467
|
e.packingType = e.packing_type;
|
|
@@ -475,7 +478,7 @@ export const RetailerProductEdition = ({
|
|
|
475
478
|
},
|
|
476
479
|
}
|
|
477
480
|
);
|
|
478
|
-
|
|
481
|
+
setMessage("Imágenes guardadas con éxito");
|
|
479
482
|
} catch (error) {
|
|
480
483
|
console.log(error);
|
|
481
484
|
}
|
|
@@ -500,11 +503,11 @@ export const RetailerProductEdition = ({
|
|
|
500
503
|
concept = action ? action : concept;
|
|
501
504
|
return (
|
|
502
505
|
(productSelected[`${concept}_status`] === "QF" &&
|
|
503
|
-
(user
|
|
506
|
+
(user?.id_role === 1 || user?.id_role === 4 || user?.id_role === 5)) ||
|
|
504
507
|
(productSelected[`${concept}_status`] === "AF" &&
|
|
505
|
-
(user
|
|
508
|
+
(user?.id_role === 1 || user?.id_role === 6)) ||
|
|
506
509
|
(productSelected[`${concept}_status`] === "RP" &&
|
|
507
|
-
(user
|
|
510
|
+
(user?.id_role === 1 || user?.id_role === 6))
|
|
508
511
|
);
|
|
509
512
|
};
|
|
510
513
|
|
|
@@ -526,7 +529,7 @@ export const RetailerProductEdition = ({
|
|
|
526
529
|
|
|
527
530
|
const updateCompaniesList = (status, result, retailerId, concept) => {
|
|
528
531
|
let serv = servicesData.slice();
|
|
529
|
-
let item = serv
|
|
532
|
+
let item = serv?.find(
|
|
530
533
|
(item) => item.id_retailer === retailerId && item.service === concept
|
|
531
534
|
);
|
|
532
535
|
let index = serv.indexOf(item);
|
|
@@ -754,7 +757,6 @@ export const RetailerProductEdition = ({
|
|
|
754
757
|
concept: concept,
|
|
755
758
|
version: version,
|
|
756
759
|
};
|
|
757
|
-
e.preventDefault();
|
|
758
760
|
await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
|
|
759
761
|
headers: {
|
|
760
762
|
Authorization: token,
|
|
@@ -818,6 +820,131 @@ export const RetailerProductEdition = ({
|
|
|
818
820
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
819
821
|
};
|
|
820
822
|
|
|
823
|
+
const evaluationComplete = (tab) => {
|
|
824
|
+
let concept = "";
|
|
825
|
+
switch (tab) {
|
|
826
|
+
case "Ficha técnica":
|
|
827
|
+
concept = "datasheet";
|
|
828
|
+
break;
|
|
829
|
+
case "Imágenes":
|
|
830
|
+
concept = "images";
|
|
831
|
+
break;
|
|
832
|
+
|
|
833
|
+
default:
|
|
834
|
+
concept = "description";
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
let serv = servicesData.filter((item) => item.service === concept);
|
|
838
|
+
let approved = "";
|
|
839
|
+
let rejected = "";
|
|
840
|
+
if (
|
|
841
|
+
product.status === "IN_PROGRESS" ||
|
|
842
|
+
product.status === "QF" ||
|
|
843
|
+
product.status === "RF"
|
|
844
|
+
) {
|
|
845
|
+
approved = "AF";
|
|
846
|
+
rejected = "RF";
|
|
847
|
+
if (product.status === "QF") {
|
|
848
|
+
return (
|
|
849
|
+
serv.filter(
|
|
850
|
+
(item) =>
|
|
851
|
+
item.status === approved ||
|
|
852
|
+
item.status === rejected ||
|
|
853
|
+
item.status === "AA" ||
|
|
854
|
+
item.status === "AP"
|
|
855
|
+
).length === serv.length
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
} else if (
|
|
859
|
+
product.status === "AF" ||
|
|
860
|
+
product.status === "RA" ||
|
|
861
|
+
product.status === "RP"
|
|
862
|
+
) {
|
|
863
|
+
approved = "AA";
|
|
864
|
+
rejected = "RA";
|
|
865
|
+
|
|
866
|
+
if (product.status === "RP" || product.status === "AF") {
|
|
867
|
+
return (
|
|
868
|
+
serv.filter(
|
|
869
|
+
(item) =>
|
|
870
|
+
item.status === approved ||
|
|
871
|
+
item.status === rejected ||
|
|
872
|
+
item.status === "AP"
|
|
873
|
+
).length === serv.length
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
} else if (product.status === "RC") {
|
|
877
|
+
approved = "AP";
|
|
878
|
+
rejected = "RA";
|
|
879
|
+
return (
|
|
880
|
+
serv.filter(
|
|
881
|
+
(item) => item.status === approved || item.status === rejected
|
|
882
|
+
).length === serv.length
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
return (
|
|
886
|
+
serv.filter(
|
|
887
|
+
(item) => item.status === approved || item.status === rejected
|
|
888
|
+
).length === serv.length
|
|
889
|
+
);
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
const downloadImages = () => {
|
|
893
|
+
selectedImages.forEach((e) => {
|
|
894
|
+
if (e.id) {
|
|
895
|
+
saveAs(
|
|
896
|
+
`https://${process.env.REACT_APP_IMAGES_BUCKET}.s3.amazonaws.com/${e.srcDB}`,
|
|
897
|
+
`${product.article.upc}_${e.name}.${e.ext}`
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
const deleteImages = () => {
|
|
904
|
+
const data = {
|
|
905
|
+
articleId: product.article.id_article,
|
|
906
|
+
deleteImages: selectedImages,
|
|
907
|
+
};
|
|
908
|
+
try {
|
|
909
|
+
axios.put(
|
|
910
|
+
`${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
|
|
911
|
+
data,
|
|
912
|
+
{
|
|
913
|
+
headers: { Authorization: token },
|
|
914
|
+
}
|
|
915
|
+
);
|
|
916
|
+
} catch (err) {
|
|
917
|
+
console.log(err);
|
|
918
|
+
}
|
|
919
|
+
setMessage("");
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
const askToDeleteImages = () => {
|
|
923
|
+
if (selectedImages.length > 0) {
|
|
924
|
+
setMessage("¿Está seguro de eliminar las imágenes seleccionadas?");
|
|
925
|
+
setComponentsArray([
|
|
926
|
+
<ScreenHeader
|
|
927
|
+
key={"1"}
|
|
928
|
+
text={""}
|
|
929
|
+
Paragraph={"¿Está seguro de eliminar las imágenes seleccionadas?"}
|
|
930
|
+
headerType="header-and-paragraph"
|
|
931
|
+
/>,
|
|
932
|
+
<Button
|
|
933
|
+
key={"2"}
|
|
934
|
+
buttonType="general-white-button"
|
|
935
|
+
label={"Cancelar"}
|
|
936
|
+
onClick={() => setMessage("")}
|
|
937
|
+
/>,
|
|
938
|
+
<Button
|
|
939
|
+
key={"3"}
|
|
940
|
+
buttonType="general-button-default"
|
|
941
|
+
label={"Aceptar"}
|
|
942
|
+
onClick={() => deleteImages()}
|
|
943
|
+
/>,
|
|
944
|
+
]);
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
|
|
821
948
|
return (
|
|
822
949
|
<Container headerTop={headerTop}>
|
|
823
950
|
<HeaderTop setHeaderTop={setHeaderTop} />
|
|
@@ -838,6 +965,7 @@ export const RetailerProductEdition = ({
|
|
|
838
965
|
imagesStatus={productSelected?.images_status}
|
|
839
966
|
setAssignation={setAssignation}
|
|
840
967
|
isRetailer={isRetailer}
|
|
968
|
+
onClickSave={() => updateImages()}
|
|
841
969
|
/>
|
|
842
970
|
</div>
|
|
843
971
|
<div className="product-information">
|
|
@@ -866,16 +994,30 @@ export const RetailerProductEdition = ({
|
|
|
866
994
|
)[0]?.status,
|
|
867
995
|
Imágenes: product?.images_status,
|
|
868
996
|
}}
|
|
869
|
-
profileImage={productData.asigned}
|
|
870
997
|
activeTab={activeTab}
|
|
871
998
|
setActiveTab={setActiveTab}
|
|
872
999
|
setImageLayout={setImageLayout}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
updateImages={updateImages}
|
|
1000
|
+
downloadImages={downloadImages}
|
|
1001
|
+
askToDeleteImages={askToDeleteImages}
|
|
876
1002
|
assig={assig[activeTab]}
|
|
877
1003
|
setAssignation={setAssignation}
|
|
878
1004
|
isRetailer={isRetailer}
|
|
1005
|
+
onClickSave={() => {
|
|
1006
|
+
switch (activeTab) {
|
|
1007
|
+
case "Descripción":
|
|
1008
|
+
saveDescriptions();
|
|
1009
|
+
break;
|
|
1010
|
+
case "Ficha técnica":
|
|
1011
|
+
saveDatasheets();
|
|
1012
|
+
break;
|
|
1013
|
+
case "Imágenes":
|
|
1014
|
+
updateImages();
|
|
1015
|
+
break;
|
|
1016
|
+
|
|
1017
|
+
default:
|
|
1018
|
+
break;
|
|
1019
|
+
}
|
|
1020
|
+
}}
|
|
879
1021
|
/>
|
|
880
1022
|
<div
|
|
881
1023
|
className={
|
|
@@ -883,7 +1025,13 @@ export const RetailerProductEdition = ({
|
|
|
883
1025
|
(imageLayout && activeTab === "Imágenes" ? "image-services" : "")
|
|
884
1026
|
}
|
|
885
1027
|
>
|
|
886
|
-
{!imageLayout &&
|
|
1028
|
+
{!imageLayout && activeTab === "Imágenes" && (
|
|
1029
|
+
<GalleryHeader
|
|
1030
|
+
setSelectedImages={setSelectedImages}
|
|
1031
|
+
checkAll={checkAll}
|
|
1032
|
+
setCheckAll={setCheckAll}
|
|
1033
|
+
/>
|
|
1034
|
+
)}
|
|
887
1035
|
{activeTab === "Ficha técnica" &&
|
|
888
1036
|
(product?.services?.datasheets === 1 ? (
|
|
889
1037
|
datasheets[0]?.data?.map((dataGroup, index) => (
|
|
@@ -908,7 +1056,7 @@ export const RetailerProductEdition = ({
|
|
|
908
1056
|
inputGroup={descriptions[0]}
|
|
909
1057
|
updatedDescriptions={updatedDescriptions}
|
|
910
1058
|
setUpdatedDescriptions={setUpdatedDescriptions}
|
|
911
|
-
articleId={
|
|
1059
|
+
articleId={product?.article?.id_article}
|
|
912
1060
|
version={version}
|
|
913
1061
|
dinamicHeight={true}
|
|
914
1062
|
/>
|
|
@@ -948,24 +1096,13 @@ export const RetailerProductEdition = ({
|
|
|
948
1096
|
onClick={(e) =>
|
|
949
1097
|
createComment(
|
|
950
1098
|
e,
|
|
951
|
-
document.
|
|
952
|
-
"description-commentary-box-0"
|
|
953
|
-
).
|
|
1099
|
+
document.querySelector(
|
|
1100
|
+
"#description-commentary-box-0 .ql-container .ql-editor > p"
|
|
1101
|
+
).innerHTML,
|
|
954
1102
|
activeTab
|
|
955
1103
|
)
|
|
956
1104
|
}
|
|
957
1105
|
/>
|
|
958
|
-
<Button
|
|
959
|
-
buttonType={
|
|
960
|
-
requiredNull !== 0 ||
|
|
961
|
-
!specialistValid(activeTab) ||
|
|
962
|
-
!versionMatch()
|
|
963
|
-
? "general-button-disabled"
|
|
964
|
-
: "general-green-button"
|
|
965
|
-
}
|
|
966
|
-
label={"Enviar evaluación"}
|
|
967
|
-
onClick={() => sendToFacilitator()}
|
|
968
|
-
/>
|
|
969
1106
|
</div>
|
|
970
1107
|
</div>
|
|
971
1108
|
) : (
|
|
@@ -983,6 +1120,17 @@ export const RetailerProductEdition = ({
|
|
|
983
1120
|
/>
|
|
984
1121
|
</div>
|
|
985
1122
|
)}
|
|
1123
|
+
<Button
|
|
1124
|
+
buttonType={
|
|
1125
|
+
!requiredNull[activeTab] === 0 ||
|
|
1126
|
+
!approveRejectButtons() ||
|
|
1127
|
+
!evaluationComplete(activeTab)
|
|
1128
|
+
? "general-button-disabled"
|
|
1129
|
+
: "general-green-button"
|
|
1130
|
+
}
|
|
1131
|
+
label={"Enviar evaluación"}
|
|
1132
|
+
onClick={() => sendToFacilitator()}
|
|
1133
|
+
/>
|
|
986
1134
|
</div>
|
|
987
1135
|
)}
|
|
988
1136
|
</div>
|
|
@@ -995,6 +1143,18 @@ export const RetailerProductEdition = ({
|
|
|
995
1143
|
approveRejectButtons={approveRejectButtons}
|
|
996
1144
|
/>
|
|
997
1145
|
)}
|
|
1146
|
+
{message.length > 0 && (
|
|
1147
|
+
<GenericModal
|
|
1148
|
+
componentsArray={
|
|
1149
|
+
componentsArray.length > 0 ? (
|
|
1150
|
+
componentsArray
|
|
1151
|
+
) : (
|
|
1152
|
+
<ScreenHeader text={message} />
|
|
1153
|
+
)
|
|
1154
|
+
}
|
|
1155
|
+
onClick={() => setMessage("")}
|
|
1156
|
+
/>
|
|
1157
|
+
)}
|
|
998
1158
|
</Container>
|
|
999
1159
|
);
|
|
1000
1160
|
};
|
|
@@ -4,6 +4,8 @@ export const Container = styled.div`
|
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
height: 100%;
|
|
7
|
+
flex: 1;
|
|
8
|
+
overflow: auto;
|
|
7
9
|
|
|
8
10
|
.data-container {
|
|
9
11
|
display: flex;
|
|
@@ -49,6 +51,12 @@ export const Container = styled.div`
|
|
|
49
51
|
align-items: flex-end;
|
|
50
52
|
|
|
51
53
|
.input-container {
|
|
54
|
+
width: 500px;
|
|
55
|
+
|
|
56
|
+
.quill {
|
|
57
|
+
height: 100px;
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
& + * {
|
|
53
61
|
margin-left: 5px;
|
|
54
62
|
}
|
|
@@ -56,7 +64,7 @@ export const Container = styled.div`
|
|
|
56
64
|
|
|
57
65
|
.buttons-box {
|
|
58
66
|
display: flex;
|
|
59
|
-
|
|
67
|
+
width: 210px;
|
|
60
68
|
flex-wrap: wrap;
|
|
61
69
|
|
|
62
70
|
.general-transparent-button {
|
|
@@ -66,8 +74,10 @@ export const Container = styled.div`
|
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
.general-transparent-button,
|
|
69
|
-
.general-green-button
|
|
70
|
-
|
|
77
|
+
.general-green-button,
|
|
78
|
+
.general-button-disabled {
|
|
79
|
+
width: fit-content;
|
|
80
|
+
min-width: 201px;
|
|
71
81
|
height: 40px;
|
|
72
82
|
}
|
|
73
83
|
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Percent } from "./index";
|
|
2
|
-
|
|
3
|
-
const status = [
|
|
4
|
-
"-",
|
|
5
|
-
"Pr",
|
|
6
|
-
"Rc",
|
|
7
|
-
"As",
|
|
8
|
-
"P",
|
|
9
|
-
"QF",
|
|
10
|
-
"AF",
|
|
11
|
-
"AA",
|
|
12
|
-
"AP",
|
|
13
|
-
"AC",
|
|
14
|
-
"RA",
|
|
15
|
-
"RF",
|
|
16
|
-
"RP",
|
|
17
|
-
"RC",
|
|
18
|
-
"Ex",
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
title: "Components/atoms/Percent",
|
|
23
|
-
component: Percent,
|
|
24
|
-
argTypes: {
|
|
25
|
-
statusType: {
|
|
26
|
-
options: status,
|
|
27
|
-
control: { type: "select" },
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const Template = (args) => <Percent {...args}/>;
|
|
33
|
-
|
|
34
|
-
export const PercentDefault = Template.bind ({});
|
|
35
|
-
|
|
36
|
-
PercentDefault.args = {
|
|
37
|
-
statusType: "-",
|
|
38
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Container } from "./styles";
|
|
2
|
-
import polygon from "../../../assets/images/arrow/polygon.svg";
|
|
3
|
-
|
|
4
|
-
export const Percent = ({ statusType }) => {
|
|
5
|
-
return (
|
|
6
|
-
<Container className={`status-${statusType}`}>
|
|
7
|
-
<p className="text">Productos en proceso</p>
|
|
8
|
-
<div className="percent-text">
|
|
9
|
-
<p className="number">20</p>
|
|
10
|
-
<img src={polygon} alt=""/>
|
|
11
|
-
<span className="span">1%</span>
|
|
12
|
-
</div>
|
|
13
|
-
</Container>
|
|
14
|
-
);
|
|
15
|
-
};
|