contentoh-components-library 21.1.96 → 21.1.99
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/pages/ProviderProductEdition/ProviderProductEdition.stories.js +1 -5
- package/dist/components/pages/ProviderProductEdition/index.js +35 -19
- package/dist/components/pages/RetailerProductEdition/index.js +20 -13
- package/package.json +1 -1
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +1 -3
- package/src/components/pages/ProviderProductEdition/index.js +29 -19
- package/src/components/pages/RetailerProductEdition/index.js +18 -12
|
@@ -162,24 +162,31 @@ var reducerImages = function reducerImages(state, action) {
|
|
|
162
162
|
|
|
163
163
|
case "orderImages":
|
|
164
164
|
{
|
|
165
|
-
var _inputsByRetailer$act;
|
|
166
|
-
|
|
167
165
|
var _inputsByRetailer = state.inputsByRetailer,
|
|
168
166
|
valuesInitial = state.valuesInitial,
|
|
169
167
|
inputsInitial = state.inputsInitial,
|
|
170
168
|
inputs = state.inputs;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
var _inputsByRetailer$act;
|
|
172
|
+
|
|
173
|
+
var orderedImages = [];
|
|
174
|
+
var imageIdArray = [];
|
|
175
|
+
if (action !== null && action !== void 0 && action.retailerId && !_inputsByRetailer[action.retailerId]) _inputsByRetailer[action.retailerId] = [];
|
|
176
|
+
action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
|
|
177
|
+
imageIdArray.push(input.id_image);
|
|
178
|
+
valuesInitial.forEach(function (value) {
|
|
179
|
+
if (value.image_id === input.id_image) orderedImages.push(value);
|
|
180
|
+
});
|
|
181
|
+
}));
|
|
182
|
+
inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
|
|
183
|
+
return imageIdArray.includes(input.id);
|
|
177
184
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
185
|
+
values = orderedImages.length > 0 ? orderedImages : [];
|
|
186
|
+
} catch (error) {
|
|
187
|
+
console.log(error);
|
|
188
|
+
}
|
|
189
|
+
|
|
183
190
|
return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
|
|
184
191
|
values: values,
|
|
185
192
|
inputs: inputs
|
|
@@ -552,11 +559,14 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
552
559
|
return getServices();
|
|
553
560
|
|
|
554
561
|
case 6:
|
|
555
|
-
if (!originProp) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
562
|
+
// if (!originProp) {
|
|
563
|
+
// setActiveRetailer(
|
|
564
|
+
// product?.retailers
|
|
565
|
+
// ? product?.retailers[0]
|
|
566
|
+
// : product?.retailersAvailable[0]
|
|
567
|
+
// );
|
|
568
|
+
// }
|
|
569
|
+
// setActiveRetailer(product?.retailers[0]);
|
|
560
570
|
setImages({
|
|
561
571
|
action: "init",
|
|
562
572
|
init: services[2]
|
|
@@ -569,7 +579,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
569
579
|
});
|
|
570
580
|
setLoading(false);
|
|
571
581
|
|
|
572
|
-
case
|
|
582
|
+
case 10:
|
|
573
583
|
case "end":
|
|
574
584
|
return _context2.stop();
|
|
575
585
|
}
|
|
@@ -705,6 +715,12 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
705
715
|
retailerId: activeRetailer.id
|
|
706
716
|
});
|
|
707
717
|
}, [product, version]);
|
|
718
|
+
(0, _react.useEffect)(function () {
|
|
719
|
+
setImages({
|
|
720
|
+
action: "orderImages",
|
|
721
|
+
retailerId: activeRetailer.id
|
|
722
|
+
});
|
|
723
|
+
}, [activeRetailer]);
|
|
708
724
|
|
|
709
725
|
var loadAssignations = function loadAssignations(currentProduct) {
|
|
710
726
|
setAssig(product === null || product === void 0 ? void 0 : product.asignations);
|
|
@@ -140,24 +140,31 @@ var reducerImages = function reducerImages(state, action) {
|
|
|
140
140
|
|
|
141
141
|
case "orderImages":
|
|
142
142
|
{
|
|
143
|
-
var _inputsByRetailer$act;
|
|
144
|
-
|
|
145
143
|
var _inputsByRetailer = state.inputsByRetailer,
|
|
146
144
|
valuesInitial = state.valuesInitial,
|
|
147
145
|
inputsInitial = state.inputsInitial,
|
|
148
146
|
inputs = state.inputs;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
var _inputsByRetailer$act;
|
|
150
|
+
|
|
151
|
+
var orderedImages = [];
|
|
152
|
+
var imageIdArray = [];
|
|
153
|
+
if (action !== null && action !== void 0 && action.retailerId && !_inputsByRetailer[action.retailerId]) _inputsByRetailer[action.retailerId] = [];
|
|
154
|
+
action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
|
|
155
|
+
imageIdArray.push(input.id_image);
|
|
156
|
+
valuesInitial.forEach(function (value) {
|
|
157
|
+
if (value.image_id === input.id_image) orderedImages.push(value);
|
|
158
|
+
});
|
|
159
|
+
}));
|
|
160
|
+
inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
|
|
161
|
+
return imageIdArray.includes(input.id);
|
|
155
162
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
163
|
+
values = orderedImages.length > 0 ? orderedImages : [];
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.log(error);
|
|
166
|
+
}
|
|
167
|
+
|
|
161
168
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
|
|
162
169
|
values: values,
|
|
163
170
|
inputs: inputs
|
package/package.json
CHANGED
|
@@ -83,21 +83,27 @@ const reducerImages = (state, action) => {
|
|
|
83
83
|
return { ...state, values };
|
|
84
84
|
case "orderImages": {
|
|
85
85
|
let { inputsByRetailer, valuesInitial, inputsInitial, inputs } = state;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
inputsByRetailer[action.retailerId]
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
try {
|
|
87
|
+
const orderedImages = [];
|
|
88
|
+
const imageIdArray = [];
|
|
89
|
+
if (action?.retailerId && !inputsByRetailer[action.retailerId])
|
|
90
|
+
inputsByRetailer[action.retailerId] = [];
|
|
91
|
+
action.retailerId &&
|
|
92
|
+
inputsByRetailer[action.retailerId]?.filter((input) => {
|
|
93
|
+
imageIdArray.push(input.id_image);
|
|
94
|
+
valuesInitial.forEach((value) => {
|
|
95
|
+
if (value.image_id === input.id_image) orderedImages.push(value);
|
|
96
|
+
});
|
|
93
97
|
});
|
|
94
|
-
});
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
inputs = inputsInitial?.filter((input) =>
|
|
100
|
+
imageIdArray.includes(input.id)
|
|
101
|
+
);
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
values = orderedImages.length > 0 ? orderedImages : [];
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.log(error);
|
|
106
|
+
}
|
|
101
107
|
return { ...state, values, inputs };
|
|
102
108
|
}
|
|
103
109
|
default:
|
|
@@ -265,13 +271,13 @@ export const ProviderProductEdition = ({
|
|
|
265
271
|
setServices(services);
|
|
266
272
|
await getServices();
|
|
267
273
|
|
|
268
|
-
if (!originProp) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
274
|
+
// if (!originProp) {
|
|
275
|
+
// setActiveRetailer(
|
|
276
|
+
// product?.retailers
|
|
277
|
+
// ? product?.retailers[0]
|
|
278
|
+
// : product?.retailersAvailable[0]
|
|
279
|
+
// );
|
|
280
|
+
// }
|
|
275
281
|
|
|
276
282
|
// setActiveRetailer(product?.retailers[0]);
|
|
277
283
|
setImages({ action: "init", init: services[2] });
|
|
@@ -352,6 +358,10 @@ export const ProviderProductEdition = ({
|
|
|
352
358
|
setImages({ action: "orderImages", retailerId: activeRetailer.id });
|
|
353
359
|
}, [product, version]);
|
|
354
360
|
|
|
361
|
+
useEffect(() => {
|
|
362
|
+
setImages({ action: "orderImages", retailerId: activeRetailer.id });
|
|
363
|
+
}, [activeRetailer]);
|
|
364
|
+
|
|
355
365
|
const loadAssignations = (currentProduct) => {
|
|
356
366
|
setAssig(product?.asignations);
|
|
357
367
|
};
|
|
@@ -73,21 +73,27 @@ const reducerImages = (state, action) => {
|
|
|
73
73
|
return { ...state, values };
|
|
74
74
|
case "orderImages": {
|
|
75
75
|
let { inputsByRetailer, valuesInitial, inputsInitial, inputs } = state;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
inputsByRetailer[action.retailerId]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
try {
|
|
77
|
+
const orderedImages = [];
|
|
78
|
+
const imageIdArray = [];
|
|
79
|
+
if (action?.retailerId && !inputsByRetailer[action.retailerId])
|
|
80
|
+
inputsByRetailer[action.retailerId] = [];
|
|
81
|
+
action.retailerId &&
|
|
82
|
+
inputsByRetailer[action.retailerId]?.filter((input) => {
|
|
83
|
+
imageIdArray.push(input.id_image);
|
|
84
|
+
valuesInitial.forEach((value) => {
|
|
85
|
+
if (value.image_id === input.id_image) orderedImages.push(value);
|
|
86
|
+
});
|
|
83
87
|
});
|
|
84
|
-
});
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
inputs = inputsInitial?.filter((input) =>
|
|
90
|
+
imageIdArray.includes(input.id)
|
|
91
|
+
);
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
values = orderedImages.length > 0 ? orderedImages : [];
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.log(error);
|
|
96
|
+
}
|
|
91
97
|
return { ...state, values, inputs };
|
|
92
98
|
}
|
|
93
99
|
default:
|