feat(F-121): completed feature
This commit is contained in:
@@ -44,7 +44,8 @@ function hasMeaningfulContent(value: string): boolean {
|
||||
return value.replace(/<[^>]*>/g, '').replace(/ | /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
Reference in New Issue
Block a user