-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegistrarProduto.html
117 lines (98 loc) · 4.74 KB
/
RegistrarProduto.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="pt-pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registrar Produto</title>
<link rel="stylesheet" href="stylesFormulario.css">
</head>
<body>
<section class="Background-IMG">
<a href="Home.html" class="botao-home"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="lucide lucide-house">
<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" />
<path
d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
</svg></a>
<a href="loginpage.html" class="LogOut"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"
fill="currentColor" class="bi bi-box-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd"
d="M6 12.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-8a.5.5 0 0 0-.5.5v2a.5.5 0 0 1-1 0v-2A1.5 1.5 0 0 1 6.5 2h8A1.5 1.5 0 0 1 16 3.5v9a1.5 1.5 0 0 1-1.5 1.5h-8A1.5 1.5 0 0 1 5 12.5v-2a.5.5 0 0 1 1 0z" />
<path fill-rule="evenodd"
d="M.146 8.354a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L1.707 7.5H10.5a.5.5 0 0 1 0 1H1.707l2.147 2.146a.5.5 0 0 1-.708.708z" />
</svg></a>
<h1>Registrar Produto</h1>
</section>
<main>
<h2 class="subtitulo">Adicione um novo produto</h2>
<form class="formulario" id="formProduto">
<label for="nomeProduto">Nome do Produto</label>
<input type="text" id="nomeProduto" name="nomeProduto" required placeholder="Digite o nome do produto">
<label for="descricao">Descrição</label>
<textarea id="descricao" name="descricao" rows="4" required placeholder="Digite a descrição do produto"></textarea>
<label for="preco">Preço</label>
<input type="number" id="preco" name="preco" step="0.01" required placeholder="Digite o preço">
<button type="submit">Registrar</button>
</form>
<script>
document.getElementById("formProduto").addEventListener("submit", async (event) => {
event.preventDefault();
const produto = {
nome: document.getElementById("nomeProduto").value,
descricao: document.getElementById("descricao").value,
preco: parseFloat(document.getElementById("preco").value)
};
const response = await fetch("http://localhost:3000/produtos", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(produto)
});
const result = await response.json();
if (response.ok) {
alert("Produto cadastrado com sucesso!");
document.getElementById("formProduto").reset();
} else {
alert(result.message);
}
});
</script>
</main>
<footer class="rodape">
<div class="container-rodape">
<!-- Coluna Esquerda -->
<div class="coluna-rodape">
<h3>Osande de Jesus</h3>
<ul class="links-esquerda">
<li><a href="#">Trabalhos</a></li>
<li><a href="#">Sobre Mim</a></li>
<li><a href="#">Serviços</a></li>
<li><a href="#">Contatos</a></li>
</ul>
</div>
<!-- Coluna Central -->
<div class="coluna-rodape central-rodape">
<h3>Contato</h3>
<p>hello@rddc.be</p>
<p>+244 999 999 999</p>
</div>
<div class="coluna-rodape central-rodape">
<h3>Estúdio</h3>
<p>Benguela</p>
</div>
<!-- Coluna Direita -->
<div class="coluna-rodape direita-rodape">
<h3>Redes Sociais</h3>
<ul class="links-sociais">
<li><a href="#">LinkedIn</a></li>
<li><a href="#">Behance</a></li>
<li><a href="#">Pinterest</a></li>
<li><a href="#">Instagram</a></li>
</ul>
</div>
</div>
<p id="slogan">Faça sua marca<sup>®</sup> a escolha óbvia</p>
</footer>
<script src="produto.js"></script>
</body>
</html>