-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTanque.js
More file actions
40 lines (36 loc) · 1.11 KB
/
Tanque.js
File metadata and controls
40 lines (36 loc) · 1.11 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
import React, { useState } from "react";
import "./tanque.css"
const Tanque = (props) => {
const [identificacao, setIdentificacao] = useState("");
const [capacidade, setCapacidade] = useState("");
const salvarTanque = () => {
const tanque = { identificacao, capacidade };
const tanquesSalvos = JSON.parse(localStorage.getItem("tanques")) || []
tanquesSalvos.push(tanque);
localStorage.setItem("tanques", JSON.stringify(tanquesSalvos))
};
return (
<div className="container">
<div className="titulo-tanque">
<h2>Tanque</h2>
</div>
<div className="input-tanque">
<input
type="text"
value={identificacao}
onChange={(e) => setIdentificacao(e.target.value)}
placeholder="identificação"
></input>
<input
type="text"
value={capacidade}
onChange={(e) => setCapacidade(e.target.value)}
placeholder="capacidade"
></input>
<button onClick={salvarTanque}>Salvar</button>
<button onClick={props.voltarParaHome}>Cancelar</button>
</div>
</div>
);
};
export default Tanque;