feat(F-096): completed feature
This commit is contained in:
@@ -152,13 +152,22 @@ export function ProductEditor({ productId }: ProductEditorProps) {
|
||||
featured,
|
||||
attributes,
|
||||
state,
|
||||
seoTitle: seoTitle || undefined,
|
||||
seoDescription: seoDesc || undefined,
|
||||
seoTitle: seoTitle.trim() || null,
|
||||
seoDescription: seoDesc.trim() || null,
|
||||
expirationDate: expirationDate || undefined,
|
||||
};
|
||||
let saved: Product;
|
||||
if (isCreate) saved = await productsApi.create(payload);
|
||||
else saved = await productsApi.update(productId, payload);
|
||||
if (!seoTitle.trim() || !seoDesc.trim()) {
|
||||
try {
|
||||
saved = await productsApi.generateSeo(saved.id);
|
||||
setSeoTitle(saved.seoTitle ?? '');
|
||||
setSeoDesc(saved.seoDescription ?? '');
|
||||
} catch (generationError) {
|
||||
setError(generationError instanceof Error ? generationError.message : 'No se pudieron generar los campos SEO');
|
||||
}
|
||||
}
|
||||
snapRef.current = getSnap();
|
||||
dirtyRef.current = false;
|
||||
setSuccess(isCreate ? '¡Producto creado!' : 'Cambios guardados');
|
||||
|
||||
Reference in New Issue
Block a user