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.
@@ -175,11 +175,7 @@ ProviderProductEditionDefault.args = {
175
175
  }]
176
176
  }]
177
177
  },
178
- location: {
179
- state: {
180
- origin: "Contentoh"
181
- }
182
- },
178
+ location: {},
183
179
  user: {
184
180
  id_user: 1237,
185
181
  name: "The Home",
@@ -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
- var orderedImages = [];
172
- var imageIdArray = [];
173
- action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
174
- imageIdArray.push(input.id_image);
175
- valuesInitial.forEach(function (value) {
176
- if (value.image_id === input.id_image) orderedImages.push(value);
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
- inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
180
- return imageIdArray.includes(input.id);
181
- });
182
- values = orderedImages.length > 0 ? orderedImages : [];
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
- setActiveRetailer(product !== null && product !== void 0 && product.retailers ? product === null || product === void 0 ? void 0 : product.retailers[0] : product === null || product === void 0 ? void 0 : product.retailersAvailable[0]);
557
- } // setActiveRetailer(product?.retailers[0]);
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 11:
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
- 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.96",
3
+ "version": "21.1.99",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -186,9 +186,7 @@ ProviderProductEditionDefault.args = {
186
186
  },
187
187
  ],
188
188
  },
189
- location: {
190
- state: { origin: "Contentoh" },
191
- },
189
+ location: {},
192
190
  user: {
193
191
  id_user: 1237,
194
192
  name: "The Home",
@@ -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
- const orderedImages = [];
87
- const imageIdArray = [];
88
- action.retailerId &&
89
- inputsByRetailer[action.retailerId]?.filter((input) => {
90
- imageIdArray.push(input.id_image);
91
- valuesInitial.forEach((value) => {
92
- if (value.image_id === input.id_image) orderedImages.push(value);
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
- inputs = inputsInitial?.filter((input) =>
97
- imageIdArray.includes(input.id)
98
- );
99
+ inputs = inputsInitial?.filter((input) =>
100
+ imageIdArray.includes(input.id)
101
+ );
99
102
 
100
- values = orderedImages.length > 0 ? orderedImages : [];
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
- setActiveRetailer(
270
- product?.retailers
271
- ? product?.retailers[0]
272
- : product?.retailersAvailable[0]
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
- 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: