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