Lil refactor
This commit is contained in:
@@ -12,31 +12,17 @@
|
||||
let name: string = item.food
|
||||
|
||||
async function update(event: KeyboardEvent & { currentTarget: (EventTarget & HTMLTableCellElement) }) {
|
||||
amount = amount.trim()
|
||||
per100 = per100.trim()
|
||||
description = description.trim()
|
||||
name = name.trim()
|
||||
|
||||
if (event.key == 'Enter') {
|
||||
event.preventDefault()
|
||||
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() ?? ''
|
||||
await updateItem()
|
||||
}
|
||||
}
|
||||
|
||||
async function focusOutUpdate() {
|
||||
await updateItem()
|
||||
}
|
||||
|
||||
async function updateItem() {
|
||||
amount = amount.trim()
|
||||
per100 = per100.trim()
|
||||
description = description.trim()
|
||||
|
Reference in New Issue
Block a user