DEAD_CODE_CLEAN #6

Merged
shafi merged 30 commits from DEAD_CODE_CLEAN into main 2026-09-14 04:29:36 +00:00
Showing only changes of commit 5d7648c6b0 - Show all commits

View file

@ -212,15 +212,20 @@ const ProductForm = forwardRef<ProductFormRef, ProductFormProps>(({
// 'quantity' feature must always go out lowercase (case-insensitive
// matching means 'Quantity'/'QUANTITY' are treated the same), and
// names are trimmed like the backend does.
// TextInputs emit strings — coerce price fields to the numeric types
// the backend zod schema requires (price required; market/flash nullable).
const toNumber = (value: unknown): number | null => {
if (value == null || value === '') return null
const n = Number(value)
return Number.isFinite(n) ? n : null
}
const normalizedValues: ProductFormData = {
...values,
variants: values.variants.map((v) => ({
...v,
// TextInputs emit strings — coerce to the numeric types the
// backend zod schema requires (price required; market/flash nullable).
price: v.price == null || v.price === '' ? undefined : Number(v.price),
marketPrice: v.marketPrice == null || v.marketPrice === '' ? null : Number(v.marketPrice),
flashPrice: v.flashPrice == null || v.flashPrice === '' ? null : Number(v.flashPrice),
price: toNumber(v.price) ?? undefined,
marketPrice: toNumber(v.marketPrice),
flashPrice: toNumber(v.flashPrice),
features: v.features.map((a) => ({
...a,
featureName: isQuantityFeature(a) ? 'quantity' : (a.featureName ?? '').trim() || null,