From 005895c8df99ed3f12d9fe7fa2dbb95aa9b50678 Mon Sep 17 00:00:00 2001 From: Mario Souto Date: Tue, 28 Jul 2020 22:07:13 -0300 Subject: [PATCH] Updates --- src/components/FormField/index.js | 19 +++++ src/pages/cadastro/Categoria/index.js | 100 +++++++++++++++++++++++--- 2 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 src/components/FormField/index.js diff --git a/src/components/FormField/index.js b/src/components/FormField/index.js new file mode 100644 index 0000000..90e6f58 --- /dev/null +++ b/src/components/FormField/index.js @@ -0,0 +1,19 @@ +import React from "react"; + +function FormField({ label, type, name, value, onChange }) { + return ( +
+ +
+ ) +} + +export default FormField; \ No newline at end of file diff --git a/src/pages/cadastro/Categoria/index.js b/src/pages/cadastro/Categoria/index.js index 2754fce..6beef7c 100644 --- a/src/pages/cadastro/Categoria/index.js +++ b/src/pages/cadastro/Categoria/index.js @@ -1,26 +1,108 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Link } from 'react-router-dom'; import PageDefault from '../../../components/PageDefault'; +import FormField from '../../../components/FormField'; function CadastroCategoria() { + const valoresIniciais = { + nome: '', + descricao: '', + cor: '', + } + const [categorias, setCategorias] = useState([]); + const [values, setValues] = useState(valoresIniciais); + + + function setValue(chave, valor) { + // chave: nome, descricao, bla, bli + setValues({ + ...values, + [chave]: valor, // nome: 'valor' + }) + } + + function handleChange(infosDoEvento) { + setValue( + infosDoEvento.target.getAttribute('name'), + infosDoEvento.target.value + ); + } + return ( -

Cadastro de Categoria

+

Cadastro de Categoria: {values.nome}

+ +
+ + - + + {/*
+