From 988665a34d9a9f1f91c31ff2e6aaa4e9324e3d60 Mon Sep 17 00:00:00 2001 From: Marco Tulio Soares Date: Tue, 13 Aug 2024 17:13:54 -0300 Subject: [PATCH 1/6] inicio front(ainda com alguns problemas) e back ainda precisa ser construido --- package-lock.json | 6 ++ riso_frontend/src/App.js | 2 + .../src/pages/Autentication/index.js | 5 +- .../src/pages/CadastroEmpresa/estilo.css | 0 .../src/pages/CadastroEmpresa/index.jsx | 87 +++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 package-lock.json create mode 100644 riso_frontend/src/pages/CadastroEmpresa/estilo.css create mode 100644 riso_frontend/src/pages/CadastroEmpresa/index.jsx diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..e14cfb930 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "2024.1-RISO-", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/riso_frontend/src/App.js b/riso_frontend/src/App.js index 951a04fbb..9f2a9d4c8 100644 --- a/riso_frontend/src/App.js +++ b/riso_frontend/src/App.js @@ -3,6 +3,7 @@ import { BrowserRouter as Router, Route, Routes} from 'react-router-dom'; // IMPORTAÇÕES DE PÁGINAS: import Autentication from './pages/Autentication'; import HomePage from './pages/HomePage'; +import RegisterUnit from './pages/CadastroEmpresa'; function App() { return ( @@ -10,6 +11,7 @@ function App() { } /> } /> + } /> ); diff --git a/riso_frontend/src/pages/Autentication/index.js b/riso_frontend/src/pages/Autentication/index.js index 6e39a55a2..47cb5feac 100644 --- a/riso_frontend/src/pages/Autentication/index.js +++ b/riso_frontend/src/pages/Autentication/index.js @@ -27,6 +27,9 @@ function Autentication() { const handleChangePassword = (event) => { setPassword(event.target.value); } + const handleSignupClick = () => { + navigate('/CadastroEmpresa'); + }; async function upUser(event){ event.preventDefault(); @@ -115,7 +118,7 @@ function Autentication() {

Olá, amigo!

Insira suas informações pessoais.

e comece sua jornada conosco.

- +

Entrar

