contentoh-components-library 21.1.97 → 21.1.98

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.
@@ -172,7 +172,7 @@ var reducerImages = function reducerImages(state, action) {
172
172
 
173
173
  var orderedImages = [];
174
174
  var imageIdArray = [];
175
- if (!_inputsByRetailer[action.retailerId]) _inputsByRetailer[action.retailerId] = [];
175
+ if (action !== null && action !== void 0 && action.retailerId && !_inputsByRetailer[action.retailerId]) _inputsByRetailer[action.retailerId] = [];
176
176
  action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
177
177
  imageIdArray.push(input.id_image);
178
178
  valuesInitial.forEach(function (value) {
@@ -712,6 +712,12 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
712
712
  retailerId: activeRetailer.id
713
713
  });
714
714
  }, [product, version]);
715
+ (0, _react.useEffect)(function () {
716
+ setImages({
717
+ action: "orderImages",
718
+ retailerId: activeRetailer.id
719
+ });
720
+ }, [activeRetailer]);
715
721
 
716
722
  var loadAssignations = function loadAssignations(currentProduct) {
717
723
  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
- var orderedImages = [];
150
- var imageIdArray = [];
151
- action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
152
- imageIdArray.push(input.id_image);
153
- valuesInitial.forEach(function (value) {
154
- if (value.image_id === input.id_image) orderedImages.push(value);
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
- inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
158
- return imageIdArray.includes(input.id);
159
- });
160
- values = orderedImages.length > 0 ? orderedImages : [];
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.1.97",
3
+ "version": "21.1.98",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -86,7 +86,7 @@ const reducerImages = (state, action) => {
86
86
  try {
87
87
  const orderedImages = [];
88
88
  const imageIdArray = [];
89
- if (!inputsByRetailer[action.retailerId])
89
+ if (action?.retailerId && !inputsByRetailer[action.retailerId])
90
90
  inputsByRetailer[action.retailerId] = [];
91
91
  action.retailerId &&
92
92
  inputsByRetailer[action.retailerId]?.filter((input) => {
@@ -358,6 +358,10 @@ export const ProviderProductEdition = ({
358
358
  setImages({ action: "orderImages", retailerId: activeRetailer.id });
359
359
  }, [product, version]);
360
360
 
361
+ useEffect(() => {
362
+ setImages({ action: "orderImages", retailerId: activeRetailer.id });
363
+ }, [activeRetailer]);
364
+
361
365
  const loadAssignations = (currentProduct) => {
362
366
  setAssig(product?.asignations);
363
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
- const orderedImages = [];
77
- const imageIdArray = [];
78
- action.retailerId &&
79
- inputsByRetailer[action.retailerId]?.filter((input) => {
80
- imageIdArray.push(input.id_image);
81
- valuesInitial.forEach((value) => {
82
- if (value.image_id === input.id_image) orderedImages.push(value);
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
- inputs = inputsInitial?.filter((input) =>
87
- imageIdArray.includes(input.id)
88
- );
89
+ inputs = inputsInitial?.filter((input) =>
90
+ imageIdArray.includes(input.id)
91
+ );
89
92
 
90
- values = orderedImages.length > 0 ? orderedImages : [];
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: