await hinzugefügt und showError import entfern
This commit is contained in:
1 parent
9c0d704748
commit
01dd5c9089
1 file changed
+6
-2
@@ -1,6 +1,6 @@
|
||||
import { ShoppingCategory } from "../../models/ShoppingCategory.js";
|
||||
import { ShoppingItem } from "../../models/ShoppingItem.js";
|
||||
import { showError, initErrors } from "../../shared/error.js";
|
||||
import { initErrors } from "../../shared/error.js";
|
||||
import * as api from "./api/listAPI.js"
|
||||
import * as ui from "./frontend/listUI.js"
|
||||
import { handleResponse } from "../../shared/helper.js";
|
||||
@@ -40,9 +40,11 @@ async function editItem(shoppingItem, id) {
|
||||
|
||||
formElement.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
let formData = Object.fromEntries(new FormData(formElement));
|
||||
console.log(`editing item ${id} with ${formData}`)
|
||||
let result = handleResponse(api.editItem(id, { itemName: formData.newItemName, itemAmount: formData.newItemAmount }), `kapot item`);
|
||||
|
||||
let result = await handleResponse(api.editItem(id, { itemName: formData.newItemName, itemAmount: formData.newItemAmount }), `kapot item`);
|
||||
if (result) ui.editItem(shoppingItem, formElement, formData);
|
||||
});
|
||||
|
||||
@@ -68,8 +70,10 @@ function editCategory(categoryDiv, id) {
|
||||
|
||||
formElement.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
let formData = Object.fromEntries(new FormData(formElement));
|
||||
console.log(`editing catogory ${id} with ${formData}`)
|
||||
|
||||
const result = await handleResponse(api.editCategory(id, { categoryName: formData.newCategoryName }), `error editing category`);
|
||||
if (result) ui.editCategory(id, formElement, formData, categoryDiv);
|
||||
|
||||
|
||||
Reference in new issue
Block a user