diff --git a/riso_frontend/src/pages/CadastroEmpresa/estilo.css b/riso_frontend/src/pages/CadastroEmpresa/estilo.css new file mode 100644 index 000000000..e69de29bb diff --git a/riso_frontend/src/pages/CadastroEmpresa/index.jsx b/riso_frontend/src/pages/CadastroEmpresa/index.jsx new file mode 100644 index 000000000..b6e5640df --- /dev/null +++ b/riso_frontend/src/pages/CadastroEmpresa/index.jsx @@ -0,0 +1,87 @@ +import React, { useState } from "react"; +import { useNavigate } from "react-router-dom"; +import "./estilo.css"; + +function RegisterUnit() { + + const navigate = useNavigate(); + + + const [unitName, setUnitName] = useState(''); + const [employeeNumber, setEmployeeNumber] = useState(''); + const [cnpj, setCnpj] = useState(''); + const [state, setState] = useState(''); + const [street, setStreet] = useState(''); + const [complement, setComplement] = useState(''); + const [number, setNumber] = useState(''); + + + const handleChangeUnitName = (event) => setUnitName(event.target.value); + const handleChangeEmployeeNumber = (event) => setEmployeeNumber(event.target.value); + const handleChangeCnpj = (event) => setCnpj(event.target.value); + const handleChangeState = (event) => setState(event.target.value); + const handleChangeStreet = (event) => setStreet(event.target.value); + const handleChangeComplement = (event) => setComplement(event.target.value); + const handleChangeNumber = (event) => setNumber(event.target.value); + + + async function submitForm(event) { + event.preventDefault(); + try { + const unitData = { + unitName, + employeeNumber, + cnpj, + state, + street, + complement, + number, + }; + console.log("Dados da Unidade:", unitData); + // Aqui você poderia fazer a chamada para a API para salvar os dados + // Exemplo: const response = await saveUnit(unitData); + // console.log(response); + + // Redirecionar para outra página após salvar (opcional) + navigate('/successPage'); + } catch (err) { + console.log(err); + } + } + + return ( +
+
+
+

Registrar Nova Unidade/Empresa

+
+ + + + + + + + +
+
+
+
+ ); +} + +export default RegisterUnit; From 415769b25bdbf63aa3a69d8f79ed835a5d1ce5f5 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 14 Aug 2024 18:40:36 -0300 Subject: [PATCH 2/6] =?UTF-8?q?cria=C3=A7=C3=A3o=20da=20pasta=20do=20back?= =?UTF-8?q?=20end=20cadastro=20de=20empresas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- riso_backend/src/models/UnidadeEmpresa.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 riso_backend/src/models/UnidadeEmpresa.js diff --git a/riso_backend/src/models/UnidadeEmpresa.js b/riso_backend/src/models/UnidadeEmpresa.js new file mode 100644 index 000000000..e69de29bb From c7b2881ebe446619ce82ae4db3d4137b6c66b72a Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 14 Aug 2024 20:59:05 -0300 Subject: [PATCH 3/6] back e integrando com o banco --- .../controllers/unidadeEmpresa.controller.js | 19 +++++++++++ riso_backend/src/models/UnidadeEmpresa.js | 33 +++++++++++++++++++ riso_backend/src/routes/index.js | 3 ++ .../src/routes/unidadeEmpresa..route.js | 9 +++++ .../src/services/unidadeEmpresa.service.js | 7 ++++ 5 files changed, 71 insertions(+) create mode 100644 riso_backend/src/controllers/unidadeEmpresa.controller.js create mode 100644 riso_backend/src/routes/unidadeEmpresa..route.js create mode 100644 riso_backend/src/services/unidadeEmpresa.service.js diff --git a/riso_backend/src/controllers/unidadeEmpresa.controller.js b/riso_backend/src/controllers/unidadeEmpresa.controller.js new file mode 100644 index 000000000..3b246ee8e --- /dev/null +++ b/riso_backend/src/controllers/unidadeEmpresa.controller.js @@ -0,0 +1,19 @@ +import unidadeEmpresaService from "../services/unidadeEmpresa.service.js"; + +const createUnidadeEmpresa = async (req, res) => { + try{ + const {nome,numeroFuncionarios,cnpj,estado,rua,complemento,numero} = req.body + + const unidadeEmpresa = await unidadeEmpresaService.createService(req.body) + + return res.status(200).send({message: 'Unity and comapany successfully created ', unidadeEmpresa:unidadeEmpresa}) + }catch (err){ + + return res.status(500).send({message: err.message}) // completar erro 404 + + } + +} + +export default {createUnidadeEmpresa}; + diff --git a/riso_backend/src/models/UnidadeEmpresa.js b/riso_backend/src/models/UnidadeEmpresa.js index e69de29bb..d389516a2 100644 --- a/riso_backend/src/models/UnidadeEmpresa.js +++ b/riso_backend/src/models/UnidadeEmpresa.js @@ -0,0 +1,33 @@ +import mongoose from 'mongoose'; + +const UnidadeEmpresaSchema = new mongoose.Schema({ + nome: { + type: String, + required: true + }, + numeroFuncionarios: { + type: Number, + required: true + }, + cnpj: { + type: Number, // mudar no front (somente nmumeros) + required: true, + unique: true, + }, + estado: { + type: String, + required: true + }, + rua: { + type: String, + required: true + }, + complemento: { + type: String, + required: true + }, + numero: Number, +}); + +const UnidadeEmpresa = mongoose.model('UnidadeEmpresa', UnidadeEmpresaSchema); +export default UnidadeEmpresa; \ No newline at end of file diff --git a/riso_backend/src/routes/index.js b/riso_backend/src/routes/index.js index 5d5fc4a14..552dc8888 100644 --- a/riso_backend/src/routes/index.js +++ b/riso_backend/src/routes/index.js @@ -1,9 +1,12 @@ import { Router } from "express"; import cors from 'cors'; import userRouter from "./user.route.js"; +import unidadeEmpresaRouter from "./unidadeEmpresa..route.js"; const router = Router(); router.use("/user", cors(), userRouter); +router.use("/unidadeEmpresa", cors(), unidadeEmpresaRouter); + export default router; \ No newline at end of file diff --git a/riso_backend/src/routes/unidadeEmpresa..route.js b/riso_backend/src/routes/unidadeEmpresa..route.js new file mode 100644 index 000000000..4735f5480 --- /dev/null +++ b/riso_backend/src/routes/unidadeEmpresa..route.js @@ -0,0 +1,9 @@ +import express from 'express'; + +const unidadeEmpresaRouter = express.Router() +import unidadeEmpresaController from '../controllers/unidadeEmpresa.controller.js'; + +unidadeEmpresaRouter.post('/createUnidadeEmpresa',unidadeEmpresaController.createUnidadeEmpresa) +export default unidadeEmpresaRouter; + + diff --git a/riso_backend/src/services/unidadeEmpresa.service.js b/riso_backend/src/services/unidadeEmpresa.service.js new file mode 100644 index 000000000..d5a536215 --- /dev/null +++ b/riso_backend/src/services/unidadeEmpresa.service.js @@ -0,0 +1,7 @@ +import UnidadeEmpresa from "../models/UnidadeEmpresa.js"; + +const createService = (body) => UnidadeEmpresa.create(body); +export default{ + createService, + +} \ No newline at end of file From f31117e12ebeecbd446f5e31f45a0f200a52ae08 Mon Sep 17 00:00:00 2001 From: Marco Tulio Soares Date: Thu, 15 Aug 2024 11:11:56 -0300 Subject: [PATCH 4/6] Co-authored-by: Daniel Rodrigues --- .../src/pages/Autentication/styles.css | 1 + .../src/pages/CadastroEmpresa/estilo.css | 32 +++++++++++++++++++ .../src/pages/CadastroEmpresa/index.jsx | 9 +++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/riso_frontend/src/pages/Autentication/styles.css b/riso_frontend/src/pages/Autentication/styles.css index c7cafdf09..853581ff2 100644 --- a/riso_frontend/src/pages/Autentication/styles.css +++ b/riso_frontend/src/pages/Autentication/styles.css @@ -37,6 +37,7 @@ body { } .title { font-size: 28px; + font-weight: bold; text-transform: capitalize; } diff --git a/riso_frontend/src/pages/CadastroEmpresa/estilo.css b/riso_frontend/src/pages/CadastroEmpresa/estilo.css index e69de29bb..d21e327e2 100644 --- a/riso_frontend/src/pages/CadastroEmpresa/estilo.css +++ b/riso_frontend/src/pages/CadastroEmpresa/estilo.css @@ -0,0 +1,32 @@ +.title-second { + color: #58af9b; + white-space: nowrap; /* Impede a quebra de linha */ + width: 100%; /* ou definir uma largura específica, como 200px */ +} + + +.label-input input { + width: 150%; /* Aumenta a largura para 100% do contêiner */ + padding: 15px; /* Aumenta o espaço interno dos inputs */ + font-size: 18px; /* Aumenta o tamanho da fonte */ + height: auto; /* Permite que o campo ajuste sua altura conforme o conteúdo */ + box-sizing: border-box; /* Inclui o padding e a borda no cálculo da largura e altura */ +} + +.container { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; /* Garante que o contêiner ocupe 100% da altura da viewport */ + width: 100%; /* Garante que o contêiner ocupe 100% da largura da viewport */ + background-color: #ecf0f1; /* Cor de fundo */ +} + +.second-column { + width: 100%; /* Aumenta a largura da coluna */ + max-width: 600px; /* Define uma largura máxima para a coluna */ + padding: 20px; + background-color: #fff; /* Cor de fundo da coluna */ + border-radius: 8px; /* Bordas arredondadas */ + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Sombra para destacar o formulário */ +} diff --git a/riso_frontend/src/pages/CadastroEmpresa/index.jsx b/riso_frontend/src/pages/CadastroEmpresa/index.jsx index b6e5640df..50ffe3936 100644 --- a/riso_frontend/src/pages/CadastroEmpresa/index.jsx +++ b/riso_frontend/src/pages/CadastroEmpresa/index.jsx @@ -1,6 +1,6 @@ import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; -import "./estilo.css"; +import './estilo.css'; function RegisterUnit() { @@ -50,16 +50,17 @@ function RegisterUnit() { } return ( +
-
+

Registrar Nova Unidade/Empresa

diff --git a/riso_frontend/src/pages/CadastroEmpresa/index.jsx b/riso_frontend/src/pages/CadastroEmpresa/index.jsx index 50ffe3936..d92606679 100644 --- a/riso_frontend/src/pages/CadastroEmpresa/index.jsx +++ b/riso_frontend/src/pages/CadastroEmpresa/index.jsx @@ -1,12 +1,12 @@ import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; +import { createUnit } from "../../services/unitServices"; import './estilo.css'; function RegisterUnit() { const navigate = useNavigate(); - const [unitName, setUnitName] = useState(''); const [employeeNumber, setEmployeeNumber] = useState(''); const [cnpj, setCnpj] = useState(''); @@ -25,27 +25,13 @@ function RegisterUnit() { const handleChangeNumber = (event) => setNumber(event.target.value); - async function submitForm(event) { + async function newUnit(event) { event.preventDefault(); try { - const unitData = { - unitName, - employeeNumber, - cnpj, - state, - street, - complement, - number, - }; - console.log("Dados da Unidade:", unitData); - // Aqui você poderia fazer a chamada para a API para salvar os dados - // Exemplo: const response = await saveUnit(unitData); - // console.log(response); - - // Redirecionar para outra página após salvar (opcional) - navigate('/successPage'); + const response = await createUnit(unitName, employeeNumber, cnpj, state, street, complement, number); + navigate('/HomePage'); } catch (err) { - console.log(err); + console.log(err.response); } } @@ -55,30 +41,28 @@ function RegisterUnit() {

Registrar Nova Unidade/Empresa

-
- - - - - - - - -
+ + + + + + + +
diff --git a/riso_frontend/src/services/unitServices.js b/riso_frontend/src/services/unitServices.js new file mode 100644 index 000000000..9b9eaa44e --- /dev/null +++ b/riso_frontend/src/services/unitServices.js @@ -0,0 +1,39 @@ +import axios from 'axios'; + +const baseURL = 'http://localhost:3000'; + +export function createUnit(nameData, numberOfficialsData, cnpjData, stateData, streetData, complementData, numberData){ + const body = { + name: nameData, + numberOfficials: numberOfficialsData, + cnpj: cnpjData, + state: stateData, + street: streetData, + complement: complementData, + }; + + if (numberData) body.number = numberData; + + const response = axios.post(`${baseURL}/unit/createUnit`, body); + return response; +}; + +export function updateUnit (id ,nameData, numberOfficialsData, cnpjData, stateData, streetData, complementData, numberData){ + const body = {} + + if (nameData) body.name = nameData; + if (numberOfficialsData) body.numberOfficials = numberOfficialsData; + if (cnpjData) body.cnpj = cnpjData; + if (stateData) body.state = stateData; + if (streetData) body.street = streetData; + if (complementData) body.complement = complementData; + if (numberData) body.number = numberData; + + const response = axios.patch(`${baseURL}/unit/updateUnit/${id}`, body); + return response; +}; + +export function deleteUnit (id){ + const response = axios.delete(`${baseURL}/unit/deleteUnit/${id}`); + return response; +} \ No newline at end of file