contentoh-components-library 21.0.92 → 21.0.97
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/atoms/AsignationOption/index.js +31 -2
- package/dist/components/atoms/AsignationOption/styles.js +1 -1
- package/dist/components/atoms/InputFormatter/index.js +1 -1
- package/dist/components/atoms/StatusTag/styles.js +1 -1
- package/dist/components/molecules/RetailerSelector/index.js +5 -2
- package/dist/components/molecules/StatusAsignationInfo/index.js +1 -1
- package/dist/components/organisms/FullProductNameHeader/index.js +29 -2
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +44 -114
- package/dist/components/pages/ProviderProductEdition/index.js +75 -44
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +44 -44
- package/dist/components/pages/RetailerProductEdition/index.js +83 -45
- package/package.json +1 -1
- package/src/components/atoms/AsignationOption/index.js +21 -0
- package/src/components/atoms/AsignationOption/styles.js +6 -0
- package/src/components/atoms/InputFormatter/index.js +1 -1
- package/src/components/atoms/StatusTag/styles.js +2 -1
- package/src/components/molecules/RetailerSelector/index.js +3 -0
- package/src/components/molecules/StatusAsignationInfo/index.js +8 -6
- package/src/components/organisms/FullProductNameHeader/index.js +19 -1
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +48 -133
- package/src/components/pages/ProviderProductEdition/index.js +50 -23
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +44 -44
- package/src/components/pages/RetailerProductEdition/index.js +60 -19
|
@@ -21,147 +21,62 @@ ProviderProductEditionDefault.args = {
|
|
|
21
21
|
category: 846,
|
|
22
22
|
version: 2,
|
|
23
23
|
productSelected: {
|
|
24
|
-
|
|
25
|
-
id_category: "
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
datasheet: 33,
|
|
35
|
-
descriptions: 14,
|
|
36
|
-
images: 3,
|
|
37
|
-
},
|
|
38
|
-
article: {
|
|
39
|
-
category: "SALUD Y BELLEZA|CUIDADO BUCAL|PASTAS DENTALES Y ASEO BUCAL",
|
|
40
|
-
company_name: "COMPANY DEV",
|
|
41
|
-
id_category: "684",
|
|
42
|
-
id_article: 33249,
|
|
43
|
-
name: "Crema dental ",
|
|
44
|
-
timestamp: "2022-06-14T23:24:08.000Z",
|
|
45
|
-
upc: "232435",
|
|
46
|
-
},
|
|
47
|
-
retailers: [
|
|
48
|
-
{
|
|
49
|
-
id: 4,
|
|
50
|
-
name: "Walmart Super y Superama",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: 9,
|
|
54
|
-
name: "Amazon",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 1013,
|
|
58
|
-
name: "Cencosud Colombia",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: 2005,
|
|
62
|
-
name: "ClubCo",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
services: {
|
|
66
|
-
datasheets: 1,
|
|
67
|
-
descriptions: 1,
|
|
68
|
-
images: 1,
|
|
69
|
-
},
|
|
24
|
+
id_article: 35319,
|
|
25
|
+
id_category: "2146",
|
|
26
|
+
name: "FOCO LED A19 (60W) LUZ AMARILLA",
|
|
27
|
+
upc: "120873",
|
|
28
|
+
timestamp: "2022-06-14T15:31:50.000Z",
|
|
29
|
+
status: "NULL",
|
|
30
|
+
categoryName: "ILUMINACIÓN|FOCOS|LEDS",
|
|
31
|
+
asignations: [],
|
|
32
|
+
version: 2,
|
|
33
|
+
version_status: "AA",
|
|
70
34
|
retailersAvailable: [
|
|
71
35
|
{
|
|
72
|
-
id:
|
|
73
|
-
name: "
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
name: "Amazon",
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: 1013,
|
|
81
|
-
name: "Cencosud Colombia",
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: 2005,
|
|
85
|
-
name: "ClubCo",
|
|
36
|
+
id: 58,
|
|
37
|
+
name: "The Home Depot Golden",
|
|
38
|
+
country: "México",
|
|
39
|
+
id_region: 1,
|
|
40
|
+
active: 1,
|
|
86
41
|
},
|
|
87
42
|
],
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
43
|
+
missing: {
|
|
44
|
+
datasheet: 33,
|
|
45
|
+
description: 0,
|
|
46
|
+
image: 23,
|
|
47
|
+
},
|
|
91
48
|
},
|
|
92
49
|
productToEdit: {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
product:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
id: 4,
|
|
122
|
-
name: "Walmart Super y Superama",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
id: 9,
|
|
126
|
-
name: "Amazon",
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: 1013,
|
|
130
|
-
name: "Cencosud Colombia",
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: 2005,
|
|
134
|
-
name: "ClubCo",
|
|
50
|
+
idCategory: "2146",
|
|
51
|
+
ArticleId: 35319,
|
|
52
|
+
product: [
|
|
53
|
+
{
|
|
54
|
+
id_article: 35319,
|
|
55
|
+
id_category: "2146",
|
|
56
|
+
name: "FOCO LED A19 (60W) LUZ AMARILLA",
|
|
57
|
+
upc: "120873",
|
|
58
|
+
timestamp: "2022-06-14T15:31:50.000Z",
|
|
59
|
+
status: "NULL",
|
|
60
|
+
categoryName: "ILUMINACIÓN|FOCOS|LEDS",
|
|
61
|
+
asignations: [],
|
|
62
|
+
version: 2,
|
|
63
|
+
version_status: "AA",
|
|
64
|
+
retailersAvailable: [
|
|
65
|
+
{
|
|
66
|
+
id: 58,
|
|
67
|
+
name: "The Home Depot Golden",
|
|
68
|
+
country: "México",
|
|
69
|
+
id_region: 1,
|
|
70
|
+
active: 1,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
missing: {
|
|
74
|
+
datasheet: 33,
|
|
75
|
+
description: 0,
|
|
76
|
+
image: 23,
|
|
135
77
|
},
|
|
136
|
-
],
|
|
137
|
-
services: {
|
|
138
|
-
datasheets: 1,
|
|
139
|
-
descriptions: 1,
|
|
140
|
-
images: 1,
|
|
141
78
|
},
|
|
142
|
-
|
|
143
|
-
{
|
|
144
|
-
id: 4,
|
|
145
|
-
name: "Walmart Super y Superama",
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
id: 9,
|
|
149
|
-
name: "Amazon",
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
id: 1013,
|
|
153
|
-
name: "Cencosud Colombia",
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
id: 2005,
|
|
157
|
-
name: "ClubCo",
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
id_article: 33249,
|
|
161
|
-
categoryName:
|
|
162
|
-
"SALUD Y BELLEZA|CUIDADO BUCAL|PASTAS DENTALES Y ASEO BUCAL",
|
|
163
|
-
version_status: "RECEPTION",
|
|
164
|
-
},
|
|
79
|
+
],
|
|
165
80
|
},
|
|
166
81
|
location: {
|
|
167
82
|
product: { articleId: 109485, versionId: 3 },
|
|
@@ -48,6 +48,11 @@ const reducerImages = (state, action) => {
|
|
|
48
48
|
case "changeAttrValue":
|
|
49
49
|
attrForImgs[action.retailer][action.index].value = action.value;
|
|
50
50
|
return { ...state, attrForImgs, values };
|
|
51
|
+
case "deleteImage":
|
|
52
|
+
values = values.filter(
|
|
53
|
+
(value) => action.selectedImages.indexOf(value) === -1
|
|
54
|
+
);
|
|
55
|
+
return { ...state, values };
|
|
51
56
|
default:
|
|
52
57
|
return state;
|
|
53
58
|
}
|
|
@@ -195,6 +200,7 @@ export const ProviderProductEdition = ({
|
|
|
195
200
|
});
|
|
196
201
|
const [modalViewTextArea, setModalViewTextArea] = useState(false);
|
|
197
202
|
const [socketType, setSocketType] = useState(null);
|
|
203
|
+
const [saving, setSaving] = useState(loading);
|
|
198
204
|
|
|
199
205
|
useEffect(() => {
|
|
200
206
|
checkAll && setSelectedImages(images.values);
|
|
@@ -213,7 +219,7 @@ export const ProviderProductEdition = ({
|
|
|
213
219
|
//setActiveRetailer(product?.retailers[0]);
|
|
214
220
|
setImages({
|
|
215
221
|
action: "init",
|
|
216
|
-
init:
|
|
222
|
+
init: services[2],
|
|
217
223
|
});
|
|
218
224
|
if (services[2]?.values?.length > 0) setActiveImage(0);
|
|
219
225
|
|
|
@@ -361,7 +367,7 @@ export const ProviderProductEdition = ({
|
|
|
361
367
|
}, [activeRetailer, services]);
|
|
362
368
|
|
|
363
369
|
const thumbs = () => {
|
|
364
|
-
const imageInputs = socketType
|
|
370
|
+
const imageInputs = socketType?.slice();
|
|
365
371
|
const imageType = images?.imageType?.map((e) => ({
|
|
366
372
|
value: e?.id,
|
|
367
373
|
name: e?.name,
|
|
@@ -500,6 +506,7 @@ export const ProviderProductEdition = ({
|
|
|
500
506
|
});
|
|
501
507
|
}
|
|
502
508
|
if (valid && duplicated?.length === 0) {
|
|
509
|
+
setLoading(true);
|
|
503
510
|
try {
|
|
504
511
|
data?.articleData?.forEach((e) => {
|
|
505
512
|
e.uuid = uuidv4();
|
|
@@ -541,7 +548,6 @@ export const ProviderProductEdition = ({
|
|
|
541
548
|
|
|
542
549
|
useEffect(async () => {
|
|
543
550
|
if (imagesUploaded) {
|
|
544
|
-
setLoading(true);
|
|
545
551
|
dataImages.articleData = dataImages?.articleData.map((e) => {
|
|
546
552
|
delete e.src;
|
|
547
553
|
e.imageID = e.image_id;
|
|
@@ -858,7 +864,21 @@ export const ProviderProductEdition = ({
|
|
|
858
864
|
});
|
|
859
865
|
|
|
860
866
|
objetcTemp["Descripción"] = desInputsRequired;
|
|
861
|
-
const
|
|
867
|
+
const retailersRequested = [];
|
|
868
|
+
services[2]?.retailerMandatories?.forEach((retMan) =>
|
|
869
|
+
retMan.forEach((rm) => retailersRequested.push(rm))
|
|
870
|
+
);
|
|
871
|
+
const requiredImages = services[2]?.inputs?.filter(
|
|
872
|
+
(e) =>
|
|
873
|
+
e.required === 1 &&
|
|
874
|
+
retailersRequested.filter(
|
|
875
|
+
(ret) =>
|
|
876
|
+
ret.id_image === e.id &&
|
|
877
|
+
servicesData.filter((srv) => srv.id_retailer === ret.id_retailer)
|
|
878
|
+
.length > 0
|
|
879
|
+
).length > 0
|
|
880
|
+
);
|
|
881
|
+
|
|
862
882
|
let requiredCounter = 0;
|
|
863
883
|
requiredImages?.forEach(
|
|
864
884
|
(req) =>
|
|
@@ -955,7 +975,6 @@ export const ProviderProductEdition = ({
|
|
|
955
975
|
|
|
956
976
|
const deleteImages = () => {
|
|
957
977
|
setLoading(true);
|
|
958
|
-
const imagesTemp = images;
|
|
959
978
|
const { values } = images;
|
|
960
979
|
const imgsInBack = [];
|
|
961
980
|
|
|
@@ -967,12 +986,10 @@ export const ProviderProductEdition = ({
|
|
|
967
986
|
(value) => selectedImages.indexOf(value) === -1
|
|
968
987
|
);
|
|
969
988
|
|
|
970
|
-
imagesTemp.values = imgsLeft;
|
|
971
|
-
|
|
972
989
|
if (imgsInBack.length > 0) {
|
|
973
990
|
const data = {
|
|
974
|
-
articleId: product
|
|
975
|
-
deleteImages:
|
|
991
|
+
articleId: product?.id_article || product?.article?.id_article,
|
|
992
|
+
deleteImages: imgsInBack,
|
|
976
993
|
};
|
|
977
994
|
try {
|
|
978
995
|
axios.put(
|
|
@@ -986,8 +1003,16 @@ export const ProviderProductEdition = ({
|
|
|
986
1003
|
console.log(err);
|
|
987
1004
|
}
|
|
988
1005
|
}
|
|
989
|
-
|
|
990
|
-
|
|
1006
|
+
|
|
1007
|
+
setImages({
|
|
1008
|
+
action: "deleteImage",
|
|
1009
|
+
selectedImages,
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1012
|
+
setTimeout(() => {
|
|
1013
|
+
setLoading(false);
|
|
1014
|
+
}, 500);
|
|
1015
|
+
|
|
991
1016
|
setMessage("");
|
|
992
1017
|
setComponentsArray([]);
|
|
993
1018
|
};
|
|
@@ -1166,6 +1191,10 @@ export const ProviderProductEdition = ({
|
|
|
1166
1191
|
return true;
|
|
1167
1192
|
};
|
|
1168
1193
|
|
|
1194
|
+
useEffect(() => {
|
|
1195
|
+
setSaving(loading);
|
|
1196
|
+
}, [loading]);
|
|
1197
|
+
|
|
1169
1198
|
return (
|
|
1170
1199
|
<Container headerTop={headerTop}>
|
|
1171
1200
|
<HeaderTop setHeaderTop={setHeaderTop} />
|
|
@@ -1278,13 +1307,13 @@ export const ProviderProductEdition = ({
|
|
|
1278
1307
|
onClickSave={() => {
|
|
1279
1308
|
switch (activeTab) {
|
|
1280
1309
|
case "Descripción":
|
|
1281
|
-
saveDescriptions();
|
|
1310
|
+
!saving && saveDescriptions();
|
|
1282
1311
|
break;
|
|
1283
1312
|
case "Ficha técnica":
|
|
1284
|
-
saveDatasheets();
|
|
1313
|
+
!saving && saveDatasheets();
|
|
1285
1314
|
break;
|
|
1286
1315
|
case "Imágenes":
|
|
1287
|
-
updateImages();
|
|
1316
|
+
!saving && updateImages();
|
|
1288
1317
|
break;
|
|
1289
1318
|
default:
|
|
1290
1319
|
break;
|
|
@@ -1301,15 +1330,13 @@ export const ProviderProductEdition = ({
|
|
|
1301
1330
|
<Loading />
|
|
1302
1331
|
) : (
|
|
1303
1332
|
<>
|
|
1304
|
-
{!imageLayout &&
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
/>
|
|
1312
|
-
)}
|
|
1333
|
+
{!imageLayout && activeTab === "Imágenes" && (
|
|
1334
|
+
<GalleryHeader
|
|
1335
|
+
setSelectedImages={setSelectedImages}
|
|
1336
|
+
checkAll={checkAll}
|
|
1337
|
+
setCheckAll={setCheckAll}
|
|
1338
|
+
/>
|
|
1339
|
+
)}
|
|
1313
1340
|
{activeTab === "Ficha técnica" &&
|
|
1314
1341
|
(product?.datasheet_status !== "NS" ? (
|
|
1315
1342
|
datasheets[0]?.data?.map((dataGroup, index) => (
|
|
@@ -26,92 +26,92 @@ RetailerProductEditionDefault.args = {
|
|
|
26
26
|
descriptions: 1,
|
|
27
27
|
images: 1,
|
|
28
28
|
},
|
|
29
|
-
orderId:
|
|
30
|
-
status: "
|
|
31
|
-
datasheet_status:
|
|
29
|
+
orderId: 4,
|
|
30
|
+
status: "ASSIGNED",
|
|
31
|
+
datasheet_status: null,
|
|
32
32
|
prio: "none",
|
|
33
|
-
version:
|
|
34
|
-
description_status:
|
|
35
|
-
images_status:
|
|
33
|
+
version: 3,
|
|
34
|
+
description_status: null,
|
|
35
|
+
images_status: null,
|
|
36
36
|
article: {
|
|
37
|
-
id_article:
|
|
38
|
-
id_category: "
|
|
39
|
-
name: "
|
|
40
|
-
upc: "
|
|
41
|
-
timestamp: "2022-06-
|
|
42
|
-
id_user:
|
|
37
|
+
id_article: 33249,
|
|
38
|
+
id_category: "684",
|
|
39
|
+
name: "Crema dental ",
|
|
40
|
+
upc: "232435",
|
|
41
|
+
timestamp: "2022-06-14T14:52:51.000Z",
|
|
42
|
+
id_user: 28,
|
|
43
43
|
status: "NULL",
|
|
44
44
|
active: 1,
|
|
45
45
|
company_id: 1,
|
|
46
|
-
company_name: "
|
|
46
|
+
company_name: "COMPANY DEV",
|
|
47
47
|
country: "México",
|
|
48
|
-
id_order:
|
|
49
|
-
id_datasheet_especialist:
|
|
50
|
-
id_datasheet_facilitator:
|
|
51
|
-
id_description_especialist:
|
|
52
|
-
id_description_facilitator:
|
|
53
|
-
id_images_especialist:
|
|
54
|
-
id_images_facilitator:
|
|
55
|
-
id_auditor:
|
|
48
|
+
id_order: 4,
|
|
49
|
+
id_datasheet_especialist: null,
|
|
50
|
+
id_datasheet_facilitator: null,
|
|
51
|
+
id_description_especialist: null,
|
|
52
|
+
id_description_facilitator: null,
|
|
53
|
+
id_images_especialist: null,
|
|
54
|
+
id_images_facilitator: null,
|
|
55
|
+
id_auditor: 37,
|
|
56
56
|
id_recepcionist: null,
|
|
57
|
-
category: "
|
|
58
|
-
missingAttributes:
|
|
59
|
-
missingDescriptions:
|
|
60
|
-
missingImages:
|
|
57
|
+
category: "SALUD Y BELLEZA|CUIDADO BUCAL|PASTAS DENTALES Y ASEO BUCAL",
|
|
58
|
+
missingAttributes: 13,
|
|
59
|
+
missingDescriptions: 4,
|
|
60
|
+
missingImages: 3,
|
|
61
61
|
},
|
|
62
62
|
retailers: [
|
|
63
63
|
{
|
|
64
|
-
id:
|
|
65
|
-
name: "
|
|
64
|
+
id: 4,
|
|
65
|
+
name: "Walmart Super y Superama",
|
|
66
66
|
country: "México",
|
|
67
67
|
id_region: 1,
|
|
68
68
|
active: 1,
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
id:
|
|
72
|
-
name: "
|
|
71
|
+
id: 9,
|
|
72
|
+
name: "Amazon",
|
|
73
73
|
country: "México",
|
|
74
74
|
id_region: 1,
|
|
75
75
|
active: 1,
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
|
-
id:
|
|
79
|
-
name: "
|
|
80
|
-
country: "
|
|
81
|
-
id_region:
|
|
78
|
+
id: 1013,
|
|
79
|
+
name: "Cencosud Colombia",
|
|
80
|
+
country: "Colombia",
|
|
81
|
+
id_region: 2,
|
|
82
82
|
active: 1,
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
id:
|
|
86
|
-
name: "
|
|
87
|
-
country: "
|
|
88
|
-
id_region:
|
|
85
|
+
id: 2005,
|
|
86
|
+
name: "ClubCo",
|
|
87
|
+
country: "Costa Rica",
|
|
88
|
+
id_region: 3,
|
|
89
89
|
active: 1,
|
|
90
90
|
},
|
|
91
91
|
],
|
|
92
92
|
country: "México",
|
|
93
|
-
upc: "
|
|
93
|
+
upc: "232435",
|
|
94
94
|
},
|
|
95
95
|
location: {
|
|
96
96
|
product: { articleId: 109485, versionId: 3 },
|
|
97
97
|
},
|
|
98
98
|
user: {
|
|
99
|
-
id_user:
|
|
100
|
-
name: "
|
|
99
|
+
id_user: 54,
|
|
100
|
+
name: "ESPECIALISTA TXTS PRUEBA",
|
|
101
101
|
last_name: "",
|
|
102
|
-
email: "
|
|
102
|
+
email: "rlegorreta@contentoh.com",
|
|
103
103
|
position: null,
|
|
104
104
|
telephone: null,
|
|
105
105
|
country: null,
|
|
106
106
|
id_company: 2,
|
|
107
|
-
id_cognito: "
|
|
107
|
+
id_cognito: "ca1d24ab-e992-4c19-b4e1-2fe6f720c16b",
|
|
108
108
|
birth_Date: null,
|
|
109
109
|
about_me: null,
|
|
110
110
|
zip_code: null,
|
|
111
111
|
address: null,
|
|
112
112
|
job: null,
|
|
113
113
|
id_stripe: null,
|
|
114
|
-
id_role:
|
|
114
|
+
id_role: 7,
|
|
115
115
|
active: 1,
|
|
116
116
|
is_retailer: 0,
|
|
117
117
|
membership: {
|
|
@@ -125,6 +125,6 @@ RetailerProductEditionDefault.args = {
|
|
|
125
125
|
products_limit: "3",
|
|
126
126
|
type: "PyMES",
|
|
127
127
|
},
|
|
128
|
-
src: "https://content-management-profile.s3.amazonaws.com/id-
|
|
128
|
+
src: "https://content-management-profile.s3.amazonaws.com/id-54/54.png?1655433250522",
|
|
129
129
|
},
|
|
130
130
|
};
|
|
@@ -45,6 +45,11 @@ const reducerImages = (state, action) => {
|
|
|
45
45
|
case "changeAttrValue":
|
|
46
46
|
attrForImgs[action.retailer][action.index].value = action.value;
|
|
47
47
|
return { ...state, attrForImgs, values };
|
|
48
|
+
case "deleteImage":
|
|
49
|
+
values = values.filter(
|
|
50
|
+
(value) => action.selectedImages.indexOf(value) === -1
|
|
51
|
+
);
|
|
52
|
+
return { ...state, values };
|
|
48
53
|
default:
|
|
49
54
|
return state;
|
|
50
55
|
}
|
|
@@ -153,6 +158,8 @@ export const RetailerProductEdition = ({
|
|
|
153
158
|
const [retailerStatus, setRetailerStatus] = useState("-");
|
|
154
159
|
const [statusArray, setStatusArray] = useState([]);
|
|
155
160
|
const [socketType, setSocketType] = useState(null);
|
|
161
|
+
const [servicesStatus, setServicesStatus] = useState([]);
|
|
162
|
+
const [saving, setSaving] = useState(loading);
|
|
156
163
|
|
|
157
164
|
useEffect(() => {
|
|
158
165
|
checkAll && setSelectedImages(images.values);
|
|
@@ -166,18 +173,15 @@ export const RetailerProductEdition = ({
|
|
|
166
173
|
);
|
|
167
174
|
//Converts the data inside the datasheets object to array
|
|
168
175
|
setServices(services);
|
|
176
|
+
getServices();
|
|
169
177
|
|
|
170
178
|
//setActiveRetailer(product?.retailers[0]);
|
|
171
179
|
setImages({
|
|
172
180
|
action: "init",
|
|
173
|
-
init:
|
|
181
|
+
init: services[2],
|
|
174
182
|
});
|
|
175
183
|
if (services[2]?.values?.length > 0) setActiveImage(0);
|
|
176
184
|
|
|
177
|
-
setActiveRetailer(
|
|
178
|
-
product.retailers ? product.retailers[0] : product.retailersAvailable[0]
|
|
179
|
-
);
|
|
180
|
-
|
|
181
185
|
getPercentage({ data: [product] }).then((res) => setPercentages(res));
|
|
182
186
|
setLoading(false);
|
|
183
187
|
};
|
|
@@ -234,7 +238,9 @@ export const RetailerProductEdition = ({
|
|
|
234
238
|
// getPercentage({ data: [product] }).then((res) =>
|
|
235
239
|
// setPercentages(res)
|
|
236
240
|
// );
|
|
237
|
-
|
|
241
|
+
setActiveRetailer(
|
|
242
|
+
product.retailers ? product.retailers[0] : product.retailersAvailable[0]
|
|
243
|
+
);
|
|
238
244
|
getComments();
|
|
239
245
|
setUserGroups(await fetchUsers(token));
|
|
240
246
|
let arr = [];
|
|
@@ -483,6 +489,7 @@ export const RetailerProductEdition = ({
|
|
|
483
489
|
});
|
|
484
490
|
}
|
|
485
491
|
if (valid && duplicated?.length === 0) {
|
|
492
|
+
setLoading(true);
|
|
486
493
|
try {
|
|
487
494
|
data?.articleData?.forEach((e) => {
|
|
488
495
|
e.uuid = uuidv4();
|
|
@@ -524,7 +531,6 @@ export const RetailerProductEdition = ({
|
|
|
524
531
|
|
|
525
532
|
useEffect(async () => {
|
|
526
533
|
if (imagesUploaded) {
|
|
527
|
-
setLoading(true);
|
|
528
534
|
dataImages.articleData = dataImages?.articleData.map((e) => {
|
|
529
535
|
delete e.src;
|
|
530
536
|
e.imageID = e.image_id;
|
|
@@ -836,7 +842,22 @@ export const RetailerProductEdition = ({
|
|
|
836
842
|
});
|
|
837
843
|
|
|
838
844
|
objetcTemp["Descripción"] = desInputsRequired;
|
|
839
|
-
|
|
845
|
+
|
|
846
|
+
const retailersRequested = [];
|
|
847
|
+
services[2]?.retailerMandatories?.forEach((retMan) =>
|
|
848
|
+
retMan.forEach((rm) => retailersRequested.push(rm))
|
|
849
|
+
);
|
|
850
|
+
const requiredImages = services[2]?.inputs?.filter(
|
|
851
|
+
(e) =>
|
|
852
|
+
e.required === 1 &&
|
|
853
|
+
retailersRequested.filter(
|
|
854
|
+
(ret) =>
|
|
855
|
+
ret.id_image === e.id &&
|
|
856
|
+
servicesData.filter((srv) => srv.id_retailer === ret.id_retailer)
|
|
857
|
+
.length > 0
|
|
858
|
+
).length > 0
|
|
859
|
+
);
|
|
860
|
+
|
|
840
861
|
let requiredCounter = 0;
|
|
841
862
|
requiredImages?.forEach(
|
|
842
863
|
(req) =>
|
|
@@ -985,7 +1006,6 @@ export const RetailerProductEdition = ({
|
|
|
985
1006
|
|
|
986
1007
|
const deleteImages = () => {
|
|
987
1008
|
setLoading(true);
|
|
988
|
-
const imagesTemp = images;
|
|
989
1009
|
const { values } = images;
|
|
990
1010
|
const imgsInBack = [];
|
|
991
1011
|
|
|
@@ -997,12 +1017,10 @@ export const RetailerProductEdition = ({
|
|
|
997
1017
|
(value) => selectedImages.indexOf(value) === -1
|
|
998
1018
|
);
|
|
999
1019
|
|
|
1000
|
-
imagesTemp.values = imgsLeft;
|
|
1001
|
-
|
|
1002
1020
|
if (imgsInBack.length > 0) {
|
|
1003
1021
|
const data = {
|
|
1004
1022
|
articleId: product.article.id_article,
|
|
1005
|
-
deleteImages:
|
|
1023
|
+
deleteImages: imgsInBack,
|
|
1006
1024
|
};
|
|
1007
1025
|
try {
|
|
1008
1026
|
axios.put(
|
|
@@ -1016,8 +1034,22 @@ export const RetailerProductEdition = ({
|
|
|
1016
1034
|
console.log(err);
|
|
1017
1035
|
}
|
|
1018
1036
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1037
|
+
|
|
1038
|
+
setImages({
|
|
1039
|
+
action: "deleteImage",
|
|
1040
|
+
selectedImages,
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
getRequired([
|
|
1044
|
+
services[0],
|
|
1045
|
+
services[1],
|
|
1046
|
+
{ ...services[2], values: imgsLeft },
|
|
1047
|
+
]);
|
|
1048
|
+
|
|
1049
|
+
setTimeout(() => {
|
|
1050
|
+
setLoading(false);
|
|
1051
|
+
}, 500);
|
|
1052
|
+
|
|
1021
1053
|
setMessage("");
|
|
1022
1054
|
setComponentsArray([]);
|
|
1023
1055
|
};
|
|
@@ -1081,7 +1113,7 @@ export const RetailerProductEdition = ({
|
|
|
1081
1113
|
service.id_retailer === activeRetailer?.id &&
|
|
1082
1114
|
service.service === concept
|
|
1083
1115
|
);
|
|
1084
|
-
return retailerService ? retailerService.status : "
|
|
1116
|
+
return retailerService ? retailerService.status : "NS";
|
|
1085
1117
|
};
|
|
1086
1118
|
|
|
1087
1119
|
useEffect(() => {
|
|
@@ -1093,6 +1125,10 @@ export const RetailerProductEdition = ({
|
|
|
1093
1125
|
services.length > 0 && getRequired(services);
|
|
1094
1126
|
}, [services, servicesData, activeTab]);
|
|
1095
1127
|
|
|
1128
|
+
useEffect(() => {
|
|
1129
|
+
setSaving(loading);
|
|
1130
|
+
}, [loading]);
|
|
1131
|
+
|
|
1096
1132
|
return (
|
|
1097
1133
|
<Container headerTop={headerTop}>
|
|
1098
1134
|
<HeaderTop setHeaderTop={setHeaderTop} />
|
|
@@ -1123,6 +1159,7 @@ export const RetailerProductEdition = ({
|
|
|
1123
1159
|
headerData={product}
|
|
1124
1160
|
percent={activePercentage}
|
|
1125
1161
|
activeRetailer={activeRetailer}
|
|
1162
|
+
servicesData={servicesData}
|
|
1126
1163
|
setActiveRetailer={setActiveRetailer}
|
|
1127
1164
|
sendToFacilitator={sendToFacilitator}
|
|
1128
1165
|
approve={() => {
|
|
@@ -1146,17 +1183,21 @@ export const RetailerProductEdition = ({
|
|
|
1146
1183
|
assig={assig[activeTab]}
|
|
1147
1184
|
setAssignation={setAssignation}
|
|
1148
1185
|
isRetailer={isRetailer}
|
|
1149
|
-
showSaveButton={
|
|
1186
|
+
showSaveButton={userAssigned()}
|
|
1150
1187
|
onClickSave={() => {
|
|
1151
1188
|
switch (activeTab) {
|
|
1152
1189
|
case "Descripción":
|
|
1153
|
-
|
|
1190
|
+
!saving &&
|
|
1191
|
+
product?.description_status !== "NS" &&
|
|
1192
|
+
saveDescriptions();
|
|
1154
1193
|
break;
|
|
1155
1194
|
case "Ficha técnica":
|
|
1156
|
-
|
|
1195
|
+
!saving &&
|
|
1196
|
+
product?.datasheet_status !== "NS" &&
|
|
1197
|
+
saveDatasheets();
|
|
1157
1198
|
break;
|
|
1158
1199
|
case "Imágenes":
|
|
1159
|
-
product?.images_status !== "NS" && updateImages();
|
|
1200
|
+
!saving && product?.images_status !== "NS" && updateImages();
|
|
1160
1201
|
break;
|
|
1161
1202
|
|
|
1162
1203
|
default:
|