diff --git a/src/lib/components/Food/FoodComp.svelte b/src/lib/components/Food/FoodComp.svelte index 382de57..98dd9cd 100644 --- a/src/lib/components/Food/FoodComp.svelte +++ b/src/lib/components/Food/FoodComp.svelte @@ -25,16 +25,38 @@ item.per100 = parseInt(per100) const [newItem, err] = await FoodService.Update(item) - name = item.food - description = item.description ?? '' - amount = item.amount.toString() - per100 = item.per100?.toString() ?? '' if (newItem && !err) { item = newItem } + name = item.food + description = item.description ?? '' + amount = item.amount.toString() + per100 = item.per100?.toString() ?? '' } } + + async function focusOutUpdate() { + amount = amount.trim() + per100 = per100.trim() + description = description.trim() + name = name.trim() + + item.food = name + item.description = description + item.amount = parseInt(amount) + item.per100 = parseInt(per100) + + const [newItem, err] = await FoodService.Update(item) + + if (newItem && !err) { + item = newItem + } + name = item.food + description = item.description ?? '' + amount = item.amount.toString() + per100 = item.per100?.toString() ?? '' + }