contentoh-components-library 21.3.59 → 21.3.60
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 +2 -0
- package/dist/components/molecules/CarouselImagesLogin/index.js +1 -1
- package/dist/components/molecules/HeaderTop/index.js +68 -11
- package/dist/components/organisms/Chat/Chat.stories.js +21 -1
- package/dist/components/organisms/Chat/ContainerItems/index.js +19 -3
- package/dist/components/organisms/Chat/ContainerItems/styles.js +1 -1
- package/dist/components/organisms/Chat/ContentChat/index.js +343 -191
- package/dist/components/organisms/Chat/Footer/index.js +48 -39
- package/dist/components/organisms/Chat/index.js +48 -3
- package/dist/components/organisms/FullProductNameHeader/index.js +2 -2
- package/dist/components/organisms/SideModal/SideModal.stories.js +42 -0
- package/dist/components/organisms/SideModal/index.js +61 -0
- package/dist/components/organisms/SideModal/styles.js +18 -0
- package/dist/components/pages/Dashboard/Dashboard.stories.js +38 -45
- package/dist/components/pages/Dashboard/index.js +8 -4
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +172 -127
- package/dist/components/pages/ProviderProductEdition/index.js +188 -129
- package/dist/components/pages/ProviderProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +7 -3
- package/dist/components/pages/RetailerProductEdition/index.js +267 -274
- package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/utils.js +61 -2
- package/package.json +1 -1
- package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
- package/src/components/molecules/HeaderTop/index.js +52 -6
- package/src/components/organisms/Chat/Chat.stories.js +21 -0
- package/src/components/organisms/Chat/ContainerItems/index.js +18 -2
- package/src/components/organisms/Chat/ContainerItems/styles.js +10 -2
- package/src/components/organisms/Chat/ContentChat/index.js +81 -6
- package/src/components/organisms/Chat/Footer/index.js +11 -0
- package/src/components/organisms/Chat/index.js +47 -3
- package/src/components/organisms/FullProductNameHeader/index.js +1 -1
- package/src/components/organisms/SideModal/SideModal.stories.js +23 -0
- package/src/components/organisms/SideModal/index.js +41 -0
- package/src/components/organisms/SideModal/styles.js +21 -0
- package/src/components/pages/Dashboard/Dashboard.stories.js +38 -47
- package/src/components/pages/Dashboard/index.js +4 -3
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +177 -130
- package/src/components/pages/ProviderProductEdition/index.js +105 -55
- package/src/components/pages/ProviderProductEdition/styles.js +5 -1
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +6 -2
- package/src/components/pages/RetailerProductEdition/index.js +111 -135
- package/src/components/pages/RetailerProductEdition/styles.js +4 -0
- package/src/components/pages/RetailerProductEdition/utils.js +37 -0
|
@@ -39,6 +39,9 @@ import Slide1_4 from "../../../assets/images/sliderToolTip/slide4.svg";
|
|
|
39
39
|
import Slide1_5 from "../../../assets/images/sliderToolTip/slide5.svg";
|
|
40
40
|
import { VersionSelector } from "../../organisms/VersionSelector";
|
|
41
41
|
import { useCloseModal } from "../../../global-files/customHooks";
|
|
42
|
+
import { createMessage, sendMessage } from "../RetailerProductEdition/utils";
|
|
43
|
+
import { Modal } from "../../organisms/Modal";
|
|
44
|
+
import { ButtonV2 } from "../../atoms/ButtonV2";
|
|
42
45
|
|
|
43
46
|
const reducerImages = (state, action) => {
|
|
44
47
|
let { values, attrForImgs, inputsByRetailer } = state;
|
|
@@ -214,6 +217,7 @@ export const ProviderProductEdition = ({
|
|
|
214
217
|
const isRetailer = user?.is_retailer;
|
|
215
218
|
const [loading, setLoading] = useState(true);
|
|
216
219
|
const [validatedAll, setValidatedAll] = useState(false);
|
|
220
|
+
const [showRejectModal, setShowRejectModal] = useState(false);
|
|
217
221
|
|
|
218
222
|
const originProp = location?.state?.origin;
|
|
219
223
|
const [origin, setOrigin] = useState({
|
|
@@ -343,28 +347,6 @@ export const ProviderProductEdition = ({
|
|
|
343
347
|
(type) => {
|
|
344
348
|
const formatter = new Intl.ListFormat("es", { type: "conjunction" });
|
|
345
349
|
switch (type) {
|
|
346
|
-
case "error":
|
|
347
|
-
setGlobalModal({
|
|
348
|
-
message: `${activeTab} rechazada`,
|
|
349
|
-
detail: "Agrega tu comentarios para enviar el rechazo",
|
|
350
|
-
img: errorModal,
|
|
351
|
-
textArea: true,
|
|
352
|
-
button1: {
|
|
353
|
-
name: "Enviar",
|
|
354
|
-
action: (e) => {
|
|
355
|
-
const textArea = document.querySelector("#area");
|
|
356
|
-
if (textArea.value) {
|
|
357
|
-
textArea.style.border = "none";
|
|
358
|
-
createComment(e, textArea.value);
|
|
359
|
-
showGlobalModal("commentsSent");
|
|
360
|
-
validatedAll ? validateAll("R") : sendEvaluation("R");
|
|
361
|
-
} else {
|
|
362
|
-
textArea.style.border = "2px solid red";
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
});
|
|
367
|
-
break;
|
|
368
350
|
case "generic":
|
|
369
351
|
setGlobalModal(dataGenericModal);
|
|
370
352
|
break;
|
|
@@ -516,7 +498,9 @@ export const ProviderProductEdition = ({
|
|
|
516
498
|
);
|
|
517
499
|
setServicesData(parsedResponse);
|
|
518
500
|
}
|
|
519
|
-
|
|
501
|
+
retailers &&
|
|
502
|
+
!activeRetailer.id &&
|
|
503
|
+
setActiveRetailer(active ? active : retailers[0]);
|
|
520
504
|
};
|
|
521
505
|
|
|
522
506
|
const isRevision = () => {
|
|
@@ -592,7 +576,7 @@ export const ProviderProductEdition = ({
|
|
|
592
576
|
});
|
|
593
577
|
}
|
|
594
578
|
setProduct(productTemp);
|
|
595
|
-
setActivePercentage(retailers[0]?.percentage);
|
|
579
|
+
retailers && setActivePercentage(retailers[0]?.percentage);
|
|
596
580
|
}, [percentages]);
|
|
597
581
|
|
|
598
582
|
const loadInputs = () => {
|
|
@@ -833,32 +817,19 @@ export const ProviderProductEdition = ({
|
|
|
833
817
|
}
|
|
834
818
|
};
|
|
835
819
|
|
|
836
|
-
const createComment = async (
|
|
837
|
-
let concept = "";
|
|
838
|
-
switch (activeTab) {
|
|
839
|
-
case "Ficha técnica":
|
|
840
|
-
concept = "datasheet";
|
|
841
|
-
break;
|
|
842
|
-
case "Imágenes":
|
|
843
|
-
concept = "images";
|
|
844
|
-
break;
|
|
845
|
-
|
|
846
|
-
default:
|
|
847
|
-
concept = "description";
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
820
|
+
const createComment = async (messages = [], retailerId) => {
|
|
850
821
|
const data = {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
|
|
858
|
-
headers: {
|
|
859
|
-
Authorization: token,
|
|
822
|
+
paramsBody: {
|
|
823
|
+
id: product.article.id_article || productEdit.ArticleId,
|
|
824
|
+
version: version,
|
|
825
|
+
items: messages,
|
|
826
|
+
retailerId: retailerId,
|
|
827
|
+
status: product.status || productEdit.product.status,
|
|
860
828
|
},
|
|
861
|
-
|
|
829
|
+
paramsHeader: { Authorization: token },
|
|
830
|
+
};
|
|
831
|
+
setMessage("");
|
|
832
|
+
return sendMessage(data);
|
|
862
833
|
};
|
|
863
834
|
|
|
864
835
|
useEffect(() => {
|
|
@@ -1058,6 +1029,27 @@ export const ProviderProductEdition = ({
|
|
|
1058
1029
|
const { newArticleStatus, newServiceStatus, newStatus } = JSON.parse(
|
|
1059
1030
|
res.data.body
|
|
1060
1031
|
);
|
|
1032
|
+
|
|
1033
|
+
const message = createMessage(
|
|
1034
|
+
product.retailers || product.retailersAvailable,
|
|
1035
|
+
activeRetailer.id,
|
|
1036
|
+
product[sectionStatusKey],
|
|
1037
|
+
newStatus,
|
|
1038
|
+
activeTab
|
|
1039
|
+
);
|
|
1040
|
+
|
|
1041
|
+
const messageData = {
|
|
1042
|
+
paramsBody: {
|
|
1043
|
+
id: product.article.id_article || productEdit.ArticleId,
|
|
1044
|
+
version: version,
|
|
1045
|
+
items: [{ type: "status", value: message }],
|
|
1046
|
+
retailerId: activeRetailer.id,
|
|
1047
|
+
status: product.status || productEdit.product.status,
|
|
1048
|
+
},
|
|
1049
|
+
paramsHeader: { Authorization: token },
|
|
1050
|
+
};
|
|
1051
|
+
await sendMessage(messageData);
|
|
1052
|
+
|
|
1061
1053
|
if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
|
|
1062
1054
|
const retailerStatusCopy = { ...retailerStatus };
|
|
1063
1055
|
retailerStatusCopy[activeRetailer.id][concept] = newStatus;
|
|
@@ -1089,6 +1081,7 @@ export const ProviderProductEdition = ({
|
|
|
1089
1081
|
result,
|
|
1090
1082
|
isAproved: result === "A",
|
|
1091
1083
|
};
|
|
1084
|
+
const messages = [];
|
|
1092
1085
|
servicesData?.forEach((ret) => {
|
|
1093
1086
|
const { service, id_retailer } = ret;
|
|
1094
1087
|
let data = {};
|
|
@@ -1105,6 +1098,18 @@ export const ProviderProductEdition = ({
|
|
|
1105
1098
|
},
|
|
1106
1099
|
})
|
|
1107
1100
|
);
|
|
1101
|
+
if (product[`${ret.service}_status`] !== "NS") {
|
|
1102
|
+
const message = createMessage(
|
|
1103
|
+
product.retailers,
|
|
1104
|
+
ret.id_retailer,
|
|
1105
|
+
product[`${ret.service}_status`],
|
|
1106
|
+
`${result}A`,
|
|
1107
|
+
ret.service
|
|
1108
|
+
);
|
|
1109
|
+
messages.push(
|
|
1110
|
+
createComment([{ type: "status", value: message }], ret.id_retailer)
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1108
1113
|
});
|
|
1109
1114
|
await Promise.all(evaluationArray);
|
|
1110
1115
|
const userType = user.is_retailer === 1 ? "CA" : "P";
|
|
@@ -1144,6 +1149,7 @@ export const ProviderProductEdition = ({
|
|
|
1144
1149
|
product: productTemp,
|
|
1145
1150
|
})
|
|
1146
1151
|
);
|
|
1152
|
+
await Promise.all(messages);
|
|
1147
1153
|
|
|
1148
1154
|
await loadData();
|
|
1149
1155
|
} catch (error) {
|
|
@@ -1271,8 +1277,7 @@ export const ProviderProductEdition = ({
|
|
|
1271
1277
|
return;
|
|
1272
1278
|
} else if (user.is_retailer) {
|
|
1273
1279
|
if (product.id_order || product.orderId) {
|
|
1274
|
-
|
|
1275
|
-
showGlobalModal("error");
|
|
1280
|
+
sendEvaluation("R");
|
|
1276
1281
|
} else {
|
|
1277
1282
|
setDataGenericModal((prev) => ({
|
|
1278
1283
|
...prev,
|
|
@@ -1284,8 +1289,7 @@ export const ProviderProductEdition = ({
|
|
|
1284
1289
|
showGlobalModal("generic");
|
|
1285
1290
|
}
|
|
1286
1291
|
} else {
|
|
1287
|
-
|
|
1288
|
-
showGlobalModal("error");
|
|
1292
|
+
sendEvaluation("R");
|
|
1289
1293
|
}
|
|
1290
1294
|
}
|
|
1291
1295
|
};
|
|
@@ -1294,6 +1298,7 @@ export const ProviderProductEdition = ({
|
|
|
1294
1298
|
<HeaderTop
|
|
1295
1299
|
setHeaderTop={setHeaderTop}
|
|
1296
1300
|
withChat={location?.state?.withChat}
|
|
1301
|
+
chatType={location?.state?.chatType}
|
|
1297
1302
|
productSelected={productSelected}
|
|
1298
1303
|
token={token}
|
|
1299
1304
|
activeRetailer={activeRetailer}
|
|
@@ -1372,7 +1377,7 @@ export const ProviderProductEdition = ({
|
|
|
1372
1377
|
} else if (user.is_retailer) {
|
|
1373
1378
|
if (product.id_order || product.orderId) {
|
|
1374
1379
|
setValidatedAll(true);
|
|
1375
|
-
|
|
1380
|
+
setShowRejectModal(true);
|
|
1376
1381
|
} else {
|
|
1377
1382
|
setDataGenericModal((prev) => ({
|
|
1378
1383
|
...prev,
|
|
@@ -1384,12 +1389,14 @@ export const ProviderProductEdition = ({
|
|
|
1384
1389
|
showGlobalModal("generic");
|
|
1385
1390
|
}
|
|
1386
1391
|
} else {
|
|
1392
|
+
setShowRejectModal(true);
|
|
1387
1393
|
setValidatedAll(true);
|
|
1388
|
-
showGlobalModal("error");
|
|
1389
1394
|
}
|
|
1390
1395
|
}}
|
|
1391
1396
|
approve={() => sendToEvaluation("A")}
|
|
1392
|
-
reject={() =>
|
|
1397
|
+
reject={() => {
|
|
1398
|
+
setShowRejectModal(true);
|
|
1399
|
+
}}
|
|
1393
1400
|
/>
|
|
1394
1401
|
<FullTabsMenu
|
|
1395
1402
|
tabsSections={tabsSections}
|
|
@@ -1624,6 +1631,49 @@ export const ProviderProductEdition = ({
|
|
|
1624
1631
|
jwt={token}
|
|
1625
1632
|
/>
|
|
1626
1633
|
)}
|
|
1634
|
+
{showRejectModal && (
|
|
1635
|
+
<Modal
|
|
1636
|
+
title={"Agregar mensaje de rechazo"}
|
|
1637
|
+
show={showRejectModal}
|
|
1638
|
+
customComponent={
|
|
1639
|
+
<TagAndInput
|
|
1640
|
+
label={"Caja de Comentario"}
|
|
1641
|
+
inputType={"textarea"}
|
|
1642
|
+
inputId={"modal-message-box"}
|
|
1643
|
+
index={0}
|
|
1644
|
+
color={"white"}
|
|
1645
|
+
/>
|
|
1646
|
+
}
|
|
1647
|
+
buttons={[
|
|
1648
|
+
<ButtonV2
|
|
1649
|
+
key={"btn-Cancelar"}
|
|
1650
|
+
type={"white"}
|
|
1651
|
+
label={"Cancelar"}
|
|
1652
|
+
size={12}
|
|
1653
|
+
onClick={() => {
|
|
1654
|
+
setShowRejectModal(false);
|
|
1655
|
+
}}
|
|
1656
|
+
/>,
|
|
1657
|
+
<ButtonV2
|
|
1658
|
+
key={"btn-Aceptar"}
|
|
1659
|
+
type={"pink"}
|
|
1660
|
+
label={"Aceptar"}
|
|
1661
|
+
size={12}
|
|
1662
|
+
onClick={async () => {
|
|
1663
|
+
const body = document.querySelector(
|
|
1664
|
+
"#modal-message-box .ql-container .ql-editor > p"
|
|
1665
|
+
).innerHTML;
|
|
1666
|
+
const messages = [
|
|
1667
|
+
{ type: "message", value: body?.replace(/<.*?\/?>/gm, "") },
|
|
1668
|
+
];
|
|
1669
|
+
await createComment(messages, activeRetailer.id);
|
|
1670
|
+
validatedAll ? validateAll("R") : sendToEvaluation("R");
|
|
1671
|
+
setShowRejectModal(false);
|
|
1672
|
+
}}
|
|
1673
|
+
/>,
|
|
1674
|
+
]}
|
|
1675
|
+
/>
|
|
1676
|
+
)}
|
|
1627
1677
|
</Container>
|
|
1628
1678
|
);
|
|
1629
1679
|
};
|
|
@@ -107,6 +107,10 @@ export const Container = styled.div`
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
#modal-message-box {
|
|
111
|
+
width: 400px;
|
|
112
|
+
height: 100px;
|
|
113
|
+
}
|
|
110
114
|
.container {
|
|
111
115
|
width: 100%;
|
|
112
116
|
height: 100%;
|
|
@@ -115,4 +119,4 @@ export const Container = styled.div`
|
|
|
115
119
|
width: 100%;
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
|
-
`;
|
|
122
|
+
`;
|
|
@@ -16,7 +16,7 @@ RetailerProductEditionDefault.args = {
|
|
|
16
16
|
Imágenes: false,
|
|
17
17
|
},
|
|
18
18
|
token:
|
|
19
|
-
"eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.
|
|
19
|
+
"eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI5YTIxMzEyOC02NDgyLTRjMTYtYTRiNi02ZTY0ZjIyNWIxYmQiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwiY29nbml0bzp1c2VybmFtZSI6IjlhMjEzMTI4LTY0ODItNGMxNi1hNGI2LTZlNjRmMjI1YjFiZCIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiI5OGE0NzYxMy04ZGIyLTRlZjUtYjA0Mi01ZDU3MWRkZjIwMWIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4Mzg3NTIyNiwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY4Mzg3ODgyNiwiaWF0IjoxNjgzODc1MjI2LCJlbWFpbCI6ImlzbWFlbDk3bG9wZXpAZ21haWwuY29tIn0.EtgmT_THMx-Zy_zB5yZK4gz6TXNTVVJEKFt5X0JK2UkGVrp_q_92YCEuejS4n976fyTez0jkwOee6IkVHLV71uZWRBDFt-3Yw4ZxfsZYPNJWhoHXGNxhMU8MCkSntfu597esBTk-VsUpstT5R7L-WJfN8viE7R-qVo-42RlPTG0TFrWA9q0oTcqjv8vbxLpOBUjiEpjmqRhg4blJZwgkGNta6MOlw1vfmisOVbo9wMvqwnCZ9xx9KMKoH9U4uNObK_JomjbvPmTmkcUXsE-wGSD7XcoSwtuhBngLC7-jiu1u8MvL_ff5Z0Qp70sSpLdUglcSS8d1Xf7j_fcZuJ5jKA",
|
|
20
20
|
productSelected: {
|
|
21
21
|
orderId: 14606,
|
|
22
22
|
status: "RA",
|
|
@@ -82,7 +82,11 @@ RetailerProductEditionDefault.args = {
|
|
|
82
82
|
],
|
|
83
83
|
},
|
|
84
84
|
location: {
|
|
85
|
-
product: { articleId:
|
|
85
|
+
product: { articleId: 354, versionId: 3 },
|
|
86
|
+
state: {
|
|
87
|
+
withChat: true,
|
|
88
|
+
chatType: "product_status",
|
|
89
|
+
},
|
|
86
90
|
},
|
|
87
91
|
user: {
|
|
88
92
|
id_user: 51,
|
|
@@ -24,15 +24,20 @@ import descriptionSent from "../../../assets/images/modalsSVGs/descriptionSent.s
|
|
|
24
24
|
import imagesSent from "../../../assets/images/modalsSVGs/uploadingImages.svg";
|
|
25
25
|
import { TagAndInput } from "../../molecules/TagAndInput/index";
|
|
26
26
|
import { Button } from "../../atoms/GeneralButton";
|
|
27
|
-
import { Commentary } from "../../atoms/Commentary";
|
|
28
27
|
import { GenericModal } from "../../atoms/GenericModal";
|
|
29
28
|
import { ScreenHeader } from "../../atoms/ScreenHeader";
|
|
30
29
|
import { Loading } from "../../atoms/Loading";
|
|
31
30
|
import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
|
|
32
|
-
import errorModal from "../../../assets/images/genericModal/errorModal.svg";
|
|
33
31
|
import { VersionSelector } from "../../organisms/VersionSelector";
|
|
34
32
|
import { useCloseModal } from "../../../global-files/customHooks";
|
|
35
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
getAuditVersion,
|
|
35
|
+
getInputsData,
|
|
36
|
+
createMessage,
|
|
37
|
+
sendMessage,
|
|
38
|
+
} from "./utils";
|
|
39
|
+
import { Modal } from "../../organisms/Modal";
|
|
40
|
+
import { ButtonV2 } from "../../atoms/ButtonV2";
|
|
36
41
|
|
|
37
42
|
const reducerImages = (state, action) => {
|
|
38
43
|
let { values, attrForImgs, inputsByRetailer } = state;
|
|
@@ -132,6 +137,7 @@ export const RetailerProductEdition = ({
|
|
|
132
137
|
const [datasheets, setDatasheets] = useState([]);
|
|
133
138
|
const [images, setImages] = useReducer(reducerImages, {});
|
|
134
139
|
const [showModal, setShowModal] = useState(false);
|
|
140
|
+
const [showRejectModal, setShowRejectModal] = useState(false);
|
|
135
141
|
const { getRootProps, getInputProps } = useDropzone({
|
|
136
142
|
accept: "image/*",
|
|
137
143
|
noKeyboard: true,
|
|
@@ -218,6 +224,7 @@ export const RetailerProductEdition = ({
|
|
|
218
224
|
const [auditDescriptions, setAuditDescriptions] = useState([]);
|
|
219
225
|
const [auditImages, setAuditImages] = useState([]);
|
|
220
226
|
const [compare, setCompare] = useState(false);
|
|
227
|
+
const [valRejAll, setValRejAll] = useState(false);
|
|
221
228
|
|
|
222
229
|
useEffect(async () => {
|
|
223
230
|
const { id_article } = product?.article || {};
|
|
@@ -337,7 +344,7 @@ export const RetailerProductEdition = ({
|
|
|
337
344
|
switch (user.id_role) {
|
|
338
345
|
case 7:
|
|
339
346
|
case 8:
|
|
340
|
-
arr = ["AS", "CA", "RC", "RA", "RP", "RCA"];
|
|
347
|
+
arr = ["PA", "AS", "CA", "RC", "RA", "RP", "RCA"];
|
|
341
348
|
break;
|
|
342
349
|
case 4:
|
|
343
350
|
case 5:
|
|
@@ -855,6 +862,25 @@ export const RetailerProductEdition = ({
|
|
|
855
862
|
const { newStatus, newOrderStatus, newArticleStatus } = JSON.parse(
|
|
856
863
|
res.data.body
|
|
857
864
|
);
|
|
865
|
+
const messageToChat = createMessage(
|
|
866
|
+
product.retailers,
|
|
867
|
+
activeRetailer.id,
|
|
868
|
+
evalStatus,
|
|
869
|
+
newStatus,
|
|
870
|
+
activeTab
|
|
871
|
+
);
|
|
872
|
+
|
|
873
|
+
const data = {
|
|
874
|
+
paramsBody: {
|
|
875
|
+
id: product.article.id_article,
|
|
876
|
+
version: version,
|
|
877
|
+
items: [{ type: "status", value: messageToChat }],
|
|
878
|
+
retailerId: activeRetailer.id,
|
|
879
|
+
status: product.status,
|
|
880
|
+
},
|
|
881
|
+
paramsHeader: { Authorization: token },
|
|
882
|
+
};
|
|
883
|
+
await sendMessage(data);
|
|
858
884
|
if (newOrderStatus) productTemp.status = newArticleStatus[articleId];
|
|
859
885
|
productTemp[`${concept}_status`] = newStatus;
|
|
860
886
|
await loadData();
|
|
@@ -897,35 +923,19 @@ export const RetailerProductEdition = ({
|
|
|
897
923
|
return product?.article[`id_auditor`] === user.id_user;
|
|
898
924
|
};
|
|
899
925
|
|
|
900
|
-
const createComment = async (
|
|
901
|
-
let concept = "";
|
|
902
|
-
switch (activeTab) {
|
|
903
|
-
case "Ficha técnica":
|
|
904
|
-
concept = "datasheet";
|
|
905
|
-
break;
|
|
906
|
-
case "Imágenes":
|
|
907
|
-
concept = "images";
|
|
908
|
-
break;
|
|
909
|
-
|
|
910
|
-
default:
|
|
911
|
-
concept = "description";
|
|
912
|
-
break;
|
|
913
|
-
}
|
|
926
|
+
const createComment = async (messages = [], retailerId) => {
|
|
914
927
|
const data = {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
|
|
922
|
-
headers: {
|
|
923
|
-
Authorization: token,
|
|
928
|
+
paramsBody: {
|
|
929
|
+
id: product.article.id_article,
|
|
930
|
+
version: version,
|
|
931
|
+
items: messages,
|
|
932
|
+
retailerId: retailerId,
|
|
933
|
+
status: product.status,
|
|
924
934
|
},
|
|
925
|
-
|
|
926
|
-
|
|
935
|
+
paramsHeader: { Authorization: token },
|
|
936
|
+
};
|
|
927
937
|
setMessage("");
|
|
928
|
-
|
|
938
|
+
return sendMessage(data);
|
|
929
939
|
};
|
|
930
940
|
|
|
931
941
|
const getRequired = (services) => {
|
|
@@ -1208,6 +1218,8 @@ export const RetailerProductEdition = ({
|
|
|
1208
1218
|
break;
|
|
1209
1219
|
}
|
|
1210
1220
|
|
|
1221
|
+
const messages = [];
|
|
1222
|
+
|
|
1211
1223
|
servicesData?.forEach((ret) => {
|
|
1212
1224
|
if (conceptArray.includes(ret.service)) {
|
|
1213
1225
|
let data = {
|
|
@@ -1218,6 +1230,21 @@ export const RetailerProductEdition = ({
|
|
|
1218
1230
|
evalStatus: ret.status,
|
|
1219
1231
|
retailerId: ret.id_retailer,
|
|
1220
1232
|
};
|
|
1233
|
+
if (product[`${ret.service}_status`] !== "NS") {
|
|
1234
|
+
const message = createMessage(
|
|
1235
|
+
product.retailers,
|
|
1236
|
+
ret.id_retailer,
|
|
1237
|
+
product[`${ret.service}_status`],
|
|
1238
|
+
`${result}A`,
|
|
1239
|
+
ret.service
|
|
1240
|
+
);
|
|
1241
|
+
messages.push(
|
|
1242
|
+
createComment(
|
|
1243
|
+
[{ type: "status", value: message }],
|
|
1244
|
+
ret.id_retailer
|
|
1245
|
+
)
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1221
1248
|
evaluationArray.push(
|
|
1222
1249
|
axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
|
|
1223
1250
|
headers: {
|
|
@@ -1251,13 +1278,14 @@ export const RetailerProductEdition = ({
|
|
|
1251
1278
|
const productTemp = product;
|
|
1252
1279
|
productTemp.status = `${result}A`;
|
|
1253
1280
|
productTemp.datasheet_status =
|
|
1254
|
-
productTemp.datasheet_status === "
|
|
1281
|
+
productTemp.datasheet_status === "NS" ? "NS" : `${result}A`;
|
|
1255
1282
|
productTemp.description_status =
|
|
1256
|
-
productTemp.description_status === "
|
|
1283
|
+
productTemp.description_status === "NS" ? "NS" : `${result}A`;
|
|
1257
1284
|
productTemp.images_status =
|
|
1258
|
-
productTemp.images_status === "
|
|
1285
|
+
productTemp.images_status === "NS" ? "NS" : `${result}A`;
|
|
1259
1286
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
1260
1287
|
setProduct(productTemp);
|
|
1288
|
+
const messagesResponse = await Promise.all(messages);
|
|
1261
1289
|
|
|
1262
1290
|
await loadData();
|
|
1263
1291
|
} catch (error) {
|
|
@@ -1273,8 +1301,10 @@ export const RetailerProductEdition = ({
|
|
|
1273
1301
|
setCompare={setCompare}
|
|
1274
1302
|
isAuditor={[1, 6].includes(user.id_role)}
|
|
1275
1303
|
withChat={location?.state?.withChat}
|
|
1276
|
-
|
|
1304
|
+
chatType={location?.state?.chatType}
|
|
1305
|
+
productSelected={product}
|
|
1277
1306
|
token={token}
|
|
1307
|
+
activeRetailer={activeRetailer}
|
|
1278
1308
|
/>
|
|
1279
1309
|
<div className="data-container">
|
|
1280
1310
|
<div className="image-data-panel">
|
|
@@ -1314,36 +1344,7 @@ export const RetailerProductEdition = ({
|
|
|
1314
1344
|
sendToFacilitator("A");
|
|
1315
1345
|
}}
|
|
1316
1346
|
reject={() => {
|
|
1317
|
-
|
|
1318
|
-
setMessage("Rechazado");
|
|
1319
|
-
setComponentsArray([
|
|
1320
|
-
<img src={errorModal} />,
|
|
1321
|
-
<ScreenHeader
|
|
1322
|
-
text={"Agrega tu comentarios para enviar el rechazo"}
|
|
1323
|
-
headerType={"input-name-header"}
|
|
1324
|
-
color={"white"}
|
|
1325
|
-
/>,
|
|
1326
|
-
<TagAndInput
|
|
1327
|
-
label={"Caja de Comentario"}
|
|
1328
|
-
inputType={"textarea"}
|
|
1329
|
-
inputId={"modal-commentary-box"}
|
|
1330
|
-
index={0}
|
|
1331
|
-
color={"white"}
|
|
1332
|
-
/>,
|
|
1333
|
-
<Button
|
|
1334
|
-
buttonType={"general-default-button"}
|
|
1335
|
-
label={"Enviar comentario"}
|
|
1336
|
-
onClick={(e) =>
|
|
1337
|
-
createComment(
|
|
1338
|
-
e,
|
|
1339
|
-
document.querySelector(
|
|
1340
|
-
"#modal-commentary-box .ql-container .ql-editor > p"
|
|
1341
|
-
).innerHTML,
|
|
1342
|
-
activeTab
|
|
1343
|
-
)
|
|
1344
|
-
}
|
|
1345
|
-
/>,
|
|
1346
|
-
]);
|
|
1347
|
+
setShowRejectModal(true);
|
|
1347
1348
|
}}
|
|
1348
1349
|
showApproveRejectAll={
|
|
1349
1350
|
approveRejectAllButtons() && (auditorAssigned() || userAssigned())
|
|
@@ -1353,36 +1354,8 @@ export const RetailerProductEdition = ({
|
|
|
1353
1354
|
}
|
|
1354
1355
|
approveAll={() => validateAll("A")}
|
|
1355
1356
|
rejectAll={() => {
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
setComponentsArray([
|
|
1359
|
-
<img src={errorModal} />,
|
|
1360
|
-
<ScreenHeader
|
|
1361
|
-
text={"Agrega tu comentarios para enviar el rechazo"}
|
|
1362
|
-
headerType={"input-name-header"}
|
|
1363
|
-
color={"white"}
|
|
1364
|
-
/>,
|
|
1365
|
-
<TagAndInput
|
|
1366
|
-
label={"Caja de Comentario"}
|
|
1367
|
-
inputType={"textarea"}
|
|
1368
|
-
inputId={"modal-commentary-box"}
|
|
1369
|
-
index={0}
|
|
1370
|
-
color={"white"}
|
|
1371
|
-
/>,
|
|
1372
|
-
<Button
|
|
1373
|
-
buttonType={"general-default-button"}
|
|
1374
|
-
label={"Enviar comentario"}
|
|
1375
|
-
onClick={(e) =>
|
|
1376
|
-
createComment(
|
|
1377
|
-
e,
|
|
1378
|
-
document.querySelector(
|
|
1379
|
-
"#modal-commentary-box .ql-container .ql-editor > p"
|
|
1380
|
-
).innerHTML,
|
|
1381
|
-
activeTab
|
|
1382
|
-
)
|
|
1383
|
-
}
|
|
1384
|
-
/>,
|
|
1385
|
-
]);
|
|
1357
|
+
setShowRejectModal(true);
|
|
1358
|
+
setValRejAll(true);
|
|
1386
1359
|
}}
|
|
1387
1360
|
/>
|
|
1388
1361
|
<FullTabsMenu
|
|
@@ -1503,47 +1476,6 @@ export const RetailerProductEdition = ({
|
|
|
1503
1476
|
{(userAssigned(activeTab) || auditorAssigned()) &&
|
|
1504
1477
|
product[`${getConcept(activeTab)}_status`] !== "NS" && (
|
|
1505
1478
|
<div className="commentary-box">
|
|
1506
|
-
{!comment ? (
|
|
1507
|
-
<div className="commentary">
|
|
1508
|
-
<TagAndInput
|
|
1509
|
-
label={"Caja de Comentario"}
|
|
1510
|
-
inputType={"textarea"}
|
|
1511
|
-
inputCols={80}
|
|
1512
|
-
inputRows={4}
|
|
1513
|
-
inputId={"commentary-box"}
|
|
1514
|
-
index={0}
|
|
1515
|
-
/>
|
|
1516
|
-
<div className="buttons-box">
|
|
1517
|
-
<Button
|
|
1518
|
-
buttonType={"general-transparent-button"}
|
|
1519
|
-
label={"Enviar comentario"}
|
|
1520
|
-
onClick={(e) =>
|
|
1521
|
-
createComment(
|
|
1522
|
-
e,
|
|
1523
|
-
document.querySelector(
|
|
1524
|
-
"#commentary-box .ql-container .ql-editor > p"
|
|
1525
|
-
).innerHTML,
|
|
1526
|
-
activeTab
|
|
1527
|
-
)
|
|
1528
|
-
}
|
|
1529
|
-
/>
|
|
1530
|
-
</div>
|
|
1531
|
-
</div>
|
|
1532
|
-
) : (
|
|
1533
|
-
<div className="feedback-box">
|
|
1534
|
-
<Commentary
|
|
1535
|
-
comment={comment?.message?.replace(/<.*?\/?>/gm, "")}
|
|
1536
|
-
reviewed={crossComment}
|
|
1537
|
-
/>
|
|
1538
|
-
<Button
|
|
1539
|
-
buttonType={"circular-button accept-button"}
|
|
1540
|
-
onClick={async () => {
|
|
1541
|
-
setCrossComment(true);
|
|
1542
|
-
commentRevised();
|
|
1543
|
-
}}
|
|
1544
|
-
/>
|
|
1545
|
-
</div>
|
|
1546
|
-
)}
|
|
1547
1479
|
{[7, 8].includes(user.id_role) && (
|
|
1548
1480
|
<Button
|
|
1549
1481
|
buttonType={
|
|
@@ -1601,6 +1533,50 @@ export const RetailerProductEdition = ({
|
|
|
1601
1533
|
jwt={token}
|
|
1602
1534
|
/>
|
|
1603
1535
|
)}
|
|
1536
|
+
{showRejectModal && (
|
|
1537
|
+
<Modal
|
|
1538
|
+
title={"Agregar mensaje de rechazo"}
|
|
1539
|
+
show={showRejectModal}
|
|
1540
|
+
customComponent={
|
|
1541
|
+
<TagAndInput
|
|
1542
|
+
label={"Caja de Comentario"}
|
|
1543
|
+
inputType={"textarea"}
|
|
1544
|
+
inputId={"modal-message-box"}
|
|
1545
|
+
index={0}
|
|
1546
|
+
color={"white"}
|
|
1547
|
+
/>
|
|
1548
|
+
}
|
|
1549
|
+
buttons={[
|
|
1550
|
+
<ButtonV2
|
|
1551
|
+
key={"btn-Cancelar"}
|
|
1552
|
+
type={"white"}
|
|
1553
|
+
label={"Cancelar"}
|
|
1554
|
+
size={12}
|
|
1555
|
+
onClick={() => {
|
|
1556
|
+
setShowRejectModal(false);
|
|
1557
|
+
}}
|
|
1558
|
+
/>,
|
|
1559
|
+
<ButtonV2
|
|
1560
|
+
key={"btn-Aceptar"}
|
|
1561
|
+
type={"pink"}
|
|
1562
|
+
label={"Aceptar"}
|
|
1563
|
+
size={12}
|
|
1564
|
+
onClick={async () => {
|
|
1565
|
+
const body = document.querySelector(
|
|
1566
|
+
"#modal-message-box .ql-container .ql-editor > p"
|
|
1567
|
+
).innerHTML;
|
|
1568
|
+
const messages = [
|
|
1569
|
+
{ type: "message", value: body?.replace(/<.*?\/?>/gm, "") },
|
|
1570
|
+
];
|
|
1571
|
+
await createComment(messages, activeRetailer.id);
|
|
1572
|
+
valRejAll ? validateAll("R") : sendToFacilitator("R");
|
|
1573
|
+
setMessage("Rechazado");
|
|
1574
|
+
setShowRejectModal(false);
|
|
1575
|
+
}}
|
|
1576
|
+
/>,
|
|
1577
|
+
]}
|
|
1578
|
+
/>
|
|
1579
|
+
)}
|
|
1604
1580
|
</Container>
|
|
1605
1581
|
);
|
|
1606
1582
|
};
|