fix: handle empty HRV field in vitals form
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

- Only include fields in payload if they have values
- Prevents sending empty strings to backend (Pydantic validation error)
- Applies to both create and update operations

Error was: 'Input should be a valid integer, unable to parse string as an integer'

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-23 14:56:17 +01:00
parent 4191c52298
commit 7433b19b7e

View File

@ -122,9 +122,12 @@ export default function VitalsPage() {
setError(null)
try {
const payload = { ...form }
if (payload.resting_hr) payload.resting_hr = parseInt(payload.resting_hr)
if (payload.hrv) payload.hrv = parseInt(payload.hrv)
const payload = { date: form.date }
// Only include fields if they have values
if (form.resting_hr) payload.resting_hr = parseInt(form.resting_hr)
if (form.hrv) payload.hrv = parseInt(form.hrv)
if (form.note) payload.note = form.note
if (!payload.resting_hr && !payload.hrv) {
setError('Mindestens Ruhepuls oder HRV muss angegeben werden')
@ -150,9 +153,13 @@ export default function VitalsPage() {
const handleUpdate = async () => {
try {
const payload = { ...editing }
if (payload.resting_hr) payload.resting_hr = parseInt(payload.resting_hr)
if (payload.hrv) payload.hrv = parseInt(payload.hrv)
const payload = {}
// Only include fields if they have values
if (editing.date) payload.date = editing.date
if (editing.resting_hr) payload.resting_hr = parseInt(editing.resting_hr)
if (editing.hrv) payload.hrv = parseInt(editing.hrv)
if (editing.note) payload.note = editing.note
await api.updateVitals(editing.id, payload)
setEditing(null)