contentoh-components-library 21.1.29 → 21.1.30

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.
@@ -77,7 +77,6 @@ export const RetailerProductEdition = ({
77
77
  tabsSections,
78
78
  productSelected = {},
79
79
  user = {},
80
- location = {},
81
80
  token,
82
81
  }) => {
83
82
  const [activeTab, setActiveTab] = useState("Descripción");
@@ -165,6 +164,7 @@ export const RetailerProductEdition = ({
165
164
  const [socketType, setSocketType] = useState(null);
166
165
  const [servicesStatus, setServicesStatus] = useState([]);
167
166
  const [saving, setSaving] = useState(loading);
167
+ const isAuditor = user.id_role === 6;
168
168
 
169
169
  useEffect(() => {
170
170
  checkAll && setSelectedImages(images.values);
@@ -425,7 +425,6 @@ export const RetailerProductEdition = ({
425
425
  articleId: product?.article?.id_article,
426
426
  articleData: updatedDatasheets,
427
427
  };
428
- console.log(updatedDatasheets, "updatedDatasheets");
429
428
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
430
429
  try {
431
430
  await axios.put(
@@ -1082,6 +1081,66 @@ export const RetailerProductEdition = ({
1082
1081
  setSaving(loading);
1083
1082
  }, [loading]);
1084
1083
 
1084
+ const validateAll = async (result) => {
1085
+ try {
1086
+ setLoading(true);
1087
+ const evaluationArray = [];
1088
+ const sendAll = [];
1089
+ const conceptArray = ["description", "datasheet", "images"];
1090
+
1091
+ servicesData?.forEach((ret) => {
1092
+ let data = {
1093
+ articleId: product.article.id_article,
1094
+ orderId: product.id_order ?? product.orderId,
1095
+ concept: ret.service,
1096
+ result: result,
1097
+ evalStatus: product[`${ret.service}_status`],
1098
+ retailerId: ret.id_retailer,
1099
+ };
1100
+ evaluationArray.push(
1101
+ axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
1102
+ headers: {
1103
+ Authorization: token,
1104
+ },
1105
+ })
1106
+ );
1107
+ });
1108
+
1109
+ await Promise.all(evaluationArray);
1110
+
1111
+ conceptArray?.forEach((concept) => {
1112
+ let data = {
1113
+ articleId: product.article.id_article,
1114
+ orderId: product.id_order ?? product.orderId,
1115
+ concept,
1116
+ evalStatus: product[`${concept}_status`],
1117
+ };
1118
+ sendAll.push(
1119
+ axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
1120
+ headers: {
1121
+ Authorization: token,
1122
+ },
1123
+ })
1124
+ );
1125
+ });
1126
+ await Promise.all(sendAll);
1127
+ const productTemp = product;
1128
+ productTemp.status = `${result}A`;
1129
+ productTemp.datasheet_status =
1130
+ productTemp.datasheet_status === "NA" ? "NA" : `${result}A`;
1131
+ productTemp.description_status =
1132
+ productTemp.description_status === "NA" ? "NA" : `${result}A`;
1133
+ productTemp.images_status =
1134
+ productTemp.images_status === "NA" ? "NA" : `${result}A`;
1135
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1136
+ setProduct(productTemp);
1137
+
1138
+ loadData();
1139
+ } catch (error) {
1140
+ console.log(error);
1141
+ }
1142
+ };
1143
+
1085
1144
  return (
1086
1145
  <Container headerTop={headerTop}>
1087
1146
  <HeaderTop setHeaderTop={setHeaderTop} />
@@ -1151,9 +1210,50 @@ export const RetailerProductEdition = ({
1151
1210
  />,
1152
1211
  ]);
1153
1212
  }}
1213
+ showApproveRejectAll={
1214
+ isAuditor &&
1215
+ servicesData.every((serv) =>
1216
+ ["RA", "AA", "AP", "AC", "AF"].includes(serv.status)
1217
+ ) &&
1218
+ approveRejectButtons() &&
1219
+ (auditorAssigned() || userAssigned())
1220
+ }
1154
1221
  showValidationButtons={
1155
1222
  approveRejectButtons() && (auditorAssigned() || userAssigned())
1156
1223
  }
1224
+ approveAll={() => validateAll("A")}
1225
+ rejectAll={() => {
1226
+ validateAll("R");
1227
+ setMessage("Rechazado");
1228
+ setComponentsArray([
1229
+ <img src={errorModal} />,
1230
+ <ScreenHeader
1231
+ text={"Agrega tu comentarios para enviar el rechazo"}
1232
+ headerType={"input-name-header"}
1233
+ color={"white"}
1234
+ />,
1235
+ <TagAndInput
1236
+ label={"Caja de Comentario"}
1237
+ inputType={"textarea"}
1238
+ inputId={"modal-commentary-box"}
1239
+ index={0}
1240
+ color={"white"}
1241
+ />,
1242
+ <Button
1243
+ buttonType={"general-default-button"}
1244
+ label={"Enviar comentario"}
1245
+ onClick={(e) =>
1246
+ createComment(
1247
+ e,
1248
+ document.querySelector(
1249
+ "#modal-commentary-box .ql-container .ql-editor > p"
1250
+ ).innerHTML,
1251
+ activeTab
1252
+ )
1253
+ }
1254
+ />,
1255
+ ]);
1256
+ }}
1157
1257
  />
1158
1258
  <FullTabsMenu
1159
1259
  tabsSections={tabsSections}
@@ -1349,4 +1449,4 @@ export const RetailerProductEdition = ({
1349
1449
  )}
1350
1450
  </Container>
1351
1451
  );
1352
- };
1452
+ };