contentoh-components-library 21.1.10 → 21.1.13
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/molecules/TableHeader/index.js +4 -2
- package/dist/components/organisms/ImageDataTable/index.js +3 -1
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +77 -87
- package/dist/components/pages/ProviderProductEdition/index.js +52 -302
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +49 -43
- package/dist/components/pages/RetailerProductEdition/index.js +99 -160
- package/package.json +1 -1
- package/src/components/molecules/TableHeader/index.js +2 -0
- package/src/components/organisms/ImageDataTable/index.js +2 -0
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +75 -90
- package/src/components/pages/ProviderProductEdition/index.js +18 -306
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +50 -43
- package/src/components/pages/RetailerProductEdition/index.js +99 -181
|
@@ -167,24 +167,28 @@ export const RetailerProductEdition = ({
|
|
|
167
167
|
}, [checkAll]);
|
|
168
168
|
|
|
169
169
|
const loadData = async () => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
170
|
+
try {
|
|
171
|
+
const services = await getRetailerServices(
|
|
172
|
+
product?.article?.id_article,
|
|
173
|
+
parseInt(product?.article?.id_category),
|
|
174
|
+
product?.version
|
|
175
|
+
);
|
|
176
|
+
//Converts the data inside the datasheets object to array
|
|
177
|
+
setServices(services);
|
|
178
|
+
getServices();
|
|
179
|
+
|
|
180
|
+
//setActiveRetailer(product?.retailers[0]);
|
|
181
|
+
setImages({
|
|
182
|
+
action: "init",
|
|
183
|
+
init: services[2],
|
|
184
|
+
});
|
|
185
|
+
if (services[2]?.values?.length > 0) setActiveImage(0);
|
|
185
186
|
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
getPercentage({ data: [product] }).then((res) => setPercentages(res));
|
|
188
|
+
setLoading(false);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.log(error);
|
|
191
|
+
}
|
|
188
192
|
};
|
|
189
193
|
|
|
190
194
|
const getServices = async () => {
|
|
@@ -194,6 +198,12 @@ export const RetailerProductEdition = ({
|
|
|
194
198
|
}&orderId=${product?.article?.id_order || product.orderId}&end=true`
|
|
195
199
|
);
|
|
196
200
|
const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
|
|
201
|
+
|
|
202
|
+
let retailers = product.retailers || product.retailersAvailable;
|
|
203
|
+
let active = retailers?.filter((retailer) =>
|
|
204
|
+
parsedResponse?.map((srv) => srv.id_retailer).includes(retailer.id)
|
|
205
|
+
)[0];
|
|
206
|
+
!activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
|
|
197
207
|
setServicesData(parsedResponse);
|
|
198
208
|
};
|
|
199
209
|
|
|
@@ -236,16 +246,6 @@ export const RetailerProductEdition = ({
|
|
|
236
246
|
|
|
237
247
|
useEffect(async () => {
|
|
238
248
|
loadData();
|
|
239
|
-
// getPercentage({ data: [product] }).then((res) =>
|
|
240
|
-
// setPercentages(res)
|
|
241
|
-
// );
|
|
242
|
-
setActiveRetailer((current) =>
|
|
243
|
-
current.id
|
|
244
|
-
? current
|
|
245
|
-
: product.retailers
|
|
246
|
-
? product.retailers[0]
|
|
247
|
-
: product.retailersAvailable[0]
|
|
248
|
-
);
|
|
249
249
|
getComments();
|
|
250
250
|
setUserGroups(await fetchUsers(token));
|
|
251
251
|
let arr = [];
|
|
@@ -353,7 +353,7 @@ export const RetailerProductEdition = ({
|
|
|
353
353
|
}, [activeRetailer, services]);
|
|
354
354
|
|
|
355
355
|
const thumbs = () => {
|
|
356
|
-
const imageInputs = socketType
|
|
356
|
+
const imageInputs = socketType?.slice();
|
|
357
357
|
const imageType = images?.imageType?.map((e) => ({
|
|
358
358
|
value: e?.id,
|
|
359
359
|
name: e?.name,
|
|
@@ -777,7 +777,8 @@ export const RetailerProductEdition = ({
|
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
return (
|
|
780
|
-
|
|
780
|
+
user.id_role === 1 ||
|
|
781
|
+
(product.article[`id_${concept}_${rol}`] === user.id_user && validUser)
|
|
781
782
|
);
|
|
782
783
|
};
|
|
783
784
|
|
|
@@ -817,75 +818,81 @@ export const RetailerProductEdition = ({
|
|
|
817
818
|
};
|
|
818
819
|
|
|
819
820
|
const getRequired = (services) => {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
(
|
|
830
|
-
srv
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
requested &&
|
|
834
|
-
Object.values(datasheet?.data).forEach((dataGroup) =>
|
|
835
|
-
dsInputsRequired.push(
|
|
836
|
-
...dataGroup.inputs.filter(
|
|
837
|
-
(input) =>
|
|
838
|
-
dsInputs[input].required &&
|
|
839
|
-
(dsInputs[input].value === undefined || !dsInputs[input].value)
|
|
840
|
-
)
|
|
841
|
-
)
|
|
821
|
+
try {
|
|
822
|
+
const objetcTemp = {};
|
|
823
|
+
const datasheetServicesArray = Object.values(services[0]);
|
|
824
|
+
const dsInputs = datasheetServicesArray.pop();
|
|
825
|
+
const descriptionsServicesArray = services[1];
|
|
826
|
+
|
|
827
|
+
let dsInputsRequired = [];
|
|
828
|
+
let desInputsRequired = 0;
|
|
829
|
+
datasheetServicesArray?.forEach((datasheet) => {
|
|
830
|
+
const [requested] = servicesData?.filter(
|
|
831
|
+
(srv) =>
|
|
832
|
+
srv.id_retailer === datasheet.retailer.id &&
|
|
833
|
+
srv.service === getConcept(activeTab)
|
|
842
834
|
);
|
|
843
|
-
|
|
835
|
+
requested &&
|
|
836
|
+
datasheet?.data &&
|
|
837
|
+
Object.values(datasheet?.data).forEach((dataGroup) =>
|
|
838
|
+
dsInputsRequired.push(
|
|
839
|
+
...dataGroup.inputs.filter(
|
|
840
|
+
(input) =>
|
|
841
|
+
dsInputs[input].required &&
|
|
842
|
+
(dsInputs[input].value === undefined ||
|
|
843
|
+
!dsInputs[input].value)
|
|
844
|
+
)
|
|
845
|
+
)
|
|
846
|
+
);
|
|
847
|
+
});
|
|
844
848
|
|
|
845
|
-
|
|
849
|
+
objetcTemp["Ficha técnica"] = dsInputsRequired.length;
|
|
846
850
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
);
|
|
853
|
-
requested &&
|
|
854
|
-
description.inputs.forEach(
|
|
855
|
-
(input) =>
|
|
856
|
-
input.required &&
|
|
857
|
-
(!input.value ||
|
|
858
|
-
input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") ===
|
|
859
|
-
"") &&
|
|
860
|
-
desInputsRequired++
|
|
851
|
+
descriptionsServicesArray.forEach((description) => {
|
|
852
|
+
const [requested] = servicesData.filter(
|
|
853
|
+
(srv) =>
|
|
854
|
+
srv.id_retailer === description.id &&
|
|
855
|
+
srv.service === getConcept(activeTab)
|
|
861
856
|
);
|
|
862
|
-
|
|
857
|
+
requested &&
|
|
858
|
+
description.inputs.forEach(
|
|
859
|
+
(input) =>
|
|
860
|
+
input.required &&
|
|
861
|
+
(!input.value ||
|
|
862
|
+
input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") ===
|
|
863
|
+
"") &&
|
|
864
|
+
desInputsRequired++
|
|
865
|
+
);
|
|
866
|
+
});
|
|
863
867
|
|
|
864
|
-
|
|
868
|
+
objetcTemp["Descripción"] = desInputsRequired;
|
|
865
869
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
870
|
+
const retailersRequested = [];
|
|
871
|
+
services[2]?.retailerMandatories?.forEach((retMan) =>
|
|
872
|
+
retMan.forEach((rm) => retailersRequested.push(rm))
|
|
873
|
+
);
|
|
874
|
+
const requiredImages = services[2]?.inputs?.filter(
|
|
875
|
+
(e) =>
|
|
876
|
+
e.required === 1 &&
|
|
877
|
+
retailersRequested.filter(
|
|
878
|
+
(ret) =>
|
|
879
|
+
ret.id_image === e.id &&
|
|
880
|
+
servicesData.filter((srv) => srv.id_retailer === ret.id_retailer)
|
|
881
|
+
.length > 0
|
|
882
|
+
).length > 0
|
|
883
|
+
);
|
|
880
884
|
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
885
|
+
let requiredCounter = 0;
|
|
886
|
+
requiredImages?.forEach(
|
|
887
|
+
(req) =>
|
|
888
|
+
services[2].values.filter((img) => img.image_id === req.id).length ===
|
|
889
|
+
0 && requiredCounter++
|
|
890
|
+
);
|
|
891
|
+
objetcTemp["Imágenes"] = requiredCounter;
|
|
892
|
+
setRequiredNull(objetcTemp);
|
|
893
|
+
} catch (error) {
|
|
894
|
+
console.log(error);
|
|
895
|
+
}
|
|
889
896
|
};
|
|
890
897
|
|
|
891
898
|
useEffect(() => {
|
|
@@ -943,76 +950,6 @@ export const RetailerProductEdition = ({
|
|
|
943
950
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
944
951
|
};
|
|
945
952
|
|
|
946
|
-
const evaluationComplete = () => {
|
|
947
|
-
let concept = "";
|
|
948
|
-
switch (activeTab) {
|
|
949
|
-
case "Ficha técnica":
|
|
950
|
-
concept = "datasheet";
|
|
951
|
-
break;
|
|
952
|
-
case "Imágenes":
|
|
953
|
-
concept = "images";
|
|
954
|
-
break;
|
|
955
|
-
case "Descripción":
|
|
956
|
-
concept = "description";
|
|
957
|
-
break;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
let serv = servicesData.filter((item) => item.service === concept);
|
|
961
|
-
let approved = "";
|
|
962
|
-
let rejected = "";
|
|
963
|
-
if (
|
|
964
|
-
product.status === "IN_PROGRESS" ||
|
|
965
|
-
product.status === "QF" ||
|
|
966
|
-
product.status === "RF"
|
|
967
|
-
) {
|
|
968
|
-
approved = "AF";
|
|
969
|
-
rejected = "RF";
|
|
970
|
-
if (product.status === "IN_PROGRESS" || product.status === "QF") {
|
|
971
|
-
return (
|
|
972
|
-
serv.filter(
|
|
973
|
-
(item) =>
|
|
974
|
-
item.status === approved ||
|
|
975
|
-
item.status === rejected ||
|
|
976
|
-
item.status === "AA" ||
|
|
977
|
-
item.status === "IN_PROGRESS" ||
|
|
978
|
-
item.status === "AP"
|
|
979
|
-
).length === serv.length
|
|
980
|
-
);
|
|
981
|
-
}
|
|
982
|
-
} else if (
|
|
983
|
-
product.status === "AF" ||
|
|
984
|
-
product.status === "RA" ||
|
|
985
|
-
product.status === "RP"
|
|
986
|
-
) {
|
|
987
|
-
approved = "AA";
|
|
988
|
-
rejected = "RA";
|
|
989
|
-
|
|
990
|
-
if (product.status === "RP" || product.status === "AF") {
|
|
991
|
-
return (
|
|
992
|
-
serv.filter(
|
|
993
|
-
(item) =>
|
|
994
|
-
item.status === approved ||
|
|
995
|
-
item.status === rejected ||
|
|
996
|
-
item.status === "AP"
|
|
997
|
-
).length === serv.length
|
|
998
|
-
);
|
|
999
|
-
}
|
|
1000
|
-
} else if (product.status === "RC") {
|
|
1001
|
-
approved = "AP";
|
|
1002
|
-
rejected = "RA";
|
|
1003
|
-
return (
|
|
1004
|
-
serv.filter(
|
|
1005
|
-
(item) => item.status === approved || item.status === rejected
|
|
1006
|
-
).length === serv.length
|
|
1007
|
-
);
|
|
1008
|
-
}
|
|
1009
|
-
return (
|
|
1010
|
-
serv.filter(
|
|
1011
|
-
(item) => item.status === approved || item.status === rejected
|
|
1012
|
-
).length === serv.length
|
|
1013
|
-
);
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
953
|
const downloadImages = () => {
|
|
1017
954
|
selectedImages.forEach((e) => {
|
|
1018
955
|
if (e.id) {
|
|
@@ -1103,26 +1040,6 @@ export const RetailerProductEdition = ({
|
|
|
1103
1040
|
}
|
|
1104
1041
|
};
|
|
1105
1042
|
|
|
1106
|
-
const specialistValid = (tab) => {
|
|
1107
|
-
let concept = "";
|
|
1108
|
-
switch (tab) {
|
|
1109
|
-
case "Ficha técnica":
|
|
1110
|
-
concept = "datasheet";
|
|
1111
|
-
break;
|
|
1112
|
-
case "Imágenes":
|
|
1113
|
-
concept = "images";
|
|
1114
|
-
break;
|
|
1115
|
-
case "Descripción":
|
|
1116
|
-
concept = "description";
|
|
1117
|
-
break;
|
|
1118
|
-
}
|
|
1119
|
-
return (
|
|
1120
|
-
product[`${concept}_status`] === "IN_PROGRESS" ||
|
|
1121
|
-
product[`${concept}_status`] === "RF" ||
|
|
1122
|
-
product[`${concept}_status`] === "RA"
|
|
1123
|
-
);
|
|
1124
|
-
};
|
|
1125
|
-
|
|
1126
1043
|
const getRetailerStatus = (servicesData, tab) => {
|
|
1127
1044
|
const arr = servicesData?.slice();
|
|
1128
1045
|
let concept = getConcept(tab);
|
|
@@ -1172,6 +1089,7 @@ export const RetailerProductEdition = ({
|
|
|
1172
1089
|
onClickSave={() =>
|
|
1173
1090
|
product?.services?.images === 1 && updateImages()
|
|
1174
1091
|
}
|
|
1092
|
+
showSaveButton={userAssigned()}
|
|
1175
1093
|
/>
|
|
1176
1094
|
</div>
|
|
1177
1095
|
<div className="product-information">
|