ProductTypesPage: openEdit() should fetch full ProductTypeDetail before populating form #39
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When an admin clicks "Edit" on an existing ProductType row with multimedia limits (e.g.,
AllowImages: true, MaxImages: 5), the form opens with all multimedia fields empty (null stubs). If the admin submits without modifying them, the update command sendsmaxImages: null→ the handler overwrites the database with null multimedia limits, silently wiping the previous config.Minimal Reproduction
AllowImages: true, MaxImages: 5, MaxImageSizeMB: 10, ...MaxImages: null, MaxImageSizeMB: null, ...— previous config lostRoot Cause
ProductTypesPage.tsx,openEdit()function maps fromProductTypeListItem(list DTO) to aProductTypeDetailstub with hardcoded null multimedia fields:The form renders these null values, and when submitted, they overwrite the database.
Solution
Before opening the edit dialog, fetch the full
ProductTypeDetailfrom the API:Alternatively, wire the existing
useProductType(id)hook that was added but never used.Impact
AllowImages: false)Acceptance Criteria
openEdit()fetches fullProductTypeDetailvia API (or hook) before opening dialogRelated
Duplicate of #37 — cerrando. Seguir el tracking en #37 que tiene el contexto completo, 3 opciones de fix con recomendación, y criterios de aceptación.