mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE-114): improve data handling in RecordingForm for numeric fields
This commit is contained in:
@@ -77,22 +77,22 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
: '',
|
: '',
|
||||||
feed_data: (values.feed_data ?? []).map((p) => ({
|
feed_data: (values.feed_data ?? []).map((p) => ({
|
||||||
feed_id: p.feed_id,
|
feed_id: p.feed_id,
|
||||||
feed_qty: typeof p.feed_qty === 'number' ? p.feed_qty : 0,
|
feed_qty: typeof p.feed_qty === 'number' ? p.feed_qty : parseFloat(String(p.feed_qty)) || 0,
|
||||||
feed_stock: p.feed_stock,
|
feed_stock: typeof p.feed_stock === 'number' ? p.feed_stock : parseFloat(String(p.feed_stock)) || 0,
|
||||||
})),
|
})),
|
||||||
body_weight: (values.body_weight ?? []).map((b) => ({
|
body_weight: (values.body_weight ?? []).map((b) => ({
|
||||||
chicken_weight: b.chicken_weight,
|
chicken_weight: typeof b.chicken_weight === 'number' ? b.chicken_weight : parseFloat(String(b.chicken_weight)) || 0,
|
||||||
chicken_count: b.chicken_count,
|
chicken_count: typeof b.chicken_count === 'number' ? b.chicken_count : parseFloat(String(b.chicken_count)) || 0,
|
||||||
average_chicken_weight: b.average_chicken_weight,
|
average_chicken_weight: typeof b.average_chicken_weight === 'number' ? b.average_chicken_weight : parseFloat(String(b.average_chicken_weight)) || 0,
|
||||||
})),
|
})),
|
||||||
vaccination: (values.vaccination ?? []).map((v) => ({
|
vaccination: (values.vaccination ?? []).map((v) => ({
|
||||||
vaccine_id: v.vaccine_id,
|
vaccine_id: v.vaccine_id,
|
||||||
total_stock: typeof v.total_stock === 'number' ? v.total_stock : 0,
|
total_stock: typeof v.total_stock === 'number' ? v.total_stock : parseFloat(String(v.total_stock)) || 0,
|
||||||
used_stock: v.used_stock,
|
used_stock: typeof v.used_stock === 'number' ? v.used_stock : parseFloat(String(v.used_stock)) || 0,
|
||||||
})),
|
})),
|
||||||
mortality: (values.mortality ?? []).map((m) => ({
|
mortality: (values.mortality ?? []).map((m) => ({
|
||||||
condition: m.condition,
|
condition: m.condition,
|
||||||
count: m.count,
|
count: typeof m.count === 'number' ? m.count : parseFloat(String(m.count)) || 0,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user