forked from laisgarc/podcome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew-dish.html
More file actions
67 lines (55 loc) · 2.04 KB
/
new-dish.html
File metadata and controls
67 lines (55 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="imgs/logo.png">
<title>Comer Melhor</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" rel="stylesheet">
<link rel="stylesheet" href="css/form.css">
<script>
function createDish() {
const prato = document.getElementById("nomeDoPrato").value;
const preco = document.getElementById("preco").value;
const nomeDoRestaurante = document.getElementById("nomeDoRestaurante").value;
let xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://127.0.0.1:8080/api/v1/prato/adicionar", true);
xhttp.setRequestHeader("Content-type", "application/json");
const w = localStorage.getItem('userLogado');
const storageObj = JSON.stringify(w);
console.log(storageObj.nome);
infos = JSON.stringify({
"nomeDoPrato":prato,
"preco":preco,
"nomeDoRestaurante":nomeDoRestaurante
});
xhttp.send(infos);
}
</script>
</head>
<body>
<div class="testbox">
<form>
<div class="banner">
<h1>Adicione seu novo prato</h1>
</div>
<br/>
<div class="item">
<label for="nomeDoPrato">Nome do prato<span>*</span></label>
<input id="nomeDoPrato" type="text" name="nomeDoPrato" />
</div>
<div class="item">
<label for="nomeDoRestaurante">Nome do restaurante<span>*</span></label>
<input id="nomeDoRestaurante" type="text" name="nomeDoRestaurante" />
</div>
<div class="item">
<label for="preco">Preço<span>*</span></label>
<input id="preco" type="text" name="preco" />
</div>
<div>
<button type="submit" onclick="createDish()" formaction="/profile-page.html">Adicionar</button>
<button type='submit' formaction="/index.html"> Voltar </button>
</div>
</form>
</div>
</body>
</html>