contentoh-components-library 15.0.0 → 18.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/assets/images/generalButton/downloadIcon.svg +3 -0
- 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 -8
- 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 +330 -169
- 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 +3 -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 -6
- package/src/components/organisms/ImageDataTable/index.js +2 -0
- package/src/components/organisms/ProductImageModal/index.js +8 -2
- package/src/components/organisms/ProductImageModal/styles.js +3 -0
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +4 -14
- package/src/components/pages/RetailerProductEdition/index.js +250 -90
- package/src/components/pages/RetailerProductEdition/styles.js +11 -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;
|
|
@@ -59,20 +62,18 @@ const myBucket = new AWS.S3({
|
|
|
59
62
|
|
|
60
63
|
export const RetailerProductEdition = ({
|
|
61
64
|
tabsSections,
|
|
62
|
-
articleId,
|
|
63
65
|
productSelected = {},
|
|
64
66
|
user = {},
|
|
65
67
|
token,
|
|
66
68
|
}) => {
|
|
67
69
|
const [activeTab, setActiveTab] = useState("Descripción");
|
|
68
70
|
const [activeImage, setActiveImage] = useState();
|
|
69
|
-
const [imageLayout, setImageLayout] = useState(
|
|
71
|
+
const [imageLayout, setImageLayout] = useState(false);
|
|
70
72
|
const [headerTop, setHeaderTop] = useState(0);
|
|
71
73
|
const [descriptions, setDescriptions] = useState([]);
|
|
72
74
|
const [datasheets, setDatasheets] = useState([]);
|
|
73
75
|
const [images, setImages] = useReducer(reducerImages, {});
|
|
74
76
|
const [showModal, setShowModal] = useState(false);
|
|
75
|
-
const [retailerSelected, setRetailerSelected] = useState(54); // revisar después como trabajar esto de mejor forma
|
|
76
77
|
const { getRootProps, getInputProps } = useDropzone({
|
|
77
78
|
accept: "image/*",
|
|
78
79
|
noKeyboard: true,
|
|
@@ -114,7 +115,7 @@ export const RetailerProductEdition = ({
|
|
|
114
115
|
const [imagesUploaded, setImagesUploaded] = useState(false);
|
|
115
116
|
const [dataImages, setDataImages] = useState();
|
|
116
117
|
const [percentages, setPercentages] = useState(
|
|
117
|
-
new Array(productSelected
|
|
118
|
+
new Array(productSelected?.retailers?.length).fill({ percentage: 0 })
|
|
118
119
|
);
|
|
119
120
|
const [activePercentage, setActivePercentage] = useState(0);
|
|
120
121
|
const [activeRetailer, setActiveRetailer] = useState({});
|
|
@@ -130,13 +131,19 @@ export const RetailerProductEdition = ({
|
|
|
130
131
|
const [crossComment, setCrossComment] = useState(false);
|
|
131
132
|
const [userGroups, setUserGroups] = useState([]);
|
|
132
133
|
const [assig, setAssig] = useState({});
|
|
134
|
+
const [selectedImages, setSelectedImages] = useState([]);
|
|
135
|
+
const [componentsArray, setComponentsArray] = useState([]);
|
|
136
|
+
const [checkAll, setCheckAll] = useState(false);
|
|
133
137
|
const isRetailer = user?.is_retailer;
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
checkAll && setSelectedImages(images.values);
|
|
140
|
+
}, [checkAll]);
|
|
134
141
|
|
|
135
142
|
const loadData = async () => {
|
|
136
143
|
const services = await getRetailerServices(
|
|
137
|
-
productSelected
|
|
138
|
-
parseInt(productSelected
|
|
139
|
-
productSelected
|
|
144
|
+
productSelected?.article?.id_article,
|
|
145
|
+
parseInt(productSelected?.article?.id_category),
|
|
146
|
+
productSelected?.version
|
|
140
147
|
);
|
|
141
148
|
|
|
142
149
|
//Converts the data inside the datasheets object to array
|
|
@@ -165,10 +172,9 @@ export const RetailerProductEdition = ({
|
|
|
165
172
|
}
|
|
166
173
|
const selected = productSelected;
|
|
167
174
|
const servicesResponse = await axios.get(
|
|
168
|
-
`${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`
|
|
169
176
|
);
|
|
170
|
-
const parsedResponse = JSON.parse(servicesResponse
|
|
171
|
-
|
|
177
|
+
const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
|
|
172
178
|
setServicesData(parsedResponse);
|
|
173
179
|
};
|
|
174
180
|
|
|
@@ -200,10 +206,10 @@ export const RetailerProductEdition = ({
|
|
|
200
206
|
let comments = {};
|
|
201
207
|
commentsResponse.forEach(
|
|
202
208
|
(comment) =>
|
|
203
|
-
JSON.parse(comment
|
|
209
|
+
JSON.parse(comment?.data?.body).data[0] &&
|
|
204
210
|
(comments[
|
|
205
|
-
translateConcept(JSON.parse(comment
|
|
206
|
-
] = JSON.parse(comment
|
|
211
|
+
translateConcept(JSON.parse(comment?.data?.body)?.data[0]?.concept)
|
|
212
|
+
] = JSON.parse(comment?.data?.body).data[0])
|
|
207
213
|
);
|
|
208
214
|
setComment(comments[tab]);
|
|
209
215
|
setComments(comments);
|
|
@@ -277,42 +283,48 @@ export const RetailerProductEdition = ({
|
|
|
277
283
|
}, [userGroups]);
|
|
278
284
|
|
|
279
285
|
useEffect(() => {
|
|
280
|
-
productSelected
|
|
281
|
-
retailer["percentage"] = percentages
|
|
282
|
-
(percent) => retailer
|
|
286
|
+
productSelected?.retailers?.forEach((retailer) => {
|
|
287
|
+
retailer["percentage"] = percentages?.filter(
|
|
288
|
+
(percent) => retailer?.id === percent?.id_retailer
|
|
283
289
|
)[0]?.percentage;
|
|
284
290
|
});
|
|
285
291
|
setActivePercentage(productSelected?.retailers[0]?.percentage);
|
|
286
292
|
}, [percentages]);
|
|
287
293
|
|
|
288
294
|
useEffect(() => {
|
|
295
|
+
const required = {};
|
|
289
296
|
if (services.length > 0) {
|
|
290
|
-
services[0][activeRetailer
|
|
291
|
-
services[0][activeRetailer
|
|
297
|
+
services[0][activeRetailer.id].data = Object.values(
|
|
298
|
+
services[0][activeRetailer.id].data
|
|
292
299
|
);
|
|
293
|
-
setActivePercentage(Math.round(activeRetailer
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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
|
|
297
305
|
);
|
|
306
|
+
setRequiredNull(required);
|
|
307
|
+
setDatasheets([datagroups, inputs]);
|
|
308
|
+
setDescriptions(descriptions);
|
|
298
309
|
}
|
|
299
310
|
}, [activeRetailer]);
|
|
300
311
|
|
|
301
312
|
const thumbs = () => {
|
|
302
|
-
const imageInputs = images
|
|
303
|
-
value: e
|
|
304
|
-
name: e
|
|
313
|
+
const imageInputs = images?.inputs?.map((e) => ({
|
|
314
|
+
value: e?.id,
|
|
315
|
+
name: e?.name,
|
|
305
316
|
}));
|
|
306
|
-
const imageType = images
|
|
307
|
-
value: e
|
|
308
|
-
name: e
|
|
317
|
+
const imageType = images?.imageType?.map((e) => ({
|
|
318
|
+
value: e?.id,
|
|
319
|
+
name: e?.name,
|
|
309
320
|
}));
|
|
310
|
-
const imagePackagingType = images
|
|
311
|
-
value: e
|
|
312
|
-
name: e
|
|
321
|
+
const imagePackagingType = images?.imagePackagingType?.map((e) => ({
|
|
322
|
+
value: e?.id,
|
|
323
|
+
name: e?.name,
|
|
313
324
|
}));
|
|
314
325
|
return images?.values?.map((image, index) => (
|
|
315
326
|
<GalleryElement
|
|
327
|
+
setCheckAll={setCheckAll}
|
|
316
328
|
key={index}
|
|
317
329
|
image={image}
|
|
318
330
|
gridLayout={imageLayout}
|
|
@@ -322,6 +334,8 @@ export const RetailerProductEdition = ({
|
|
|
322
334
|
imagePackagingType={imagePackagingType}
|
|
323
335
|
imageInputs={imageInputs}
|
|
324
336
|
changeImage={setImages}
|
|
337
|
+
selectedImages={selectedImages}
|
|
338
|
+
setSelectedImages={setSelectedImages}
|
|
325
339
|
/>
|
|
326
340
|
));
|
|
327
341
|
};
|
|
@@ -361,7 +375,6 @@ export const RetailerProductEdition = ({
|
|
|
361
375
|
},
|
|
362
376
|
}
|
|
363
377
|
);
|
|
364
|
-
console.log("saved");
|
|
365
378
|
} catch (error) {
|
|
366
379
|
console.log(error);
|
|
367
380
|
}
|
|
@@ -369,53 +382,53 @@ export const RetailerProductEdition = ({
|
|
|
369
382
|
|
|
370
383
|
const updateImages = useCallback(async () => {
|
|
371
384
|
const imagesList = images?.values?.slice();
|
|
372
|
-
const imagesListTemp = imagesList
|
|
373
|
-
acc[image
|
|
385
|
+
const imagesListTemp = imagesList?.reduce((acc, image) => {
|
|
386
|
+
acc[image?.image_id] = ++acc[image?.image_id] || 0;
|
|
374
387
|
return acc;
|
|
375
388
|
}, {});
|
|
376
389
|
|
|
377
|
-
const duplicated = imagesList
|
|
378
|
-
return imagesListTemp[image
|
|
390
|
+
const duplicated = imagesList?.filter((image) => {
|
|
391
|
+
return imagesListTemp[image?.image_id];
|
|
379
392
|
});
|
|
380
393
|
|
|
381
394
|
const attrForImgs = Object.values(images?.attrForImgs);
|
|
382
395
|
attrForImgs.pop();
|
|
383
396
|
const data = {
|
|
384
|
-
articleId,
|
|
385
|
-
attrReqImgs: attrForImgs
|
|
386
|
-
attrId: e[0]
|
|
387
|
-
value: e[0]
|
|
397
|
+
articleId: product?.article?.id_article,
|
|
398
|
+
attrReqImgs: attrForImgs?.map((e) => ({
|
|
399
|
+
attrId: e[0]?.id,
|
|
400
|
+
value: e[0]?.value,
|
|
388
401
|
})),
|
|
389
|
-
articleData: imagesList
|
|
390
|
-
updateImages: imagesList
|
|
402
|
+
articleData: imagesList?.filter((e) => !e.id),
|
|
403
|
+
updateImages: imagesList?.filter((e) => e.id),
|
|
391
404
|
};
|
|
392
405
|
let valid =
|
|
393
|
-
data
|
|
406
|
+
data?.articleData?.length === 0
|
|
394
407
|
? true
|
|
395
|
-
: data
|
|
396
|
-
if (e
|
|
408
|
+
: data?.articleData?.every((e, i) => {
|
|
409
|
+
if (e?.image_id && e?.packing_type && e?.image_type) {
|
|
397
410
|
return true;
|
|
398
411
|
}
|
|
399
412
|
return false;
|
|
400
413
|
});
|
|
401
|
-
if (valid && data
|
|
402
|
-
valid = data
|
|
403
|
-
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) {
|
|
404
417
|
return true;
|
|
405
418
|
}
|
|
406
419
|
return false;
|
|
407
420
|
});
|
|
408
421
|
}
|
|
409
|
-
if (valid && duplicated
|
|
422
|
+
if (valid && duplicated?.length === 0) {
|
|
410
423
|
try {
|
|
411
|
-
data
|
|
424
|
+
data?.articleData?.forEach((e) => {
|
|
412
425
|
e.uuid = uuidv4();
|
|
413
426
|
});
|
|
414
427
|
setDataImages(data);
|
|
415
|
-
if (data
|
|
428
|
+
if (data?.articleData?.length > 0) {
|
|
416
429
|
setImagesUploaded(false);
|
|
417
430
|
const promiseArray = [];
|
|
418
|
-
data
|
|
431
|
+
data?.articleData?.forEach((e) => {
|
|
419
432
|
const file = Buffer.from(
|
|
420
433
|
e.src.replace(/^data:image\/\w+;base64,/, ""),
|
|
421
434
|
"base64"
|
|
@@ -424,7 +437,7 @@ export const RetailerProductEdition = ({
|
|
|
424
437
|
ACL: "public-read",
|
|
425
438
|
Body: file,
|
|
426
439
|
Bucket: S3_BUCKET,
|
|
427
|
-
Key: `id-${data.articleId}/${version}/${e
|
|
440
|
+
Key: `id-${data.articleId}/${version}/${e?.image_id}-${e?.uuid}.${e?.ext}`,
|
|
428
441
|
};
|
|
429
442
|
promiseArray.push(myBucket.putObject(params).promise());
|
|
430
443
|
});
|
|
@@ -439,25 +452,16 @@ export const RetailerProductEdition = ({
|
|
|
439
452
|
}
|
|
440
453
|
} else {
|
|
441
454
|
// setMainLoading(false);
|
|
442
|
-
|
|
443
|
-
"Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma."
|
|
444
|
-
"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.\nRecuerda hay campos obligatorios y no podras avanzar si no estan completos."
|
|
445
457
|
);
|
|
446
|
-
// setAlertList((prev) => [
|
|
447
|
-
// ...prev,
|
|
448
|
-
// {
|
|
449
|
-
// titleMsg: "Completa los campos que solicita cada una de la imágenes",
|
|
450
|
-
// alertMsg:
|
|
451
|
-
// "Recuerda hay campos obligatorios y no podras avanzar si no estan completos.",
|
|
452
|
-
// },
|
|
453
|
-
// ]);
|
|
454
458
|
}
|
|
455
459
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
456
460
|
}, [images, imagesUploaded]);
|
|
457
461
|
|
|
458
462
|
useEffect(async () => {
|
|
459
463
|
if (imagesUploaded) {
|
|
460
|
-
dataImages.articleData = dataImages
|
|
464
|
+
dataImages.articleData = dataImages?.articleData.map((e) => {
|
|
461
465
|
delete e.src;
|
|
462
466
|
e.imageID = e.image_id;
|
|
463
467
|
e.packingType = e.packing_type;
|
|
@@ -474,7 +478,7 @@ export const RetailerProductEdition = ({
|
|
|
474
478
|
},
|
|
475
479
|
}
|
|
476
480
|
);
|
|
477
|
-
|
|
481
|
+
setMessage("Imágenes guardadas con éxito");
|
|
478
482
|
} catch (error) {
|
|
479
483
|
console.log(error);
|
|
480
484
|
}
|
|
@@ -499,11 +503,11 @@ export const RetailerProductEdition = ({
|
|
|
499
503
|
concept = action ? action : concept;
|
|
500
504
|
return (
|
|
501
505
|
(productSelected[`${concept}_status`] === "QF" &&
|
|
502
|
-
(user
|
|
506
|
+
(user?.id_role === 1 || user?.id_role === 4 || user?.id_role === 5)) ||
|
|
503
507
|
(productSelected[`${concept}_status`] === "AF" &&
|
|
504
|
-
(user
|
|
508
|
+
(user?.id_role === 1 || user?.id_role === 6)) ||
|
|
505
509
|
(productSelected[`${concept}_status`] === "RP" &&
|
|
506
|
-
(user
|
|
510
|
+
(user?.id_role === 1 || user?.id_role === 6))
|
|
507
511
|
);
|
|
508
512
|
};
|
|
509
513
|
|
|
@@ -525,7 +529,7 @@ export const RetailerProductEdition = ({
|
|
|
525
529
|
|
|
526
530
|
const updateCompaniesList = (status, result, retailerId, concept) => {
|
|
527
531
|
let serv = servicesData.slice();
|
|
528
|
-
let item = serv
|
|
532
|
+
let item = serv?.find(
|
|
529
533
|
(item) => item.id_retailer === retailerId && item.service === concept
|
|
530
534
|
);
|
|
531
535
|
let index = serv.indexOf(item);
|
|
@@ -753,7 +757,6 @@ export const RetailerProductEdition = ({
|
|
|
753
757
|
concept: concept,
|
|
754
758
|
version: version,
|
|
755
759
|
};
|
|
756
|
-
e.preventDefault();
|
|
757
760
|
await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
|
|
758
761
|
headers: {
|
|
759
762
|
Authorization: token,
|
|
@@ -817,6 +820,131 @@ export const RetailerProductEdition = ({
|
|
|
817
820
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
818
821
|
};
|
|
819
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
|
+
|
|
820
948
|
return (
|
|
821
949
|
<Container headerTop={headerTop}>
|
|
822
950
|
<HeaderTop setHeaderTop={setHeaderTop} />
|
|
@@ -837,6 +965,7 @@ export const RetailerProductEdition = ({
|
|
|
837
965
|
imagesStatus={productSelected?.images_status}
|
|
838
966
|
setAssignation={setAssignation}
|
|
839
967
|
isRetailer={isRetailer}
|
|
968
|
+
onClickSave={() => updateImages()}
|
|
840
969
|
/>
|
|
841
970
|
</div>
|
|
842
971
|
<div className="product-information">
|
|
@@ -868,12 +997,27 @@ export const RetailerProductEdition = ({
|
|
|
868
997
|
activeTab={activeTab}
|
|
869
998
|
setActiveTab={setActiveTab}
|
|
870
999
|
setImageLayout={setImageLayout}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
updateImages={updateImages}
|
|
1000
|
+
downloadImages={downloadImages}
|
|
1001
|
+
askToDeleteImages={askToDeleteImages}
|
|
874
1002
|
assig={assig[activeTab]}
|
|
875
1003
|
setAssignation={setAssignation}
|
|
876
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
|
+
}}
|
|
877
1021
|
/>
|
|
878
1022
|
<div
|
|
879
1023
|
className={
|
|
@@ -881,7 +1025,13 @@ export const RetailerProductEdition = ({
|
|
|
881
1025
|
(imageLayout && activeTab === "Imágenes" ? "image-services" : "")
|
|
882
1026
|
}
|
|
883
1027
|
>
|
|
884
|
-
{!imageLayout &&
|
|
1028
|
+
{!imageLayout && activeTab === "Imágenes" && (
|
|
1029
|
+
<GalleryHeader
|
|
1030
|
+
setSelectedImages={setSelectedImages}
|
|
1031
|
+
checkAll={checkAll}
|
|
1032
|
+
setCheckAll={setCheckAll}
|
|
1033
|
+
/>
|
|
1034
|
+
)}
|
|
885
1035
|
{activeTab === "Ficha técnica" &&
|
|
886
1036
|
(product?.services?.datasheets === 1 ? (
|
|
887
1037
|
datasheets[0]?.data?.map((dataGroup, index) => (
|
|
@@ -906,7 +1056,7 @@ export const RetailerProductEdition = ({
|
|
|
906
1056
|
inputGroup={descriptions[0]}
|
|
907
1057
|
updatedDescriptions={updatedDescriptions}
|
|
908
1058
|
setUpdatedDescriptions={setUpdatedDescriptions}
|
|
909
|
-
articleId={
|
|
1059
|
+
articleId={product?.article?.id_article}
|
|
910
1060
|
version={version}
|
|
911
1061
|
dinamicHeight={true}
|
|
912
1062
|
/>
|
|
@@ -946,24 +1096,13 @@ export const RetailerProductEdition = ({
|
|
|
946
1096
|
onClick={(e) =>
|
|
947
1097
|
createComment(
|
|
948
1098
|
e,
|
|
949
|
-
document.
|
|
950
|
-
"description-commentary-box-0"
|
|
951
|
-
).
|
|
1099
|
+
document.querySelector(
|
|
1100
|
+
"#description-commentary-box-0 .ql-container .ql-editor > p"
|
|
1101
|
+
).innerHTML,
|
|
952
1102
|
activeTab
|
|
953
1103
|
)
|
|
954
1104
|
}
|
|
955
1105
|
/>
|
|
956
|
-
<Button
|
|
957
|
-
buttonType={
|
|
958
|
-
requiredNull !== 0 ||
|
|
959
|
-
!specialistValid(activeTab) ||
|
|
960
|
-
!versionMatch()
|
|
961
|
-
? "general-button-disabled"
|
|
962
|
-
: "general-green-button"
|
|
963
|
-
}
|
|
964
|
-
label={"Enviar evaluación"}
|
|
965
|
-
onClick={() => sendToFacilitator()}
|
|
966
|
-
/>
|
|
967
1106
|
</div>
|
|
968
1107
|
</div>
|
|
969
1108
|
) : (
|
|
@@ -981,6 +1120,17 @@ export const RetailerProductEdition = ({
|
|
|
981
1120
|
/>
|
|
982
1121
|
</div>
|
|
983
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
|
+
/>
|
|
984
1134
|
</div>
|
|
985
1135
|
)}
|
|
986
1136
|
</div>
|
|
@@ -993,6 +1143,16 @@ export const RetailerProductEdition = ({
|
|
|
993
1143
|
approveRejectButtons={approveRejectButtons}
|
|
994
1144
|
/>
|
|
995
1145
|
)}
|
|
1146
|
+
{message.length > 0 && (
|
|
1147
|
+
<GenericModal
|
|
1148
|
+
componentsArray={
|
|
1149
|
+
componentsArray.length > 0
|
|
1150
|
+
? componentsArray
|
|
1151
|
+
: [<ScreenHeader key="1" text={message} />]
|
|
1152
|
+
}
|
|
1153
|
+
onClick={() => setMessage("")}
|
|
1154
|
+
/>
|
|
1155
|
+
)}
|
|
996
1156
|
</Container>
|
|
997
1157
|
);
|
|
998
1158
|
};
|
|
@@ -51,6 +51,12 @@ export const Container = styled.div`
|
|
|
51
51
|
align-items: flex-end;
|
|
52
52
|
|
|
53
53
|
.input-container {
|
|
54
|
+
width: 500px;
|
|
55
|
+
|
|
56
|
+
.quill {
|
|
57
|
+
height: 100px;
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
& + * {
|
|
55
61
|
margin-left: 5px;
|
|
56
62
|
}
|
|
@@ -58,7 +64,7 @@ export const Container = styled.div`
|
|
|
58
64
|
|
|
59
65
|
.buttons-box {
|
|
60
66
|
display: flex;
|
|
61
|
-
|
|
67
|
+
width: 210px;
|
|
62
68
|
flex-wrap: wrap;
|
|
63
69
|
|
|
64
70
|
.general-transparent-button {
|
|
@@ -68,8 +74,10 @@ export const Container = styled.div`
|
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
.general-transparent-button,
|
|
71
|
-
.general-green-button
|
|
72
|
-
|
|
77
|
+
.general-green-button,
|
|
78
|
+
.general-button-disabled {
|
|
79
|
+
width: fit-content;
|
|
80
|
+
min-width: 201px;
|
|
73
81
|
height: 40px;
|
|
74
82
|
}
|
|
75
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
|
-
};
|