Services: editing a saved service no longer fails validation

PocketBase reads an empty number back as 0, so mapItemRecord gave every
service capacity 0 and bufferMinutes 0. The edit form then showed
'Places in a group session: 0', below the field's min of 1, and the
browser refused to submit. 0 now maps to null (not set) for both;
every reader already treats them alike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gWt7pNdAsocjxujY3m
This commit is contained in:
agent 2026-11-04 22:47:01 +00:00
parent e896fd3c99
commit 80cbe6ddb2

View file

@ -27,8 +27,10 @@ export function mapItemRecord(record: Record<string, any>): ItemRecord {
durations: type === 'item_with_time' ? parseDurations(record.durations) : [],
bundleParts: type === 'bundle' ? parseBundleParts(record.bundleParts) : [],
validMonths: type === 'bundle' ? Number(record.validMonths) || null : null,
bufferMinutes: record.bufferMinutes ?? null,
capacity: record.capacity ?? null,
// PocketBase reads an empty number back as 0, never null: 0 means "not set" for both
// (and a 0 in the admin form would fail capacity's min of 1, blocking every save).
bufferMinutes: Number(record.bufferMinutes) || null,
capacity: Number(record.capacity) || null,
active: record.active !== false,
priority: Number(record.priority) || 0,
popularRank: null