contentoh-components-library 21.5.95 → 21.5.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.
@@ -206,6 +206,8 @@ const RetailerProductEditionView = ({
206
206
 
207
207
  const productNormalized = normalizeProduct(product);
208
208
 
209
+ console.log({productNormalized});
210
+
209
211
  dispatch({
210
212
  type: "SET_PRODUCT",
211
213
  payload: productNormalized,
@@ -730,8 +732,10 @@ const RetailerProductEditionView = ({
730
732
  );
731
733
 
732
734
  const newStatuses = JSON.parse(res.data.body);
733
- const serviceStatus =
734
- newStatuses.newServiceStatus[articleId][`${concept}Status`];
735
+ const serviceStatus = newStatuses.newServiceStatus[articleId][`${concept}Status`];
736
+ const articleStatus = newStatuses.newArticleStatus[articleId];
737
+
738
+ console.log({newStatuses});
735
739
 
736
740
  // Actualizar el producto con los nuevos estados
737
741
  const updatedStatusByRetailer = state.product.statusByRetailer.map(
@@ -744,6 +748,9 @@ const RetailerProductEditionView = ({
744
748
  const updatedProduct = {
745
749
  ...state.product,
746
750
  statusByRetailer: updatedStatusByRetailer,
751
+ // version_status: articleStatus,
752
+ // status: articleStatus,
753
+ // article_status: articleStatus
747
754
  };
748
755
 
749
756
  dispatch({ type: "SET_PRODUCT", payload: updatedProduct });
@@ -789,6 +796,10 @@ const RetailerProductEditionView = ({
789
796
 
790
797
  const { newStatus, newOrderStatus, newArticleStatus } = JSON.parse( res.data.body );
791
798
 
799
+ const articleStatus = newArticleStatus[articleId];
800
+
801
+ console.log({newArticleStatus});
802
+
792
803
  // const retailers = state.product.categoryRetailer.map((r) => ({
793
804
  // id: r.id_retailer,
794
805
  // name: r.retailerName,
@@ -823,6 +834,9 @@ const RetailerProductEditionView = ({
823
834
  }
824
835
  return item;
825
836
  }),
837
+ // version_status: articleStatus,
838
+ // status: articleStatus,
839
+ // article_status: articleStatus
826
840
  };
827
841
 
828
842
  //Actualizamos el services_data en el servicio específico del retailer actual
@@ -1151,6 +1165,7 @@ const RetailerProductEditionView = ({
1151
1165
  };
1152
1166
 
1153
1167
  const handleOnChangeProductVersion = (version) => {
1168
+ console.log('se cambia la version')
1154
1169
  dispatch({
1155
1170
  type: "SET_PRODUCT_VERSION",
1156
1171
  payload: version,
@@ -1280,10 +1295,14 @@ const RetailerProductEditionView = ({
1280
1295
  </Box>
1281
1296
  </div>
1282
1297
  </div>
1283
- </Container>
1298
+ </Container>
1284
1299
  );
1285
1300
  };
1286
1301
 
1302
+ useEffect(() => {
1303
+ console.log({stateProduct: state.product})
1304
+ }, [state.product]);
1305
+
1287
1306
  if (state.loading || !state.services || !state.product)
1288
1307
  return (
1289
1308
  <>
@@ -7,7 +7,7 @@ export const AiProductEdition = createContext();
7
7
  export const useAiProductEdition = () => {
8
8
  const context = useContext(AiProductEdition);
9
9
 
10
- if (!context) throw new Error("El contexto debe tener un provider");
10
+ if (!context) return {};
11
11
 
12
12
  return context;
13
13
  };
@@ -205,6 +205,12 @@ export const AiProductEditionProvider = ({
205
205
  }
206
206
  });
207
207
 
208
+ const errorsRaw = JSON.parse(data?.body)?.error;
209
+
210
+ const errorMessage = errorsRaw ? JSON.parse(errorsRaw)?.error?.message : null;
211
+
212
+ if(errorMessage) throw new Error(errorMessage ?? 'Error desconocido')
213
+
208
214
  const results = JSON.parse(data?.body)?.data ?? [];
209
215
 
210
216
  if(!results)
@@ -224,7 +230,7 @@ export const AiProductEditionProvider = ({
224
230
  // Verificamos si los servicios de ficha técnica e imágenes estan completos
225
231
  useEffect(() => {
226
232
 
227
- if (!productSelected) return;
233
+ if (!productSelected || !isCreators) return;
228
234
 
229
235
  const {
230
236
  name: productName,
@@ -273,7 +279,7 @@ export const AiProductEditionProvider = ({
273
279
  // Inicializamos la ficha técnica con el objetivo de posteriormente pasarlo a la generación con IA
274
280
  useEffect(() => {
275
281
 
276
- if (!datasheetInputs) return;
282
+ if (!datasheetInputs || !isCreators) return;
277
283
 
278
284
  const datasheetToArray = Object.values(datasheetInputs);
279
285
 
@@ -291,6 +297,8 @@ export const AiProductEditionProvider = ({
291
297
  // Inicializamos las imágenes con el objetivo de posteriormente pasarlo a la generación con IA
292
298
  useEffect(() => {
293
299
 
300
+ if(!isCreators) return;
301
+
294
302
  const currentRetailerImageInputs = imagesData?.inputsByRetailer?.[0]?.filter(input => input?.id_retailer === activeRetailer?.id_retailer);
295
303
 
296
304
  if(!Array.isArray(currentRetailerImageInputs) || currentRetailerImageInputs.length === 0) return console.log('No existen imágenes para la cadena seleccionada')