diff --git a/add.html b/add.html new file mode 100644 index 0000000..0da7463 --- /dev/null +++ b/add.html @@ -0,0 +1,20 @@ + + + + + + Aggiungi pizza + + + +
+
+
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/index.html b/index.html index e5495e8..bcea420 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@
- +

diff --git a/script.js b/script.js index e188447..83135d4 100644 --- a/script.js +++ b/script.js @@ -84,7 +84,7 @@ function editPizza(id){ } } -function addPizza(nome, id, prezzo){ +function addPizza(id, nome, prezzo){ const myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); @@ -105,10 +105,20 @@ function addPizza(nome, id, prezzo){ .then((response) => response.text()) .then((result) => { alert("Pizza aggiunta con successo!"); - listPizze(); + window.close(); }) .catch((error) => { console.error(error) alert("Errore nell'aggiunta, controllare la console per dettagli sull'errore."); }); +} + +function handleAddPizza(event){ + event.preventDefault(); + + const nome = document.getElementById("name").value; + const id = document.getElementById("id").value; + const prezzo = document.getElementById("price").value; + + addPizza(id, nome, prezzo); } \ No newline at end of file