feat(F-121): completed feature

This commit is contained in:
chattie
2026-08-21 15:35:51 +02:00
parent a5538fc8f0
commit a40d78d1d9
9 changed files with 125 additions and 32 deletions

View File

@@ -44,7 +44,8 @@ function hasMeaningfulContent(value: string): boolean {
return value.replace(/<[^>]*>/g, '').replace(/&nbsp;|&#160;/gi, ' ').trim().length > 0;
}
export function ProductEditor({ productId }: ProductEditorProps) {
export function ProductEditor({ productId: initialProductId }: ProductEditorProps) {
const [productId, setProductId] = useState<string | undefined>(initialProductId);
const router = useRouter();
const isCreate = !productId;
const [tab, setTab] = useState<'general' | 'images' | 'seo' | 'publish'>('general');
@@ -182,7 +183,13 @@ export function ProductEditor({ productId }: ProductEditorProps) {
}
snapRef.current = getSnap();
dirtyRef.current = false;
if (isCreate) router.push(`/products/${saved.id}`);
if (isCreate) {
// Stay on the same React component but unlock the price/stock/EAN
// section by giving it a real productId. router.replace avoids a
// full page reload so the dirty state is preserved (F-121).
setProductId(saved.id);
router.replace(`/products/${saved.id}`);
}
} catch (err) {
setError(err instanceof Error ? err.message : 'Error al guardar');
} finally {

File diff suppressed because one or more lines are too long