contentoh-components-library 21.1.63 → 21.1.64
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/.env.development +1 -0
- package/.env.production +1 -0
- package/dist/components/atoms/GeneralButton/index.js +3 -1
- package/dist/components/atoms/GeneralButton/styles.js +2 -2
- package/dist/components/atoms/InputFormatter/index.js +3 -3
- package/dist/components/atoms/ProductPercentCard/Percent.stories.js +1 -1
- package/dist/components/atoms/ProductPercentCard/styles.js +1 -1
- package/dist/components/atoms/Select/VersionSelect.js +37 -0
- package/dist/components/atoms/Select/index.js +4 -3
- package/dist/components/atoms/Select/style.js +10 -4
- package/dist/components/atoms/SliderToolTip/styles.js +2 -2
- package/dist/components/molecules/AssignedWork/AssignedWork.stories.js +1 -1
- package/dist/components/molecules/AssignedWork/styles.js +1 -1
- package/dist/components/molecules/StatusAsignationInfo/index.js +9 -1
- package/dist/components/molecules/VersionItem/VersionItem.stories.js +28 -0
- package/dist/components/molecules/VersionItem/index.js +64 -0
- package/dist/components/molecules/VersionItem/styles.js +20 -0
- package/dist/components/organisms/CreateVersion/CreateVersion.stories.js +31 -0
- package/dist/components/organisms/CreateVersion/RenderChilds.js +157 -0
- package/dist/components/organisms/CreateVersion/index.js +170 -0
- package/dist/components/organisms/CreateVersion/styles.js +28 -0
- package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
- package/dist/components/organisms/FullTabsMenu/index.js +6 -2
- package/dist/components/organisms/VersionSelector/VersionSelector.stories.js +32 -0
- package/dist/components/organisms/VersionSelector/index.js +129 -0
- package/dist/components/organisms/VersionSelector/styles.js +20 -0
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +102 -112
- package/dist/components/pages/ProviderProductEdition/index.js +449 -431
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +53 -72
- package/dist/components/pages/RetailerProductEdition/index.js +245 -231
- package/dist/global-files/customHooks.js +35 -0
- package/dist/global-files/data.js +8 -8
- package/package.json +2 -2
- package/src/assets/images/versionSelector/acceptIcon.svg +3 -0
- package/src/assets/images/versionSelector/addVersion.svg +5 -0
- package/src/assets/images/versionSelector/closeVersionSelector.svg +4 -0
- package/src/assets/images/versionSelector/createVersion.svg +3 -0
- package/src/assets/images/versionSelector/nullIcon.svg +3 -0
- package/src/assets/images/versionSelector/versionSelected.svg +3 -0
- package/src/components/atoms/GeneralButton/index.js +2 -0
- package/src/components/atoms/GeneralButton/styles.js +18 -0
- package/src/components/atoms/InputFormatter/index.js +6 -3
- package/src/components/atoms/ProductPercentCard/Percent.stories.js +12 -11
- package/src/components/atoms/ProductPercentCard/styles.js +9 -9
- package/src/components/atoms/ProgressBar/styles.js +69 -0
- package/src/components/atoms/Select/VersionSelect.js +25 -0
- package/src/components/atoms/Select/index.js +1 -1
- package/src/components/atoms/Select/style.js +19 -0
- package/src/components/atoms/SliderToolTip/styles.js +18 -14
- package/src/components/molecules/AssignedWork/AssignedWork.stories.js +8 -8
- package/src/components/molecules/AssignedWork/styles.js +10 -9
- package/src/components/molecules/StatusAsignationInfo/index.js +10 -1
- package/src/components/molecules/VersionItem/VersionItem.stories.js +14 -0
- package/src/components/molecules/VersionItem/index.js +47 -0
- package/src/components/molecules/VersionItem/styles.js +32 -0
- package/src/components/organisms/CreateVersion/CreateVersion.stories.js +14 -0
- package/src/components/organisms/CreateVersion/RenderChilds.js +137 -0
- package/src/components/organisms/CreateVersion/index.js +88 -0
- package/src/components/organisms/CreateVersion/styles.js +79 -0
- package/src/components/organisms/FullProductNameHeader/index.js +2 -2
- package/src/components/organisms/FullTabsMenu/index.js +5 -1
- package/src/components/organisms/VersionSelector/VersionSelector.stories.js +15 -0
- package/src/components/organisms/VersionSelector/index.js +75 -0
- package/src/components/organisms/VersionSelector/styles.js +28 -0
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +116 -134
- package/src/components/pages/ProviderProductEdition/index.js +267 -234
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +53 -74
- package/src/components/pages/RetailerProductEdition/index.js +201 -151
- package/src/global-files/customHooks.js +26 -0
- package/src/global-files/data.js +8 -8
- package/src/global-files/global-styles.css +1 -0
|
@@ -29,7 +29,11 @@ import { GenericModal } from "../../atoms/GenericModal";
|
|
|
29
29
|
import { ScreenHeader } from "../../atoms/ScreenHeader";
|
|
30
30
|
import { Loading } from "../../atoms/Loading";
|
|
31
31
|
import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
|
|
32
|
+
import { getNewStatus } from "../../../global-files/data";
|
|
32
33
|
import errorModal from "../../../assets/images/genericModal/errorModal.svg";
|
|
34
|
+
import { VersionSelector } from "../../organisms/VersionSelector";
|
|
35
|
+
import { closeModals } from "../../../global-files/customHooks";
|
|
36
|
+
import { CreateVersion } from "../../organisms/CreateVersion";
|
|
33
37
|
|
|
34
38
|
const reducerImages = (state, action) => {
|
|
35
39
|
let { values, attrForImgs } = state;
|
|
@@ -164,6 +168,9 @@ export const RetailerProductEdition = ({
|
|
|
164
168
|
const [servicesStatus, setServicesStatus] = useState([]);
|
|
165
169
|
const [saving, setSaving] = useState(loading);
|
|
166
170
|
const isAuditor = user.id_role === 6;
|
|
171
|
+
const [showVersionSelector, setShowVersionSelector] =
|
|
172
|
+
closeModals("version-selector");
|
|
173
|
+
const [showCreateVersion, setShowCreateVersion] = useState(false);
|
|
167
174
|
|
|
168
175
|
useEffect(() => {
|
|
169
176
|
checkAll && setSelectedImages(images.values);
|
|
@@ -175,14 +182,17 @@ export const RetailerProductEdition = ({
|
|
|
175
182
|
product?.article?.id_article,
|
|
176
183
|
product?.article?.category,
|
|
177
184
|
parseInt(product?.article?.id_category),
|
|
178
|
-
|
|
185
|
+
version
|
|
179
186
|
);
|
|
180
187
|
//Converts the data inside the datasheets object to array
|
|
181
188
|
setServices(services);
|
|
182
189
|
getServices();
|
|
183
190
|
|
|
184
|
-
//
|
|
185
|
-
setImages({
|
|
191
|
+
//setActiveRetailer(product?.retailers[0]);
|
|
192
|
+
setImages({
|
|
193
|
+
action: "init",
|
|
194
|
+
init: services[2],
|
|
195
|
+
});
|
|
186
196
|
if (services[2]?.values?.length > 0) setActiveImage(0);
|
|
187
197
|
|
|
188
198
|
getPercentage({ data: [product] }).then((res) => setPercentages(res));
|
|
@@ -200,22 +210,24 @@ export const RetailerProductEdition = ({
|
|
|
200
210
|
);
|
|
201
211
|
const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
|
|
202
212
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
);
|
|
213
|
+
let retailers = product.retailers || product.retailersAvailable;
|
|
214
|
+
let active = retailers?.filter((retailer) =>
|
|
215
|
+
parsedResponse?.map((srv) => srv.id_retailer).includes(retailer.id)
|
|
216
|
+
)[0];
|
|
208
217
|
!activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
|
|
209
218
|
setServicesData(parsedResponse);
|
|
210
219
|
};
|
|
211
220
|
|
|
212
221
|
const translateConcept = (concept) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
let translation = "";
|
|
223
|
+
if (concept === "datasheet") {
|
|
224
|
+
translation = "Ficha técnica";
|
|
225
|
+
} else if (concept === "description") {
|
|
226
|
+
translation = "Descripción";
|
|
227
|
+
} else if (concept === "images") {
|
|
228
|
+
translation = "Imágenes";
|
|
229
|
+
}
|
|
230
|
+
return translation;
|
|
219
231
|
};
|
|
220
232
|
|
|
221
233
|
const getComments = async (tab = "Descripción") => {
|
|
@@ -244,6 +256,7 @@ export const RetailerProductEdition = ({
|
|
|
244
256
|
};
|
|
245
257
|
|
|
246
258
|
useEffect(async () => {
|
|
259
|
+
setLoading(true);
|
|
247
260
|
loadData();
|
|
248
261
|
getComments();
|
|
249
262
|
setUserGroups(await fetchUsers(token));
|
|
@@ -251,21 +264,21 @@ export const RetailerProductEdition = ({
|
|
|
251
264
|
switch (user.id_role) {
|
|
252
265
|
case 7:
|
|
253
266
|
case 8:
|
|
254
|
-
arr = ["
|
|
267
|
+
arr = ["IN_PROGRESS", "RF", "RA"];
|
|
255
268
|
break;
|
|
256
269
|
case 4:
|
|
257
270
|
case 5:
|
|
258
|
-
arr = ["
|
|
271
|
+
arr = ["RF", "AF", "AA", "AP", "AC"];
|
|
259
272
|
break;
|
|
260
273
|
case 6:
|
|
261
|
-
arr = ["RP", "
|
|
274
|
+
arr = ["RP", "RC", "AF", "RA"];
|
|
262
275
|
break;
|
|
263
276
|
default:
|
|
264
277
|
arr = [];
|
|
265
278
|
break;
|
|
266
279
|
}
|
|
267
280
|
setStatusArray(arr);
|
|
268
|
-
}, [product]);
|
|
281
|
+
}, [product, version]);
|
|
269
282
|
|
|
270
283
|
const loadAssignations = (currentProduct) => {
|
|
271
284
|
setAssig({
|
|
@@ -384,14 +397,13 @@ export const RetailerProductEdition = ({
|
|
|
384
397
|
const saveDescriptions = async () => {
|
|
385
398
|
setLoading(true);
|
|
386
399
|
const productTemp = product;
|
|
387
|
-
const articleId = product?.article?.id_article;
|
|
388
400
|
const dataObject = {
|
|
389
|
-
articleId,
|
|
401
|
+
articleId: product?.article?.id_article,
|
|
390
402
|
articleData: updatedDescriptions,
|
|
391
403
|
};
|
|
392
404
|
if (product?.orderId) dataObject["orderId"] = product?.orderId;
|
|
393
405
|
try {
|
|
394
|
-
|
|
406
|
+
await axios.put(
|
|
395
407
|
`${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?description=true&version=${version}`,
|
|
396
408
|
dataObject,
|
|
397
409
|
{
|
|
@@ -400,16 +412,14 @@ export const RetailerProductEdition = ({
|
|
|
400
412
|
},
|
|
401
413
|
}
|
|
402
414
|
);
|
|
403
|
-
if (
|
|
404
|
-
|
|
405
|
-
if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
|
|
406
|
-
if (newStatus) productTemp.description_status = newStatus;
|
|
415
|
+
if (productTemp.status === "ASSIGNED") {
|
|
416
|
+
productTemp.status = "IN_PROGRESS";
|
|
407
417
|
setProduct(productTemp);
|
|
408
418
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
409
|
-
|
|
410
|
-
setMessage("Descripciones guardadas con éxito");
|
|
411
|
-
await loadData();
|
|
412
419
|
}
|
|
420
|
+
|
|
421
|
+
setMessage("Descripciones guardadas con éxito");
|
|
422
|
+
loadData();
|
|
413
423
|
} catch (error) {
|
|
414
424
|
console.log(error);
|
|
415
425
|
}
|
|
@@ -418,14 +428,13 @@ export const RetailerProductEdition = ({
|
|
|
418
428
|
const saveDatasheets = async () => {
|
|
419
429
|
setLoading(true);
|
|
420
430
|
const productTemp = product;
|
|
421
|
-
const articleId = product?.article?.id_article;
|
|
422
431
|
const dataObject = {
|
|
423
|
-
articleId,
|
|
432
|
+
articleId: product?.article?.id_article,
|
|
424
433
|
articleData: updatedDatasheets,
|
|
425
434
|
};
|
|
426
435
|
if (product?.orderId) dataObject["orderId"] = product?.orderId;
|
|
427
436
|
try {
|
|
428
|
-
|
|
437
|
+
await axios.put(
|
|
429
438
|
`${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?datasheet=true&version=${version}`,
|
|
430
439
|
dataObject,
|
|
431
440
|
{
|
|
@@ -434,16 +443,13 @@ export const RetailerProductEdition = ({
|
|
|
434
443
|
},
|
|
435
444
|
}
|
|
436
445
|
);
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if (newStatus) productTemp.datasheet_status = newStatus;
|
|
446
|
+
setMessage("Fichas técnicas guardadas");
|
|
447
|
+
if (productTemp.status === "ASSIGNED") {
|
|
448
|
+
productTemp.status = "IN_PROGRESS";
|
|
441
449
|
setProduct(productTemp);
|
|
442
450
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
443
|
-
|
|
444
|
-
setMessage("Fichas técnicas guardadas");
|
|
445
|
-
await loadData();
|
|
446
451
|
}
|
|
452
|
+
loadData();
|
|
447
453
|
} catch (error) {
|
|
448
454
|
console.log(error);
|
|
449
455
|
}
|
|
@@ -526,6 +532,15 @@ export const RetailerProductEdition = ({
|
|
|
526
532
|
} else {
|
|
527
533
|
setImagesUploaded(true);
|
|
528
534
|
}
|
|
535
|
+
let productTemp = product;
|
|
536
|
+
if (productTemp.status === "ASSIGNED") {
|
|
537
|
+
productTemp.status = "IN_PROGRESS";
|
|
538
|
+
setProduct(productTemp);
|
|
539
|
+
sessionStorage.setItem(
|
|
540
|
+
"productSelected",
|
|
541
|
+
JSON.stringify(productTemp)
|
|
542
|
+
);
|
|
543
|
+
}
|
|
529
544
|
} catch (err) {
|
|
530
545
|
console.log(err);
|
|
531
546
|
// setMainLoading(false);
|
|
@@ -550,7 +565,7 @@ export const RetailerProductEdition = ({
|
|
|
550
565
|
return e;
|
|
551
566
|
});
|
|
552
567
|
try {
|
|
553
|
-
|
|
568
|
+
await axios.put(
|
|
554
569
|
`${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
|
|
555
570
|
dataImages,
|
|
556
571
|
{
|
|
@@ -559,21 +574,9 @@ export const RetailerProductEdition = ({
|
|
|
559
574
|
},
|
|
560
575
|
}
|
|
561
576
|
);
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
if (newArticleStatus)
|
|
566
|
-
productTemp.status = newArticleStatus[articleId];
|
|
567
|
-
if (newStatus) productTemp.images_status = newStatus;
|
|
568
|
-
setProduct(productTemp);
|
|
569
|
-
sessionStorage.setItem(
|
|
570
|
-
"productSelected",
|
|
571
|
-
JSON.stringify(productTemp)
|
|
572
|
-
);
|
|
573
|
-
setMessage("Imágenes guardadas con éxito");
|
|
574
|
-
sessionStorage.removeItem("imagesList");
|
|
575
|
-
await loadData();
|
|
576
|
-
}
|
|
577
|
+
setMessage("Imágenes guardadas con éxito");
|
|
578
|
+
sessionStorage.removeItem("imagesList");
|
|
579
|
+
loadData();
|
|
577
580
|
} catch (error) {
|
|
578
581
|
console.log(error);
|
|
579
582
|
}
|
|
@@ -582,23 +585,24 @@ export const RetailerProductEdition = ({
|
|
|
582
585
|
|
|
583
586
|
const evaluationFinished = (userId, tab, statusArray) => {
|
|
584
587
|
const srv = servicesData.filter((serv) => serv.service === getConcept(tab));
|
|
585
|
-
const srvActive = srv
|
|
586
|
-
|
|
587
|
-
?.status?.replace(/.*\//, "");
|
|
588
|
-
const currStatus = product[`${getConcept(tab)}_status`]?.replace(
|
|
589
|
-
/.*\//,
|
|
590
|
-
""
|
|
588
|
+
const [srvActive] = srv.filter(
|
|
589
|
+
(serv) => serv.id_retailer === activeRetailer?.id
|
|
591
590
|
);
|
|
592
|
-
const unvalidated =
|
|
591
|
+
const unvalidated =
|
|
592
|
+
product[`${getConcept(tab)}_status`] === "QF" ||
|
|
593
|
+
product[`${getConcept(tab)}_status`] === "IN_PROGRESS";
|
|
593
594
|
|
|
594
|
-
const auditorUnvalidated = !["RA", "AA", "
|
|
595
|
+
const auditorUnvalidated = !["RA", "AA", "AC", "AP"].includes(
|
|
596
|
+
product[`${getConcept(tab)}_status`]
|
|
597
|
+
);
|
|
595
598
|
|
|
596
599
|
switch (userId) {
|
|
597
600
|
case 7:
|
|
598
601
|
case 8:
|
|
599
602
|
return (
|
|
600
|
-
|
|
601
|
-
|
|
603
|
+
(["RA", "RF"].includes(product?.status) && //"IN_PROGRESS", "RF", "RA"
|
|
604
|
+
statusArray.includes(srvActive?.status)) ||
|
|
605
|
+
(statusArray.includes(product.status) &&
|
|
602
606
|
srv.filter((serv) => statusArray.includes(serv.status)).length ===
|
|
603
607
|
srv.length)
|
|
604
608
|
);
|
|
@@ -606,16 +610,14 @@ export const RetailerProductEdition = ({
|
|
|
606
610
|
case 5:
|
|
607
611
|
return (
|
|
608
612
|
unvalidated &&
|
|
609
|
-
["
|
|
613
|
+
["IN_PROGRESS", "QF"].includes(product.status) && //"RF", "AF", "AA", "AP", "AC
|
|
610
614
|
srv.filter((serv) => statusArray.includes(serv.status)).length ===
|
|
611
615
|
srv.length
|
|
612
616
|
);
|
|
613
617
|
case 6:
|
|
614
618
|
return (
|
|
615
|
-
statusArray.includes(product.status) && //
|
|
616
|
-
srv.every((serv) =>
|
|
617
|
-
["RA", "AA", "AP", "ACA"].includes(serv.status)
|
|
618
|
-
) &&
|
|
619
|
+
statusArray.includes(product.status) && //RP, RC, AF, RA true
|
|
620
|
+
srv.every((serv) => ["RA", "AA", "AP", "AC"].includes(serv.status)) &&
|
|
619
621
|
auditorUnvalidated
|
|
620
622
|
);
|
|
621
623
|
default:
|
|
@@ -637,20 +639,20 @@ export const RetailerProductEdition = ({
|
|
|
637
639
|
const approveRejectButtons = (action) => {
|
|
638
640
|
let concept = getConcept(action || activeTab);
|
|
639
641
|
|
|
640
|
-
const retailerStatus = servicesData
|
|
641
|
-
.
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
?.status
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
retailerStatus === "
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
642
|
+
const [retailerStatus] = servicesData.filter(
|
|
643
|
+
(srv) => srv.id_retailer === activeRetailer?.id && srv.service === concept
|
|
644
|
+
);
|
|
645
|
+
|
|
646
|
+
return (
|
|
647
|
+
(retailerStatus?.status === "QF" &&
|
|
648
|
+
(user.id_role === 1 || user.id_role === 4 || user.id_role === 5)) ||
|
|
649
|
+
(retailerStatus?.status === "AF" && //sessionStorage product
|
|
650
|
+
(user.id_role === 1 || user.id_role === 6)) ||
|
|
651
|
+
(retailerStatus?.status === "RP" &&
|
|
652
|
+
(user.id_role === 1 || user.id_role === 6)) ||
|
|
653
|
+
(retailerStatus?.status === "RC" &&
|
|
654
|
+
(user.id_role === 1 || user.id_role === 6))
|
|
655
|
+
);
|
|
654
656
|
};
|
|
655
657
|
|
|
656
658
|
const getSectionIcon = () => {
|
|
@@ -674,57 +676,92 @@ export const RetailerProductEdition = ({
|
|
|
674
676
|
try {
|
|
675
677
|
let concept = getConcept(activeTab);
|
|
676
678
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
let data = {
|
|
683
|
-
articleId,
|
|
684
|
-
orderId,
|
|
685
|
-
concept,
|
|
686
|
-
evalStatus,
|
|
687
|
-
retailerId: activeRetailer.id,
|
|
688
|
-
};
|
|
689
|
-
let res;
|
|
690
|
-
let message;
|
|
679
|
+
let productTemp = { ...product };
|
|
680
|
+
let evalStatus = product[`${concept}_status`];
|
|
681
|
+
|
|
682
|
+
let data = {};
|
|
691
683
|
if (result) {
|
|
692
|
-
data
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
684
|
+
data = {
|
|
685
|
+
articleId: product.article.id_article,
|
|
686
|
+
orderId: product.orderId,
|
|
687
|
+
concept: concept,
|
|
688
|
+
result: result,
|
|
689
|
+
evalStatus: evalStatus,
|
|
690
|
+
retailerId: activeRetailer.id,
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
await axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
|
|
694
|
+
headers: {
|
|
695
|
+
Authorization: token,
|
|
696
|
+
},
|
|
697
|
+
});
|
|
702
698
|
getServices();
|
|
703
699
|
} else {
|
|
704
|
-
const specialistDone =
|
|
700
|
+
const specialistDone =
|
|
701
|
+
evalStatus === "RF" ||
|
|
702
|
+
evalStatus === "RA" ||
|
|
703
|
+
evalStatus === "IN_PROGRESS";
|
|
705
704
|
|
|
706
705
|
if (specialistDone) {
|
|
707
|
-
|
|
706
|
+
setMessage(`${activeTab} enviada a facilitador`);
|
|
707
|
+
getSectionIcon();
|
|
708
|
+
} else if (evalStatus === "QF") {
|
|
709
|
+
setMessage("Evaluación enviada");
|
|
710
|
+
getSectionIcon();
|
|
711
|
+
} else if (evalStatus === "AF") {
|
|
712
|
+
setMessage("Evaluación enviada");
|
|
713
|
+
getSectionIcon();
|
|
714
|
+
} else if (evalStatus === "RP") {
|
|
715
|
+
setMessage("Evaluación enviada");
|
|
708
716
|
getSectionIcon();
|
|
709
|
-
} else if (
|
|
710
|
-
|
|
717
|
+
} else if (evalStatus === "RC") {
|
|
718
|
+
setMessage("Evaluación enviada");
|
|
711
719
|
getSectionIcon();
|
|
712
720
|
}
|
|
713
|
-
|
|
721
|
+
let statusArr = [];
|
|
722
|
+
servicesData.forEach((srv) => {
|
|
723
|
+
srv.service === concept && statusArr.push(srv.status);
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
productTemp[`${concept}_status`] = getNewStatus(statusArr);
|
|
727
|
+
|
|
728
|
+
let newStatus = getNewStatus([
|
|
729
|
+
productTemp.datasheet_status,
|
|
730
|
+
productTemp.description_status,
|
|
731
|
+
productTemp.images_status,
|
|
732
|
+
]);
|
|
733
|
+
|
|
734
|
+
productTemp.status = newStatus;
|
|
735
|
+
|
|
736
|
+
data = {
|
|
737
|
+
articleId: product.article.id_article,
|
|
738
|
+
orderId: product.orderId,
|
|
739
|
+
concept: concept,
|
|
740
|
+
evalStatus: evalStatus,
|
|
741
|
+
retailerId: activeRetailer.id,
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
switch (user.id_role) {
|
|
745
|
+
case 7:
|
|
746
|
+
case 8:
|
|
747
|
+
data.especialist = true;
|
|
748
|
+
break;
|
|
749
|
+
case 4:
|
|
750
|
+
case 5:
|
|
751
|
+
data.facilitator = true;
|
|
752
|
+
break;
|
|
753
|
+
default:
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
await axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
|
|
714
757
|
headers: {
|
|
715
758
|
Authorization: token,
|
|
716
759
|
},
|
|
717
760
|
});
|
|
718
761
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
productTemp[`${concept}_status`] = newStatus;
|
|
723
|
-
await loadData();
|
|
724
|
-
if (message) setMessage(message);
|
|
725
|
-
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
726
|
-
setProduct(productTemp);
|
|
727
|
-
}
|
|
762
|
+
loadData();
|
|
763
|
+
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
764
|
+
setProduct(productTemp);
|
|
728
765
|
} catch (error) {
|
|
729
766
|
console.log(error);
|
|
730
767
|
}
|
|
@@ -822,23 +859,21 @@ export const RetailerProductEdition = ({
|
|
|
822
859
|
|
|
823
860
|
objetcTemp["Ficha técnica"] = dsInputsRequired.length;
|
|
824
861
|
|
|
825
|
-
const regex = /(<\/?p>)|(<\/?strong>)|(<br>)/gm;
|
|
826
862
|
descriptionsServicesArray.forEach((description) => {
|
|
827
863
|
const [requested] = servicesData.filter(
|
|
828
864
|
(srv) =>
|
|
829
865
|
srv.id_retailer === description.id &&
|
|
830
866
|
srv.service === getConcept(activeTab)
|
|
831
867
|
);
|
|
832
|
-
|
|
833
|
-
description.inputs.forEach(
|
|
834
|
-
|
|
868
|
+
requested &&
|
|
869
|
+
description.inputs.forEach(
|
|
870
|
+
(input) =>
|
|
835
871
|
input.required &&
|
|
836
|
-
(!input.value ||
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
}
|
|
872
|
+
(!input.value ||
|
|
873
|
+
input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") ===
|
|
874
|
+
"") &&
|
|
875
|
+
desInputsRequired++
|
|
876
|
+
);
|
|
842
877
|
});
|
|
843
878
|
|
|
844
879
|
objetcTemp["Descripción"] = desInputsRequired;
|
|
@@ -912,12 +947,12 @@ export const RetailerProductEdition = ({
|
|
|
912
947
|
},
|
|
913
948
|
],
|
|
914
949
|
concept: concept,
|
|
915
|
-
|
|
950
|
+
[`${assignationType}Id`]: assignationId,
|
|
916
951
|
};
|
|
917
|
-
|
|
952
|
+
axios({
|
|
918
953
|
method: "post",
|
|
919
954
|
url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
|
|
920
|
-
data,
|
|
955
|
+
data: data,
|
|
921
956
|
headers: {
|
|
922
957
|
Authorization: token,
|
|
923
958
|
},
|
|
@@ -1106,7 +1141,7 @@ export const RetailerProductEdition = ({
|
|
|
1106
1141
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
1107
1142
|
setProduct(productTemp);
|
|
1108
1143
|
|
|
1109
|
-
|
|
1144
|
+
loadData();
|
|
1110
1145
|
} catch (error) {
|
|
1111
1146
|
console.log(error);
|
|
1112
1147
|
}
|
|
@@ -1184,7 +1219,7 @@ export const RetailerProductEdition = ({
|
|
|
1184
1219
|
showApproveRejectAll={
|
|
1185
1220
|
isAuditor &&
|
|
1186
1221
|
servicesData.every((serv) =>
|
|
1187
|
-
["RA", "AA", "AP", "
|
|
1222
|
+
["RA", "AA", "AP", "AC", "AF"].includes(serv.status)
|
|
1188
1223
|
) &&
|
|
1189
1224
|
approveRejectButtons() &&
|
|
1190
1225
|
(auditorAssigned() || userAssigned())
|
|
@@ -1227,6 +1262,7 @@ export const RetailerProductEdition = ({
|
|
|
1227
1262
|
}}
|
|
1228
1263
|
/>
|
|
1229
1264
|
<FullTabsMenu
|
|
1265
|
+
canAssign={![7, 8].includes(user.id_role)}
|
|
1230
1266
|
tabsSections={tabsSections}
|
|
1231
1267
|
status={retailerStatus}
|
|
1232
1268
|
activeTab={activeTab}
|
|
@@ -1238,6 +1274,8 @@ export const RetailerProductEdition = ({
|
|
|
1238
1274
|
setAssignation={setAssignation}
|
|
1239
1275
|
isRetailer={isRetailer}
|
|
1240
1276
|
showSaveButton={auditorAssigned() || userAssigned()}
|
|
1277
|
+
version={version}
|
|
1278
|
+
setShowVersionSelector={setShowVersionSelector}
|
|
1241
1279
|
onClickSave={() => {
|
|
1242
1280
|
switch (activeTab) {
|
|
1243
1281
|
case "Descripción":
|
|
@@ -1377,21 +1415,16 @@ export const RetailerProductEdition = ({
|
|
|
1377
1415
|
/>
|
|
1378
1416
|
</div>
|
|
1379
1417
|
)}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
}
|
|
1391
|
-
label={"Enviar evaluación"}
|
|
1392
|
-
onClick={() => sendToFacilitator()}
|
|
1393
|
-
/>
|
|
1394
|
-
)}
|
|
1418
|
+
<Button
|
|
1419
|
+
buttonType={
|
|
1420
|
+
evaluationFinished(user.id_role, activeTab, statusArray) &&
|
|
1421
|
+
requiredNull[activeTab] === 0
|
|
1422
|
+
? "general-green-button"
|
|
1423
|
+
: "general-button-disabled"
|
|
1424
|
+
}
|
|
1425
|
+
label={"Enviar evaluación"}
|
|
1426
|
+
onClick={() => sendToFacilitator()}
|
|
1427
|
+
/>
|
|
1395
1428
|
</div>
|
|
1396
1429
|
)}
|
|
1397
1430
|
</div>
|
|
@@ -1423,6 +1456,23 @@ export const RetailerProductEdition = ({
|
|
|
1423
1456
|
onClick={() => setMessage("")}
|
|
1424
1457
|
/>
|
|
1425
1458
|
)}
|
|
1459
|
+
{showVersionSelector && (
|
|
1460
|
+
<VersionSelector
|
|
1461
|
+
modalId={"version-selector"}
|
|
1462
|
+
articleId={product.article.id_article}
|
|
1463
|
+
setVersion={setVersion}
|
|
1464
|
+
companyName={product.article.company_name}
|
|
1465
|
+
currentVersion={version}
|
|
1466
|
+
setShowCreateVersion={setShowCreateVersion}
|
|
1467
|
+
/>
|
|
1468
|
+
)}
|
|
1469
|
+
{showCreateVersion && (
|
|
1470
|
+
<CreateVersion
|
|
1471
|
+
idArticle={product.article.id_article}
|
|
1472
|
+
version={version}
|
|
1473
|
+
setShowCreateVersion={setShowCreateVersion}
|
|
1474
|
+
/>
|
|
1475
|
+
)}
|
|
1426
1476
|
</Container>
|
|
1427
1477
|
);
|
|
1428
1478
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
|
|
4
|
+
export const closeModals = (id) => {
|
|
5
|
+
const [showModal, setShowModal] = useState(false);
|
|
6
|
+
|
|
7
|
+
const closeModal = (e) => {
|
|
8
|
+
if (
|
|
9
|
+
(!e.target.closest(`#${id}`) ||
|
|
10
|
+
e.target.closest("#close-button") ||
|
|
11
|
+
e.target.closest("#add-version")) &&
|
|
12
|
+
showModal
|
|
13
|
+
) {
|
|
14
|
+
document.removeEventListener("click", closeModal);
|
|
15
|
+
setShowModal(false);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (showModal) {
|
|
21
|
+
document.addEventListener("click", closeModal);
|
|
22
|
+
}
|
|
23
|
+
}, [showModal]);
|
|
24
|
+
|
|
25
|
+
return [showModal, setShowModal];
|
|
26
|
+
};
|
package/src/global-files/data.js
CHANGED
|
@@ -195,18 +195,18 @@ export const fetchUsers = async (auth) => {
|
|
|
195
195
|
export const getNewStatus = (statusArray) => {
|
|
196
196
|
let lookupString = "";
|
|
197
197
|
statusArray.forEach((element) => (lookupString += element + "/"));
|
|
198
|
-
if (lookupString.includes("
|
|
199
|
-
if (lookupString.includes("RC")) return "RC";
|
|
198
|
+
if (lookupString.includes("RF")) return "RF";
|
|
200
199
|
if (lookupString.includes("RA")) return "RA";
|
|
201
200
|
if (lookupString.includes("RP")) return "RP";
|
|
202
|
-
if (lookupString.includes("
|
|
203
|
-
if (lookupString.includes("
|
|
204
|
-
if (lookupString.includes("
|
|
205
|
-
if (lookupString.includes("
|
|
206
|
-
if (lookupString.includes("
|
|
201
|
+
if (lookupString.includes("RC")) return "RC";
|
|
202
|
+
if (lookupString.includes("UNASSIGNED")) return "IN_PROGRESS";
|
|
203
|
+
if (lookupString.includes("IN_PROGRESS")) return "IN_PROGRESS";
|
|
204
|
+
if (lookupString.includes("QF")) return "QF";
|
|
205
|
+
if (lookupString.includes("AF")) return "AF";
|
|
207
206
|
if (lookupString.includes("AA")) return "AA";
|
|
208
207
|
if (lookupString.includes("AP")) return "AP";
|
|
209
|
-
if (lookupString.includes("
|
|
208
|
+
if (lookupString.includes("AC")) return "AC";
|
|
209
|
+
if (lookupString.includes("RECEIVED")) return "RECEIVED";
|
|
210
210
|
if (lookupString.includes("NA")) return "NA";
|
|
211
211
|
return new Error("Status not found");
|
|
212
212
|
};
|