From 33197c30133e1cadc6107e9e57c937ddfd6851aa Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Thu, 4 Aug 2022 20:50:16 -0300 Subject: [PATCH 001/146] =?UTF-8?q?subindo=20vers=C3=A3o=20base=20da=20nov?= =?UTF-8?q?a=20branch=20que=20iremos=20trabalhar=20na=20sprint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 1 + .../Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" | 0 2 files changed, 1 insertion(+) create mode 100644 "Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" create mode 100644 "Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" new file mode 100644 index 0000000..35d5fca --- /dev/null +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -0,0 +1 @@ +import './Ações.css'; \ No newline at end of file diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" new file mode 100644 index 0000000..e69de29 From b28bf8dbbb1571fcfdb9adcf44057d82793aecde Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 5 Aug 2022 11:56:11 -0300 Subject: [PATCH 002/146] adicionando a base do css que vamos utilizar e criando os primeiros states --- Front/src/App.tsx | 2 + .../A\303\247oes.tsx" | 38 ++++++++++++++++++- .../A\303\247\303\265es.css" | 31 +++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 7cb18aa..c07624c 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -2,6 +2,7 @@ import './App.css' import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; +import CadastroAcoes from './pages/Cadastro de Ações/Açoes'; function App() { @@ -11,6 +12,7 @@ function App() { } /> } /> + } /> diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 35d5fca..be50938 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -1 +1,37 @@ -import './Ações.css'; \ No newline at end of file +import { IMaskInput } from "react-imask"; +import { IoMdArrowBack } from 'react-icons/io'; +import './Ações.css'; +import { useState } from "react"; +import { parseISO, isAfter, sub, add } from "date-fns"; +import { Link, useNavigate } from "react-router-dom"; +import Axios from "axios"; + +const CadastroAcoes = () => { + + const [error, setError] = useState(""); + const [assets,setAssets] = useState(""); //Assets é os ativos + const [stockPrice, setStockPrice] = useState(""); //preço das ações + const [date, setDate] = useState(""); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + + setError(""); + + } + + return ( + +
+
+

Comprar/Vender

+ +
+
+ + + ) +} + + +export default CadastroAcoes; \ No newline at end of file diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index e69de29..06ca2e5 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -0,0 +1,31 @@ +body { + margin: 0; +} +.background-img { + display: flex; + align-items: center; + justify-content: center; + position: absolute; + height: 100vh; + width:100vw; + background-image: url('../../assets/background.jpeg'); + background-size: cover; + background-repeat: no-repeat; +} + +.div-cadastro{ + display: flex; + flex-direction: column; + padding: 2%; + width: 80%; + background-color: rgba(10, 17, 79, 0.8); + border-radius: 40px; + color: white; + opacity: 25%; +} + +.titulo { + text-align: center; + font-size: 2.5em; + margin-bottom: 0.5em; +} \ No newline at end of file From 20815cfae6cb2ed66eae1fe8a1b13a4e569a0f45 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 5 Aug 2022 17:37:48 -0300 Subject: [PATCH 003/146] =?UTF-8?q?Elaborando=20um=20esqueleto=20base=20pa?= =?UTF-8?q?ra=20produ=C3=A7=C3=A3o=20da=20tela?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A\303\247oes.tsx" | 56 ++++++++++++++- .../A\303\247\303\265es.css" | 68 +++++++++++++++++++ 2 files changed, 122 insertions(+), 2 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index be50938..ccd389e 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -12,20 +12,72 @@ const CadastroAcoes = () => { const [assets,setAssets] = useState(""); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações const [date, setDate] = useState(""); + const [quantity,setQuantity] = useState(""); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); - } + //p formatar data + const [inputType, setInputType] = useState("text"); + return (
-

Comprar/Vender

+

Invext-Comprar/Vender

+
+

Ativo

+ setAssets(e.target.value)} + /> + {/*A ideia é alinhar eles na mesma linha */} +
+

Preço da Ação

+ setStockPrice(e.target.value)} + /> +

Quantidade

+ setQuantity(e.target.value)} + /> +
+

Data

+ setDate(e.target.value)} + onFocus={() => setInputType("date")} + onBlur={() => setInputType("text")} + /> +
+ + {error &&

{error}

} + + {error &&

{error}

} +
+
diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 06ca2e5..3e62f6c 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -28,4 +28,72 @@ body { text-align: center; font-size: 2.5em; margin-bottom: 0.5em; +} + +input{ + background-color:rgba(169, 178, 194, 0.7); + color: white; + width: 50%; + padding: 0.5em; + border: none; + border-radius: 40px; + font-size: 1.5em; + text-align: center; + font-weight: bold; +} + +input::placeholder{ + color: rgba(255, 255, 255, 0.7); + font-family: 'Roboto'; +} + +.buy-button { + background-color:#47B802; + color:white; + border: none; + border-radius:70px; + font-size: 1.5em; + text-align: center; + padding: 0.5em 1.5em; + cursor: pointer; + transition: 0.25s; +} + +.buy-button:hover{ + background: white; + color: black; +} + +.sell-button { + background-color:#9F0303; + color:white; + border: none; + border-radius:70px; + font-size: 1.5em; + text-align: center; + padding: 0.5em 1.5em; + cursor: pointer; + transition: 0.25s; +} + +.sellbutton:hover{ + background: white; + color: black; +} + +.error{ + color:#721c24; + background-color: #F8D7D4; + border: 1px solid #F5C6CB; + padding: 0.5em 1.5em; + border-radius: 5px; + +} + +.buttonBox{ + display: inline; +} + +.columnBox { + display: inline; } \ No newline at end of file From 40b00ba08fb44df14f5e0e14597a5490687fb45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Sun, 7 Aug 2022 17:43:44 -0300 Subject: [PATCH 004/146] =?UTF-8?q?adicionado=20escopo=20do=20banco=20de?= =?UTF-8?q?=20dados=20da=20a=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/app.js | 42 +++--- Back/src/controller/UserController.js | 179 +++++++++++++------------- Back/src/models/Acao.js | 55 ++++++++ Back/src/models/User.js | 104 +++++++-------- Back/src/models/db.js | 28 ++-- Back/src/server.js | 14 +- 6 files changed, 239 insertions(+), 183 deletions(-) create mode 100644 Back/src/models/Acao.js diff --git a/Back/src/app.js b/Back/src/app.js index bc7c0e3..51a4521 100644 --- a/Back/src/app.js +++ b/Back/src/app.js @@ -1,22 +1,22 @@ -const express = require("express"); -const app = express(); -const bodyParser = require("body-parser"); -const cors = require("cors"); - -const userControler = require('../src/controller/UserController.js'); - -app.use(express.json()); - -app.use(bodyParser.urlencoded({extended: false})); -app.use(bodyParser.json()); -app.use(cors()) - -app.get("/", (req, res) => { - res.status(200).json({ - message: "GFour Invext" - }); -}); - -app.use('/usuario', userControler); - +const express = require("express"); +const app = express(); +const bodyParser = require("body-parser"); +const cors = require("cors"); + +const userControler = require('../src/controller/UserController.js'); + +app.use(express.json()); + +app.use(bodyParser.urlencoded({extended: false})); +app.use(bodyParser.json()); +app.use(cors()) + +app.get("/", (req, res) => { + res.status(200).json({ + message: "GFour Invext" + }); +}); + +app.use('/usuario', userControler); + module.exports = app; \ No newline at end of file diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 6f64a25..6f8d45a 100644 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -1,90 +1,91 @@ -const express = require("express"); -const bcrypt = require("bcryptjs"); -const jwt = require('jsonwebtoken'); - -const User = require("../models/User"); -const app = express(); - -// funciona -app.post("/cadastrar", async (req, res) => { - const salt = await bcrypt.genSalt(10); - - const novo_usuario = { - nomeCompleto: req.body.nomeCompleto, - dataNascimento: req.body.dataNascimento, - telefone: req.body.telefone, - email: req.body.email, - senha: await bcrypt.hash(req.body.senha, salt) - }; - - const usuario = await User.findOne({ where: { email: novo_usuario.email} }); - - if (usuario === null){ - await User.create(novo_usuario) - .then(() => { - return res.json({ - erro: false, - message: "Usuario cadastrado com sucesso!" - }) - }).catch((error) => { - console.log(error); - return res.status(400).json({ - erro: true, - message: error.message - }) - }); - } else { - return res.status(400).json({ - erro: true, - message: "Usuario ja existente no banco!" - }) - } -}) - -// funciona -app.post("/login", async (req, res) => { - const usuario = await User.findOne({ - attributes: ["id", "email", "senha"], - where: { - email: req.body.email - } - }); - - if(usuario === null){ - return res.status(400).json({ - erro: true, - message: "Usuario nao encontrado!" - }); - } else { - if(!(await bcrypt.compare(req.body.senha, usuario.senha))){ - return res.status(400).json({ - erro: true, - message: "Senha incorreta!" - }); - } else { - const token = jwt.sign({id: usuario.id}, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3", { - // expiresIn: 600 //10 min - // expiresIn: '7d' // 7 dia - expiresIn: 1800 //30 min - }); - - return res.json({ - erro: false, - message: "Login realizado com sucesso!", - token - }); - } - } -}); - -// nao funciona -> somente o usuario logado deve conseguir atualizar suas infos -app.post("/atualizar", async (req, res) => { - -}) - -// nao funciona -> somente o usuario logado deve conseguir deletar sua conta -app.post("/deletar", async (req, res) => { - -}) - +const express = require("express"); +const bcrypt = require("bcryptjs"); +const jwt = require('jsonwebtoken'); + +const User = require("../models/User"); +const Acoes = require("../models/Acao"); +const app = express(); + +// funciona +app.post("/cadastrar", async (req, res) => { + const salt = await bcrypt.genSalt(10); + + const novo_usuario = { + nomeCompleto: req.body.nomeCompleto, + dataNascimento: req.body.dataNascimento, + telefone: req.body.telefone, + email: req.body.email, + senha: await bcrypt.hash(req.body.senha, salt) + }; + + const usuario = await User.findOne({ where: { email: novo_usuario.email} }); + + if (usuario === null){ + await User.create(novo_usuario) + .then(() => { + return res.json({ + erro: false, + message: "Usuario cadastrado com sucesso!" + }) + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + message: error.message + }) + }); + } else { + return res.status(400).json({ + erro: true, + message: "Usuario ja existente no banco!" + }) + } +}) + +// funciona +app.post("/login", async (req, res) => { + const usuario = await User.findOne({ + attributes: ["id", "email", "senha"], + where: { + email: req.body.email + } + }); + + if(usuario === null){ + return res.status(400).json({ + erro: true, + message: "Usuario nao encontrado!" + }); + } else { + if(!(await bcrypt.compare(req.body.senha, usuario.senha))){ + return res.status(400).json({ + erro: true, + message: "Senha incorreta!" + }); + } else { + const token = jwt.sign({id: usuario.id}, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3", { + // expiresIn: 600 //10 min + // expiresIn: '7d' // 7 dia + expiresIn: 1800 //30 min + }); + + return res.json({ + erro: false, + message: "Login realizado com sucesso!", + token + }); + } + } +}); + +// nao funciona -> somente o usuario logado deve conseguir atualizar suas infos +app.post("/atualizar", async (req, res) => { + +}) + +// nao funciona -> somente o usuario logado deve conseguir deletar sua conta +app.post("/deletar", async (req, res) => { + +}) + module.exports = app; \ No newline at end of file diff --git a/Back/src/models/Acao.js b/Back/src/models/Acao.js new file mode 100644 index 0000000..d29f793 --- /dev/null +++ b/Back/src/models/Acao.js @@ -0,0 +1,55 @@ +const Sequelize = require('sequelize'); +const db = require('./db'); + +const Acao = db.define('acoes', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + allowNull: false, + primaryKey: true + }, + ativo: { + type: Sequelize.JSON, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + preco: { + type: Sequelize.DOUBLE, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + quantidade: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + data: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, +}); +Acao.sync() +Acao.sync({ alter: true }) + + +// verifica se existe alteração na model que não está no BD + + +module.exports = Acao; \ No newline at end of file diff --git a/Back/src/models/User.js b/Back/src/models/User.js index 8f8fccd..93ee13a 100644 --- a/Back/src/models/User.js +++ b/Back/src/models/User.js @@ -1,53 +1,53 @@ -const Sequelize = require('sequelize'); -const db = require('./db'); - -const User = db.define('users', { - id: { - type: Sequelize.INTEGER, - autoIncrement: true, - allowNull: false, - primaryKey: true - }, - nomeCompleto: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - dataNascimento: { - type: Sequelize.STRING, - allowNull: false, - }, - telefone: { - type: Sequelize.STRING, - allowNull: true, - }, - email: { - type: Sequelize.STRING, - allowNull: false, - validate: { - isEmail: { - msg: "Email digitado eh invalido!" - } - } - }, - senha: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - } -}); - -User.sync() - -// verifica se existe alteração na model que não está no BD -// User.sync({ alter: true }) - +const Sequelize = require('sequelize'); +const db = require('./db'); + +const User = db.define('users', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + allowNull: false, + primaryKey: true + }, + nomeCompleto: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + dataNascimento: { + type: Sequelize.STRING, + allowNull: false, + }, + telefone: { + type: Sequelize.STRING, + allowNull: true, + }, + email: { + type: Sequelize.STRING, + allowNull: false, + validate: { + isEmail: { + msg: "Email digitado eh invalido!" + } + } + }, + senha: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + } +}); + +User.sync() + +// verifica se existe alteração na model que não está no BD +// User.sync({ alter: true }) + module.exports = User; \ No newline at end of file diff --git a/Back/src/models/db.js b/Back/src/models/db.js index 8fa8ff6..b48ef26 100644 --- a/Back/src/models/db.js +++ b/Back/src/models/db.js @@ -1,15 +1,15 @@ -const Sequelize = require('sequelize'); - -const sequelize = new Sequelize("usuario", "root", "12345678", { - host: 'localhost', - dialect: 'mysql' -}); - -sequelize.authenticate() -.then(function(){ - console.log("Success: Database conection running.") -}).catch(function(){ - console.log("Error: Database conection failed.") -}) - +const Sequelize = require('sequelize'); + +const sequelize = new Sequelize("usuario", "root", "12345678", { + host: 'localhost', + dialect: 'mysql' +}); + +sequelize.authenticate() +.then(function(){ + console.log("Success: Database conection running.") +}).catch(function(){ + console.log("Error: Database conection failed.") +}) + module.exports = sequelize; \ No newline at end of file diff --git a/Back/src/server.js b/Back/src/server.js index 89f28cd..f5e9d12 100644 --- a/Back/src/server.js +++ b/Back/src/server.js @@ -1,8 +1,8 @@ -const http = require("http"); -const app = require("./app"); - -const port = process.env.PORT || 3000; - -const server = http.createServer(app); - +const http = require("http"); +const app = require("./app"); + +const port = process.env.PORT || 3000; + +const server = http.createServer(app); + server.listen(port); \ No newline at end of file From e69a8f2e65a78e433c54d1a9ced1036ec029a789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Sun, 7 Aug 2022 18:10:21 -0300 Subject: [PATCH 005/146] =?UTF-8?q?Revert=20"adicionado=20escopo=20do=20ba?= =?UTF-8?q?nco=20de=20dados=20da=20a=C3=A7=C3=A3o"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 40b00ba08fb44df14f5e0e14597a5490687fb45b. --- Back/src/app.js | 42 +++--- Back/src/controller/UserController.js | 179 +++++++++++++------------- Back/src/models/Acao.js | 55 -------- Back/src/models/User.js | 104 +++++++-------- Back/src/models/db.js | 28 ++-- Back/src/server.js | 14 +- 6 files changed, 183 insertions(+), 239 deletions(-) delete mode 100644 Back/src/models/Acao.js diff --git a/Back/src/app.js b/Back/src/app.js index 51a4521..bc7c0e3 100644 --- a/Back/src/app.js +++ b/Back/src/app.js @@ -1,22 +1,22 @@ -const express = require("express"); -const app = express(); -const bodyParser = require("body-parser"); -const cors = require("cors"); - -const userControler = require('../src/controller/UserController.js'); - -app.use(express.json()); - -app.use(bodyParser.urlencoded({extended: false})); -app.use(bodyParser.json()); -app.use(cors()) - -app.get("/", (req, res) => { - res.status(200).json({ - message: "GFour Invext" - }); -}); - -app.use('/usuario', userControler); - +const express = require("express"); +const app = express(); +const bodyParser = require("body-parser"); +const cors = require("cors"); + +const userControler = require('../src/controller/UserController.js'); + +app.use(express.json()); + +app.use(bodyParser.urlencoded({extended: false})); +app.use(bodyParser.json()); +app.use(cors()) + +app.get("/", (req, res) => { + res.status(200).json({ + message: "GFour Invext" + }); +}); + +app.use('/usuario', userControler); + module.exports = app; \ No newline at end of file diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 6f8d45a..6f64a25 100644 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -1,91 +1,90 @@ -const express = require("express"); -const bcrypt = require("bcryptjs"); -const jwt = require('jsonwebtoken'); - -const User = require("../models/User"); -const Acoes = require("../models/Acao"); -const app = express(); - -// funciona -app.post("/cadastrar", async (req, res) => { - const salt = await bcrypt.genSalt(10); - - const novo_usuario = { - nomeCompleto: req.body.nomeCompleto, - dataNascimento: req.body.dataNascimento, - telefone: req.body.telefone, - email: req.body.email, - senha: await bcrypt.hash(req.body.senha, salt) - }; - - const usuario = await User.findOne({ where: { email: novo_usuario.email} }); - - if (usuario === null){ - await User.create(novo_usuario) - .then(() => { - return res.json({ - erro: false, - message: "Usuario cadastrado com sucesso!" - }) - }).catch((error) => { - console.log(error); - return res.status(400).json({ - erro: true, - message: error.message - }) - }); - } else { - return res.status(400).json({ - erro: true, - message: "Usuario ja existente no banco!" - }) - } -}) - -// funciona -app.post("/login", async (req, res) => { - const usuario = await User.findOne({ - attributes: ["id", "email", "senha"], - where: { - email: req.body.email - } - }); - - if(usuario === null){ - return res.status(400).json({ - erro: true, - message: "Usuario nao encontrado!" - }); - } else { - if(!(await bcrypt.compare(req.body.senha, usuario.senha))){ - return res.status(400).json({ - erro: true, - message: "Senha incorreta!" - }); - } else { - const token = jwt.sign({id: usuario.id}, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3", { - // expiresIn: 600 //10 min - // expiresIn: '7d' // 7 dia - expiresIn: 1800 //30 min - }); - - return res.json({ - erro: false, - message: "Login realizado com sucesso!", - token - }); - } - } -}); - -// nao funciona -> somente o usuario logado deve conseguir atualizar suas infos -app.post("/atualizar", async (req, res) => { - -}) - -// nao funciona -> somente o usuario logado deve conseguir deletar sua conta -app.post("/deletar", async (req, res) => { - -}) - +const express = require("express"); +const bcrypt = require("bcryptjs"); +const jwt = require('jsonwebtoken'); + +const User = require("../models/User"); +const app = express(); + +// funciona +app.post("/cadastrar", async (req, res) => { + const salt = await bcrypt.genSalt(10); + + const novo_usuario = { + nomeCompleto: req.body.nomeCompleto, + dataNascimento: req.body.dataNascimento, + telefone: req.body.telefone, + email: req.body.email, + senha: await bcrypt.hash(req.body.senha, salt) + }; + + const usuario = await User.findOne({ where: { email: novo_usuario.email} }); + + if (usuario === null){ + await User.create(novo_usuario) + .then(() => { + return res.json({ + erro: false, + message: "Usuario cadastrado com sucesso!" + }) + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + message: error.message + }) + }); + } else { + return res.status(400).json({ + erro: true, + message: "Usuario ja existente no banco!" + }) + } +}) + +// funciona +app.post("/login", async (req, res) => { + const usuario = await User.findOne({ + attributes: ["id", "email", "senha"], + where: { + email: req.body.email + } + }); + + if(usuario === null){ + return res.status(400).json({ + erro: true, + message: "Usuario nao encontrado!" + }); + } else { + if(!(await bcrypt.compare(req.body.senha, usuario.senha))){ + return res.status(400).json({ + erro: true, + message: "Senha incorreta!" + }); + } else { + const token = jwt.sign({id: usuario.id}, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3", { + // expiresIn: 600 //10 min + // expiresIn: '7d' // 7 dia + expiresIn: 1800 //30 min + }); + + return res.json({ + erro: false, + message: "Login realizado com sucesso!", + token + }); + } + } +}); + +// nao funciona -> somente o usuario logado deve conseguir atualizar suas infos +app.post("/atualizar", async (req, res) => { + +}) + +// nao funciona -> somente o usuario logado deve conseguir deletar sua conta +app.post("/deletar", async (req, res) => { + +}) + module.exports = app; \ No newline at end of file diff --git a/Back/src/models/Acao.js b/Back/src/models/Acao.js deleted file mode 100644 index d29f793..0000000 --- a/Back/src/models/Acao.js +++ /dev/null @@ -1,55 +0,0 @@ -const Sequelize = require('sequelize'); -const db = require('./db'); - -const Acao = db.define('acoes', { - id: { - type: Sequelize.INTEGER, - autoIncrement: true, - allowNull: false, - primaryKey: true - }, - ativo: { - type: Sequelize.JSON, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - preco: { - type: Sequelize.DOUBLE, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - quantidade: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - data: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, -}); -Acao.sync() -Acao.sync({ alter: true }) - - -// verifica se existe alteração na model que não está no BD - - -module.exports = Acao; \ No newline at end of file diff --git a/Back/src/models/User.js b/Back/src/models/User.js index 93ee13a..8f8fccd 100644 --- a/Back/src/models/User.js +++ b/Back/src/models/User.js @@ -1,53 +1,53 @@ -const Sequelize = require('sequelize'); -const db = require('./db'); - -const User = db.define('users', { - id: { - type: Sequelize.INTEGER, - autoIncrement: true, - allowNull: false, - primaryKey: true - }, - nomeCompleto: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - dataNascimento: { - type: Sequelize.STRING, - allowNull: false, - }, - telefone: { - type: Sequelize.STRING, - allowNull: true, - }, - email: { - type: Sequelize.STRING, - allowNull: false, - validate: { - isEmail: { - msg: "Email digitado eh invalido!" - } - } - }, - senha: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - } -}); - -User.sync() - -// verifica se existe alteração na model que não está no BD -// User.sync({ alter: true }) - +const Sequelize = require('sequelize'); +const db = require('./db'); + +const User = db.define('users', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + allowNull: false, + primaryKey: true + }, + nomeCompleto: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + dataNascimento: { + type: Sequelize.STRING, + allowNull: false, + }, + telefone: { + type: Sequelize.STRING, + allowNull: true, + }, + email: { + type: Sequelize.STRING, + allowNull: false, + validate: { + isEmail: { + msg: "Email digitado eh invalido!" + } + } + }, + senha: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + } +}); + +User.sync() + +// verifica se existe alteração na model que não está no BD +// User.sync({ alter: true }) + module.exports = User; \ No newline at end of file diff --git a/Back/src/models/db.js b/Back/src/models/db.js index b48ef26..8fa8ff6 100644 --- a/Back/src/models/db.js +++ b/Back/src/models/db.js @@ -1,15 +1,15 @@ -const Sequelize = require('sequelize'); - -const sequelize = new Sequelize("usuario", "root", "12345678", { - host: 'localhost', - dialect: 'mysql' -}); - -sequelize.authenticate() -.then(function(){ - console.log("Success: Database conection running.") -}).catch(function(){ - console.log("Error: Database conection failed.") -}) - +const Sequelize = require('sequelize'); + +const sequelize = new Sequelize("usuario", "root", "12345678", { + host: 'localhost', + dialect: 'mysql' +}); + +sequelize.authenticate() +.then(function(){ + console.log("Success: Database conection running.") +}).catch(function(){ + console.log("Error: Database conection failed.") +}) + module.exports = sequelize; \ No newline at end of file diff --git a/Back/src/server.js b/Back/src/server.js index f5e9d12..89f28cd 100644 --- a/Back/src/server.js +++ b/Back/src/server.js @@ -1,8 +1,8 @@ -const http = require("http"); -const app = require("./app"); - -const port = process.env.PORT || 3000; - -const server = http.createServer(app); - +const http = require("http"); +const app = require("./app"); + +const port = process.env.PORT || 3000; + +const server = http.createServer(app); + server.listen(port); \ No newline at end of file From 34b28534ccded78f5ca16437998af4e3d49f06f6 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Sun, 7 Aug 2022 23:17:16 -0300 Subject: [PATCH 006/146] Configurancao tabela de acao no banco de dados --- Back/src/models/Acao.js | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Back/src/models/Acao.js diff --git a/Back/src/models/Acao.js b/Back/src/models/Acao.js new file mode 100644 index 0000000..bb578b4 --- /dev/null +++ b/Back/src/models/Acao.js @@ -0,0 +1,58 @@ +const Sequelize = require('sequelize'); +const db = require('./db'); + +const Acao = db.define('acao', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + allowNull: false, + primaryKey: true + }, + nomeAtivo: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + sigla: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + preco: { + type: Sequelize.FLOAT, + allowNull: true, + }, + quantidade: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + dataCompra: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + } +}); + +Acao.sync() + +// verifica se existe alteração na model que não está no BD +// Acao.sync({ alter: true }) + +module.exports = Acao; \ No newline at end of file From b018f9effa5581b1205a5362cb31c2de3e6a27a6 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 8 Aug 2022 18:06:30 -0300 Subject: [PATCH 007/146] =?UTF-8?q?Cria=C3=A7=C3=A3o=20das=20configura?= =?UTF-8?q?=C3=A7=C3=B5es=20de=20usuario=20logado/nao=20logado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/services/Provider.tsx | 49 ++++++++++++++++++++++++++++++ Front/src/services/authToken.tsx | 17 +++++++++++ Front/src/services/requireAuth.tsx | 19 ++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 Front/src/services/Provider.tsx create mode 100644 Front/src/services/authToken.tsx create mode 100644 Front/src/services/requireAuth.tsx diff --git a/Front/src/services/Provider.tsx b/Front/src/services/Provider.tsx new file mode 100644 index 0000000..4c8c0f1 --- /dev/null +++ b/Front/src/services/Provider.tsx @@ -0,0 +1,49 @@ +import { createContext, useContext,useState, useMemo } from "react"; +import { returnToken, setarToken, destroyToken } from "./authToken"; +// import { useLocalStorage } from "./useLocalStorage"; + +// Criação de um Context para saber se o usuario estah logad o ou nao +interface AuthContextType { + getToken: () => any; + user: any; + login: (token: string, newUser: any, callback: VoidFunction) => void; + logout: (callback: VoidFunction) => void; +} + +const AuthContext = createContext(null!); + +export const AuthProvider = ({ children }: { children: JSX.Element }) => { + + const [user, setUser] = useState(null); + + // call this function when you want to authenticate the user + const login = (token: string, newUser: any, callback: VoidFunction) => { + return setarToken(token, () => { + setUser(newUser); + callback(); + }); + + + }; + + // call this function to sign out logged in user + const logout = (callback: VoidFunction) => { + return destroyToken(() => { + setUser(null); + callback(); + }); + + }; + + const getToken = () =>{ + return returnToken(); + }; + + let value = { getToken, user, login, logout }; + + return {children}; +}; + +export const useAuth = () => { + return useContext(AuthContext); +}; \ No newline at end of file diff --git a/Front/src/services/authToken.tsx b/Front/src/services/authToken.tsx new file mode 100644 index 0000000..d7b7dd7 --- /dev/null +++ b/Front/src/services/authToken.tsx @@ -0,0 +1,17 @@ + +export const TOKEN_KEY = "@invext-Token"; + +export const returnToken = () => localStorage.getItem(TOKEN_KEY); + +export const setarToken = (token: string, callback : VoidFunction) => { + localStorage.setItem(TOKEN_KEY, token); + callback(); +}; + +export const destroyToken = (callback: VoidFunction) => { + localStorage.removeItem(TOKEN_KEY,); + callback(); +}; + + + diff --git a/Front/src/services/requireAuth.tsx b/Front/src/services/requireAuth.tsx new file mode 100644 index 0000000..e6e99f4 --- /dev/null +++ b/Front/src/services/requireAuth.tsx @@ -0,0 +1,19 @@ +import { useAuth } from "./Provider"; +import { useLocation, Navigate } from "react-router-dom"; + + + +export function RequireAuth ( { children }: { children: JSX.Element } ) : JSX.Element{ + let auth = useAuth(); + let location = useLocation(); + + console.log(auth.getToken()); + if (!auth.getToken()) { + // Redirect them to the /login page, but save the current location they were + // trying to go to when they were redirected. This allows us to send them + // along to that page after they login, which is a nicer user experience + // than dropping them off on the home page. + return ; + } + return children; + } \ No newline at end of file From 4a1ff3b28f6ed69de26dc8748a04c9b2d437f045 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 8 Aug 2022 18:15:09 -0300 Subject: [PATCH 008/146] =?UTF-8?q?Configura=C3=A7=C3=A3o=20das=20rotas=20?= =?UTF-8?q?no=20App=20e=20na=20Main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/App.tsx | 21 ++++++++++++++++++--- Front/src/main.tsx | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 7cb18aa..7373df1 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -1,18 +1,33 @@ import './App.css' import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' -import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; +import {Route, Routes } from "react-router-dom"; +import { AuthProvider } from './services/Provider'; +import { RequireAuth } from './services/requireAuth'; + +// Remover e colocar a side bar que realmente será implementada +function SideBar() { + return
SideBar
+} function App() { return (
- + } /> } /> + + + + + } > + {/* Aqui ficarão as outras rotas do usuário logado */} + - +
) } diff --git a/Front/src/main.tsx b/Front/src/main.tsx index 238fccb..d46eb1e 100644 --- a/Front/src/main.tsx +++ b/Front/src/main.tsx @@ -1,10 +1,13 @@ import React from 'react' import ReactDOM from 'react-dom/client' import App from './App' +import { BrowserRouter } from "react-router-dom"; import './index.css' ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + ) From 14c5893f2f521e69f34dded43bd22398a65f1b48 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 8 Aug 2022 18:16:39 -0300 Subject: [PATCH 009/146] =?UTF-8?q?Configura=C3=A7=C3=A3o=20do=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/controller/UserController.js | 3 ++- Front/src/pages/LoginUsuario/Login.tsx | 19 +++++++++++++++---- Front/src/services/requireAuth.tsx | 1 - 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 6f64a25..7270b24 100644 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -71,7 +71,8 @@ app.post("/login", async (req, res) => { return res.json({ erro: false, message: "Login realizado com sucesso!", - token + token, + usuario }); } } diff --git a/Front/src/pages/LoginUsuario/Login.tsx b/Front/src/pages/LoginUsuario/Login.tsx index f84835d..84a72f6 100644 --- a/Front/src/pages/LoginUsuario/Login.tsx +++ b/Front/src/pages/LoginUsuario/Login.tsx @@ -1,6 +1,7 @@ import './Login.css'; import { useState } from "react"; -import { Link } from 'react-router-dom'; +import { Link, useLocation, useNavigate} from 'react-router-dom'; +import { useAuth } from '../../services/Provider'; import Axios from "axios"; const LoginUsuario = () => { @@ -8,8 +9,13 @@ const LoginUsuario = () => { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); - const [user, setUser] = useState([]); + // Variaveis para encaminhamento de usuario logado/nao logado + let navigate = useNavigate(); + let location = useLocation(); + let auth = useAuth(); + + let from = location.state?.from?.pathname || "/index"; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -26,8 +32,13 @@ const LoginUsuario = () => { senha: password }).then(function (response) { const message = response.data.message; - const token = response.data.token; - alert(message); + const token = response.data.token; + const user = response.data.usuario; + + auth.login(token, user, () => { + navigate(from, { replace: true }); + }); + }).catch(function (response) { // Caso caia nesse catch, o usuario nao eh gravado no banco e retorna um erro const message = response.response.data.message; diff --git a/Front/src/services/requireAuth.tsx b/Front/src/services/requireAuth.tsx index e6e99f4..22fe328 100644 --- a/Front/src/services/requireAuth.tsx +++ b/Front/src/services/requireAuth.tsx @@ -7,7 +7,6 @@ export function RequireAuth ( { children }: { children: JSX.Element } ) : JSX.El let auth = useAuth(); let location = useLocation(); - console.log(auth.getToken()); if (!auth.getToken()) { // Redirect them to the /login page, but save the current location they were // trying to go to when they were redirected. This allows us to send them From 5c21afd81d63f718a694eeef5993ea6077a4ff07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Tue, 9 Aug 2022 11:30:09 -0300 Subject: [PATCH 010/146] =?UTF-8?q?Adicionado=20novo=20campo=20para=20tipo?= =?UTF-8?q?=20de=20opera=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/models/Acao.js | 118 +++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/Back/src/models/Acao.js b/Back/src/models/Acao.js index bb578b4..7c6d7c4 100644 --- a/Back/src/models/Acao.js +++ b/Back/src/models/Acao.js @@ -1,58 +1,62 @@ -const Sequelize = require('sequelize'); -const db = require('./db'); - -const Acao = db.define('acao', { - id: { - type: Sequelize.INTEGER, - autoIncrement: true, - allowNull: false, - primaryKey: true - }, - nomeAtivo: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - sigla: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - preco: { - type: Sequelize.FLOAT, - allowNull: true, - }, - quantidade: { - type: Sequelize.INTEGER, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - }, - dataCompra: { - type: Sequelize.STRING, - allowNull: false, - validate: { - notEmpty: { - msg: "Esse campo nao pode ser vazio" - } - } - } -}); - -Acao.sync() - -// verifica se existe alteração na model que não está no BD -// Acao.sync({ alter: true }) - +const Sequelize = require('sequelize'); +const db = require('./db'); + +const Acao = db.define('acao', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + allowNull: false, + primaryKey: true + }, + nomeAtivo: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + tipo: { + type: Sequelize.STRING, + allowNull: false, + }, + sigla: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + preco: { + type: Sequelize.FLOAT, + allowNull: true, + }, + quantidade: { + type: Sequelize.INTEGER, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + }, + dataCompra: { + type: Sequelize.STRING, + allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } + } +}); + +Acao.sync() + +// verifica se existe alteração na model que não está no BD +// Acao.sync({ alter: true }) + module.exports = Acao; \ No newline at end of file From 46435828165ccee33c3eb3d9dba7fcad4ff39128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Tue, 9 Aug 2022 11:32:39 -0300 Subject: [PATCH 011/146] =?UTF-8?q?Criado=20a=20controller=20e=20a=20fun?= =?UTF-8?q?=C3=A7=C3=A3o=20de=20cadastro=20de=20a=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/app.js | 3 ++- Back/src/controller/AcaoController.js | 37 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Back/src/controller/AcaoController.js diff --git a/Back/src/app.js b/Back/src/app.js index bc7c0e3..010fdfb 100644 --- a/Back/src/app.js +++ b/Back/src/app.js @@ -4,7 +4,7 @@ const bodyParser = require("body-parser"); const cors = require("cors"); const userControler = require('../src/controller/UserController.js'); - +const acaoControler = require('../src/controller/AcaoController.js') app.use(express.json()); app.use(bodyParser.urlencoded({extended: false})); @@ -18,5 +18,6 @@ app.get("/", (req, res) => { }); app.use('/usuario', userControler); +app.use('/acao', acaoControler); module.exports = app; \ No newline at end of file diff --git a/Back/src/controller/AcaoController.js b/Back/src/controller/AcaoController.js new file mode 100644 index 0000000..fac0921 --- /dev/null +++ b/Back/src/controller/AcaoController.js @@ -0,0 +1,37 @@ +const express = require("express"); +const Acao = require("../models/Acao"); +const app = express(); + + +app.post("/cadastrarAcao", async (req, res) => { + + const nova_acao = { + nomeAtivo: req.body.nomeAtivo, + tipo: req.body.tipo, + sigla: req.body.sigla, + preco: req.body.preco, + quantidade: req.body.quantidade, + dataCompra: req.body.dataCompra, + }; + + const acoes = await Acao.findOne({ where: { nomeAtivo: nova_acao.nomeAtivo} }); + + if (acoes === null || acoes === acoes){ + await Acao.create(nova_acao) + .then(() => { + return res.json({ + erro: false, + message: "Ação cadastrada com sucesso!" + }) + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + message: error.message + }) + }); + } +}) + + +module.exports = app; \ No newline at end of file From 8b49317029c54be81e14b7fe89a4f4563e50c7a9 Mon Sep 17 00:00:00 2001 From: LeonardoPadre Date: Tue, 9 Aug 2022 14:52:33 -0300 Subject: [PATCH 012/146] Modificacao na Models Ativo --- Back/package.json | 0 Back/src/app.js | 4 ++-- .../{AcaoController.js => AtivoController.js} | 15 +++++++-------- Back/src/controller/UserController.js | 0 Back/src/models/{Acao.js => Ativo.js} | 19 +++++++++---------- Back/src/models/User.js | 0 Back/src/models/db.js | 0 Back/src/server.js | 0 8 files changed, 18 insertions(+), 20 deletions(-) mode change 100644 => 100755 Back/package.json mode change 100644 => 100755 Back/src/app.js rename Back/src/controller/{AcaoController.js => AtivoController.js} (63%) mode change 100644 => 100755 mode change 100644 => 100755 Back/src/controller/UserController.js rename Back/src/models/{Acao.js => Ativo.js} (84%) mode change 100644 => 100755 mode change 100644 => 100755 Back/src/models/User.js mode change 100644 => 100755 Back/src/models/db.js mode change 100644 => 100755 Back/src/server.js diff --git a/Back/package.json b/Back/package.json old mode 100644 new mode 100755 diff --git a/Back/src/app.js b/Back/src/app.js old mode 100644 new mode 100755 index 010fdfb..b737009 --- a/Back/src/app.js +++ b/Back/src/app.js @@ -4,7 +4,7 @@ const bodyParser = require("body-parser"); const cors = require("cors"); const userControler = require('../src/controller/UserController.js'); -const acaoControler = require('../src/controller/AcaoController.js') +const acaoControler = require('./controller/AtivoController.js'); app.use(express.json()); app.use(bodyParser.urlencoded({extended: false})); @@ -18,6 +18,6 @@ app.get("/", (req, res) => { }); app.use('/usuario', userControler); -app.use('/acao', acaoControler); +app.use('/ativo', acaoControler); module.exports = app; \ No newline at end of file diff --git a/Back/src/controller/AcaoController.js b/Back/src/controller/AtivoController.js old mode 100644 new mode 100755 similarity index 63% rename from Back/src/controller/AcaoController.js rename to Back/src/controller/AtivoController.js index fac0921..e640f8d --- a/Back/src/controller/AcaoController.js +++ b/Back/src/controller/AtivoController.js @@ -1,23 +1,22 @@ const express = require("express"); -const Acao = require("../models/Acao"); +const Ativo = require("../models/Ativo"); const app = express(); -app.post("/cadastrarAcao", async (req, res) => { +app.post("/cadastrar", async (req, res) => { - const nova_acao = { + const novo_ativo = { nomeAtivo: req.body.nomeAtivo, - tipo: req.body.tipo, sigla: req.body.sigla, preco: req.body.preco, quantidade: req.body.quantidade, - dataCompra: req.body.dataCompra, + dataCompra: req.body.data }; - const acoes = await Acao.findOne({ where: { nomeAtivo: nova_acao.nomeAtivo} }); + const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); - if (acoes === null || acoes === acoes){ - await Acao.create(nova_acao) + if (ativos === null || ativos === ativos){ + await Ativo.create(novo_ativo) .then(() => { return res.json({ erro: false, diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js old mode 100644 new mode 100755 diff --git a/Back/src/models/Acao.js b/Back/src/models/Ativo.js old mode 100644 new mode 100755 similarity index 84% rename from Back/src/models/Acao.js rename to Back/src/models/Ativo.js index 7c6d7c4..bb1cffc --- a/Back/src/models/Acao.js +++ b/Back/src/models/Ativo.js @@ -1,10 +1,9 @@ const Sequelize = require('sequelize'); const db = require('./db'); -const Acao = db.define('acao', { +const Ativo = db.define('ativo', { id: { type: Sequelize.INTEGER, - autoIncrement: true, allowNull: false, primaryKey: true }, @@ -17,10 +16,6 @@ const Acao = db.define('acao', { } } }, - tipo: { - type: Sequelize.STRING, - allowNull: false, - }, sigla: { type: Sequelize.STRING, allowNull: false, @@ -32,7 +27,7 @@ const Acao = db.define('acao', { }, preco: { type: Sequelize.FLOAT, - allowNull: true, + allowNull: false, }, quantidade: { type: Sequelize.INTEGER, @@ -43,7 +38,7 @@ const Acao = db.define('acao', { } } }, - dataCompra: { + data: { type: Sequelize.STRING, allowNull: false, validate: { @@ -51,12 +46,16 @@ const Acao = db.define('acao', { msg: "Esse campo nao pode ser vazio" } } + }, + execucao: { + type: Sequelize.STRING, + allowNull: false } }); -Acao.sync() +Ativo.sync() // verifica se existe alteração na model que não está no BD // Acao.sync({ alter: true }) -module.exports = Acao; \ No newline at end of file +module.exports = Ativo; \ No newline at end of file diff --git a/Back/src/models/User.js b/Back/src/models/User.js old mode 100644 new mode 100755 diff --git a/Back/src/models/db.js b/Back/src/models/db.js old mode 100644 new mode 100755 diff --git a/Back/src/server.js b/Back/src/server.js old mode 100644 new mode 100755 From 9ff66ccec138b9d2f3c2e89d70062c9b330766c4 Mon Sep 17 00:00:00 2001 From: MariaAbritta Date: Tue, 9 Aug 2022 18:59:00 -0300 Subject: [PATCH 013/146] criando o filtro de nome e sigla das empresas --- Back/src/app.js | 4 ++-- Back/src/controller/AtivoController.js | 23 +++++++++++++++++++++-- Back/src/controller/UserController.js | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Back/src/app.js b/Back/src/app.js index b737009..5abc79f 100755 --- a/Back/src/app.js +++ b/Back/src/app.js @@ -4,7 +4,7 @@ const bodyParser = require("body-parser"); const cors = require("cors"); const userControler = require('../src/controller/UserController.js'); -const acaoControler = require('./controller/AtivoController.js'); +const ativoControler = require('./controller/AtivoController.js'); app.use(express.json()); app.use(bodyParser.urlencoded({extended: false})); @@ -18,6 +18,6 @@ app.get("/", (req, res) => { }); app.use('/usuario', userControler); -app.use('/ativo', acaoControler); +app.use('/ativo', ativoControler); module.exports = app; \ No newline at end of file diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index e640f8d..80f3697 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -1,18 +1,37 @@ const express = require("express"); const Ativo = require("../models/Ativo"); const app = express(); - +const Axios = require("axios"); +const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); app.post("/cadastrar", async (req, res) => { const novo_ativo = { nomeAtivo: req.body.nomeAtivo, - sigla: req.body.sigla, + sigla: "", preco: req.body.preco, quantidade: req.body.quantidade, dataCompra: req.body.data }; + Axios.get(linkApi, { + + }).then(function(res){ + const data = res.data; + + for(let ativo of data){ + const { nm_empresa } = ativo; + const { cd_acao } = ativo; + //console.log(nm_empresa, cd_acao); + + if(nm_empresa === nomeAtivo){ + novo_ativo.sigla = cd_acao; + } + } + }).catch(function(err){ + console.log(err); + }); + const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); if (ativos === null || ativos === ativos){ diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 6f64a25..a918ea7 100755 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -41,7 +41,7 @@ app.post("/cadastrar", async (req, res) => { } }) -// funciona +//funciona app.post("/login", async (req, res) => { const usuario = await User.findOne({ attributes: ["id", "email", "senha"], From 9af1b5642122fbc0cda9002e69b256de12ba58ef Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Tue, 9 Aug 2022 19:47:24 -0300 Subject: [PATCH 014/146] adicionando validacoes na busca estatica do ativo e no cadastro --- Back/src/controller/AtivoController.js | 51 +++++++++++++++++--------- Back/src/models/Ativo.js | 8 +++- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 80f3697..4ae72a7 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -5,41 +5,54 @@ const Axios = require("axios"); const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); app.post("/cadastrar", async (req, res) => { + let sigla = null; - const novo_ativo = { - nomeAtivo: req.body.nomeAtivo, - sigla: "", - preco: req.body.preco, - quantidade: req.body.quantidade, - dataCompra: req.body.data - }; - - Axios.get(linkApi, { - + // verifica na API da B3 qual eh a sigla do ativo que o + // usuario deseja cadastrar + await Axios.get(linkApi, { + }).then(function(res){ + const { nomeAtivo } = req.body; const data = res.data; for(let ativo of data){ const { nm_empresa } = ativo; const { cd_acao } = ativo; //console.log(nm_empresa, cd_acao); - - if(nm_empresa === nomeAtivo){ - novo_ativo.sigla = cd_acao; + + if(nm_empresa === nomeAtivo) { + sigla = cd_acao; } } }).catch(function(err){ console.log(err); }); + + const novo_ativo = { + nomeAtivo: req.body.nomeAtivo, + sigla: sigla, + preco: req.body.preco, + quantidade: req.body.quantidade, + data: req.body.data + }; + + // caso nao ache o nome da empresa, + // o ativo nao eh cadastrado + if (novo_ativo.sigla === null) { + return res.json({ + erro: true, + message: "Ativo nao listado na B3!" + }) + } const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); - if (ativos === null || ativos === ativos){ + if (ativos === null){ await Ativo.create(novo_ativo) .then(() => { return res.json({ erro: false, - message: "Ação cadastrada com sucesso!" + message: "Ativo cadastrado com sucesso!" }) }).catch((error) => { console.log(error); @@ -48,8 +61,12 @@ app.post("/cadastrar", async (req, res) => { message: error.message }) }); - } + } else { + return res.status(400).json({ + erro: true, + message: "Ativo ja existente no banco!" + }) + } }) - module.exports = app; \ No newline at end of file diff --git a/Back/src/models/Ativo.js b/Back/src/models/Ativo.js index bb1cffc..c4fa60d 100755 --- a/Back/src/models/Ativo.js +++ b/Back/src/models/Ativo.js @@ -4,6 +4,7 @@ const db = require('./db'); const Ativo = db.define('ativo', { id: { type: Sequelize.INTEGER, + autoIncrement: true, allowNull: false, primaryKey: true }, @@ -28,6 +29,11 @@ const Ativo = db.define('ativo', { preco: { type: Sequelize.FLOAT, allowNull: false, + validate: { + notEmpty: { + msg: "Esse campo nao pode ser vazio" + } + } }, quantidade: { type: Sequelize.INTEGER, @@ -49,7 +55,7 @@ const Ativo = db.define('ativo', { }, execucao: { type: Sequelize.STRING, - allowNull: false + allowNull: true } }); From bcfd9299a13f02c5b4fa001f0ec0c1556ee002c6 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Tue, 9 Aug 2022 20:56:36 -0300 Subject: [PATCH 015/146] =?UTF-8?q?ajustando=20pequenos=20detalhes=20no=20?= =?UTF-8?q?design,=20e=20implementando=20algumas=20l=C3=B3gicas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luciano Freitas --- Front/src/App.tsx | 2 +- .../A\303\247oes.tsx" | 105 ++++++++---------- .../A\303\247\303\265es.css" | 34 ++++-- 3 files changed, 74 insertions(+), 67 deletions(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index c07624c..a8556ff 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -12,7 +12,7 @@ function App() { } /> } /> - } /> + } /> diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index ccd389e..33affb0 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -1,10 +1,7 @@ -import { IMaskInput } from "react-imask"; -import { IoMdArrowBack } from 'react-icons/io'; import './Ações.css'; +import { IMaskInput } from "react-imask"; import { useState } from "react"; -import { parseISO, isAfter, sub, add } from "date-fns"; -import { Link, useNavigate } from "react-router-dom"; -import Axios from "axios"; + const CadastroAcoes = () => { @@ -24,64 +21,58 @@ const CadastroAcoes = () => { const [inputType, setInputType] = useState("text"); return ( - -
-
-

Invext-Comprar/Vender

-
- -

Ativo

- setAssets(e.target.value)} - /> - {/*A ideia é alinhar eles na mesma linha */} -
-

Preço da Ação

+
+

Compra/Venda de Ativos

+
+ setStockPrice(e.target.value)} - /> -

Quantidade

- setQuantity(e.target.value)} - /> -
-

Data

- setDate(e.target.value)} - onFocus={() => setInputType("date")} - onBlur={() => setInputType("text")} + type="text" + name="ativo" + className="busca-input" + required + placeholder="Busque seu ativo" + value={assets} + onChange={(e) => setAssets(e.target.value)} + /> + {/*A ideia é alinhar eles na mesma linha */} +
+ setStockPrice(e.target.value)} + /> + setQuantity(e.target.value)} /> -
+
+ setDate(e.target.value)} + onFocus={() => setInputType("date")} + onBlur={() => setInputType("text")} + /> +
{error &&

{error}

} {error &&

{error}

} -
- -
-
- - +
+ +
+
) } diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 3e62f6c..01d26fc 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -1,14 +1,12 @@ -body { - margin: 0; -} .background-img { display: flex; - align-items: center; + flex-direction: column; alig-rn-items: center; justify-content: center; position: absolute; height: 100vh; width:100vw; background-image: url('../../assets/background.jpeg'); + background-color: #232239; background-size: cover; background-repeat: no-repeat; } @@ -17,23 +15,26 @@ body { display: flex; flex-direction: column; padding: 2%; - width: 80%; + width: 60%; background-color: rgba(10, 17, 79, 0.8); border-radius: 40px; color: white; - opacity: 25%; + } .titulo { text-align: center; font-size: 2.5em; margin-bottom: 0.5em; + align-items: center; + color: white; + font-weight: bold; } input{ background-color:rgba(169, 178, 194, 0.7); color: white; - width: 50%; + width: 30%; padding: 0.5em; border: none; border-radius: 40px; @@ -45,6 +46,11 @@ input{ input::placeholder{ color: rgba(255, 255, 255, 0.7); font-family: 'Roboto'; + font-size: 1em; +} + +.busca-input{ + width: 85%; } .buy-button { @@ -91,9 +97,19 @@ input::placeholder{ } .buttonBox{ - display: inline; + display: flex; + + justify-content: space-between; + } .columnBox { - display: inline; + display: flex; + justify-content: space-between; +} +.date-input{ + justify-items: right; + text-align: center; + width: 30%; + } \ No newline at end of file From 69b0cb2facc36fb5cd89bb064eab58eaa2e68f1e Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Tue, 9 Aug 2022 21:30:20 -0300 Subject: [PATCH 016/146] =?UTF-8?q?Ultimos=20ajustes=20da=20configura?= =?UTF-8?q?=C3=A7=C3=A3o=20das=20rotas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antônio Júnior --- Back/src/controller/UserController.js | 3 +-- Front/src/App.tsx | 17 +++++++++-------- Front/src/pages/LoginUsuario/Login.tsx | 3 +-- Front/src/pages/Sidebar/Sidebar.css | 0 Front/src/pages/Sidebar/Sidebar.tsx | 15 +++++++++++++++ Front/src/services/Provider.tsx | 11 +++-------- Front/src/services/publicRoute.tsx | 17 +++++++++++++++++ Front/src/services/requireAuth.tsx | 2 +- 8 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 Front/src/pages/Sidebar/Sidebar.css create mode 100644 Front/src/pages/Sidebar/Sidebar.tsx create mode 100644 Front/src/services/publicRoute.tsx diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 7270b24..6f64a25 100644 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -71,8 +71,7 @@ app.post("/login", async (req, res) => { return res.json({ erro: false, message: "Login realizado com sucesso!", - token, - usuario + token }); } } diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 7373df1..5a1c843 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -1,14 +1,12 @@ import './App.css' import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' -import {Route, Routes } from "react-router-dom"; -import { AuthProvider } from './services/Provider'; +import {Route, Routes} from "react-router-dom"; +import { AuthProvider} from './services/Provider'; import { RequireAuth } from './services/requireAuth'; +import { SideBar } from './pages/Sidebar/Sidebar'; +import { PublicRoute } from './services/publicRoute'; -// Remover e colocar a side bar que realmente será implementada -function SideBar() { - return
SideBar
-} function App() { @@ -16,8 +14,11 @@ function App() {
- } /> - } /> + }> + } /> + } /> + + diff --git a/Front/src/pages/LoginUsuario/Login.tsx b/Front/src/pages/LoginUsuario/Login.tsx index 84a72f6..f47dd08 100644 --- a/Front/src/pages/LoginUsuario/Login.tsx +++ b/Front/src/pages/LoginUsuario/Login.tsx @@ -33,9 +33,8 @@ const LoginUsuario = () => { }).then(function (response) { const message = response.data.message; const token = response.data.token; - const user = response.data.usuario; - auth.login(token, user, () => { + auth.login(token, () => { navigate(from, { replace: true }); }); diff --git a/Front/src/pages/Sidebar/Sidebar.css b/Front/src/pages/Sidebar/Sidebar.css new file mode 100644 index 0000000..e69de29 diff --git a/Front/src/pages/Sidebar/Sidebar.tsx b/Front/src/pages/Sidebar/Sidebar.tsx new file mode 100644 index 0000000..54c6c07 --- /dev/null +++ b/Front/src/pages/Sidebar/Sidebar.tsx @@ -0,0 +1,15 @@ +import { useNavigate } from "react-router-dom"; +import { useAuth } from "../../services/Provider"; + + +export const SideBar = () => { + let auth = useAuth(); + let navigate = useNavigate(); + + return( +
+

Bem vindo usuario

+ + +
+ )}; \ No newline at end of file diff --git a/Front/src/services/Provider.tsx b/Front/src/services/Provider.tsx index 4c8c0f1..34b81d6 100644 --- a/Front/src/services/Provider.tsx +++ b/Front/src/services/Provider.tsx @@ -5,8 +5,7 @@ import { returnToken, setarToken, destroyToken } from "./authToken"; // Criação de um Context para saber se o usuario estah logad o ou nao interface AuthContextType { getToken: () => any; - user: any; - login: (token: string, newUser: any, callback: VoidFunction) => void; + login: (token: string, callback: VoidFunction) => void; logout: (callback: VoidFunction) => void; } @@ -14,12 +13,9 @@ const AuthContext = createContext(null!); export const AuthProvider = ({ children }: { children: JSX.Element }) => { - const [user, setUser] = useState(null); - // call this function when you want to authenticate the user - const login = (token: string, newUser: any, callback: VoidFunction) => { + const login = (token: string, callback: VoidFunction) => { return setarToken(token, () => { - setUser(newUser); callback(); }); @@ -29,7 +25,6 @@ export const AuthProvider = ({ children }: { children: JSX.Element }) => { // call this function to sign out logged in user const logout = (callback: VoidFunction) => { return destroyToken(() => { - setUser(null); callback(); }); @@ -39,7 +34,7 @@ export const AuthProvider = ({ children }: { children: JSX.Element }) => { return returnToken(); }; - let value = { getToken, user, login, logout }; + let value = { getToken, login, logout }; return {children}; }; diff --git a/Front/src/services/publicRoute.tsx b/Front/src/services/publicRoute.tsx new file mode 100644 index 0000000..1da4999 --- /dev/null +++ b/Front/src/services/publicRoute.tsx @@ -0,0 +1,17 @@ +import { useLocation , Navigate, Outlet} from "react-router-dom"; +import { useAuth } from "./Provider"; + +export const PublicRoute = ( ) => { + let auth = useAuth(); + let location = useLocation(); + + let from = location.state?.from?.pathname || "/index"; + + // Se o usuario não estiver logado, ele tem acesso a parte publica das rotas + if (!auth.getToken()) { + return ; + } + // Caso ele esteja logado, ele é redirecionado para o ultimo local + // que ele estava antes de tentar deslogar + return ; + } \ No newline at end of file diff --git a/Front/src/services/requireAuth.tsx b/Front/src/services/requireAuth.tsx index 22fe328..a8641f2 100644 --- a/Front/src/services/requireAuth.tsx +++ b/Front/src/services/requireAuth.tsx @@ -3,7 +3,7 @@ import { useLocation, Navigate } from "react-router-dom"; -export function RequireAuth ( { children }: { children: JSX.Element } ) : JSX.Element{ +export const RequireAuth = ( { children }: { children: JSX.Element } ) => { let auth = useAuth(); let location = useLocation(); From dcdd7eb009d17ba681fab578697d8eee91803adf Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Wed, 10 Aug 2022 10:23:36 -0300 Subject: [PATCH 017/146] Cria a Sidebar --- Front/src/pages/Componentes/Sidebar.tsx | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Front/src/pages/Componentes/Sidebar.tsx diff --git a/Front/src/pages/Componentes/Sidebar.tsx b/Front/src/pages/Componentes/Sidebar.tsx new file mode 100644 index 0000000..f1f9703 --- /dev/null +++ b/Front/src/pages/Componentes/Sidebar.tsx @@ -0,0 +1,27 @@ +/******import React, {FC, useState} from 'react'; +import { Link } from 'react-router-dom'; +import { IconContext } from 'react-icons'; +import { AiOutlineMenu, AiOutlineClose } from 'react-icons/ai'; +import styled from "styled-components"; + +const Nav = styled.div` + display: flex; + justify-content: flex-start; + align-items: center; + height: 5rem; + background-color: black; +`; + +const SidebarNav = styled.div<{ sidebar: boolean}> + width: 250px; + height: 100vh; + backgroud-color: black; + position: fixed; + top: 0; + left: ${({ sidebar }) => (sidebar ? '0' : '-100%')}; + transition: 350ms; +; + +const SidebarWrap = styled.div``; + +**/ \ No newline at end of file From 156b8c9b2b732dd272a27c2b0b9d95e75547e3c0 Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Wed, 10 Aug 2022 10:43:50 -0300 Subject: [PATCH 018/146] Atualiza Cadastro --- .../src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 33affb0..ed97b7a 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -17,7 +17,7 @@ const CadastroAcoes = () => { setError(""); } - //p formatar data + //Formatar data const [inputType, setInputType] = useState("text"); return ( From 957fb442ba296a5f753b2efc2ef8ed84ff5c1741 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 10 Aug 2022 11:52:00 -0300 Subject: [PATCH 019/146] =?UTF-8?q?fazendo=20alguns=20ajustes=20na=20estil?= =?UTF-8?q?iza=C3=A7=C3=A3o=20para=20se=20assemelhar=20ao=20prototipo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A\303\247oes.tsx" | 7 +++-- .../A\303\247\303\265es.css" | 26 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 33affb0..bb3160c 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -52,11 +52,11 @@ const CadastroAcoes = () => { value={quantity} onChange={(e) => setQuantity(e.target.value)} /> -
+ +
{ onFocus={() => setInputType("date")} onBlur={() => setInputType("text")} /> +
{error &&

{error}

} + + {error &&

{error}

}
diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 01d26fc..1b80cf8 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -16,6 +16,7 @@ flex-direction: column; padding: 2%; width: 60%; + height: 60%; background-color: rgba(10, 17, 79, 0.8); border-radius: 40px; color: white; @@ -34,13 +35,14 @@ input{ background-color:rgba(169, 178, 194, 0.7); color: white; - width: 30%; + width: 45%; padding: 0.5em; border: none; border-radius: 40px; font-size: 1.5em; text-align: center; font-weight: bold; + } input::placeholder{ @@ -77,9 +79,11 @@ input::placeholder{ border-radius:70px; font-size: 1.5em; text-align: center; - padding: 0.5em 1.5em; + padding: 0.5em 2em; cursor: pointer; transition: 0.25s; + align-content: space-between; + } .sellbutton:hover{ @@ -98,9 +102,7 @@ input::placeholder{ .buttonBox{ display: flex; - - justify-content: space-between; - + margin-top: 12.5%; } .columnBox { @@ -108,8 +110,16 @@ input::placeholder{ justify-content: space-between; } .date-input{ - justify-items: right; + background-color:rgba(169, 178, 194, 0.7); + color: white; + width: 45%; + padding: 0.5em; + border: none; + border-radius: 40px; + font-size: 1em; text-align: center; - width: 30%; - + font-weight: bold; + + + } \ No newline at end of file From 75dd5ce3665fb3e5b042b7a337c06b962d0046b8 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 10 Aug 2022 17:05:30 -0300 Subject: [PATCH 020/146] =?UTF-8?q?Progresso=20da=20estiliza=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A\303\247oes.tsx" | 2 ++ .../A\303\247\303\265es.css" | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index bb3160c..a85bd91 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -1,3 +1,5 @@ +//talvez podemos começar a checar os subtitulos igual no prototipo usando uma nova div e mexendo apenas no p. +//lembrar de alterar o fundo import './Ações.css'; import { IMaskInput } from "react-imask"; import { useState } from "react"; diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 1b80cf8..3b52274 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -33,8 +33,8 @@ } input{ - background-color:rgba(169, 178, 194, 0.7); - color: white; + background-color:white; + color:black; width: 45%; padding: 0.5em; border: none; @@ -46,7 +46,7 @@ input{ } input::placeholder{ - color: rgba(255, 255, 255, 0.7); + color:gray; font-family: 'Roboto'; font-size: 1em; } @@ -65,11 +65,15 @@ input::placeholder{ padding: 0.5em 1.5em; cursor: pointer; transition: 0.25s; + margin-right: 25%; } .buy-button:hover{ + float: left; background: white; color: black; + align-items: left; + justify-items: left; } .sell-button { @@ -82,7 +86,7 @@ input::placeholder{ padding: 0.5em 2em; cursor: pointer; transition: 0.25s; - align-content: space-between; + margin-right: 20%; } @@ -102,7 +106,8 @@ input::placeholder{ .buttonBox{ display: flex; - margin-top: 12.5%; + margin-top: 6.75%; + } .columnBox { @@ -110,16 +115,15 @@ input::placeholder{ justify-content: space-between; } .date-input{ - background-color:rgba(169, 178, 194, 0.7); - color: white; + float: left; + background-color:white; + color:gray; width: 45%; padding: 0.5em; border: none; border-radius: 40px; font-size: 1em; text-align: center; - font-weight: bold; - - - -} \ No newline at end of file + margin-right: 50%; + +} From 44e7831f902f7f3ca9a6b20eb250bbde81d6eee7 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 10 Aug 2022 17:15:57 -0300 Subject: [PATCH 021/146] corrigindo erro de sintaxe --- .../Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 3b52274..978aa9e 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -1,6 +1,6 @@ .background-img { display: flex; - flex-direction: column; alig-rn-items: center; + flex-direction: column; justify-content: center; position: absolute; height: 100vh; From c7b0c3d16451bf94ce84a7f8b42c69097fbc163c Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 10 Aug 2022 17:31:55 -0300 Subject: [PATCH 022/146] =?UTF-8?q?iniciando=20a=20montagem=20da=20parte?= =?UTF-8?q?=20l=C3=B3gica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index a85bd91..abaf530 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -3,6 +3,7 @@ import './Ações.css'; import { IMaskInput } from "react-imask"; import { useState } from "react"; +import { parseISO } from 'date-fns'; const CadastroAcoes = () => { @@ -17,6 +18,15 @@ const CadastroAcoes = () => { e.preventDefault(); setError(""); + // Transforma a data de compra em um objeto Date + const parsedBirth = parseISO(date); //vamos validar somente os anos de compra e venda ? + + + //p fazer as máscaras depois + {/*const nameMask = function (value: string) { + var pattern = new RegExp(/^[A-Za-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ ]+$/); + return pattern.test(value); + };*/} } //p formatar data From 15ef39c600883346e90f0dbd81eae5d6970a4090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= <82157394+zjosuez@users.noreply.github.com> Date: Wed, 10 Aug 2022 17:44:28 -0300 Subject: [PATCH 023/146] =?UTF-8?q?docs:=20altera=C3=A7=C3=A3o=20do=20temp?= =?UTF-8?q?late=20para=20pull=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/pull_request_template.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3a7d783..6b366e8 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,11 +1,23 @@ -#### O que essa PR faz? - Descreva tudo o que essa PR faz e suas alterações +## Descrição -#### Tarefas desenvolvidas: -- [ ] tarefa 1 -- [ ] tarefa 2 -- [ ] tarefa 3 +Inclua um resumo da alteração e qual problema foi corrigido. Inclua também motivação e contexto relevantes. Liste todas as dependências necessárias para essa alteração. -#### Link relacionada a issue: [Link da issue]() +Correções # [Link da issue]() +## Tipo de alteração +Marque com um 'x' as alterações relevantes. -#### Observações adicionais: +Exclua as opções que não são relevantes. + +- [ ] Correção de bug (mudança ininterrupta que corrige um problema) +- [ ] Novo recurso (mudança ininterrupta que adiciona funcionalidade) +- [ ] Mudança de última hora (correção ou recurso que faria com que a funcionalidade existente não funcionasse conforme o esperado) +- [ ] Esta alteração requer uma atualização da documentação + +## Lista de controle: + +- [ ] Meu código segue as diretrizes de estilo deste projeto +- [ ] Realizei uma auto-revisão do meu próprio código +- [ ] Eu comentei meu código, principalmente em áreas difíceis de entender +- [ ] Fiz as alterações correspondentes na documentação +- [ ] Minhas alterações não geram novos avisos +- [ ] Verifiquei meu código e corrigi qualquer erro de ortografia From 816aaeb46ed30c0834ab5bf1a9d0cb37ddc9a5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= <82157394+zjosuez@users.noreply.github.com> Date: Wed, 10 Aug 2022 17:48:50 -0300 Subject: [PATCH 024/146] =?UTF-8?q?docs:=20alterado=20algumas=20informa?= =?UTF-8?q?=C3=A7=C3=B5es=20no=20guia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f74daba..df1d771 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,22 +12,19 @@ Caso encontre um bug ou tenha alguma sugestão de melhoria ao projeto, siga os p 1. Defina as labels que são pertinentes ao problema ou sugestão; 1. Se aplicável, defina os responsáveis pela issue, o milestone e o projeto. 1. Retire dúvidas através da issue. -## Gitflow + Para contribuir com o projeto, observe as políticas adotadas em relação a padronização e organização de código e documentação. -Documentação -Regras: +Documentação: [Acesso a documentação](https://fga-eps-mds.github.io/GFour-Invext/#/pages/DocumentoDeArquiteturaDeSoftware) -1. Novas branchs devem ser criadas a partir da main; -1. Depois de fazer modificações na branch, submete-a por pull request para integrar a branch principal (main); -1. Após aprovado ou recusado o pull request, apague a branch. +Issues: [Acesso as issues](https://github.com/fga-eps-mds/GFour-Invext/issues) + +## Política de Branches -## Código 1. Novas branchs devem ser criadas a partir da dev; 1. Depois de fazer modificações na branch, submete-a por pull request para integrar a branch secundária (Develop); 1. Após aprovado ou recusado o pull request, apague a branch. -## Política de Branches ### **main:** main é a branch de produção, onde se encontra a versão que estará disponível para utilização no mercado. @@ -35,16 +32,28 @@ main é a branch de produção, onde se encontra a versão que estará disponív develop é a branch de homologação, onde se encontra a versão mais atualizada do projeto. ### **Nome das Branches** -Crie a branch com a seguinte estrutura: +Para criar novas branchs crie com a seguinte estrutura: [número-da-issue]- ## Política de Commits -Para commits individuais, use: git commit -m "Mensagem". Para commits em pares, digite git commit e atribua os co-authoreds na mensagem: +Para realizar commits, utilize o template abaixo: + git commit -m "tipo: Exemplo de commit" - Mensagem do commit: - Co-authored-by: Nome e sobrenome do parceiro(a) +- Os commits devem utilizar o tempo presente. Exemplo: "Adiciona funcionalidade" e não "Adicionada a funcionalidade". + +- Escreva o commit de maneira objetiva, descrevendo brevemente o que foi implementado, alterado, etc. + +- Utilize os comentários da issue para detalhar mais sobre o que etá sendo implementado. + +Os tipos de commits podem ser: +- **feat** (novo recurso) +- **fix** (correção de bug) +- **refactor** (refatorando o código de produção) +- **style** (formatação, falta de ponto e vírgula, etc; sem alteração de código) +- **docs** (alterações na documentação) +- **teste** (adicionando ou refatorando testes; sem alteração do código de produção) ## Política de Merges e Pull Requests ### Pull Requests: @@ -57,6 +66,8 @@ Quando disponível uma nova release ou funcionalidade, esta será integrada atra Durante a criação de um pull request, deve-se observar o template definido no repositório. +Após a revisão do código e aceitação do pull request, deve ser realizado o merge. + ## Code Review Na revisão de código de pull request, observe os pontos abaixo: From 623b25bad276e0258a42065ca4f2d6ea7977b332 Mon Sep 17 00:00:00 2001 From: LeonardoPadre Date: Wed, 10 Aug 2022 17:57:07 -0300 Subject: [PATCH 025/146] =?UTF-8?q?Adi=C3=A7=C3=A3o=20do=20middleware?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/controller/AtivoController.js | 4 +++- Back/src/middleware/auth.js | 14 ++++++++++++++ Back/src/models/Ativo.js | 1 - 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 Back/src/middleware/auth.js diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 4ae72a7..f950f8f 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -3,8 +3,9 @@ const Ativo = require("../models/Ativo"); const app = express(); const Axios = require("axios"); const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); +const auth = require("../middleware/auth"); -app.post("/cadastrar", async (req, res) => { +app.post("/cadastrar", auth, async (req, res) => { let sigla = null; // verifica na API da B3 qual eh a sigla do ativo que o @@ -29,6 +30,7 @@ app.post("/cadastrar", async (req, res) => { }); const novo_ativo = { + id: req.usuario.id, nomeAtivo: req.body.nomeAtivo, sigla: sigla, preco: req.body.preco, diff --git a/Back/src/middleware/auth.js b/Back/src/middleware/auth.js new file mode 100644 index 0000000..80db9f6 --- /dev/null +++ b/Back/src/middleware/auth.js @@ -0,0 +1,14 @@ +const jwt = require('jsonwebtoken'); + +module.exports = (req, res, next) => { + try { + const decode = jwt.verify(req.body.token, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3"); + req.usuario = decode; + next(); + } catch (error) { + return res.status(401).json({ + erro: true, + message: "Falha na autenticação!" + }); + } +} \ No newline at end of file diff --git a/Back/src/models/Ativo.js b/Back/src/models/Ativo.js index c4fa60d..6ccf0b1 100755 --- a/Back/src/models/Ativo.js +++ b/Back/src/models/Ativo.js @@ -4,7 +4,6 @@ const db = require('./db'); const Ativo = db.define('ativo', { id: { type: Sequelize.INTEGER, - autoIncrement: true, allowNull: false, primaryKey: true }, From 7de68aa27f248eb1f2499dad7f9a45ba97cb7957 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Wed, 10 Aug 2022 19:48:24 -0300 Subject: [PATCH 026/146] adicionando a coluna de id unico para os ativos --- Back/src/controller/AtivoController.js | 2 +- Back/src/models/Ativo.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index f950f8f..d1a8534 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -30,7 +30,7 @@ app.post("/cadastrar", auth, async (req, res) => { }); const novo_ativo = { - id: req.usuario.id, + id_usuario: req.usuario.id, nomeAtivo: req.body.nomeAtivo, sigla: sigla, preco: req.body.preco, diff --git a/Back/src/models/Ativo.js b/Back/src/models/Ativo.js index 6ccf0b1..9b33795 100755 --- a/Back/src/models/Ativo.js +++ b/Back/src/models/Ativo.js @@ -3,6 +3,12 @@ const db = require('./db'); const Ativo = db.define('ativo', { id: { + type: Sequelize.INTEGER, + autoIncrement: true, + allowNull: false, + primaryKey: true + }, + id_usuario: { type: Sequelize.INTEGER, allowNull: false, primaryKey: true From de1ef10c67b442ec7d21d0e3e0eb6c78d1f05b74 Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Wed, 10 Aug 2022 19:55:54 -0300 Subject: [PATCH 027/146] Implementa Sidebar --- Front/package.json | 4 ++ Front/src/App.css | 5 +++ Front/src/App.tsx | 7 +++- .../A\303\247oes.tsx" | 6 ++- Front/src/pages/Componentes/Sidebar.css | 13 ++++++ Front/src/pages/Componentes/Sidebar.tsx | 40 +++++++++---------- Front/src/pages/Componentes/SidebarData.tsx | 31 ++++++++++++++ Front/vite.config.ts | 3 +- 8 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 Front/src/pages/Componentes/Sidebar.css create mode 100644 Front/src/pages/Componentes/SidebarData.tsx diff --git a/Front/package.json b/Front/package.json index feb4a2f..e83ce5e 100644 --- a/Front/package.json +++ b/Front/package.json @@ -7,10 +7,12 @@ "dev": "vite", "build": "tsc && vite build", "preview": "vite preview" + }, "dependencies": { "axios": "^0.27.2", "date-fns": "^2.29.1", + "module-alias": "^2.2.2", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.4.0", @@ -18,10 +20,12 @@ "react-router-dom": "^6.3.0" }, "devDependencies": { + "@types/module-alias": "^2.0.1", "@types/react": "^18.0.15", "@types/react-dom": "^18.0.6", "@vitejs/plugin-react": "^2.0.0", "typescript": "^4.6.4", "vite": "^3.0.0" } + } diff --git a/Front/src/App.css b/Front/src/App.css index 6798013..7646e72 100644 --- a/Front/src/App.css +++ b/Front/src/App.css @@ -3,3 +3,8 @@ font-style: normal; font-weight: 400; } + +body { + margin: 0; + padding: 0; +} \ No newline at end of file diff --git a/Front/src/App.tsx b/Front/src/App.tsx index a8556ff..2bd3104 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -3,11 +3,14 @@ import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; import CadastroAcoes from './pages/Cadastro de Ações/Açoes'; +/*import Sidebar from "./Componentes./Sidebar";*/ + function App() { return ( -
+
+

Sidebar

} /> @@ -16,7 +19,7 @@ function App() {
- ) + ); } export default App diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index ed97b7a..61434dc 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -1,10 +1,12 @@ import './Ações.css'; import { IMaskInput } from "react-imask"; import { useState } from "react"; +import Sidebar from "../Componentes/Sidebar"; +import React from "react" const CadastroAcoes = () => { - + const [error, setError] = useState(""); const [assets,setAssets] = useState(""); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações @@ -73,7 +75,7 @@ const CadastroAcoes = () => {
- ) + ); } diff --git a/Front/src/pages/Componentes/Sidebar.css b/Front/src/pages/Componentes/Sidebar.css new file mode 100644 index 0000000..776ca6e --- /dev/null +++ b/Front/src/pages/Componentes/Sidebar.css @@ -0,0 +1,13 @@ +.sidebar{ + display: flex; + align-items: center; + justify-content: start; + height: 80px; + background-color: rgb(14, 3, 61); +} + +.menu-bars{ + margin-left: 2rem; + font-size: 2rem; + background: none; +} \ No newline at end of file diff --git a/Front/src/pages/Componentes/Sidebar.tsx b/Front/src/pages/Componentes/Sidebar.tsx index f1f9703..e043a88 100644 --- a/Front/src/pages/Componentes/Sidebar.tsx +++ b/Front/src/pages/Componentes/Sidebar.tsx @@ -1,27 +1,25 @@ -/******import React, {FC, useState} from 'react'; +import React, { useState } from 'react' +import * as FaIcons from 'react-icons/fa'; import { Link } from 'react-router-dom'; +import './Sidebar.css' +import * as AiIcons from 'react-icons/ai'; import { IconContext } from 'react-icons'; -import { AiOutlineMenu, AiOutlineClose } from 'react-icons/ai'; -import styled from "styled-components"; +import { SidebarData } from './SidebarData'; -const Nav = styled.div` - display: flex; - justify-content: flex-start; - align-items: center; - height: 5rem; - background-color: black; -`; -const SidebarNav = styled.div<{ sidebar: boolean}> - width: 250px; - height: 100vh; - backgroud-color: black; - position: fixed; - top: 0; - left: ${({ sidebar }) => (sidebar ? '0' : '-100%')}; - transition: 350ms; -; -const SidebarWrap = styled.div``; +function Sidebar() { + const [currImg, setCurrImg] = useState(0); -**/ \ No newline at end of file + return ( + <> +
+ + + +
+ + ); +} + +export default Sidebar; \ No newline at end of file diff --git a/Front/src/pages/Componentes/SidebarData.tsx b/Front/src/pages/Componentes/SidebarData.tsx new file mode 100644 index 0000000..37c3e90 --- /dev/null +++ b/Front/src/pages/Componentes/SidebarData.tsx @@ -0,0 +1,31 @@ +import React from 'react' +import * as FaIcons from 'react-icons/fa' +import * as AiIcons from 'react-icons/ai' +import * as IoIcons from 'react-icons/io' + +export const SidebarData = [ + { + title:'Minha Carteira', + path:'/', + icon: , + cName:' nav-test ', + }, + { + title:' Ações ', + path:'/Acoes', + icon: , + cName:'nav-test', + }, + { + title:'Meu Perfil', + path:'/MeuPerfil', + icon: , + cName:'nav-test', + }, + { + title:'Sair ', + path:'/Sair', + icon: , + cName:'nav-test', + }, +] \ No newline at end of file diff --git a/Front/vite.config.ts b/Front/vite.config.ts index b1b5f91..3ac8361 100644 --- a/Front/vite.config.ts +++ b/Front/vite.config.ts @@ -1,7 +1,8 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import module from 'module-alias/register'; -// https://vitejs.dev/config/ +//https://vitejs.dev/config/ export default defineConfig({ plugins: [react()] }) From 64ca7eeded8f4d84a1f2b41c3188056ce2a5f0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= <82157394+zjosuez@users.noreply.github.com> Date: Wed, 10 Aug 2022 20:22:29 -0300 Subject: [PATCH 028/146] =?UTF-8?q?docs:=20novo=20conte=C3=BAdo=20na=20val?= =?UTF-8?q?ida=C3=A7=C3=A3o=20do=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index df1d771..840fd84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,7 +64,9 @@ Pull requests serão realizados para controle de estabilidade das branches: Quando disponível uma nova release ou funcionalidade, esta será integrada através de pull request na branch main. -Durante a criação de um pull request, deve-se observar o template definido no repositório. +Durante a criação de um pull request, deve-se observar o template definido no repositório e adicionar o scrum team como reviewer. + +Todos os merges devem ser realizados pelos scrum teams, com excessão de quando o scrum team é quem fez o codigo. Nesse caso o código deve ser revisado por alguém do outro time. Após a revisão do código e aceitação do pull request, deve ser realizado o merge. From 4b6370d408eb9b80c79e0bed2e27a962447fab68 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Fri, 12 Aug 2022 15:42:19 -0300 Subject: [PATCH 029/146] =?UTF-8?q?Corre=C3=A7=C3=B5es=20no=20PR=20#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/App.tsx | 7 +++---- Front/src/pages/Sidebar/Sidebar.css | 7 +++++++ Front/src/pages/Sidebar/Sidebar.tsx | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 40cda56..2354839 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -1,9 +1,8 @@ import './App.css' import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' -import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; +import { Route, Routes } from "react-router-dom"; import CadastroAcoes from './pages/Cadastro de Ações/Açoes'; -import {Route, Routes} from "react-router-dom"; import { AuthProvider} from './services/Provider'; import { RequireAuth } from './services/requireAuth'; import { SideBar } from './pages/Sidebar/Sidebar'; @@ -26,8 +25,8 @@ function App() { } > - } /> - {/* Aqui ficarão as outras rotas do usuário logado */} + } /> + diff --git a/Front/src/pages/Sidebar/Sidebar.css b/Front/src/pages/Sidebar/Sidebar.css index e69de29..f07a86b 100644 --- a/Front/src/pages/Sidebar/Sidebar.css +++ b/Front/src/pages/Sidebar/Sidebar.css @@ -0,0 +1,7 @@ +.sidebar{ + display: flex; + flex-direction: column; + max-width: 20%; + position: absolute; + z-index: 10; +} \ No newline at end of file diff --git a/Front/src/pages/Sidebar/Sidebar.tsx b/Front/src/pages/Sidebar/Sidebar.tsx index 54c6c07..ea45165 100644 --- a/Front/src/pages/Sidebar/Sidebar.tsx +++ b/Front/src/pages/Sidebar/Sidebar.tsx @@ -1,5 +1,6 @@ -import { useNavigate } from "react-router-dom"; +import { Outlet, useNavigate } from "react-router-dom"; import { useAuth } from "../../services/Provider"; +import "./Sidebar.css"; export const SideBar = () => { @@ -7,9 +8,9 @@ export const SideBar = () => { let navigate = useNavigate(); return( -
+

Bem vindo usuario

- +
)}; \ No newline at end of file From 32aeacfd58fac59e7fe4e186394a32f8202bf6ea Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Sat, 13 Aug 2022 23:50:17 -0300 Subject: [PATCH 030/146] Modifica Sidebar Visualmente --- Front/package.json | 2 - Front/src/App.css | 20 ++++- Front/src/App.tsx | 8 +- .../A\303\247oes.tsx" | 1 - Front/src/pages/Componentes/Sidebar.css | 75 +++++++++++++++++-- Front/src/pages/Componentes/Sidebar.tsx | 35 +++++++-- Front/src/pages/Componentes/SidebarData.tsx | 8 +- 7 files changed, 126 insertions(+), 23 deletions(-) diff --git a/Front/package.json b/Front/package.json index e83ce5e..9a6cdf6 100644 --- a/Front/package.json +++ b/Front/package.json @@ -7,7 +7,6 @@ "dev": "vite", "build": "tsc && vite build", "preview": "vite preview" - }, "dependencies": { "axios": "^0.27.2", @@ -27,5 +26,4 @@ "typescript": "^4.6.4", "vite": "^3.0.0" } - } diff --git a/Front/src/App.css b/Front/src/App.css index 7646e72..838f00c 100644 --- a/Front/src/App.css +++ b/Front/src/App.css @@ -7,4 +7,22 @@ body { margin: 0; padding: 0; -} \ No newline at end of file +} + +.MinhaCarteira, +.Ações, +.MeuPerfil +.Sair { + display: flex; + height: 90vh; + align-items: center; + justify-content: center; + font-size: 3rem; +} + +* { + box-sizing: border-box; + margin: 0; + padding: 0; + font-family: 'Lato', sans-serif; +} diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 2bd3104..ef2b7a4 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -3,15 +3,15 @@ import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; import CadastroAcoes from './pages/Cadastro de Ações/Açoes'; -/*import Sidebar from "./Componentes./Sidebar";*/ - +import Sidebar from './pages/Componentes/Sidebar'; +import React from 'react'; function App() { return (
-

Sidebar

+ } /> } /> @@ -22,4 +22,4 @@ function App() { ); } -export default App +export default App; diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 61434dc..baa3a17 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -6,7 +6,6 @@ import React from "react" const CadastroAcoes = () => { - const [error, setError] = useState(""); const [assets,setAssets] = useState(""); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações diff --git a/Front/src/pages/Componentes/Sidebar.css b/Front/src/pages/Componentes/Sidebar.css index 776ca6e..c456894 100644 --- a/Front/src/pages/Componentes/Sidebar.css +++ b/Front/src/pages/Componentes/Sidebar.css @@ -1,13 +1,72 @@ -.sidebar{ +.navbar { + background-color: #060b26; + height: 80px; display: flex; - align-items: center; justify-content: start; - height: 80px; - background-color: rgb(14, 3, 61); -} - -.menu-bars{ + align-items: center; + } + + .menu-bars { margin-left: 2rem; font-size: 2rem; background: none; -} \ No newline at end of file + } + + .nav-menu { + background-color: #060b26; + width: 250px; + height: 100vh; + display: flex; + justify-content: center; + position: fixed; + top: 0; + left: -100%; + transition: 850ms; + } + + .nav-menu.active { + left: 0; + transition: 350ms; + } + + .nav-text { + display: flex; + justify-content: start; + align-items: center; + padding: 8px 0px 8px 16px; + list-style: none; + height: 60px; + } + + .nav-text a { + text-decoration: none; + color: #f5f5f5; + font-size: 18px; + width: 95%; + height: 100%; + display: flex; + align-items: center; + padding: 0 16px; + border-radius: 4px; + } + + .nav-text a:hover { + background-color: #1a83ff; + } + + .nav-menu-items { + width: 100%; + } + + .navbar-toggle { + background-color: #060b26; + width: 100%; + height: 80px; + display: flex; + justify-content: start; + align-items: center; + } + + span { + margin-left: 16px; + } \ No newline at end of file diff --git a/Front/src/pages/Componentes/Sidebar.tsx b/Front/src/pages/Componentes/Sidebar.tsx index e043a88..f4482f9 100644 --- a/Front/src/pages/Componentes/Sidebar.tsx +++ b/Front/src/pages/Componentes/Sidebar.tsx @@ -10,14 +10,37 @@ import { SidebarData } from './SidebarData'; function Sidebar() { const [currImg, setCurrImg] = useState(0); + const [sidebar, setSidebar] = useState(false); + const showSidebar = () => (!sidebar); return ( - <> -
- - - -
+ <> + +
+ + + +
+ +
); } diff --git a/Front/src/pages/Componentes/SidebarData.tsx b/Front/src/pages/Componentes/SidebarData.tsx index 37c3e90..3649776 100644 --- a/Front/src/pages/Componentes/SidebarData.tsx +++ b/Front/src/pages/Componentes/SidebarData.tsx @@ -28,4 +28,10 @@ export const SidebarData = [ icon: , cName:'nav-test', }, -] \ No newline at end of file + { + title: 'Support', + path: '/support', + icon: , + cName: 'nav-text' + } +]; \ No newline at end of file From 5941752e8ab8aca74921bdd00deb95338ec22c84 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Mon, 15 Aug 2022 23:48:49 -0300 Subject: [PATCH 031/146] adicionando a model de todos os ativos da B3 no mysql --- Back/src/models/AtivosB3.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 Back/src/models/AtivosB3.js diff --git a/Back/src/models/AtivosB3.js b/Back/src/models/AtivosB3.js new file mode 100755 index 0000000..0dae2e1 --- /dev/null +++ b/Back/src/models/AtivosB3.js @@ -0,0 +1,31 @@ +const Sequelize = require('sequelize'); +const db = require('./db'); + +const AtivosB3 = db.define('b3_ativo', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + allowNull: false, + primaryKey: true + }, + data_pregao: { + type: Sequelize.STRING, + allowNull: false, + }, + codigo_acao: { + type: Sequelize.STRING, + allowNull: false, + }, + nome_empresa: { + type: Sequelize.STRING, + allowNull: false, + }, + valor_fechamento: { + type: Sequelize.FLOAT, + allowNull: false, + }, +}); + +AtivosB3.sync() + +module.exports = AtivosB3; \ No newline at end of file From 6f325e5436266fcaa18f6c61f911b2ac7e67befa Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Mon, 15 Aug 2022 23:50:12 -0300 Subject: [PATCH 032/146] adicionando a logica de pegar todas os ativos da B3 e salvar no banco --- Back/src/util/AtivosB3Util.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Back/src/util/AtivosB3Util.js diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js new file mode 100644 index 0000000..b2aba8b --- /dev/null +++ b/Back/src/util/AtivosB3Util.js @@ -0,0 +1,35 @@ +const Axios = require("axios"); +const AtivosB3 = require("../models/AtivosB3") + +exports.updateAtivosB3 = async function () { + let dt_ultimo_pregao; + + // Pega a data do ultimo pregao dispnivel na API da B3 + await Axios.get("https://api-cotacao-b3.labdo.it/api/sysinfo", { + }).then(function(res){ + const { data } = res; + dt_ultimo_pregao = data.dt_ultimo_pregao; + }).catch(function(err){ + console.log(err); + }); + + // Seleciona todas as informacoes disponiveis sobre todos os ativos nesse dia + // e atualiza o banco de dados com as novas contacoes do dia + await Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/dt/${dt_ultimo_pregao}/02`, { + }).then(function(res){ + const { data } = res; + + for (let ativo of data) { + const novo_ativo = { + data_pregao: ativo.dt_pregao, + codigo_acao: ativo.cd_acao, + nome_empresa: ativo.nm_empresa_rdz, + valor_fechamento: ativo.vl_fechamento + } + + AtivosB3.create(novo_ativo); // adiciona o novo ativo no banco a cada iteracao + } + }).catch(function(err){ + console.log(err); + }); +} \ No newline at end of file From 4516803fae29d26993e1edc3018691e5a316d5ac Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Mon, 15 Aug 2022 23:51:00 -0300 Subject: [PATCH 033/146] ajustando model e controller para receber a nova logica dos ativos --- Back/src/controller/AtivoController.js | 32 ++++++++++---------------- Back/src/controller/UserController.js | 5 ++++ Back/src/models/Ativo.js | 2 +- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index d1a8534..6ecbba9 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -35,7 +35,8 @@ app.post("/cadastrar", auth, async (req, res) => { sigla: sigla, preco: req.body.preco, quantidade: req.body.quantidade, - data: req.body.data + data: req.body.data, + execucao: "compra" }; // caso nao ache o nome da empresa, @@ -47,28 +48,19 @@ app.post("/cadastrar", auth, async (req, res) => { }) } - const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); - - if (ativos === null){ - await Ativo.create(novo_ativo) - .then(() => { - return res.json({ - erro: false, - message: "Ativo cadastrado com sucesso!" - }) - }).catch((error) => { - console.log(error); - return res.status(400).json({ - erro: true, - message: error.message - }) - }); - } else { + await Ativo.create(novo_ativo) + .then(() => { + return res.json({ + erro: false, + message: "Ativo cadastrado com sucesso!" + }) + }).catch((error) => { + console.log(error); return res.status(400).json({ erro: true, - message: "Ativo ja existente no banco!" + message: error.message }) - } + }); }) module.exports = app; \ No newline at end of file diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index a918ea7..9dd7a28 100755 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -4,6 +4,7 @@ const jwt = require('jsonwebtoken'); const User = require("../models/User"); const app = express(); +const AtivosB3 = require("../util/AtivosB3Util"); // funciona app.post("/cadastrar", async (req, res) => { @@ -68,6 +69,10 @@ app.post("/login", async (req, res) => { expiresIn: 1800 //30 min }); + // Quando o usuario fizer login, o banco de dados + // com todos os ativos eh atualizado + AtivosB3.updateAtivosB3(); + return res.json({ erro: false, message: "Login realizado com sucesso!", diff --git a/Back/src/models/Ativo.js b/Back/src/models/Ativo.js index 9b33795..0e0e290 100755 --- a/Back/src/models/Ativo.js +++ b/Back/src/models/Ativo.js @@ -60,7 +60,7 @@ const Ativo = db.define('ativo', { }, execucao: { type: Sequelize.STRING, - allowNull: true + allowNull: false } }); From a274c577f183aea9a9d667685665535b16dbb238 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Tue, 16 Aug 2022 11:38:41 -0300 Subject: [PATCH 034/146] =?UTF-8?q?Inicio=20conex=C3=A3o=20com=20back-end?= =?UTF-8?q?=20e=20valida=C3=A7=C3=A3o=20de=20quantidade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luciano Freitas --- Back/src/middleware/auth.js | 3 +- Front/src/App.tsx | 2 +- .../A\303\247oes.tsx" | 71 ++++++++++++++----- Front/src/pages/LoginUsuario/Login.tsx | 1 - 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/Back/src/middleware/auth.js b/Back/src/middleware/auth.js index 80db9f6..058fc4f 100644 --- a/Back/src/middleware/auth.js +++ b/Back/src/middleware/auth.js @@ -2,7 +2,8 @@ const jwt = require('jsonwebtoken'); module.exports = (req, res, next) => { try { - const decode = jwt.verify(req.body.token, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3"); + const token = req.body.token; + const decode = jwt.verify(token, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3"); req.usuario = decode; next(); } catch (error) { diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 2354839..1a5ea7c 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -2,7 +2,7 @@ import './App.css' import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' import { Route, Routes } from "react-router-dom"; -import CadastroAcoes from './pages/Cadastro de Ações/Açoes'; +import { CadastroAcoes } from './pages/Cadastro de Ações/Açoes'; import { AuthProvider} from './services/Provider'; import { RequireAuth } from './services/requireAuth'; import { SideBar } from './pages/Sidebar/Sidebar'; diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index abaf530..7792b5f 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -4,9 +4,12 @@ import './Ações.css'; import { IMaskInput } from "react-imask"; import { useState } from "react"; import { parseISO } from 'date-fns'; +import Axios from "axios"; +import { useNavigate } from 'react-router-dom'; +import { useAuth } from '../../services/Provider'; -const CadastroAcoes = () => { +export const CadastroAcoes = () => { const [error, setError] = useState(""); const [assets,setAssets] = useState(""); //Assets é os ativos @@ -15,20 +18,51 @@ const CadastroAcoes = () => { const [quantity,setQuantity] = useState(""); const handleSubmit = async (e: React.FormEvent) => { + const navigate = useNavigate(); + const auth = useAuth(); e.preventDefault(); setError(""); // Transforma a data de compra em um objeto Date - const parsedBirth = parseISO(date); //vamos validar somente os anos de compra e venda ? + const parsedBirth = parseISO(date); + + if (quantity.length < 0 ){ + setError("É necessário inserir uma quantidade válida") + + }else if (stockPrice.length < 0 ) { + setError("É necessário inserir um valor válido") + + } else { + const token = auth.getToken(); + Axios.post("http://localhost:3000/ativo/cadastrar", + { + token: token, + nomeAtivo: assets, + preco: stockPrice, + quantidade: quantity, + data: date + }).then(function (response) { + console.log(response); + alert(response.data.message); + // descomentar a linha abaixo para o usuario ser redirecionado para o historico + // de acoes + // navigate("/historico"); - - //p fazer as máscaras depois - {/*const nameMask = function (value: string) { - var pattern = new RegExp(/^[A-Za-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ ]+$/); - return pattern.test(value); - };*/} + }).catch(function (response) { + const message = response.data.message; + console.log(response); + setError(message); + }) + } } + //mascara para quantidade + const quantityMask = function (value: string) { + var pattern = new RegExp(/^[0-9 ]+$/); + return pattern.test(value); + }; + + //p formatar data const [inputType, setInputType] = useState("text"); @@ -48,21 +82,26 @@ const CadastroAcoes = () => { /> {/*A ideia é alinhar eles na mesma linha */}
- setStockPrice(e.target.value)} + onChange={(e: React.ChangeEvent) => + setStockPrice(e.target.value)} /> - setQuantity(e.target.value)} + onChange={(e: React.ChangeEvent) => + setQuantity(e.target.value)} />
@@ -88,8 +127,6 @@ const CadastroAcoes = () => {
- ) + ); } - -export default CadastroAcoes; \ No newline at end of file diff --git a/Front/src/pages/LoginUsuario/Login.tsx b/Front/src/pages/LoginUsuario/Login.tsx index f47dd08..f61d946 100644 --- a/Front/src/pages/LoginUsuario/Login.tsx +++ b/Front/src/pages/LoginUsuario/Login.tsx @@ -31,7 +31,6 @@ const LoginUsuario = () => { email: email, senha: password }).then(function (response) { - const message = response.data.message; const token = response.data.token; auth.login(token, () => { From 26e7fa711fa4e382785951da4f71cab43d4a4ad3 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Tue, 16 Aug 2022 12:15:21 -0300 Subject: [PATCH 035/146] =?UTF-8?q?criando=20estrutura=20base=20=20para=20?= =?UTF-8?q?m=C3=A1scara=20de=20pre=C3=A7o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 7792b5f..a0c6e51 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -62,7 +62,12 @@ export const CadastroAcoes = () => { return pattern.test(value); }; - + //mascara para preço + const priceMask = function (value: string) { + var pattern = new RegExp(/^\d+([.,]\d{2})?$/); + return pattern.test(value); + } + //p formatar data const [inputType, setInputType] = useState("text"); @@ -86,7 +91,7 @@ export const CadastroAcoes = () => { Date: Tue, 16 Aug 2022 13:16:35 -0300 Subject: [PATCH 036/146] =?UTF-8?q?feat:=20valida=C3=A7=C3=A3o=20do=20inpu?= =?UTF-8?q?t=20de=20pre=C3=A7o=20do=20ativo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A\303\247oes.tsx" | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index a0c6e51..aa96ba2 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -58,16 +58,10 @@ export const CadastroAcoes = () => { //mascara para quantidade const quantityMask = function (value: string) { - var pattern = new RegExp(/^[0-9 ]+$/); + var pattern = new RegExp(/^[0-9]+$/); return pattern.test(value); }; - //mascara para preço - const priceMask = function (value: string) { - var pattern = new RegExp(/^\d+([.,]\d{2})?$/); - return pattern.test(value); - } - //p formatar data const [inputType, setInputType] = useState("text"); @@ -89,9 +83,11 @@ export const CadastroAcoes = () => {
Date: Tue, 16 Aug 2022 13:37:10 -0300 Subject: [PATCH 037/146] =?UTF-8?q?fix:=20ajustanto=20o=20input=20de=20dat?= =?UTF-8?q?a=20de=20compra=20e=20venda=20das=20a=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index aa96ba2..0c11315 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -24,7 +24,7 @@ export const CadastroAcoes = () => { setError(""); // Transforma a data de compra em um objeto Date - const parsedBirth = parseISO(date); + const parsedDate = parseISO(date); if (quantity.length < 0 ){ setError("É necessário inserir uma quantidade válida") @@ -107,12 +107,13 @@ export const CadastroAcoes = () => {
setDate(e.target.value)} + onChange={(e: React.ChangeEvent) => + setDate(e.currentTarget.value)} onFocus={() => setInputType("date")} onBlur={() => setInputType("text")} /> From 6b97ddb1c38ae67fcf64dac13ef8b35608881ad5 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Tue, 16 Aug 2022 22:19:56 -0300 Subject: [PATCH 038/146] Adicianando busca por caractere. > > Co-authored-by: MariaAbritta <87709987+MariaAbritta@users.noreply.github.com> --- Back/src/controller/AtivoController.js | 40 ++------------------------ Back/src/util/BuscaAtivosB3.js | 22 ++++++++++++++ 2 files changed, 25 insertions(+), 37 deletions(-) create mode 100644 Back/src/util/BuscaAtivosB3.js diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 6ecbba9..84bf7f2 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -1,53 +1,19 @@ const express = require("express"); const Ativo = require("../models/Ativo"); const app = express(); -const Axios = require("axios"); -const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); const auth = require("../middleware/auth"); -app.post("/cadastrar", auth, async (req, res) => { - let sigla = null; - - // verifica na API da B3 qual eh a sigla do ativo que o - // usuario deseja cadastrar - await Axios.get(linkApi, { - - }).then(function(res){ - const { nomeAtivo } = req.body; - const data = res.data; - - for(let ativo of data){ - const { nm_empresa } = ativo; - const { cd_acao } = ativo; - //console.log(nm_empresa, cd_acao); - - if(nm_empresa === nomeAtivo) { - sigla = cd_acao; - } - } - }).catch(function(err){ - console.log(err); - }); - +app.post("/cadastrar", auth, async (req, res) => { const novo_ativo = { - id_usuario: req.usuario.id, + id_usuario: "token", // ESTA ERRADO <============== TEM QUE PUXAR DO BACK nomeAtivo: req.body.nomeAtivo, - sigla: sigla, + sigla: req.body.sigla, preco: req.body.preco, quantidade: req.body.quantidade, data: req.body.data, execucao: "compra" }; - // caso nao ache o nome da empresa, - // o ativo nao eh cadastrado - if (novo_ativo.sigla === null) { - return res.json({ - erro: true, - message: "Ativo nao listado na B3!" - }) - } - await Ativo.create(novo_ativo) .then(() => { return res.json({ diff --git a/Back/src/util/BuscaAtivosB3.js b/Back/src/util/BuscaAtivosB3.js new file mode 100644 index 0000000..7566cb5 --- /dev/null +++ b/Back/src/util/BuscaAtivosB3.js @@ -0,0 +1,22 @@ +const { QueryTypes } = require('sequelize'); +const Sequelize = require('sequelize'); + +const sequelize = new Sequelize("usuario", "root", "12345678", { + host: 'localhost', + dialect: 'mysql' +}); + +exports.buscaPorCaractere = function (caracter) { + let caracter = "BANANA" + const query = sequelize.query(`SELECT * FROM b3_ativos WHERE (nome_empresa LIKE '${caracter}%' OR codigo_acao LIKE '${caracter}%');`, { type: QueryTypes.SELECT }). + then(function(res) { + var lista_ativos = []; + for (let ativo of res) { + const { nome_empresa } = ativo; + const { codigo_acao } = ativo; + const linha_ativo = `${nome_empresa} - ${codigo_acao}` + lista.push(linha_ativo); + } + return lista_ativos; + }) +} From afcdd6bd3623857007827715c57996e301ef8d2a Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Tue, 16 Aug 2022 22:23:41 -0300 Subject: [PATCH 039/146] Finalizando a busca. > > Co-authored-by: Maria Abritta <87709987+MariaAbritta@users.noreply.github.com> --- Back/src/util/BuscaAtivosB3.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Back/src/util/BuscaAtivosB3.js b/Back/src/util/BuscaAtivosB3.js index 7566cb5..f807d99 100644 --- a/Back/src/util/BuscaAtivosB3.js +++ b/Back/src/util/BuscaAtivosB3.js @@ -7,8 +7,7 @@ const sequelize = new Sequelize("usuario", "root", "12345678", { }); exports.buscaPorCaractere = function (caracter) { - let caracter = "BANANA" - const query = sequelize.query(`SELECT * FROM b3_ativos WHERE (nome_empresa LIKE '${caracter}%' OR codigo_acao LIKE '${caracter}%');`, { type: QueryTypes.SELECT }). + sequelize.query(`SELECT * FROM b3_ativos WHERE (nome_empresa LIKE '${caracter}%' OR codigo_acao LIKE '${caracter}%');`, { type: QueryTypes.SELECT }). then(function(res) { var lista_ativos = []; for (let ativo of res) { From baa8ce034cd107c7cf8bf16d09ba4387a4ad499c Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Wed, 17 Aug 2022 00:01:32 -0300 Subject: [PATCH 040/146] Liga sidebar com outtras telas. --- Front/src/App.css | 18 +-- Front/src/App.tsx | 4 +- Front/src/pages/Componentes/Sidebar.css | 142 ++++++++++---------- Front/src/pages/Componentes/Sidebar.tsx | 20 +-- Front/src/pages/Componentes/SidebarData.tsx | 28 ++-- Front/tsconfig.json | 2 +- 6 files changed, 106 insertions(+), 108 deletions(-) diff --git a/Front/src/App.css b/Front/src/App.css index 838f00c..12c0ee9 100644 --- a/Front/src/App.css +++ b/Front/src/App.css @@ -1,3 +1,4 @@ +@import url('https://fonts.googleapis.com/css2?family=Lato&display=swap'); .App { font-family: 'Roboto Flex'; font-style: normal; @@ -9,20 +10,13 @@ body { padding: 0; } -.MinhaCarteira, -.Ações, -.MeuPerfil -.Sair { +.carteira, +.acoes, +.historico, +.perfil { display: flex; height: 90vh; align-items: center; justify-content: center; font-size: 3rem; -} - -* { - box-sizing: border-box; - margin: 0; - padding: 0; - font-family: 'Lato', sans-serif; -} +}; \ No newline at end of file diff --git a/Front/src/App.tsx b/Front/src/App.tsx index ef2b7a4..f9ffaaf 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -1,7 +1,7 @@ import './App.css' import CadastroUsuario from './pages/CadastroUsuario/Cadastro' import LoginUsuario from './pages/LoginUsuario/Login' -import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; +import { BrowserRouter as Router, Route, Routes} from "react-router-dom"; import CadastroAcoes from './pages/Cadastro de Ações/Açoes'; import Sidebar from './pages/Componentes/Sidebar'; import React from 'react'; @@ -11,7 +11,7 @@ function App() { return (
- + } /> } /> diff --git a/Front/src/pages/Componentes/Sidebar.css b/Front/src/pages/Componentes/Sidebar.css index c456894..8e6fec4 100644 --- a/Front/src/pages/Componentes/Sidebar.css +++ b/Front/src/pages/Componentes/Sidebar.css @@ -1,72 +1,70 @@ -.navbar { - background-color: #060b26; - height: 80px; - display: flex; - justify-content: start; - align-items: center; - } - - .menu-bars { - margin-left: 2rem; - font-size: 2rem; - background: none; - } - - .nav-menu { - background-color: #060b26; - width: 250px; - height: 100vh; - display: flex; - justify-content: center; - position: fixed; - top: 0; - left: -100%; - transition: 850ms; - } - - .nav-menu.active { - left: 0; - transition: 350ms; - } - - .nav-text { - display: flex; - justify-content: start; - align-items: center; - padding: 8px 0px 8px 16px; - list-style: none; - height: 60px; - } - - .nav-text a { - text-decoration: none; - color: #f5f5f5; - font-size: 18px; - width: 95%; - height: 100%; - display: flex; - align-items: center; - padding: 0 16px; - border-radius: 4px; - } - - .nav-text a:hover { - background-color: #1a83ff; - } - - .nav-menu-items { - width: 100%; - } - - .navbar-toggle { - background-color: #060b26; - width: 100%; - height: 80px; - display: flex; - justify-content: start; - align-items: center; - } - - span { - margin-left: 16px; - } \ No newline at end of file +.sidebar { + background-color: #060b26; + height: 60px; + display: flex; + justify-content: start; + align-items: center; +} + +.menu-bars { + margin-left: 2rem; + font-size: 2rem; + background: none; +} + +.nav-menu { + background-color: #060b26; + width: 250px; + height: 100vh; + display: flex; + justify-content: center; + position: fixed; + top: 0; + left: -100%; + transition: 850ms; +} + +.nav-menu.active { + left: 0; + transition: 350ms; +} + +.nav-text { + display: flex; + justify-content: start ; + align-items: center; + padding: 8px 0px 8px 16px; + list-style: none; + height: 60px; +} +.nav-text a { + text-decoration: none; + color: #f5f5f5; + font-size: 18px; + width: 95%; + height: 100%; + display: flex; + align-items: center; + padding: 0 16px; + border-radius: 4px; +} +.nav-text a:hover { + background-color: #1a83ff; +} + +.nav-menu-items { + width: 100%; +} + +.sidebar-toggle { + background-color: #060b26; + width: 100%; + height: 80px; + display: flex; + justify-content: start; + align-items: center; +} + +span { + margin-left: 16px; +} \ No newline at end of file diff --git a/Front/src/pages/Componentes/Sidebar.tsx b/Front/src/pages/Componentes/Sidebar.tsx index f4482f9..43fbc9a 100644 --- a/Front/src/pages/Componentes/Sidebar.tsx +++ b/Front/src/pages/Componentes/Sidebar.tsx @@ -1,29 +1,29 @@ import React, { useState } from 'react' import * as FaIcons from 'react-icons/fa'; +import * as AiIcons from 'react-icons/ai'; import { Link } from 'react-router-dom'; +import { SidebarData } from './SidebarData'; import './Sidebar.css' -import * as AiIcons from 'react-icons/ai'; import { IconContext } from 'react-icons'; -import { SidebarData } from './SidebarData'; function Sidebar() { - const [currImg, setCurrImg] = useState(0); - const [sidebar, setSidebar] = useState(false); + const [navbar, setNavbar] = useState(false); + + const showNavbar = () => setNavbar(!navbar); - const showSidebar = () => (!sidebar); return ( <> -
+
- +
-
- {error &&

{error}

} - - {error &&

{error}

} +
+ {error &&

{error}

}
diff --git a/Front/src/pages/LoginUsuario/Login.tsx b/Front/src/pages/LoginUsuario/Login.tsx index f61d946..e028919 100644 --- a/Front/src/pages/LoginUsuario/Login.tsx +++ b/Front/src/pages/LoginUsuario/Login.tsx @@ -22,11 +22,6 @@ const LoginUsuario = () => { setError(""); - const user = { - email, - password, - } - Axios.post("http://localhost:3000/usuario/login", { email: email, senha: password From 72d3a971f7d97f63eef64803523b8c66ef7dfede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Wed, 17 Aug 2022 18:16:19 -0300 Subject: [PATCH 042/146] =?UTF-8?q?[feat]=20cria=20a=20fun=C3=A7=C3=A3o=20?= =?UTF-8?q?venda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: LeonardoPadre --- Back/src/controller/AtivoController.js | 246 +++++++++++++++++-------- 1 file changed, 173 insertions(+), 73 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index d1a8534..f6be30c 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -1,74 +1,174 @@ -const express = require("express"); -const Ativo = require("../models/Ativo"); -const app = express(); -const Axios = require("axios"); -const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); -const auth = require("../middleware/auth"); - -app.post("/cadastrar", auth, async (req, res) => { - let sigla = null; - - // verifica na API da B3 qual eh a sigla do ativo que o - // usuario deseja cadastrar - await Axios.get(linkApi, { - - }).then(function(res){ - const { nomeAtivo } = req.body; - const data = res.data; - - for(let ativo of data){ - const { nm_empresa } = ativo; - const { cd_acao } = ativo; - //console.log(nm_empresa, cd_acao); - - if(nm_empresa === nomeAtivo) { - sigla = cd_acao; - } - } - }).catch(function(err){ - console.log(err); - }); - - const novo_ativo = { - id_usuario: req.usuario.id, - nomeAtivo: req.body.nomeAtivo, - sigla: sigla, - preco: req.body.preco, - quantidade: req.body.quantidade, - data: req.body.data - }; - - // caso nao ache o nome da empresa, - // o ativo nao eh cadastrado - if (novo_ativo.sigla === null) { - return res.json({ - erro: true, - message: "Ativo nao listado na B3!" - }) - } - - const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); - - if (ativos === null){ - await Ativo.create(novo_ativo) - .then(() => { - return res.json({ - erro: false, - message: "Ativo cadastrado com sucesso!" - }) - }).catch((error) => { - console.log(error); - return res.status(400).json({ - erro: true, - message: error.message - }) - }); - } else { - return res.status(400).json({ - erro: true, - message: "Ativo ja existente no banco!" - }) - } -}) - +const express = require("express"); +const Ativo = require("../models/Ativo"); +const app = express(); +const sequelize = require('sequelize'); +const Axios = require("axios"); +const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); +const auth = require("../middleware/auth"); + +app.post("/cadastrar", auth, async (req, res) => { + let sigla = null; + + // verifica na API da B3 qual eh a sigla do ativo que o + // usuario deseja cadastrar + await Axios.get(linkApi, { + + }).then(function(res){ + const { nomeAtivo } = req.body; + const data = res.data; + + for(let ativo of data){ + const { nm_empresa } = ativo; + const { cd_acao } = ativo; + //console.log(nm_empresa, cd_acao); + + if(nm_empresa === nomeAtivo) { + sigla = cd_acao; + } + } + }).catch(function(err){ + console.log(err); + }); + + + + + const novo_ativo = { + id_usuario: req.usuario.id, + nomeAtivo: req.body.nomeAtivo, + sigla: sigla, + preco: req.body.preco, + quantidade: req.body.quantidade, + data: req.body.data, + execucao: req.body.execucao + }; + + // caso nao ache o nome da empresa, + // o ativo nao eh cadastrado + if (!novo_ativo.sigla) { + return res.json({ + erro: true, + message: "Ativo nao listado na B3!" + }) + } + + const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); + + + await Ativo.create(novo_ativo) + .then(() => { + return res.json({ + erro: false, + message: "Ativo cadastrado com sucesso!" + }) + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + message: error.message + }) + }); +}) + +app.post("/venda", auth, async (req,res) => { + + // filtro que soma a quantidade de compra do ativo + const ativo_comprado = await Ativo.findAll({ + attributes: [ + "id_usuario", + "nomeAtivo", + "execucao", + [sequelize.fn("sum", sequelize.col("quantidade")), "total"]], + group : ['id_usuario', 'nomeAtivo', 'execucao'], + raw: true, + where: { + "id_usuario" : req.usuario.id, + "nomeAtivo" : req.body.nomeAtivo, + "execucao" : "compra" + }, + }) + + // filtro que soma a quantidade de venda do ativo + const ativo_vendido = await Ativo.findAll({ + attributes: [ + "id_usuario", + "nomeAtivo", + "execucao", + [sequelize.fn("sum", sequelize.col("quantidade")), "total"]], + group : ['id_usuario', 'nomeAtivo', 'execucao'], + raw: true, + where: { + "id_usuario" : req.usuario.id, + "nomeAtivo" : req.body.nomeAtivo, + "execucao" : "venda" + }, + }) + + const totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; + + let sigla = null; + + // verifica na API da B3 qual eh a sigla do ativo que o + // usuario deseja cadastrar + await Axios.get(linkApi, { + + }).then(function(res){ + const { nomeAtivo } = req.body; + const data = res.data; + + for(let ativo of data){ + const { nm_empresa } = ativo; + const { cd_acao } = ativo; + //console.log(nm_empresa, cd_acao); + + if(nm_empresa === nomeAtivo) { + sigla = cd_acao; + } + } + }).catch(function(err){ + console.log(err); + }); + + const nova_venda = { + id_usuario: req.usuario.id, + nomeAtivo: req.body.nomeAtivo, + sigla: sigla, + preco: req.body.preco, + quantidade: req.body.quantidade, + data: req.body.data, + execucao: req.body.execucao + }; + + if (!nova_venda.sigla) { + return res.json({ + erro: true, + message: "Ativo nao listado na B3!" + }) + } + + if (req.body.quantidade <= totalQuantidade) { + + await Ativo.create(nova_venda) + .then(() => { + return res.json({ + erro: false, + message: "Ativo vendido com sucesso!" + }) + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + message: "Erro na venda do ativo" + }) + }); + } else { + return res.status(400).json({ + erro: true, + message: "Erro na venda do ativo" + }) + } +}) + + + module.exports = app; \ No newline at end of file From 691ff385886a8aa4d3a6bc96051a88af45d51d55 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 19 Aug 2022 10:09:02 -0300 Subject: [PATCH 043/146] testando branch --- Front/src/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 6493d5d..c6e7ab6 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -25,10 +25,10 @@ function App() { } > - } /> + - + } />
From 18ebbeeda0ff70678f5a84be16ff436f1ba020da Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 19 Aug 2022 11:10:16 -0300 Subject: [PATCH 044/146] tentando ajustar a algo da sidebar --- .../A\303\247oes.tsx" | 45 ++++++++++++------- .../A\303\247\303\265es.css" | 33 +++++--------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 983b765..861324d 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -3,30 +3,40 @@ import './Ações.css'; import { IMaskInput } from "react-imask"; import { useState } from "react"; +import { parseISO } from 'date-fns'; import Axios from "axios"; +import { useNavigate } from 'react-router-dom'; +import { useAuth } from '../../services/Provider'; export const CadastroAcoes = () => { const [error, setError] = useState(""); - const [assets,setAssets] = useState(""); //Assets é o ativo + const [assets,setAssets] = useState(""); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações const [date, setDate] = useState(""); const [quantity,setQuantity] = useState(""); const handleSubmit = async (e: React.FormEvent) => { + const navigate = useNavigate(); + const auth = useAuth(); e.preventDefault(); + setError(""); - + // Transforma a data de compra em um objeto Date + const parsedDate = parseISO(date); + if (quantity.length < 0 ){ - setError("É necessário inserir uma quantidade válida"); + setError("É necessário inserir uma quantidade válida") }else if (stockPrice.length < 0 ) { - setError("É necessário inserir um valor válido"); + setError("É necessário inserir um valor válido") } else { - // Funciona somente quando não está sendo usado o auth no back - Axios.post("http://localhost:3000/ativo/cadastrar", { + const token = auth.getToken(); + Axios.post("http://localhost:3000/ativo/cadastrar", + { + token: token, nomeAtivo: assets, preco: stockPrice, quantidade: quantity, @@ -34,16 +44,19 @@ export const CadastroAcoes = () => { }).then(function (response) { console.log(response); alert(response.data.message); - // Colocar posteriormente o redirecionamento para o historico de acoes + // descomentar a linha abaixo para o usuario ser redirecionado para o historico + // de acoes + // navigate("/historico"); - }).catch(function (error) { - const message = error.response.data.message; + }).catch(function (response) { + const message = response.data.message; + console.log(response); setError(message); }) } } - // mascara para quantidade + //mascara para quantidade const quantityMask = function (value: string) { var pattern = new RegExp(/^[0-9]+$/); return pattern.test(value); @@ -56,7 +69,7 @@ export const CadastroAcoes = () => {

Compra/Venda de Ativos

-
+ { onChange={(e) => setAssets(e.target.value)} /> {/*A ideia é alinhar eles na mesma linha */} -
+
{ {
+ {error &&

{error}

} + - + {error &&

{error}

}
- {error &&

{error}

}
diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 978aa9e..d3bc53d 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -10,17 +10,18 @@ background-size: cover; background-repeat: no-repeat; } - .div-cadastro{ display: flex; - flex-direction: column; - padding: 2%; width: 60%; height: 60%; background-color: rgba(10, 17, 79, 0.8); border-radius: 40px; +} +.form-cadastro{ + display: flex; + flex-direction: column; + padding: 2%; color: white; - } .titulo { @@ -36,13 +37,13 @@ input{ background-color:white; color:black; width: 45%; - padding: 0.5em; border: none; - border-radius: 40px; + border-radius: 40px; font-size: 1.5em; text-align: center; font-weight: bold; + } input::placeholder{ @@ -52,7 +53,7 @@ input::placeholder{ } .busca-input{ - width: 85%; + width: 100%; } .buy-button { @@ -90,7 +91,7 @@ input::placeholder{ } -.sellbutton:hover{ +.sell-button:hover{ background: white; color: black; } @@ -110,20 +111,8 @@ input::placeholder{ } -.columnBox { +.linebox { display: flex; justify-content: space-between; } -.date-input{ - float: left; - background-color:white; - color:gray; - width: 45%; - padding: 0.5em; - border: none; - border-radius: 40px; - font-size: 1em; - text-align: center; - margin-right: 50%; - -} + From b27e15561eb9223e209df7774afbc73d8c97b29b Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 19 Aug 2022 11:32:55 -0300 Subject: [PATCH 045/146] ajustando a tela de cadastro de ativos --- .../A\303\247\303\265es.css" | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index d3bc53d..09e88af 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -42,6 +42,7 @@ input{ font-size: 1.5em; text-align: center; font-weight: bold; + padding: 0.5em; } @@ -66,7 +67,7 @@ input::placeholder{ padding: 0.5em 1.5em; cursor: pointer; transition: 0.25s; - margin-right: 25%; + margin-right: 15%; } .buy-button:hover{ @@ -87,7 +88,7 @@ input::placeholder{ padding: 0.5em 2em; cursor: pointer; transition: 0.25s; - margin-right: 20%; + margin-right: 30%; } @@ -116,3 +117,11 @@ input::placeholder{ justify-content: space-between; } +.date-input{ + margin-left: 40%; + display: flex; + width: 80%; + border: none; + border-radius: 40px; + margin-right: 60%; +} \ No newline at end of file From 579cb3c6fe5a6b458bc28db68de7c48be2e9da1d Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 19 Aug 2022 12:42:47 -0300 Subject: [PATCH 046/146] arrumando detalhes --- .../Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 09e88af..8cf33f0 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -54,7 +54,8 @@ input::placeholder{ } .busca-input{ - width: 100%; + width: 97%; + margin-right: 0%; } .buy-button { From fb024b869292c3280749bd19cc818d1614237c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20J=C3=BAnior?= <72047826+antonioleaojr@users.noreply.github.com> Date: Fri, 19 Aug 2022 12:51:09 -0300 Subject: [PATCH 047/146] =?UTF-8?q?Cria=C3=A7=C3=A3o=20das=20pastas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/HistoricoDeAcoes/historico.css | 0 Front/src/pages/HistoricoDeAcoes/historico.tsx | 1 + 2 files changed, 1 insertion(+) create mode 100644 Front/src/pages/HistoricoDeAcoes/historico.css create mode 100644 Front/src/pages/HistoricoDeAcoes/historico.tsx diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css new file mode 100644 index 0000000..e69de29 diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx new file mode 100644 index 0000000..991aa1a --- /dev/null +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -0,0 +1 @@ + \ No newline at end of file From 514d2d527b707f1ae9202df0bedbfdd0a3c7d2d4 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 19 Aug 2022 12:55:38 -0300 Subject: [PATCH 048/146] Finalizando os ajustes --- .../Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 7 ++----- .../A\303\247\303\265es.css" | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 861324d..2ff7046 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -11,7 +11,7 @@ import { useAuth } from '../../services/Provider'; export const CadastroAcoes = () => { - const [error, setError] = useState(""); + const [error, setError] = useState("É necessário inserir uma quantidade válida"); const [assets,setAssets] = useState(""); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações const [date, setDate] = useState(""); @@ -120,12 +120,9 @@ export const CadastroAcoes = () => {
- {error &&

{error}

} - - - {error &&

{error}

}
+ {error &&

{error}

} diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 8cf33f0..8a768dc 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -22,6 +22,7 @@ flex-direction: column; padding: 2%; color: white; + gap:1.25em; } .titulo { @@ -109,8 +110,8 @@ input::placeholder{ .buttonBox{ display: flex; - margin-top: 6.75%; - + margin-top: 5.75%; + margin-right: 5%; } .linebox { From 1706b42d75183128fa3d6eeea39f38463387f85e Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Fri, 19 Aug 2022 13:16:05 -0300 Subject: [PATCH 049/146] =?UTF-8?q?bug:=20centraliza=C3=A7=C3=A3o=20dos=20?= =?UTF-8?q?elementos=20de=20cadastro=20de=20ativos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A\303\247\303\265es.css" | 46 +++++++------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 8a768dc..431b5d0 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -24,7 +24,9 @@ color: white; gap:1.25em; } - +div{ + width: 100%; +} .titulo { text-align: center; font-size: 2.5em; @@ -33,7 +35,10 @@ color: white; font-weight: bold; } - +.linebox { + display: flex; + justify-content: space-between; +} input{ background-color:white; color:black; @@ -59,8 +64,7 @@ input::placeholder{ margin-right: 0%; } -.buy-button { - background-color:#47B802; +button{ color:white; border: none; border-radius:70px; @@ -68,35 +72,22 @@ input::placeholder{ text-align: center; padding: 0.5em 1.5em; cursor: pointer; - transition: 0.25s; - margin-right: 15%; + transition: 0.25s; } - -.buy-button:hover{ +button:hover{ float: left; background: white; color: black; align-items: left; justify-items: left; } +.buy-button { + background-color:#47B802; +} .sell-button { background-color:#9F0303; - color:white; - border: none; - border-radius:70px; - font-size: 1.5em; - text-align: center; padding: 0.5em 2em; - cursor: pointer; - transition: 0.25s; - margin-right: 30%; - -} - -.sell-button:hover{ - background: white; - color: black; } .error{ @@ -110,15 +101,10 @@ input::placeholder{ .buttonBox{ display: flex; - margin-top: 5.75%; - margin-right: 5%; -} - -.linebox { - display: flex; - justify-content: space-between; + justify-content: center; + align-items: center; + gap: 2.5em; } - .date-input{ margin-left: 40%; display: flex; From 411c6ce5fb19913c41e71fe9fbb1f2198bac20d9 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Fri, 19 Aug 2022 13:24:08 -0300 Subject: [PATCH 050/146] =?UTF-8?q?fix:=20espa=C3=A7amento=20dos=20bot?= =?UTF-8?q?=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 2 +- .../Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 2ff7046..9810c6d 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -11,7 +11,7 @@ import { useAuth } from '../../services/Provider'; export const CadastroAcoes = () => { - const [error, setError] = useState("É necessário inserir uma quantidade válida"); + const [error, setError] = useState(""); const [assets,setAssets] = useState(""); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações const [date, setDate] = useState(""); diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 431b5d0..b6113ec 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -104,6 +104,7 @@ button:hover{ justify-content: center; align-items: center; gap: 2.5em; + margin-top: 1.75em; } .date-input{ margin-left: 40%; From 2e63bc7aef35331b683418054af4f1cc66eeef98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20J=C3=BAnior?= <72047826+antonioleaojr@users.noreply.github.com> Date: Fri, 19 Aug 2022 19:21:33 -0300 Subject: [PATCH 051/146] =?UTF-8?q?Come=C3=A7ando=20a=20implementa=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/App.tsx | 8 ++-- .../src/pages/HistoricoDeAcoes/historico.css | 38 +++++++++++++++++++ .../src/pages/HistoricoDeAcoes/historico.tsx | 28 +++++++++++++- package-lock.json | 6 +++ 4 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 package-lock.json diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 6493d5d..759f3c4 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -1,6 +1,7 @@ import './App.css' -import CadastroUsuario from './pages/CadastroUsuario/Cadastro' -import LoginUsuario from './pages/LoginUsuario/Login' +import CadastroUsuario from './pages/CadastroUsuario/Cadastro'; +import LoginUsuario from './pages/LoginUsuario/Login'; +import HistoricoDeAcoes from './pages/HistoricoDeAcoes/historico'; import { Route, Routes } from "react-router-dom"; import { CadastroAcoes } from './pages/Cadastro de Ações/Açoes'; import { AuthProvider} from './services/Provider'; @@ -18,13 +19,14 @@ function App() { }> } /> } /> + } /> - } > + } > } /> diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css index e69de29..219c136 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.css +++ b/Front/src/pages/HistoricoDeAcoes/historico.css @@ -0,0 +1,38 @@ +body { + margin: 0; +} +.background-img { + display: flex; + align-items: center; + justify-content: center; + position: absolute; + height: 100vh; + width:100vw; + background-image: url('../../assets/background.jpeg'); + background-size: cover; + background-repeat: no-repeat; +} + +.titulo { + font-size: 2.5em; +} + +ul { + color: #000000; + padding-right: 10px; + display: flex; +} +li{ + padding: 10px; +} +.div-historico { + display: flex; + flex-direction: column; + padding: 2%; + width: 80%; + height: 50%; + background-color: hsla(218, 17%, 71%, 0.796); + border-radius: 40px; + color: white; +} + diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index 991aa1a..e2efaa0 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -1 +1,27 @@ - \ No newline at end of file +import './historico.css'; + + +const HistoricoDeAcoes = () => { + + const strings = ['Ativo', 'Sigla', 'Ordem', 'Quantidade', 'Valor']; + const listItems = strings.map((strings) => +
  • {strings}
  • + ); + +return ( + + +
    +

    Invext - Histórico de ações

    +
    +
      {listItems}
    +
    +
    + + +) + +} + +export default HistoricoDeAcoes; + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b46c28f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "GFour-Invext", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} From aeb11e668a7c84af83dca8c369e437db906aa1fc Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Sat, 20 Aug 2022 09:57:17 -0300 Subject: [PATCH 052/146] =?UTF-8?q?criando=20a=20base=20da=20fun=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20busca=20de=20ativos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 4 ++++ 1 file changed, 4 insertions(+) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 9810c6d..53e6a97 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -8,6 +8,10 @@ import Axios from "axios"; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../../services/Provider'; +//templante da função onde será feita a busca de ativos que verei com o luciano +const buscaAtivos = function(value:string) { + return +} export const CadastroAcoes = () => { From 7c7b25cffb7640aa005177cf8dd054ad19fc3b02 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Sat, 20 Aug 2022 16:10:45 -0300 Subject: [PATCH 053/146] fix: mostrar a sidebar junto dos outros componentes --- Front/package.json | 1 + Front/src/App.tsx | 12 +++++----- Front/src/components/AvisoSair/avisoSair.css | 6 +++++ Front/src/components/AvisoSair/avisoSair.tsx | 23 +++++++++++++++++++ Front/src/pages/LoginUsuario/Login.tsx | 4 +--- .../{Componentes => Sidebar}/Sidebar.css | 4 ++++ .../{Componentes => Sidebar}/Sidebar.tsx | 9 +++++--- .../{Componentes => Sidebar}/SidebarData.tsx | 20 ++++++---------- Front/src/services/publicRoute.tsx | 3 +-- 9 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 Front/src/components/AvisoSair/avisoSair.css create mode 100644 Front/src/components/AvisoSair/avisoSair.tsx rename Front/src/pages/{Componentes => Sidebar}/Sidebar.css (95%) rename Front/src/pages/{Componentes => Sidebar}/Sidebar.tsx (88%) rename Front/src/pages/{Componentes => Sidebar}/SidebarData.tsx (67%) diff --git a/Front/package.json b/Front/package.json index 9a6cdf6..a2eed91 100644 --- a/Front/package.json +++ b/Front/package.json @@ -13,6 +13,7 @@ "date-fns": "^2.29.1", "module-alias": "^2.2.2", "react": "^18.2.0", + "react-bootstrap": "^2.5.0", "react-dom": "^18.2.0", "react-icons": "^4.4.0", "react-imask": "^6.4.2", diff --git a/Front/src/App.tsx b/Front/src/App.tsx index c6e7ab6..10ae1ca 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -5,8 +5,9 @@ import { Route, Routes } from "react-router-dom"; import { CadastroAcoes } from './pages/Cadastro de Ações/Açoes'; import { AuthProvider} from './services/Provider'; import { RequireAuth } from './services/requireAuth'; -import { Sidebar } from './pages/Componentes/Sidebar'; +import { Sidebar } from './pages/Sidebar/Sidebar'; import { PublicRoute } from './services/publicRoute'; +import { AvisoSair } from './components/AvisoSair/avisoSair'; function App() { @@ -24,11 +25,10 @@ function App() { - } > - - -
    - } /> + }> + } /> + } /> + diff --git a/Front/src/components/AvisoSair/avisoSair.css b/Front/src/components/AvisoSair/avisoSair.css new file mode 100644 index 0000000..b6e90bc --- /dev/null +++ b/Front/src/components/AvisoSair/avisoSair.css @@ -0,0 +1,6 @@ +.container{ + width: 100%; + display: flex; + justify-content: center; + align-items: center; +} \ No newline at end of file diff --git a/Front/src/components/AvisoSair/avisoSair.tsx b/Front/src/components/AvisoSair/avisoSair.tsx new file mode 100644 index 0000000..d3deabb --- /dev/null +++ b/Front/src/components/AvisoSair/avisoSair.tsx @@ -0,0 +1,23 @@ +import { useNavigate } from "react-router-dom"; +import { useAuth } from "../../services/Provider"; + + +export const AvisoSair = () =>{ + + const auth = useAuth(); + const navigate = useNavigate(); + + const logout = () =>{ + auth.logout(() => { + navigate("/"); + }) + } + + return( + <> + {logout()} + + ) + +} + \ No newline at end of file diff --git a/Front/src/pages/LoginUsuario/Login.tsx b/Front/src/pages/LoginUsuario/Login.tsx index e028919..147918d 100644 --- a/Front/src/pages/LoginUsuario/Login.tsx +++ b/Front/src/pages/LoginUsuario/Login.tsx @@ -15,8 +15,6 @@ const LoginUsuario = () => { let location = useLocation(); let auth = useAuth(); - let from = location.state?.from?.pathname || "/index"; - const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -29,7 +27,7 @@ const LoginUsuario = () => { const token = response.data.token; auth.login(token, () => { - navigate(from, { replace: true }); + navigate("/index", { replace: true }); }); }).catch(function (response) { diff --git a/Front/src/pages/Componentes/Sidebar.css b/Front/src/pages/Sidebar/Sidebar.css similarity index 95% rename from Front/src/pages/Componentes/Sidebar.css rename to Front/src/pages/Sidebar/Sidebar.css index 8e6fec4..84d05d9 100644 --- a/Front/src/pages/Componentes/Sidebar.css +++ b/Front/src/pages/Sidebar/Sidebar.css @@ -1,3 +1,7 @@ +.container{ + position: absolute; + z-index: 10; +} .sidebar { background-color: #060b26; height: 60px; diff --git a/Front/src/pages/Componentes/Sidebar.tsx b/Front/src/pages/Sidebar/Sidebar.tsx similarity index 88% rename from Front/src/pages/Componentes/Sidebar.tsx rename to Front/src/pages/Sidebar/Sidebar.tsx index 984f56b..c7de6be 100644 --- a/Front/src/pages/Componentes/Sidebar.tsx +++ b/Front/src/pages/Sidebar/Sidebar.tsx @@ -1,13 +1,12 @@ import React, { useState } from 'react' import * as FaIcons from 'react-icons/fa'; import * as AiIcons from 'react-icons/ai'; -import { Link } from 'react-router-dom'; +import { Link, Outlet } from 'react-router-dom'; import { SidebarData } from './SidebarData'; import './Sidebar.css' import { IconContext } from 'react-icons'; - export const Sidebar = () => { const [navbar, setNavbar] = useState(false); @@ -15,6 +14,8 @@ export const Sidebar = () => { return ( <> +
    +
    @@ -30,7 +31,7 @@ export const Sidebar = () => { {SidebarData.map((item, index) => { return ( -
  • +
  • {item.icon} {item.title} @@ -41,6 +42,8 @@ export const Sidebar = () => { +
  • + ); } \ No newline at end of file diff --git a/Front/src/pages/Componentes/SidebarData.tsx b/Front/src/pages/Sidebar/SidebarData.tsx similarity index 67% rename from Front/src/pages/Componentes/SidebarData.tsx rename to Front/src/pages/Sidebar/SidebarData.tsx index bd06eda..31ef065 100644 --- a/Front/src/pages/Componentes/SidebarData.tsx +++ b/Front/src/pages/Sidebar/SidebarData.tsx @@ -6,38 +6,32 @@ import * as IoIcons from 'react-icons/io' export const SidebarData = [ { title:'Carteira', - path:'/Carteira', + path:'carteira', icon: , - cName:'nav-test', }, { title:'Ações', - path:'/Acoes', + path:'acoes', icon: , - cName:'nav-test', }, { title:'Histórico', - path:'/Historico', + path:'historico', icon: , - cName: 'nav-test', }, { title:'Perfil', - path:'/Perfil', + path:'perfil', icon: , - cName:'nav-test', }, { title:'Sair', - path:'/Sair', + path:'sair', icon: , - cName:'nav-test', }, { title:'Ajuda', - path:'/Ajuda', + path:'ajuda', icon: , - cName:'nav-text' - }, + }, ]; \ No newline at end of file diff --git a/Front/src/services/publicRoute.tsx b/Front/src/services/publicRoute.tsx index 1da4999..4797993 100644 --- a/Front/src/services/publicRoute.tsx +++ b/Front/src/services/publicRoute.tsx @@ -5,7 +5,6 @@ export const PublicRoute = ( ) => { let auth = useAuth(); let location = useLocation(); - let from = location.state?.from?.pathname || "/index"; // Se o usuario não estiver logado, ele tem acesso a parte publica das rotas if (!auth.getToken()) { @@ -13,5 +12,5 @@ export const PublicRoute = ( ) => { } // Caso ele esteja logado, ele é redirecionado para o ultimo local // que ele estava antes de tentar deslogar - return ; + return ; } \ No newline at end of file From 2807859c967ee4ea4d0f82d39d52887d3530ddbb Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Sat, 20 Aug 2022 17:39:57 -0300 Subject: [PATCH 054/146] criando a base da parte de busca Co-authored-by: Luciano Freitas --- Front/package.json | 3 +- .../A\303\247oes.tsx" | 10 +++-- .../Busca.tsx" | 42 +++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 "Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" diff --git a/Front/package.json b/Front/package.json index 9a6cdf6..36bd6ca 100644 --- a/Front/package.json +++ b/Front/package.json @@ -16,7 +16,8 @@ "react-dom": "^18.2.0", "react-icons": "^4.4.0", "react-imask": "^6.4.2", - "react-router-dom": "^6.3.0" + "react-router-dom": "^6.3.0", + "react-select": "^5.4.0" }, "devDependencies": { "@types/module-alias": "^2.0.1", diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 53e6a97..288a034 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -7,11 +7,11 @@ import { parseISO } from 'date-fns'; import Axios from "axios"; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../../services/Provider'; +import {BuscaAtivo} from './Busca'; + //templante da função onde será feita a busca de ativos que verei com o luciano -const buscaAtivos = function(value:string) { - return -} + export const CadastroAcoes = () => { @@ -83,7 +83,9 @@ export const CadastroAcoes = () => { value={assets} onChange={(e) => setAssets(e.target.value)} /> - {/*A ideia é alinhar eles na mesma linha */} +
    + +
    { + var result : Opcao; + const buscaAtivos = (search:string) => { + return AtivosExample.map((ativos) => {result.value = ativos; result.label = ativos}) + } + console.log(buscaAtivos(assets)); + + return( + setAssets(e.target.value)} + + -
    - +
    diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index b6113ec..961de71 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -59,11 +59,6 @@ input::placeholder{ font-size: 1em; } -.busca-input{ - width: 97%; - margin-right: 0%; -} - button{ color:white; border: none; diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.css" new file mode 100644 index 0000000..eb421da --- /dev/null +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.css" @@ -0,0 +1,33 @@ +.select{ + display: flex; + text-align: center; + color:black; + width: 100%; + font-size: 1.5em; + text-align: center; + font-weight: bold; + +} +.react-select__control{ + border-radius: 40px !important; + padding: 0.25em; +} + +.react-select__value-container{ + margin-left: 10%; + width: 90%; + cursor: text; + display: flex; + justify-content: center; + align-items: center; +} + +.react-select__indicators{ + width: 10%; + +} +.react-select__indicator{ + display: flex; + justify-content: center; + align-items: center; +} diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index ec3d328..71a1017 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -1,4 +1,7 @@ +import { useState } from 'react'; import Select from 'react-select'; +import './Busca.css'; + const AtivosExample = [ "AMERICANAS - AMER3", @@ -12,31 +15,27 @@ const AtivosExample = [ "BRADESCO - BBDC4", "BBSEGURIDADE - BBSE3" ] -interface Opcao{ - value: string, - label: string -} interface Props{ - assets: string + setValue: Function } // Fazer o props para pergar o assets para pesquisa -export const BuscaAtivo = ({assets}:Props) => { - var result : Opcao; - const buscaAtivos = (search:string) => { - return AtivosExample.map((ativos) => {result.value = ativos; result.label = ativos}) +export const BuscaAtivo = (props:Props) => { + + const Options = () => { + return AtivosExample.map((ativos) => ({value: ativos, label: ativos})) } - console.log(buscaAtivos(assets)); return( - "Ativo não encontrado"} + isClearable + components={{ DropdownIndicator:() => null, IndicatorSeparator: () => null}} + // Se o valor for diferente de null, colocamos o valor dele, caso contrário colocamos '' + onChange={e => e ? props.setValue(e.value) : props.setValue('')} + /> ); } \ No newline at end of file From d4339ab95609ae97a7dbaf4b81dfe31265d9c40a Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Sat, 20 Aug 2022 20:56:38 -0300 Subject: [PATCH 056/146] =?UTF-8?q?refactor:=20mudan=C3=A7a=20na=20estrutu?= =?UTF-8?q?ra=20do=20assets=20para=20conter=20a=20sigla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A\303\247oes.tsx" | 11 +++++---- .../Busca.tsx" | 24 +++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index c922f68..0a9a863 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -7,11 +7,14 @@ import Axios from "axios"; import { useAuth } from '../../services/Provider'; import {BuscaAtivo} from './Busca'; - +interface Assets{ + name: string, + initials: string +} export const CadastroAcoes = () => { const [error, setError] = useState(""); - const [assets,setAssets] = useState(""); //Assets é os ativos + const [assets,setAssets] = useState(); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações const [date, setDate] = useState(""); const [quantity,setQuantity] = useState(""); @@ -37,7 +40,8 @@ export const CadastroAcoes = () => { Axios.post("http://localhost:3000/ativo/cadastrar", { token: token, - nomeAtivo: assets, + nomeAtivo: assets.name, + sigla: assets.initials, preco: stockPrice, quantidade: quantity, data: date @@ -74,7 +78,6 @@ export const CadastroAcoes = () => { -
    diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index 71a1017..74135e9 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -2,19 +2,19 @@ import { useState } from 'react'; import Select from 'react-select'; import './Busca.css'; - +interface Assets{ + name: string, + initials: string +} const AtivosExample = [ - "AMERICANAS - AMER3", - "ELETROBRAS - ELET3", - "EMBRAER - EMBRAER", - "ITAUUNIBANCO - ITUB4", - "PETROBRAS - PETR4", - "RAIADROGASIL - RADL3", - "VIAVAREJO - VVAR3", - "CIELO - CIEL3", - "BRADESCO - BBDC4", - "BBSEGURIDADE - BBSE3" + {name: "AMERICANAS", sigla: "AMER3"}, + {name: "ELETROBRAS", sigla: "ELET3"}, + {name: "EMBRAER", sigla: "EMBRAER"}, + {name: "ITAUUNIBANCO", sigla: "ITUB4"}, + {name: "PETROBRAS", sigla: "ITUB4"}, + {name: "RAIADROGASIL", sigla: "RADL3"} ] + interface Props{ setValue: Function } @@ -22,7 +22,7 @@ interface Props{ export const BuscaAtivo = (props:Props) => { const Options = () => { - return AtivosExample.map((ativos) => ({value: ativos, label: ativos})) + return AtivosExample.map((ativos) => ({value: ativos, label: ativos.name.concat(' - ',ativos.sigla)})) } return( From e46237d26c2987c45b6858279562f7a89e263aa8 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Sat, 20 Aug 2022 23:39:45 -0300 Subject: [PATCH 057/146] =?UTF-8?q?fix:=20Arrumado=20integra=C3=A7=C3=A3o?= =?UTF-8?q?=20b=C3=A1sica=20em=20CadAtivos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/controller/AtivoController.js | 5 +---- .../A\303\247oes.tsx" | 15 ++++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index c9dca18..c702361 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -46,14 +46,11 @@ app.post("/cadastrar", auth, async (req, res) => { // caso nao ache o nome da empresa, // o ativo nao eh cadastrado if (!novo_ativo.sigla) { - return res.json({ + return res.status(400).json({ erro: true, message: "Ativo nao listado na B3!" }) } - - const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); - await Ativo.create(novo_ativo) .then(() => { diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 9810c6d..8a520a7 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -17,9 +17,12 @@ export const CadastroAcoes = () => { const [date, setDate] = useState(""); const [quantity,setQuantity] = useState(""); + const navigate = useNavigate(); + const auth = useAuth(); + const token = auth.getToken(); + const handleSubmit = async (e: React.FormEvent) => { - const navigate = useNavigate(); - const auth = useAuth(); + e.preventDefault(); setError(""); @@ -33,7 +36,6 @@ export const CadastroAcoes = () => { setError("É necessário inserir um valor válido") } else { - const token = auth.getToken(); Axios.post("http://localhost:3000/ativo/cadastrar", { token: token, @@ -42,15 +44,14 @@ export const CadastroAcoes = () => { quantidade: quantity, data: date }).then(function (response) { - console.log(response); alert(response.data.message); // descomentar a linha abaixo para o usuario ser redirecionado para o historico // de acoes // navigate("/historico"); - }).catch(function (response) { - const message = response.data.message; - console.log(response); + }).catch(function (error) { + console.log(error); + const message = error.response.data.message; setError(message); }) } From 014912a5829b2db18907b82b572312557930c51e Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Sun, 21 Aug 2022 22:25:21 -0300 Subject: [PATCH 058/146] =?UTF-8?q?Cria=20tabela=20na=20tela=20de=20hist?= =?UTF-8?q?=C3=B3rico.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/HistoricoDeAcoes/historico.css | 18 +++++++- .../src/pages/HistoricoDeAcoes/historico.tsx | 41 ++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css index 219c136..90f4c4f 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.css +++ b/Front/src/pages/HistoricoDeAcoes/historico.css @@ -30,9 +30,23 @@ li{ flex-direction: column; padding: 2%; width: 80%; - height: 50%; + height: 70%; background-color: hsla(218, 17%, 71%, 0.796); border-radius: 40px; color: white; } - +table { + border-radius: 40px ; + background-color: hsla(218, 17%, 71%, 0.796); + width: 100%; + height: 100%; +} +table th { + background-color: rgb(3, 3, 56); + color: #fff; + +} +table td { + background-color: hsla(218, 17%, 71%, 0.7); + color: #0c0c0c; +} \ No newline at end of file diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index e2efaa0..f712388 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -1,4 +1,7 @@ +import { Link } from 'react-router-dom'; import './historico.css'; +var novaTabela = document.createElement("table"); + const HistoricoDeAcoes = () => { @@ -14,7 +17,43 @@ return (

    Invext - Histórico de ações

    -
      {listItems}
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AtivoSiglaOrdemQuantidadeValor
    ----------
    ----------
    ----------
    +
    From 562a3ea492fdc094e08ec9ff71a3b60d7e08e3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20J=C3=BAnior?= <72047826+antonioleaojr@users.noreply.github.com> Date: Sun, 21 Aug 2022 22:38:33 -0300 Subject: [PATCH 059/146] =?UTF-8?q?exclus=C3=A3o=20antiga=20Lista?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/HistoricoDeAcoes/historico.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index f712388..d8be8ec 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -6,11 +6,8 @@ var novaTabela = document.createElement("table"); const HistoricoDeAcoes = () => { - const strings = ['Ativo', 'Sigla', 'Ordem', 'Quantidade', 'Valor']; - const listItems = strings.map((strings) => -
  • {strings}
  • - ); + return ( From 3558a7e848dab1cec8198d99ca7e087059bdf413 Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Mon, 22 Aug 2022 16:17:23 -0300 Subject: [PATCH 060/146] =?UTF-8?q?Complementa=20tabela=20e=20cria=20bot?= =?UTF-8?q?=C3=A3o=20para=20filtro.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/HistoricoDeAcoes/historico.css | 17 ++ .../src/pages/HistoricoDeAcoes/historico.tsx | 145 +++++++++++++++++- 2 files changed, 161 insertions(+), 1 deletion(-) diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css index 90f4c4f..b21b9cb 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.css +++ b/Front/src/pages/HistoricoDeAcoes/historico.css @@ -49,4 +49,21 @@ table th { table td { background-color: hsla(218, 17%, 71%, 0.7); color: #0c0c0c; +} +.buttonBox{ + display: flex; + margin-top: 6%; +} +.select-button { + background-color:#3f413ee1; + color:white; + border: #000000; + border-color: #000000; + border-radius: 10cm; + font-size: 1em; + text-align: center; + padding: 0.1mm 0.5cm; + cursor:pointer; + transition: 0.25s; + margin-right: 25%; } \ No newline at end of file diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index d8be8ec..4bc2715 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -22,7 +22,7 @@ return ( Ativo Sigla Ordem - Quantidade + Quant. Valor @@ -48,9 +48,152 @@ return ( -- -- + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- + + + -- + -- + -- + -- + -- +
    +
    + +
    From c69b6f40c549b312fb782397d98d05493586af25 Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Mon, 22 Aug 2022 17:18:06 -0300 Subject: [PATCH 061/146] Modifica cor e acrescenta editar e excluir. --- .../src/pages/HistoricoDeAcoes/historico.css | 20 +++---- .../src/pages/HistoricoDeAcoes/historico.tsx | 56 +++++++++++++++++-- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css index b21b9cb..cd64351 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.css +++ b/Front/src/pages/HistoricoDeAcoes/historico.css @@ -31,23 +31,21 @@ li{ padding: 2%; width: 80%; height: 70%; - background-color: hsla(218, 17%, 71%, 0.796); - border-radius: 40px; + background-color: #dadadace; + border-radius: 0.5cm; color: white; } table { - border-radius: 40px ; - background-color: hsla(218, 17%, 71%, 0.796); + background-color: #dadada4d; width: 100%; - height: 100%; } table th { - background-color: rgb(3, 3, 56); + background-color: #181f33d2; color: #fff; } table td { - background-color: hsla(218, 17%, 71%, 0.7); + background-color: #dadada4d; color: #0c0c0c; } .buttonBox{ @@ -55,12 +53,10 @@ table td { margin-top: 6%; } .select-button { - background-color:#3f413ee1; - color:white; - border: #000000; - border-color: #000000; + background-color:#181f33d2; + color:white; border-radius: 10cm; - font-size: 1em; + font-size: 0.8em; text-align: center; padding: 0.1mm 0.5cm; cursor:pointer; diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index 4bc2715..674e85a 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -1,12 +1,9 @@ import { Link } from 'react-router-dom'; import './historico.css'; -var novaTabela = document.createElement("table"); - - +import * as FaIcons from 'react-icons/fa'; +import * as AiIcons from 'react-icons/ai'; const HistoricoDeAcoes = () => { - - return ( @@ -24,6 +21,9 @@ return ( Ordem Quant. Valor + Editar + Excluir + @@ -33,6 +33,8 @@ return ( -- -- -- + -- + -- -- @@ -40,6 +42,8 @@ return ( -- -- -- + -- + -- -- @@ -47,6 +51,8 @@ return ( -- -- -- + -- + -- -- @@ -54,6 +60,8 @@ return ( -- -- -- + -- + -- -- @@ -61,6 +69,8 @@ return ( -- -- -- + -- + -- -- @@ -68,6 +78,8 @@ return ( -- -- -- + -- + -- -- @@ -75,6 +87,8 @@ return ( -- -- -- + -- + -- -- @@ -82,6 +96,8 @@ return ( -- -- -- + -- + -- -- @@ -89,6 +105,8 @@ return ( -- -- -- + -- + -- -- @@ -96,6 +114,8 @@ return ( -- -- -- + -- + -- -- @@ -103,6 +123,8 @@ return ( -- -- -- + -- + -- -- @@ -110,6 +132,8 @@ return ( -- -- -- + -- + -- -- @@ -117,6 +141,8 @@ return ( -- -- -- + -- + -- -- @@ -124,6 +150,8 @@ return ( -- -- -- + -- + -- -- @@ -131,6 +159,8 @@ return ( -- -- -- + -- + -- -- @@ -138,6 +168,8 @@ return ( -- -- -- + -- + -- -- @@ -145,6 +177,8 @@ return ( -- -- -- + -- + -- -- @@ -152,6 +186,8 @@ return ( -- -- -- + -- + -- -- @@ -159,6 +195,8 @@ return ( -- -- -- + -- + -- -- @@ -166,6 +204,8 @@ return ( -- -- -- + -- + -- -- @@ -173,6 +213,8 @@ return ( -- -- -- + -- + -- -- @@ -180,6 +222,8 @@ return ( -- -- -- + -- + -- -- @@ -187,6 +231,8 @@ return ( -- -- -- + -- + -- From abaf503c1576a169cbd24a2d28a1d0ab7c3f92f0 Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Mon, 22 Aug 2022 19:50:39 -0300 Subject: [PATCH 062/146] =?UTF-8?q?Altera=C3=A7=C3=A3o=20do=20=C3=ADcone?= =?UTF-8?q?=20de=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Sidebar/SidebarData.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Front/src/pages/Sidebar/SidebarData.tsx b/Front/src/pages/Sidebar/SidebarData.tsx index 31ef065..20aabb9 100644 --- a/Front/src/pages/Sidebar/SidebarData.tsx +++ b/Front/src/pages/Sidebar/SidebarData.tsx @@ -2,6 +2,7 @@ import React from 'react' import * as FaIcons from 'react-icons/fa' import * as AiIcons from 'react-icons/ai' import * as IoIcons from 'react-icons/io' +import * as CgIcons from "react-icons/cg"; export const SidebarData = [ { @@ -22,7 +23,7 @@ export const SidebarData = [ { title:'Perfil', path:'perfil', - icon: , + icon: , }, { title:'Sair', From e7731b9b4574e962303d66b08b01b7344b2866d8 Mon Sep 17 00:00:00 2001 From: MariaAbritta Date: Mon, 22 Aug 2022 23:03:23 -0300 Subject: [PATCH 063/146] Criando o editar e excluir dos Ativos Co-authored-by: Lucas Gomes --- Back/src/controller/AtivoController.js | 171 +++++++++++-------------- Back/src/controller/UserController.js | 12 +- Back/src/util/BuscaAtivosB3.js | 23 ++-- 3 files changed, 92 insertions(+), 114 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index e2d18d5..e0537d2 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -1,65 +1,27 @@ const express = require("express"); -const Ativo = require("../models/Ativo"); -const app = express(); -const sequelize = require('sequelize'); +const router = express().Router(); const Axios = require("axios"); -const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); -const auth = require("../middleware/auth"); - -app.post("/cadastrar", auth, async (req, res) => { - let sigla = null; - - // verifica na API da B3 qual eh a sigla do ativo que o - // usuario deseja cadastrar - await Axios.get(linkApi, { - - }).then(function(res){ - const { nomeAtivo } = req.body; - const data = res.data; - - for(let ativo of data){ - const { nm_empresa } = ativo; - const { cd_acao } = ativo; - //console.log(nm_empresa, cd_acao); - - if(nm_empresa === nomeAtivo) { - sigla = cd_acao; - } - } - }).catch(function(err){ - console.log(err); - }); - +const sequelize = require('sequelize'); - +const auth = require("../middleware/auth"); +const Ativo = require("../models/Ativo"); +router.post("/cadastrar", auth, async (req, res) => { const novo_ativo = { - id_usuario: req.usuario.id, + // id_usuario: "token", nomeAtivo: req.body.nomeAtivo, - sigla: sigla, + sigla: req.body.sigla, preco: req.body.preco, quantidade: req.body.quantidade, data: req.body.data, - execucao: req.body.execucao + execucao: "compra" }; - // caso nao ache o nome da empresa, - // o ativo nao eh cadastrado - if (!novo_ativo.sigla) { - return res.json({ - erro: true, - message: "Ativo nao listado na B3!" - }) - } - - const ativos = await Ativo.findOne({ where: { nomeAtivo: novo_ativo.nomeAtivo} }); - - await Ativo.create(novo_ativo) .then(() => { return res.json({ erro: false, - message: "Ativo cadastrado com sucesso!" + message: "Compra de ativo cadastrada com sucesso!" }) }).catch((error) => { console.log(error); @@ -68,9 +30,9 @@ app.post("/cadastrar", auth, async (req, res) => { message: error.message }) }); -}) +}); -app.post("/venda", auth, async (req,res) => { +router.post("/vender", auth, async (req,res) => { // filtro que soma a quantidade de compra do ativo const ativo_comprado = await Ativo.findAll({ @@ -106,68 +68,89 @@ app.post("/venda", auth, async (req,res) => { const totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; - let sigla = null; - - // verifica na API da B3 qual eh a sigla do ativo que o - // usuario deseja cadastrar - await Axios.get(linkApi, { - - }).then(function(res){ - const { nomeAtivo } = req.body; - const data = res.data; - - for(let ativo of data){ - const { nm_empresa } = ativo; - const { cd_acao } = ativo; - //console.log(nm_empresa, cd_acao); - - if(nm_empresa === nomeAtivo) { - sigla = cd_acao; - } - } - }).catch(function(err){ - console.log(err); - }); - - const nova_venda = { - id_usuario: req.usuario.id, + const novo_ativo = { + // id_usuario: "token", nomeAtivo: req.body.nomeAtivo, - sigla: sigla, + sigla: req.body.sigla, preco: req.body.preco, quantidade: req.body.quantidade, data: req.body.data, - execucao: req.body.execucao + execucao: "venda" }; - if (!nova_venda.sigla) { - return res.json({ - erro: true, - message: "Ativo nao listado na B3!" - }) - } - - if (req.body.quantidade <= totalQuantidade) { - - await Ativo.create(nova_venda) + await Ativo.create(novo_ativo) .then(() => { return res.json({ erro: false, - message: "Ativo vendido com sucesso!" + message: "Venda de ativo cadastrada com sucesso!" }) }).catch((error) => { console.log(error); return res.status(400).json({ erro: true, - message: "Erro na venda do ativo" + message: error.message }) }); - } else { +}); + +router.post("/editar", auth, async (req,res) => { + const { id } = req.body; + const { sigla } = req.body; + const { preco } = req.body; + const { quantidade } = req.body; + + try { + if (sigla !== null) { + await Ativo.update( + { sigla: sigla }, + { where: {id: id}} + ); + } + + if (preco !== null) { + await Ativo.update( + { preco: preco }, + { where: {id: id}} + ) + } + + if (quantidade !== null) { + await Ativo.update( + { quantidade: quantidade }, + { where: {id: id}} + ); + } + + return res.json({ + erro: false, + message: "Ativo editado com sucesso!" + }); + + } catch (error) { return res.status(400).json({ erro: true, - message: "Erro na venda do ativo" - }) + message: error.message + }); } -}) - +}); + +router.post("/excluir", auth, async (req,res) => { + const { id } = req.body; + + await Ativo.destroy({ + where: { id: id } + }).then(() => { + return res.json({ + erro: false, + message: `Ativo ${id} excluido com sucesso!` + }) + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + message: error.message + }) + }); +}); -module.exports = app; \ No newline at end of file +module.exports = router; \ No newline at end of file diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 9dd7a28..0a4bdbf 100755 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -1,13 +1,13 @@ const express = require("express"); +const router = express().Router(); const bcrypt = require("bcryptjs"); const jwt = require('jsonwebtoken'); const User = require("../models/User"); -const app = express(); const AtivosB3 = require("../util/AtivosB3Util"); // funciona -app.post("/cadastrar", async (req, res) => { +router.post("/cadastrar", async (req, res) => { const salt = await bcrypt.genSalt(10); const novo_usuario = { @@ -43,7 +43,7 @@ app.post("/cadastrar", async (req, res) => { }) //funciona -app.post("/login", async (req, res) => { +router.post("/login", async (req, res) => { const usuario = await User.findOne({ attributes: ["id", "email", "senha"], where: { @@ -83,13 +83,13 @@ app.post("/login", async (req, res) => { }); // nao funciona -> somente o usuario logado deve conseguir atualizar suas infos -app.post("/atualizar", async (req, res) => { +router.post("/atualizar", async (req, res) => { }) // nao funciona -> somente o usuario logado deve conseguir deletar sua conta -app.post("/deletar", async (req, res) => { +router.post("/deletar", async (req, res) => { }) -module.exports = app; \ No newline at end of file +module.exports = router; \ No newline at end of file diff --git a/Back/src/util/BuscaAtivosB3.js b/Back/src/util/BuscaAtivosB3.js index f807d99..1ac6313 100644 --- a/Back/src/util/BuscaAtivosB3.js +++ b/Back/src/util/BuscaAtivosB3.js @@ -1,21 +1,16 @@ -const { QueryTypes } = require('sequelize'); -const Sequelize = require('sequelize'); +const AtivosB3 = require("../models/AtivosB3"); -const sequelize = new Sequelize("usuario", "root", "12345678", { - host: 'localhost', - dialect: 'mysql' -}); - -exports.buscaPorCaractere = function (caracter) { - sequelize.query(`SELECT * FROM b3_ativos WHERE (nome_empresa LIKE '${caracter}%' OR codigo_acao LIKE '${caracter}%');`, { type: QueryTypes.SELECT }). +exports.buscaPorCaractere = async function (caracter) { + var lista = []; + await AtivosB3.findAll(). then(function(res) { - var lista_ativos = []; for (let ativo of res) { const { nome_empresa } = ativo; const { codigo_acao } = ativo; - const linha_ativo = `${nome_empresa} - ${codigo_acao}` - lista.push(linha_ativo); + lista.push(nome_empresa, codigo_acao); } - return lista_ativos; - }) + return lista; + }).catch(() => { + return lista; + }); } From fa3babb229c9447204068ecd3f37c67ed59f0c76 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Tue, 23 Aug 2022 10:27:47 -0300 Subject: [PATCH 064/146] =?UTF-8?q?atuaizando=20a=20branch=20com=20a=20atu?= =?UTF-8?q?aliza=C3=A7=C3=A3o=20do=20back=20para=20fazermos=20a=20parte=20?= =?UTF-8?q?de=20busca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" | 3 +++ 1 file changed, 3 insertions(+) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index 74135e9..6ac0998 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -1,6 +1,9 @@ import { useState } from 'react'; import Select from 'react-select'; import './Busca.css'; +//caso a conexão seja via post +import Axios from "axios"; + interface Assets{ name: string, From 61b4744a0ab9dbc94299bacac787b54e996d2d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Tue, 23 Aug 2022 10:37:06 -0300 Subject: [PATCH 065/146] teste: adicionado o escopo inicial dos testes --- .gitignore | 2 +- Back/jest.config.js | 194 +++++++++++++++++++++++++++++++++ Back/package.json | 8 +- Back/src/__tests__/sum.test.js | 13 +++ 4 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 Back/jest.config.js create mode 100644 Back/src/__tests__/sum.test.js diff --git a/.gitignore b/.gitignore index 7be7da1..98aa75a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ Back/node_modules Back/package-lock.json Front/node_modules Front/package-lock.json - +Back/coverage/ # Logs Front/logs Front/*.log diff --git a/Back/jest.config.js b/Back/jest.config.js new file mode 100644 index 0000000..8f9a124 --- /dev/null +++ b/Back/jest.config.js @@ -0,0 +1,194 @@ +/* + * For a detailed explanation regarding each configuration property, visit: + * https://jestjs.io/docs/configuration + */ + +module.exports = { + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after `n` failures + // bail: 0, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "/tmp/jest_rs", + + // Automatically clear mock calls, instances, contexts and results before every test + clearMocks: true, + + // Indicates whether the coverage information should be collected while executing the test + collectCoverage: true, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: undefined, + + // The directory where Jest should output its coverage files + coverageDirectory: "coverage", + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "/node_modules/" + // ], + + // Indicates which provider should be used to instrument code for coverage + coverageProvider: "v8", + + // A list of reporter names that Jest uses when writing coverage reports + // coverageReporters: [ + // "json", + // "text", + // "lcov", + // "clover" + // ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: undefined, + + // A path to a custom dependency extractor + // dependencyExtractor: undefined, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // The default configuration for fake timers + // fakeTimers: { + // "enableGlobally": false + // }, + + // Force coverage collection from ignored files using an array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: undefined, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: undefined, + + // A set of global variables that need to be available in all test environments + // globals: {}, + + // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. + // maxWorkers: "50%", + + // An array of directory names to be searched recursively up from the requiring module's location + // moduleDirectories: [ + // "node_modules" + // ], + + // An array of file extensions your modules use + // moduleFileExtensions: [ + // "js", + // "mjs", + // "cjs", + // "jsx", + // "ts", + // "tsx", + // "json", + // "node" + // ], + + // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module + // moduleNameMapper: {}, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "failure-change", + + // A preset that is used as a base for Jest's configuration + // preset: undefined, + + // Run tests from one or more projects + // projects: undefined, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state before every test + // resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: undefined, + + // Automatically restore mock state and implementation before every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: undefined, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + // setupFiles: [], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + // setupFilesAfterEnv: [], + + // The number of seconds after which a test is considered as slow and reported as such in the results. + // slowTestThreshold: 5, + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // The test environment that will be used for testing + // testEnvironment: "jest-environment-node", + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + testMatch: [ + "**/__tests__/**/*.test.js?(x)", + ], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + // testPathIgnorePatterns: [ + // "/node_modules/" + // ], + + // The regexp pattern or array of patterns that Jest uses to detect test files + // testRegex: [], + + // This option allows the use of a custom results processor + // testResultsProcessor: undefined, + + // This option allows use of a custom test runner + // testRunner: "jest-circus/runner", + + // A map from regular expressions to paths to transformers + // transform: undefined, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + // transformIgnorePatterns: [ + // "/node_modules/", + // "\\.pnp\\.[^\\/]+$" + // ], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: undefined, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, +}; diff --git a/Back/package.json b/Back/package.json index 5ba83b8..090fa8d 100755 --- a/Back/package.json +++ b/Back/package.json @@ -7,8 +7,8 @@ "doc": "docs" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "nodemon src/server.js" + "test": "jest", + "start": "nodemon src/server.js --ignore tests" }, "repository": { "type": "git", @@ -32,5 +32,9 @@ "mysql2": "^2.3.3", "nodemon": "^2.0.19", "sequelize": "^6.21.3" + }, + "devDependencies": { + "jest": "^28.1.3", + "supertest": "^6.2.4" } } diff --git a/Back/src/__tests__/sum.test.js b/Back/src/__tests__/sum.test.js new file mode 100644 index 0000000..ea6e038 --- /dev/null +++ b/Back/src/__tests__/sum.test.js @@ -0,0 +1,13 @@ +describe('sum test', () => { + it('should sum to numbers', () => { + const a = 1, b = 2; + const c = a + b; + expect(c).toBe(3); + }); + + it('should sum to numbers',() => { + const a = 1, b = 2; + const c = a + b; + expect(c).toBe(3); + }); + }); \ No newline at end of file From 8d8195730220ce18e45e844c98c3204395955090 Mon Sep 17 00:00:00 2001 From: LeonardoPadre Date: Tue, 23 Aug 2022 17:53:51 -0300 Subject: [PATCH 066/146] =?UTF-8?q?refactor:=20Adi=C3=A7=C3=A3o=20do=20id?= =?UTF-8?q?=5Fusuario=20no=20cadastro=20de=20ativo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/controller/AtivoController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index e0537d2..21707dc 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -8,7 +8,7 @@ const Ativo = require("../models/Ativo"); router.post("/cadastrar", auth, async (req, res) => { const novo_ativo = { - // id_usuario: "token", + id_usuario: req.usuario.id, nomeAtivo: req.body.nomeAtivo, sigla: req.body.sigla, preco: req.body.preco, @@ -69,7 +69,7 @@ router.post("/vender", auth, async (req,res) => { const totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; const novo_ativo = { - // id_usuario: "token", + id_usuario: req.usuario.id, nomeAtivo: req.body.nomeAtivo, sigla: req.body.sigla, preco: req.body.preco, From 8ef70e71c8b03bcd6e920fcab3ae57d56fc19e41 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Tue, 23 Aug 2022 17:58:53 -0300 Subject: [PATCH 067/146] =?UTF-8?q?feat/fix:=20Adicionado=20request=20de?= =?UTF-8?q?=20venda=20de=20ativo=20/=20arrumado=20valida=C3=A7=C3=A3o=20do?= =?UTF-8?q?s=20inputs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/controller/AtivoController.js | 8 +- Back/src/controller/UserController.js | 2 +- .../A\303\247oes.tsx" | 164 ++++++++++-------- 3 files changed, 94 insertions(+), 80 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index afc8db5..9c88572 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -40,7 +40,7 @@ app.post("/cadastrar", auth, async (req, res) => { preco: req.body.preco, quantidade: req.body.quantidade, data: req.body.data, - execucao: req.body.execucao + execucao: "compra" }; // caso nao ache o nome da empresa, @@ -56,7 +56,7 @@ app.post("/cadastrar", auth, async (req, res) => { .then(() => { return res.json({ erro: false, - message: "Ativo cadastrado com sucesso!" + message: "Ativo comprado com sucesso!" }) }).catch((error) => { console.log(error); @@ -133,7 +133,7 @@ app.post("/venda", auth, async (req,res) => { preco: req.body.preco, quantidade: req.body.quantidade, data: req.body.data, - execucao: req.body.execucao + execucao: "venda" }; if (!nova_venda.sigla) { @@ -161,7 +161,7 @@ app.post("/venda", auth, async (req,res) => { } else { return res.status(400).json({ erro: true, - message: "Erro na venda do ativo" + message: "Erro: Quantidade de venda menor que disponível" }) } }) diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 9dd7a28..1b90346 100755 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -66,7 +66,7 @@ app.post("/login", async (req, res) => { const token = jwt.sign({id: usuario.id}, "INVEXTGFOURD62ST92Y7A6V7K5C6W9ZU6W8KS3", { // expiresIn: 600 //10 min // expiresIn: '7d' // 7 dia - expiresIn: 1800 //30 min + // expiresIn: 1800 //30 min }); // Quando o usuario fizer login, o banco de dados diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 8a520a7..a0b08cb 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -12,58 +12,62 @@ import { useAuth } from '../../services/Provider'; export const CadastroAcoes = () => { const [error, setError] = useState(""); - const [assets,setAssets] = useState(""); //Assets é os ativos + const [assets, setAssets] = useState(""); //Assets é os ativos const [stockPrice, setStockPrice] = useState(""); //preço das ações const [date, setDate] = useState(""); - const [quantity,setQuantity] = useState(""); + const [quantity, setQuantity] = useState(""); + + // Altera o handleSubmit, a depender do butão que é acionado + const [buttonSubmit, setButtonSubmit] = useState(""); + // Link para o request do backend + const [linkBackend, setLinkBackend] = useState(""); const navigate = useNavigate(); const auth = useAuth(); const token = auth.getToken(); - + const handleSubmit = async (e: React.FormEvent) => { - + e.preventDefault(); setError(""); - // Transforma a data de compra em um objeto Date - const parsedDate = parseISO(date); + // Altera o request do backend, a depender do butão que é clicado + if(buttonSubmit == "compra") { + setLinkBackend("http://localhost:3000/ativo/cadastrar"); - if (quantity.length < 0 ){ + }else if(buttonSubmit == "venda") { + setLinkBackend("http://localhost:3000/ativo/venda"); + } + + // Validações dos inputs antes de fazer o request ao backend + if (parseInt(quantity) <= 0) { setError("É necessário inserir uma quantidade válida") - - }else if (stockPrice.length < 0 ) { + + } else if (parseInt(stockPrice) <= 0) { setError("É necessário inserir um valor válido") - + } else { - Axios.post("http://localhost:3000/ativo/cadastrar", - { - token: token, - nomeAtivo: assets, - preco: stockPrice, - quantidade: quantity, - data: date - }).then(function (response) { - alert(response.data.message); - // descomentar a linha abaixo para o usuario ser redirecionado para o historico - // de acoes - // navigate("/historico"); - - }).catch(function (error) { - console.log(error); - const message = error.response.data.message; - setError(message); - }) + Axios.post(linkBackend, + { + token: token, + nomeAtivo: assets, + preco: stockPrice, + quantidade: quantity, + data: date + }).then(function (response) { + alert(response.data.message); + // descomentar a linha abaixo para o usuario ser redirecionado para o historico + // de acoes + // navigate("/historico"); + + }).catch(function (error) { + const message = error.response.data.message; + setError(message); + }) } } - //mascara para quantidade - const quantityMask = function (value: string) { - var pattern = new RegExp(/^[0-9]+$/); - return pattern.test(value); - }; - - //p formatar data + //para a formatar a data const [inputType, setInputType] = useState("text"); return ( @@ -80,48 +84,58 @@ export const CadastroAcoes = () => { value={assets} onChange={(e) => setAssets(e.target.value)} /> - {/*A ideia é alinhar eles na mesma linha */} -
    - - ) => - setStockPrice(e.target.value)} - /> - ) => - setQuantity(e.target.value)} + +
    + ) => + setStockPrice(e.target.value)} /> -
    -
    - ) => - setDate(e.currentTarget.value)} - onFocus={() => setInputType("date")} - onBlur={() => setInputType("text")} - /> -
    + ) => + setQuantity(e.target.value)} + /> +
    +
    + ) => + setDate(e.currentTarget.value)} + onFocus={() => setInputType("date")} + onBlur={() => setInputType("text")} + /> +
    - - + +
    {error &&

    {error}

    } From f8335400873a2354fb63a39c9a02a96b19dab258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Tue, 23 Aug 2022 19:31:18 -0300 Subject: [PATCH 068/146] fix: correcao da rota de vendas Co-authored-by: LeonardoPadre --- Back/src/controller/AtivoController.js | 27 +++++++++++++++++++------- Back/src/controller/UserController.js | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 21707dc..1467567 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -1,5 +1,5 @@ const express = require("express"); -const router = express().Router(); +const router = express.Router(); const Axios = require("axios"); const sequelize = require('sequelize'); @@ -65,10 +65,14 @@ router.post("/vender", auth, async (req,res) => { "execucao" : "venda" }, }) - - const totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; - const novo_ativo = { + if (ativo_vendido[0] == null) { + var totalQuantidade = ativo_comprado[0].total - 0; + } else { + var totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; + } + + const nova_venda = { id_usuario: req.usuario.id, nomeAtivo: req.body.nomeAtivo, sigla: req.body.sigla, @@ -78,19 +82,28 @@ router.post("/vender", auth, async (req,res) => { execucao: "venda" }; - await Ativo.create(novo_ativo) + if (req.body.quantidade <= totalQuantidade) { + + await Ativo.create(nova_venda) .then(() => { return res.json({ erro: false, - message: "Venda de ativo cadastrada com sucesso!" + message: "Ativo vendido com sucesso!" }) }).catch((error) => { console.log(error); return res.status(400).json({ erro: true, - message: error.message + message: "Erro na venda do ativo" }) }); + } else { + return res.status(400).json({ + erro: true, + message: "Erro na venda do ativo" + }) + } + }); router.post("/editar", auth, async (req,res) => { diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 0a4bdbf..30e95b8 100755 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -1,5 +1,5 @@ const express = require("express"); -const router = express().Router(); +const router = express.Router(); const bcrypt = require("bcryptjs"); const jwt = require('jsonwebtoken'); From 5a88b4142f754d1be6bb8a426ab8683a98ae0c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Tue, 23 Aug 2022 20:00:09 -0300 Subject: [PATCH 069/146] feat: cria a rota do historico Co-authored-by: LeonardoPadre --- Back/src/controller/AtivoController.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 1467567..72568b2 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -106,6 +106,28 @@ router.post("/vender", auth, async (req,res) => { }); +// Rota que envia o historico da acao do usuario +router.get("/historico", auth, async (req,res) => { + + const dadoHistorico = await Ativo.findAll({ + attributes: [ + "id_usuario", + "nomeAtivo", + "sigla", + "preco", + "quantidade", + "data", + "execucao", + ], + raw: true, + where: { + "id_usuario": req.usuario.id + }, + }) + console.log(dadoHistorico); + +}) + router.post("/editar", auth, async (req,res) => { const { id } = req.body; const { sigla } = req.body; From 220d44212aa66a446f7665a58d7d3656093d90cf Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Tue, 23 Aug 2022 22:14:23 -0300 Subject: [PATCH 070/146] =?UTF-8?q?continuando=20a=20conex=C3=A3o=20com=20?= =?UTF-8?q?o=20backend=20Co-authored-by:=20Luciano=20Freitas=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/util/BuscaAtivosB3.js | 11 +++++++---- .../Cadastro de A\303\247\303\265es/Busca.tsx" | 16 ++++++++++------ Front/tsconfig.json | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Back/src/util/BuscaAtivosB3.js b/Back/src/util/BuscaAtivosB3.js index f807d99..6c01a3d 100644 --- a/Back/src/util/BuscaAtivosB3.js +++ b/Back/src/util/BuscaAtivosB3.js @@ -7,15 +7,18 @@ const sequelize = new Sequelize("usuario", "root", "12345678", { }); exports.buscaPorCaractere = function (caracter) { + var lista_ativos = []; sequelize.query(`SELECT * FROM b3_ativos WHERE (nome_empresa LIKE '${caracter}%' OR codigo_acao LIKE '${caracter}%');`, { type: QueryTypes.SELECT }). then(function(res) { - var lista_ativos = []; + for (let ativo of res) { const { nome_empresa } = ativo; const { codigo_acao } = ativo; - const linha_ativo = `${nome_empresa} - ${codigo_acao}` + const linha_ativo = {nome: nome_empresa, sigla: codigo_acao}; lista.push(linha_ativo); } - return lista_ativos; - }) + }).catch(function(err){ + console.log(err); + }); + return lista_ativos; } diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index 6ac0998..535613c 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -1,14 +1,13 @@ import { useState } from 'react'; import Select from 'react-select'; -import './Busca.css'; -//caso a conexão seja via post -import Axios from "axios"; - +import './Busca.css'; +import { buscaPorCaractere } from "../../../../Back/src/util/BuscaAtivosB3.js"; interface Assets{ name: string, initials: string } + const AtivosExample = [ {name: "AMERICANAS", sigla: "AMER3"}, {name: "ELETROBRAS", sigla: "ELET3"}, @@ -21,11 +20,14 @@ const AtivosExample = [ interface Props{ setValue: Function } + // Fazer o props para pergar o assets para pesquisa export const BuscaAtivo = (props:Props) => { + const busca = buscaPorCaractere(""); + const Options = () => { - return AtivosExample.map((ativos) => ({value: ativos, label: ativos.name.concat(' - ',ativos.sigla)})) + return busca.map((ativos) => ({value: ativos, label: ativos.nome.concat(' - ',ativos.sigla)})) } return( @@ -41,4 +43,6 @@ export const BuscaAtivo = (props:Props) => { onChange={e => e ? props.setValue(e.value) : props.setValue('')} /> ); -} \ No newline at end of file +} + + diff --git a/Front/tsconfig.json b/Front/tsconfig.json index 846f377..9a5ba3f 100644 --- a/Front/tsconfig.json +++ b/Front/tsconfig.json @@ -3,7 +3,7 @@ "target": "ESNext", "useDefineForClassFields": true, "lib": ["DOM", "DOM.Iterable", "ESNext"], - "allowJs": false, + "allowJs": true, "skipLibCheck": true, "esModuleInterop": false, "allowSyntheticDefaultImports": true, From 0eb9f22d612170cd391b14cec78789259f2642e5 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Wed, 24 Aug 2022 02:38:28 -0300 Subject: [PATCH 071/146] =?UTF-8?q?fix:=20Compra=20e=20venda=20agora=20oco?= =?UTF-8?q?rrem=20quando=20o=20bot=C3=A3o=20=C3=A9=20chamado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../A\303\247oes.tsx" | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index a0b08cb..686e95d 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -3,7 +3,6 @@ import './Ações.css'; import { IMaskInput } from "react-imask"; import { useState } from "react"; -import { parseISO } from 'date-fns'; import Axios from "axios"; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../../services/Provider'; @@ -17,8 +16,6 @@ export const CadastroAcoes = () => { const [date, setDate] = useState(""); const [quantity, setQuantity] = useState(""); - // Altera o handleSubmit, a depender do butão que é acionado - const [buttonSubmit, setButtonSubmit] = useState(""); // Link para o request do backend const [linkBackend, setLinkBackend] = useState(""); @@ -31,13 +28,6 @@ export const CadastroAcoes = () => { e.preventDefault(); setError(""); - // Altera o request do backend, a depender do butão que é clicado - if(buttonSubmit == "compra") { - setLinkBackend("http://localhost:3000/ativo/cadastrar"); - - }else if(buttonSubmit == "venda") { - setLinkBackend("http://localhost:3000/ativo/venda"); - } // Validações dos inputs antes de fazer o request ao backend if (parseInt(quantity) <= 0) { @@ -128,12 +118,12 @@ export const CadastroAcoes = () => {
    From 515a2b205b0f92e77640311abc6232077a3db5c3 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Wed, 24 Aug 2022 02:53:32 -0300 Subject: [PATCH 072/146] refactor: Caminhos do axios encurtados --- Front/src/main.tsx | 2 ++ .../Cadastro de A\303\247\303\265es/A\303\247oes.tsx" | 10 +++++----- Front/src/pages/CadastroUsuario/Cadastro.tsx | 2 +- Front/src/pages/LoginUsuario/Login.tsx | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Front/src/main.tsx b/Front/src/main.tsx index d46eb1e..86a5146 100644 --- a/Front/src/main.tsx +++ b/Front/src/main.tsx @@ -3,7 +3,9 @@ import ReactDOM from 'react-dom/client' import App from './App' import { BrowserRouter } from "react-router-dom"; import './index.css' +import axios from 'axios'; +axios.defaults.baseURL = 'http://localhost:3000'; ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 686e95d..1bf1666 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -16,8 +16,8 @@ export const CadastroAcoes = () => { const [date, setDate] = useState(""); const [quantity, setQuantity] = useState(""); - // Link para o request do backend - const [linkBackend, setLinkBackend] = useState(""); + // Define qual tipo de operação será efetuada no request (compra/venda) + const [requestType, setRequestType] = useState(""); const navigate = useNavigate(); const auth = useAuth(); @@ -37,7 +37,7 @@ export const CadastroAcoes = () => { setError("É necessário inserir um valor válido") } else { - Axios.post(linkBackend, + Axios.post("/ativo/"+requestType, { token: token, nomeAtivo: assets, @@ -118,12 +118,12 @@ export const CadastroAcoes = () => {
    diff --git a/Front/src/pages/CadastroUsuario/Cadastro.tsx b/Front/src/pages/CadastroUsuario/Cadastro.tsx index 5b705a5..9b7227e 100644 --- a/Front/src/pages/CadastroUsuario/Cadastro.tsx +++ b/Front/src/pages/CadastroUsuario/Cadastro.tsx @@ -42,7 +42,7 @@ const CadastroUsuario = () => { setError("As senhas precisam ser iguais"); } else { - Axios.post("http://localhost:3000/usuario/cadastrar", { + Axios.post("/usuario/cadastrar", { nomeCompleto: displayName, dataNascimento: birth, telefone: phone, diff --git a/Front/src/pages/LoginUsuario/Login.tsx b/Front/src/pages/LoginUsuario/Login.tsx index 147918d..99d6069 100644 --- a/Front/src/pages/LoginUsuario/Login.tsx +++ b/Front/src/pages/LoginUsuario/Login.tsx @@ -20,7 +20,7 @@ const LoginUsuario = () => { setError(""); - Axios.post("http://localhost:3000/usuario/login", { + Axios.post("/usuario/login", { email: email, senha: password }).then(function (response) { From 22e3c6ca7f18d32a31f051ef084284113e183078 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Wed, 24 Aug 2022 09:03:51 -0300 Subject: [PATCH 073/146] criando a rota de busca de ativos do banco --- Back/src/controller/AtivoController.js | 204 +++++++++++++++---------- Back/src/util/BuscaAtivosB3.js | 21 --- 2 files changed, 126 insertions(+), 99 deletions(-) delete mode 100644 Back/src/util/BuscaAtivosB3.js diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 9c88572..c3d82c1 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -1,62 +1,28 @@ const express = require("express"); -const Ativo = require("../models/Ativo"); -const app = express(); -const sequelize = require('sequelize'); +const router = express.Router(); const Axios = require("axios"); -const linkApi = ("https://api-cotacao-b3.labdo.it/api/carteira"); -const auth = require("../middleware/auth"); - -app.post("/cadastrar", auth, async (req, res) => { - let sigla = null; - - // verifica na API da B3 qual eh a sigla do ativo que o - // usuario deseja cadastrar - await Axios.get(linkApi, { - - }).then(function(res){ - const { nomeAtivo } = req.body; - const data = res.data; - - for(let ativo of data){ - const { nm_empresa } = ativo; - const { cd_acao } = ativo; - //console.log(nm_empresa, cd_acao); - - if(nm_empresa === nomeAtivo) { - sigla = cd_acao; - } - } - }).catch(function(err){ - console.log(err); - }); - +const sequelize = require('sequelize'); - +const auth = require("../middleware/auth"); +const Ativo = require("../models/Ativo"); +const AtivosB3 = require("../models/AtivosB3"); +router.post("/cadastrar", auth, async (req, res) => { const novo_ativo = { id_usuario: req.usuario.id, nomeAtivo: req.body.nomeAtivo, - sigla: sigla, + sigla: req.body.sigla, preco: req.body.preco, quantidade: req.body.quantidade, data: req.body.data, execucao: "compra" }; - // caso nao ache o nome da empresa, - // o ativo nao eh cadastrado - if (!novo_ativo.sigla) { - return res.status(400).json({ - erro: true, - message: "Ativo nao listado na B3!" - }) - } - await Ativo.create(novo_ativo) .then(() => { return res.json({ erro: false, - message: "Ativo comprado com sucesso!" + message: "Compra de ativo cadastrada com sucesso!" }) }).catch((error) => { console.log(error); @@ -65,9 +31,9 @@ app.post("/cadastrar", auth, async (req, res) => { message: error.message }) }); -}) +}); -app.post("/venda", auth, async (req,res) => { +router.post("/vender", auth, async (req,res) => { // filtro que soma a quantidade de compra do ativo const ativo_comprado = await Ativo.findAll({ @@ -100,49 +66,23 @@ app.post("/venda", auth, async (req,res) => { "execucao" : "venda" }, }) - - const totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; - let sigla = null; - - // verifica na API da B3 qual eh a sigla do ativo que o - // usuario deseja cadastrar - await Axios.get(linkApi, { - - }).then(function(res){ - const { nomeAtivo } = req.body; - const data = res.data; - - for(let ativo of data){ - const { nm_empresa } = ativo; - const { cd_acao } = ativo; - //console.log(nm_empresa, cd_acao); - - if(nm_empresa === nomeAtivo) { - sigla = cd_acao; - } - } - }).catch(function(err){ - console.log(err); - }); + if (ativo_vendido[0] == null) { + var totalQuantidade = ativo_comprado[0].total - 0; + } else { + var totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; + } const nova_venda = { id_usuario: req.usuario.id, nomeAtivo: req.body.nomeAtivo, - sigla: sigla, + sigla: req.body.sigla, preco: req.body.preco, quantidade: req.body.quantidade, data: req.body.data, execucao: "venda" }; - if (!nova_venda.sigla) { - return res.json({ - erro: true, - message: "Ativo nao listado na B3!" - }) - } - if (req.body.quantidade <= totalQuantidade) { await Ativo.create(nova_venda) @@ -161,9 +101,117 @@ app.post("/venda", auth, async (req,res) => { } else { return res.status(400).json({ erro: true, - message: "Erro: Quantidade de venda menor que disponível" + message: "Erro na venda do ativo" }) } + +}); + +// Rota que envia o historico da acao do usuario +router.get("/historico", auth, async (req,res) => { + + const dadoHistorico = await Ativo.findAll({ + attributes: [ + "id_usuario", + "nomeAtivo", + "sigla", + "preco", + "quantidade", + "data", + "execucao", + ], + raw: true, + where: { + "id_usuario": req.usuario.id + }, + }) + console.log(dadoHistorico); + }) -module.exports = app; \ No newline at end of file +router.post("/editar", auth, async (req,res) => { + const { id } = req.body; + const { sigla } = req.body; + const { preco } = req.body; + const { quantidade } = req.body; + + try { + if (sigla !== null) { + await Ativo.update( + { sigla: sigla }, + { where: {id: id}} + ); + } + + if (preco !== null) { + await Ativo.update( + { preco: preco }, + { where: {id: id}} + ) + } + + if (quantidade !== null) { + await Ativo.update( + { quantidade: quantidade }, + { where: {id: id}} + ); + } + + return res.json({ + erro: false, + message: "Ativo editado com sucesso!" + }); + + } catch (error) { + return res.status(400).json({ + erro: true, + message: error.message + }); + } +}); + +router.post("/excluir", auth, async (req,res) => { + const { id } = req.body; + + await Ativo.destroy({ + where: { id: id } + }).then(() => { + return res.json({ + erro: false, + message: `Ativo ${id} excluido com sucesso!` + }) + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + message: error.message + }) + }); +}); + +router.get("/buscaativos", async (req,res) => { + var lista = []; + var linha = []; + await AtivosB3.findAll(). + then(function(response) { + for (let ativo of response) { + const { nome_empresa } = ativo; + const { codigo_acao } = ativo; + linha = [nome_empresa, codigo_acao] + lista.push(linha); + } + + return res.json({ + erro: false, + lista: lista + }); + + }).catch(() => { + return res.status(400).json({ + erro: true, + lista: lista + }); + }); +}); + +module.exports = router; \ No newline at end of file diff --git a/Back/src/util/BuscaAtivosB3.js b/Back/src/util/BuscaAtivosB3.js deleted file mode 100644 index f807d99..0000000 --- a/Back/src/util/BuscaAtivosB3.js +++ /dev/null @@ -1,21 +0,0 @@ -const { QueryTypes } = require('sequelize'); -const Sequelize = require('sequelize'); - -const sequelize = new Sequelize("usuario", "root", "12345678", { - host: 'localhost', - dialect: 'mysql' -}); - -exports.buscaPorCaractere = function (caracter) { - sequelize.query(`SELECT * FROM b3_ativos WHERE (nome_empresa LIKE '${caracter}%' OR codigo_acao LIKE '${caracter}%');`, { type: QueryTypes.SELECT }). - then(function(res) { - var lista_ativos = []; - for (let ativo of res) { - const { nome_empresa } = ativo; - const { codigo_acao } = ativo; - const linha_ativo = `${nome_empresa} - ${codigo_acao}` - lista.push(linha_ativo); - } - return lista_ativos; - }) -} From ae695a497bb1c4ff1a96a434ff3fde1ae952ff56 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Wed, 24 Aug 2022 09:53:46 -0300 Subject: [PATCH 074/146] adicionando a rota de busca e modificando o login --- Back/src/controller/AtivoController.js | 26 ++++++++++++++++++++++++ Back/src/controller/UserController.js | 19 +++++++++++------ Back/src/util/AtivosB3Util.js | 28 ++++++++++++++++---------- Back/src/util/BuscaAtivosB3.js | 16 --------------- 4 files changed, 56 insertions(+), 33 deletions(-) delete mode 100644 Back/src/util/BuscaAtivosB3.js diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 72568b2..0277f7d 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -5,6 +5,7 @@ const sequelize = require('sequelize'); const auth = require("../middleware/auth"); const Ativo = require("../models/Ativo"); +const AtivosB3 = require("../models/AtivosB3"); router.post("/cadastrar", auth, async (req, res) => { const novo_ativo = { @@ -188,4 +189,29 @@ router.post("/excluir", auth, async (req,res) => { }); }); +router.get("/buscaativos", auth, async (req,res) => { + var lista = []; + var linha = []; + await AtivosB3.findAll(). + then(function(response) { + for (let ativo of response) { + const { nome_empresa } = ativo; + const { codigo_acao } = ativo; + linha = [nome_empresa, codigo_acao] + lista.push(linha); + } + + return res.json({ + erro: false, + lista: lista + }); + + }).catch(() => { + return res.status(400).json({ + erro: true, + lista: lista + }); + }); +}); + module.exports = router; \ No newline at end of file diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index 30e95b8..bbf354f 100755 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -71,13 +71,20 @@ router.post("/login", async (req, res) => { // Quando o usuario fizer login, o banco de dados // com todos os ativos eh atualizado - AtivosB3.updateAtivosB3(); - - return res.json({ - erro: false, - message: "Login realizado com sucesso!", - token + await AtivosB3.updateAtivosB3(). + then(async () => { + return res.json({ + erro: false, + message: "Login realizado com sucesso!", + token + }); + }).catch(async () => { + return res.status(400).json({ + erro: true, + message: "Login nao realizado com sucesso!!" + }); }); + } } }); diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index b2aba8b..bba6ffe 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -16,19 +16,25 @@ exports.updateAtivosB3 = async function () { // Seleciona todas as informacoes disponiveis sobre todos os ativos nesse dia // e atualiza o banco de dados com as novas contacoes do dia await Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/dt/${dt_ultimo_pregao}/02`, { - }).then(function(res){ + }).then(async function(res){ const { data } = res; - - for (let ativo of data) { - const novo_ativo = { - data_pregao: ativo.dt_pregao, - codigo_acao: ativo.cd_acao, - nome_empresa: ativo.nm_empresa_rdz, - valor_fechamento: ativo.vl_fechamento + var lista = []; + // deleta todos os registros do banco primeiro + await AtivosB3.destroy({ + where: {}, + truncate: true + }).then(async () => { + for (let ativo of data) { + const novo_ativo = { + data_pregao: ativo.dt_pregao, + codigo_acao: ativo.cd_acao, + nome_empresa: ativo.nm_empresa_rdz, + valor_fechamento: ativo.vl_fechamento + } + lista.push(novo_ativo); } - - AtivosB3.create(novo_ativo); // adiciona o novo ativo no banco a cada iteracao - } + await AtivosB3.bulkCreate(lista); // adiciona todos os ativos no banco de uma vez + }); }).catch(function(err){ console.log(err); }); diff --git a/Back/src/util/BuscaAtivosB3.js b/Back/src/util/BuscaAtivosB3.js deleted file mode 100644 index 1ac6313..0000000 --- a/Back/src/util/BuscaAtivosB3.js +++ /dev/null @@ -1,16 +0,0 @@ -const AtivosB3 = require("../models/AtivosB3"); - -exports.buscaPorCaractere = async function (caracter) { - var lista = []; - await AtivosB3.findAll(). - then(function(res) { - for (let ativo of res) { - const { nome_empresa } = ativo; - const { codigo_acao } = ativo; - lista.push(nome_empresa, codigo_acao); - } - return lista; - }).catch(() => { - return lista; - }); -} From dd1fd2ca842548f75a6f7b4455ccb1487adc7efa Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 24 Aug 2022 11:42:09 -0300 Subject: [PATCH 075/146] ajustando o bug na parte de sair Co-authored-by: Luciano Freitas --- Front/src/App.tsx | 2 - Front/src/components/AvisoSair/avisoSair.css | 6 -- Front/src/components/AvisoSair/avisoSair.tsx | 23 ----- Front/src/pages/Sidebar/Sidebar.css | 4 +- Front/src/pages/Sidebar/Sidebar.tsx | 97 ++++++++++++-------- 5 files changed, 59 insertions(+), 73 deletions(-) delete mode 100644 Front/src/components/AvisoSair/avisoSair.css delete mode 100644 Front/src/components/AvisoSair/avisoSair.tsx diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 10ae1ca..6f842cc 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -7,7 +7,6 @@ import { AuthProvider} from './services/Provider'; import { RequireAuth } from './services/requireAuth'; import { Sidebar } from './pages/Sidebar/Sidebar'; import { PublicRoute } from './services/publicRoute'; -import { AvisoSair } from './components/AvisoSair/avisoSair'; function App() { @@ -27,7 +26,6 @@ function App() { }> } /> - } /> diff --git a/Front/src/components/AvisoSair/avisoSair.css b/Front/src/components/AvisoSair/avisoSair.css deleted file mode 100644 index b6e90bc..0000000 --- a/Front/src/components/AvisoSair/avisoSair.css +++ /dev/null @@ -1,6 +0,0 @@ -.container{ - width: 100%; - display: flex; - justify-content: center; - align-items: center; -} \ No newline at end of file diff --git a/Front/src/components/AvisoSair/avisoSair.tsx b/Front/src/components/AvisoSair/avisoSair.tsx deleted file mode 100644 index d3deabb..0000000 --- a/Front/src/components/AvisoSair/avisoSair.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { useNavigate } from "react-router-dom"; -import { useAuth } from "../../services/Provider"; - - -export const AvisoSair = () =>{ - - const auth = useAuth(); - const navigate = useNavigate(); - - const logout = () =>{ - auth.logout(() => { - navigate("/"); - }) - } - - return( - <> - {logout()} - - ) - -} - \ No newline at end of file diff --git a/Front/src/pages/Sidebar/Sidebar.css b/Front/src/pages/Sidebar/Sidebar.css index 84d05d9..a67846c 100644 --- a/Front/src/pages/Sidebar/Sidebar.css +++ b/Front/src/pages/Sidebar/Sidebar.css @@ -41,7 +41,7 @@ list-style: none; height: 60px; } -.nav-text a { +.nav-link { text-decoration: none; color: #f5f5f5; font-size: 18px; @@ -52,7 +52,7 @@ padding: 0 16px; border-radius: 4px; } -.nav-text a:hover { +.nav-link:hover { background-color: #1a83ff; } diff --git a/Front/src/pages/Sidebar/Sidebar.tsx b/Front/src/pages/Sidebar/Sidebar.tsx index c7de6be..1ee6bc7 100644 --- a/Front/src/pages/Sidebar/Sidebar.tsx +++ b/Front/src/pages/Sidebar/Sidebar.tsx @@ -1,49 +1,66 @@ -import React, { useState } from 'react' -import * as FaIcons from 'react-icons/fa'; -import * as AiIcons from 'react-icons/ai'; -import { Link, Outlet } from 'react-router-dom'; -import { SidebarData } from './SidebarData'; -import './Sidebar.css' -import { IconContext } from 'react-icons'; +import React, { useState } from "react"; +import * as FaIcons from "react-icons/fa"; +import * as AiIcons from "react-icons/ai"; +import { Link, Outlet } from "react-router-dom"; +import { SidebarData } from "./SidebarData"; +import "./Sidebar.css"; +import { IconContext } from "react-icons"; +import { useAuth } from "../../services/Provider"; +import { useNavigate } from "react-router-dom"; export const Sidebar = () => { - const [navbar, setNavbar] = useState(false); + const [navbar, setNavbar] = useState(false); - const showNavbar = () => setNavbar(!navbar); + const showNavbar = () => setNavbar(!navbar); - return ( - <> -
    + const auth = useAuth(); + const navigate = useNavigate(); + + const logout = () => { + auth.logout(() => { + navigate("/"); + }); + }; - -
    - - - -
    - -
    + return ( + <> +
    + +
    + + + +
    + +
    - + ); -} \ No newline at end of file +}; From 16c47e60c1d597b77fbf6f90165a657986e1972f Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Wed, 24 Aug 2022 21:03:22 -0300 Subject: [PATCH 076/146] Resolve bug da tela Cadastro, e atualiza rotas --- Front/src/App.tsx | 5 ++--- Front/src/pages/CadastroUsuario/Cadastro.css | 22 ++++++++++++-------- Front/src/pages/CadastroUsuario/Cadastro.tsx | 16 +++++++------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 759f3c4..c43bbf2 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -18,8 +18,7 @@ function App() { }> } /> - } /> - } /> + } /> } > } /> - + } /> diff --git a/Front/src/pages/CadastroUsuario/Cadastro.css b/Front/src/pages/CadastroUsuario/Cadastro.css index 73499bc..545d736 100644 --- a/Front/src/pages/CadastroUsuario/Cadastro.css +++ b/Front/src/pages/CadastroUsuario/Cadastro.css @@ -1,6 +1,7 @@ -body { - margin: 0; +.body{ + margin: 0px; } + .background-img { display: flex; align-items: center; @@ -17,11 +18,12 @@ body { display: flex; flex-direction: column; padding: 2%; - width: 80%; + width: 60%; + height: 80%; background-color: rgba(10, 17, 79, 0.8); border-radius: 40px; color: white; -} +} .titulo { text-align: center; @@ -31,7 +33,7 @@ body { .icone-voltar{ color: white; - font-size: 2em; + font-size: 2.5em; cursor: pointer; } @@ -44,12 +46,14 @@ body { } .form-cadastro{ - display: flex; - flex-direction: column; + display:flex ; + flex-direction:column; justify-content: center; align-content: center; align-items: center; - gap: 1em; + width: 100%; + height: 100%; + gap: 0.5em; } input{ @@ -59,7 +63,7 @@ input{ padding: 0.5em; border: none; border-radius: 40px; - font-size: 1.5em; + font-size: 1em; text-align: center; font-weight: bold; } diff --git a/Front/src/pages/CadastroUsuario/Cadastro.tsx b/Front/src/pages/CadastroUsuario/Cadastro.tsx index 5b705a5..d997826 100644 --- a/Front/src/pages/CadastroUsuario/Cadastro.tsx +++ b/Front/src/pages/CadastroUsuario/Cadastro.tsx @@ -72,17 +72,17 @@ const CadastroUsuario = () => { return ( -
    +
    - - + + -

    Cadastrar

    +

    Cadastrar

    { setConfirmPassword(e.target.value)} /> - {error &&

    {error}

    } +
    From b42ba1cd93e3dc19c0bef54647ca37b6cb83393c Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Wed, 24 Aug 2022 21:55:31 -0300 Subject: [PATCH 077/146] Atualiza tela Cadastro e App --- Front/src/App.tsx | 5 ++--- .../Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index c43bbf2..8431a46 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -19,6 +19,7 @@ function App() { }> } /> } /> + } /> } > - } /> - } /> - + } />
    diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 978aa9e..c87878f 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -122,7 +122,7 @@ input::placeholder{ padding: 0.5em; border: none; border-radius: 40px; - font-size: 1em; + font-size: 1.05em; text-align: center; margin-right: 50%; From 22ec5674deef87eaa67fd1cc6b9785e0414093ac Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Thu, 25 Aug 2022 20:08:22 -0300 Subject: [PATCH 078/146] =?UTF-8?q?feat:=20integra=C3=A7=C3=A3o=20da=20bus?= =?UTF-8?q?ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lucas Felipe Soares <88278278+lucasfs1007@users.noreply.github.com> --- Back/src/controller/AtivoController.js | 2 +- .../A\303\247oes.tsx" | 3 +- .../Busca.tsx" | 36 +++++++++---------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index c3d82c1..beaa337 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -197,7 +197,7 @@ router.get("/buscaativos", async (req,res) => { for (let ativo of response) { const { nome_empresa } = ativo; const { codigo_acao } = ativo; - linha = [nome_empresa, codigo_acao] + linha = {nome: nome_empresa, sigla: codigo_acao}; lista.push(linha); } diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index bfa93b1..1bf1bb3 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -5,6 +5,7 @@ import { IMaskInput } from "react-imask"; import { useState } from "react"; import Axios from "axios"; import { useAuth } from '../../services/Provider'; +import { useNavigate } from 'react-router-dom'; import {BuscaAtivo} from './Busca'; interface Assets{ @@ -34,7 +35,7 @@ export const CadastroAcoes = () => { if (!assets){ setError("Selecione um ativo") - }else if (quantity.length < 0 ){ + }else if (parseInt(quantity) <= 0 ){ setError("É necessário inserir uma quantidade válida") } else if (parseInt(stockPrice) <= 0) { diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index 535613c..1b6e06b 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -1,38 +1,34 @@ -import { useState } from 'react'; -import Select from 'react-select'; +import axios from 'axios'; +import AsyncSelect from 'react-select'; import './Busca.css'; -import { buscaPorCaractere } from "../../../../Back/src/util/BuscaAtivosB3.js"; interface Assets{ - name: string, - initials: string + nome: string, + sigla: string } -const AtivosExample = [ - {name: "AMERICANAS", sigla: "AMER3"}, - {name: "ELETROBRAS", sigla: "ELET3"}, - {name: "EMBRAER", sigla: "EMBRAER"}, - {name: "ITAUUNIBANCO", sigla: "ITUB4"}, - {name: "PETROBRAS", sigla: "ITUB4"}, - {name: "RAIADROGASIL", sigla: "RADL3"} -] - interface Props{ setValue: Function } // Fazer o props para pergar o assets para pesquisa export const BuscaAtivo = (props:Props) => { - - const busca = buscaPorCaractere(""); - + const Options = () => { - return busca.map((ativos) => ({value: ativos, label: ativos.nome.concat(' - ',ativos.sigla)})) + const ativos:Assets[] = []; + axios.get("/ativo/buscaativos") + .then(function(response){ + ativos.push.apply(ativos, response.data.lista); + + }).catch(function(error){ + console.log(error); + }); + return ativos.map((ativos) => ({value: ativos, label: ativos.nome.concat(' - ', ativos.sigla)})) } return( - { // Vai redirecionar a pagina para o login - let navigate = useNavigate(); + const navigate = useNavigate(); const [displayName, setDisplayName] = useState(""); const [birth, setBirth] = useState(""); @@ -71,7 +71,7 @@ const CadastroUsuario = () => { const [inputType, setInputType] = useState("text"); return ( - +
    @@ -82,7 +82,7 @@ const CadastroUsuario = () => {
    -

    Cadastrar

    +

    Cadastrar

    {
    - + ) } From 58c15f4eff0c3df8621b6368cdf422f063181096 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 29 Aug 2022 17:01:58 -0300 Subject: [PATCH 083/146] bug: css das telas --- .../A\303\247oes.tsx" | 4 +-- .../A\303\247\303\265es.css" | 29 +++++++++---------- .../src/pages/HistoricoDeAcoes/historico.css | 19 ++++++------ .../src/pages/HistoricoDeAcoes/historico.tsx | 2 +- Front/src/pages/Sidebar/Sidebar.css | 3 +- Front/src/pages/Sidebar/Sidebar.tsx | 2 +- 6 files changed, 28 insertions(+), 31 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index de002dd..efafdb0 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -46,9 +46,7 @@ export const CadastroAcoes = () => { data: date }).then(function (response) { alert(response.data.message); - // descomentar a linha abaixo para o usuario ser redirecionado para o historico - // de acoes - // navigate("/historico"); + navigate("../historico"); }).catch(function (error) { const message = error.response.data.message; diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index c52881d..6ea3dfa 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -12,21 +12,27 @@ } .div-acoes{ display: flex; - width: 60%; - height: 60%; + justify-content: center; + align-items: center; background-color: rgba(10, 17, 79, 0.8); border-radius: 40px; + width: 65%; +} +.div-acoes div{ + width: 100%; } .form-acoes{ + width: 100%; display: flex; flex-direction: column; - padding: 2%; + justify-content: center; + align-items: center; color: white; gap:1.25em; + padding: 5%; + padding-bottom: 7.5%; } -div{ - width: 100%; -} + .titulo-acoes { text-align: center; font-size: 2.5em; @@ -57,9 +63,8 @@ div{ font-size: 1em; } -.busca-input{ +.form-acoes .busca-input{ width: 97%; - margin-right: 0%; } .div-acoes button{ @@ -104,11 +109,3 @@ div{ gap: 2.5em; margin-top: 1.75em; } -.date-input{ - margin-left: 40%; - display: flex; - width: 80%; - border: none; - border-radius: 40px; - margin-right: 60%; -} \ No newline at end of file diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css index 8139e2a..3d428ae 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.css +++ b/Front/src/pages/HistoricoDeAcoes/historico.css @@ -1,6 +1,3 @@ -body { - margin: 0; -} .background-img { display: flex; align-items: center; @@ -13,17 +10,21 @@ body { background-repeat: no-repeat; } -.titulo { +.titulo-historico{ + text-align: center; font-size: 2.5em; + margin-bottom: 0.5em; + color: white; + font-weight: bold; margin-top: 2.5%; } -ul { +.div-historico ul { color: #000000; padding-right: 10px; display: flex; } -li{ +.div-historico li{ padding: 10px; } .div-historico { @@ -35,16 +36,16 @@ li{ border-radius: 0.5cm; color: white; } -table { +.div-historico table { background-color: #dadada4d; width: 100%; } -table th { +.div-historico table th { background-color: #181f33d2; color: #fff; } -table td { +.div-historico table td { background-color: #dadada4d; color: #0c0c0c; } diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index 77f653a..fa91967 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -8,7 +8,7 @@ const HistoricoDeAcoes = () => { return (
    -

    Histórico de Ativos

    +

    Histórico de Ativos

    diff --git a/Front/src/pages/Sidebar/Sidebar.css b/Front/src/pages/Sidebar/Sidebar.css index 7f0e5dd..a8dd83f 100644 --- a/Front/src/pages/Sidebar/Sidebar.css +++ b/Front/src/pages/Sidebar/Sidebar.css @@ -1,6 +1,7 @@ .container{ position: absolute; - z-index: 10; + z-index: 100; + width: 100%; } .sidebar { background-color: #060b26; diff --git a/Front/src/pages/Sidebar/Sidebar.tsx b/Front/src/pages/Sidebar/Sidebar.tsx index 1ee6bc7..0b97763 100644 --- a/Front/src/pages/Sidebar/Sidebar.tsx +++ b/Front/src/pages/Sidebar/Sidebar.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import { useState } from "react"; import * as FaIcons from "react-icons/fa"; import * as AiIcons from "react-icons/ai"; import { Link, Outlet } from "react-router-dom"; From aa5fc8d31b755505ddd0a2f300dadcda795a5105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20J=C3=BAnior?= <72047826+antonioleaojr@users.noreply.github.com> Date: Mon, 29 Aug 2022 20:20:32 -0300 Subject: [PATCH 084/146] =?UTF-8?q?cria=C3=A7=C3=A3o=20da=20pasta,=20css?= =?UTF-8?q?=20e=20typescript.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Carteira/carteira.css | 0 Front/src/pages/Carteira/carteira.tsx | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 Front/src/pages/Carteira/carteira.css create mode 100644 Front/src/pages/Carteira/carteira.tsx diff --git a/Front/src/pages/Carteira/carteira.css b/Front/src/pages/Carteira/carteira.css new file mode 100644 index 0000000..e69de29 diff --git a/Front/src/pages/Carteira/carteira.tsx b/Front/src/pages/Carteira/carteira.tsx new file mode 100644 index 0000000..67b8a5e --- /dev/null +++ b/Front/src/pages/Carteira/carteira.tsx @@ -0,0 +1,10 @@ +const Carteira = () => { + + +return ( +

    Invext - Minha carteira

    +) + +} + +export default Carteira \ No newline at end of file From 4731714d04826a0ef79a3b4bb2847acc5f9ba3c0 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 29 Aug 2022 21:06:04 -0300 Subject: [PATCH 085/146] feat: busca de ativos --- .../Busca.tsx" | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index 1b6e06b..71916b9 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -1,34 +1,43 @@ import axios from 'axios'; -import AsyncSelect from 'react-select'; +import { useState } from 'react'; +import { useEffect } from 'react'; +import Select from 'react-select'; import './Busca.css'; interface Assets{ nome: string, sigla: string } - +interface Option{ + value: Assets, + label: string +} interface Props{ setValue: Function } // Fazer o props para pergar o assets para pesquisa -export const BuscaAtivo = (props:Props) => { +export const BuscaAtivo = (props:Props) => { + const [options, setOptions] = useState(); - const Options = () => { - const ativos:Assets[] = []; + useEffect(() => { axios.get("/ativo/buscaativos") - .then(function(response){ - ativos.push.apply(ativos, response.data.lista); + .then(async function(response){ + const ativos:Assets[] = await response.data.lista; + var array = ativos.map((ativos) => ({value: ativos, label: ativos.nome.concat(' - ', ativos.sigla)})); + setOptions(array); }).catch(function(error){ console.log(error); }); - return ativos.map((ativos) => ({value: ativos, label: ativos.nome.concat(' - ', ativos.sigla)})) - } - + + }, []); + + + return( - Date: Mon, 29 Aug 2022 21:26:21 -0300 Subject: [PATCH 086/146] =?UTF-8?q?removendo=20o=20await=20pois=20ele=20n?= =?UTF-8?q?=C3=A3o=20=C3=A9=20=C3=BAtil=20para=20essa=20rederiza=C3=A7?= =?UTF-8?q?=C3=A3o.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index 71916b9..c607e5f 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -16,14 +16,14 @@ interface Props{ setValue: Function } -// Fazer o props para pergar o assets para pesquisa -export const BuscaAtivo = (props:Props) => { +// Fazer o props para pegar o assets para pesquisa + export const BuscaAtivo = (props:Props) => { const [options, setOptions] = useState(); useEffect(() => { axios.get("/ativo/buscaativos") - .then(async function(response){ - const ativos:Assets[] = await response.data.lista; + .then( function(response){ + const ativos:Assets[] = response.data.lista; var array = ativos.map((ativos) => ({value: ativos, label: ativos.nome.concat(' - ', ativos.sigla)})); setOptions(array); From be6b0e3720cf054445fce5387f660e0b04683997 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Tue, 30 Aug 2022 15:28:18 -0300 Subject: [PATCH 087/146] refactor: melhoria de desempenho da busca de ativos --- Front/package.json | 4 +++- .../src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Front/package.json b/Front/package.json index 9e542df..60c3b2e 100644 --- a/Front/package.json +++ b/Front/package.json @@ -18,7 +18,9 @@ "react-icons": "^4.4.0", "react-imask": "^6.4.2", "react-router-dom": "^6.3.0", - "react-select": "^5.4.0" + "react-select": "^5.4.0", + "react-window": "^1.8.7", + "react-windowed-select": "^5.1.0" }, "devDependencies": { "@types/module-alias": "^2.0.1", diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index c607e5f..5e0e22e 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -1,7 +1,8 @@ import axios from 'axios'; import { useState } from 'react'; import { useEffect } from 'react'; -import Select from 'react-select'; +import WindowedSelect from "react-windowed-select"; +import { createFilter } from 'react-windowed-select'; import './Busca.css'; interface Assets{ @@ -33,11 +34,13 @@ interface Props{ }, []); - + console.log(options); return( - setAssets(e.target.value)} ->>>>>>> Develop +
    @@ -160,7 +128,7 @@ export const CadastroAcoes = () => { {error &&

    {error}

    }
    -
    +
    ); } diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" index 345accf..2a7ec93 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247\303\265es.css" @@ -63,15 +63,8 @@ font-size: 1em; } -<<<<<<< HEAD -button{ -======= -.form-acoes .busca-input{ - width: 97%; -} .div-acoes button{ ->>>>>>> Develop color:white; border: none; border-radius:70px; diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" index 5e0e22e..233e7f4 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" @@ -1,54 +1,59 @@ import axios from 'axios'; -import { useState } from 'react'; -import { useEffect } from 'react'; -import WindowedSelect from "react-windowed-select"; -import { createFilter } from 'react-windowed-select'; -import './Busca.css'; +import { useState, useEffect } from 'react'; +import WindowedSelect, { createFilter } from "react-windowed-select"; +import './Busca.css'; -interface Assets{ +interface Assets { nome: string, sigla: string } -interface Option{ +interface Option { value: Assets, label: string } -interface Props{ +interface Props { setValue: Function } // Fazer o props para pegar o assets para pesquisa - export const BuscaAtivo = (props:Props) => { +export const BuscaAtivo = (props: Props) => { const [options, setOptions] = useState(); - + useEffect(() => { axios.get("/ativo/buscaativos") - .then( function(response){ - const ativos:Assets[] = response.data.lista; - var array = ativos.map((ativos) => ({value: ativos, label: ativos.nome.concat(' - ', ativos.sigla)})); - setOptions(array); - - }).catch(function(error){ - console.log(error); - }); - + .then(function (response) { + const ativos: Assets[] = response.data.lista; + var array = ativos.map((ativos) => ({ value: ativos, label: ativos.nome.concat(' - ', ativos.sigla) })); + setOptions(array); + + }).catch(function (error) { + console.log(error); + }); + }, []); - - console.log(options); - - return( + + const handleChange = (e:unknown) =>{ + if(e){ + const option = e as Option; + props.setValue(option.value); + + } else { + props.setValue(''); + } + } + return ( "Ativo não encontrado"} - isClearable - components={{ DropdownIndicator:() => null, IndicatorSeparator: () => null}} - // Se o valor for diferente de null, colocamos o valor dele, caso contrário colocamos '' - onChange={e => e ? props.setValue(e.value) : props.setValue('')} + windowThreshold={100} + options={options} + filterOption={createFilter({ ignoreAccents: false })} + placeholder="Busque seu ativo" + classNamePrefix='react-select' + className='select' + noOptionsMessage={() => "Ativo não encontrado"} + isClearable + components={{ DropdownIndicator: () => null, IndicatorSeparator: () => null }} + onChange={handleChange} + /> ); } From 57dd4b9f050609fbf65cfa34b70006b8b71df2dc Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 31 Aug 2022 09:57:17 -0300 Subject: [PATCH 091/146] ajustando a rota para se testar a tela de carteira --- Front/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 16aecf4..023f61a 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -20,7 +20,6 @@ function App() { }> } /> } /> - } /> } /> } /> + } /> From 2630decc1b45268575d747554884b72d60f33605 Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Wed, 31 Aug 2022 11:04:13 -0300 Subject: [PATCH 092/146] =?UTF-8?q?Refatora=20o=20Hist=C3=B3rico=20com=20o?= =?UTF-8?q?=20datagrid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/package.json | 4 + .../src/pages/HistoricoDeAcoes/historico.css | 30 +- .../src/pages/HistoricoDeAcoes/historico.tsx | 263 +++--------------- 3 files changed, 40 insertions(+), 257 deletions(-) diff --git a/Front/package.json b/Front/package.json index a2eed91..f17cdba 100644 --- a/Front/package.json +++ b/Front/package.json @@ -9,6 +9,10 @@ "preview": "vite preview" }, "dependencies": { + "@emotion/react": "^11.10.4", + "@emotion/styled": "^11.10.4", + "@mui/material": "^5.10.3", + "@mui/x-data-grid": "^5.16.0", "axios": "^0.27.2", "date-fns": "^2.29.1", "module-alias": "^2.2.2", diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css index 3d428ae..44c17c5 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.css +++ b/Front/src/pages/HistoricoDeAcoes/historico.css @@ -32,35 +32,7 @@ flex-direction: column; padding: 2%; width: 80%; - background-color: #dadadace; + background-color: #cacacaf1; border-radius: 0.5cm; color: white; -} -.div-historico table { - background-color: #dadada4d; - width: 100%; -} -.div-historico table th { - background-color: #181f33d2; - color: #fff; - -} -.div-historico table td { - background-color: #dadada4d; - color: #0c0c0c; -} -.buttonBox{ - display: flex; - margin-top: 6%; -} -.select-button { - background-color:#181f33d2; - color:white; - border-radius: 10cm; - font-size: 0.8em; - text-align: center; - padding: 0.1mm 0.5cm; - cursor:pointer; - transition: 0.25s; - margin-right: 25%; } \ No newline at end of file diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index fa91967..e1328ac 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -2,6 +2,33 @@ import { Link } from 'react-router-dom'; import './historico.css'; import * as FaIcons from 'react-icons/fa'; import * as AiIcons from 'react-icons/ai'; +import * as React from 'react'; +import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; + +const columns: GridColDef[] = [ + { field: 'id', headerName: 'ID', width: 70 }, + { field: 'ativo', headerName: 'Ativo', width: 130 }, + { field: 'sigla', headerName: 'Sigla', width: 130 }, + { field: 'ordem', headerName: 'Ordem', width: 130 }, + { field: 'quantidade', headerName: 'Quantidade', width: 130 }, + { field: 'negociação', headerName: 'Negociação', width: 130 }, + { field: 'valor', headerName: 'Valor', width: 130 }, + +]; + +const rows = [ + { id: 1, ativo: 'Americanas', sigla: 'AMER3', ordem: 'Compra', quantidade:'1', negociação:'06/05/2021', valor:'R$16,82'}, + { id: 2, ativo: 'Magazine Luiza', sigla: 'MGLU3', ordem: 'Venda' , quantidade:'2', negociação:'06/05/2021', valor:'R$8,96'}, + { id: 3, ativo: 'Itaú', sigla: 'ITUB4', ordem: 'Compra' , quantidade:'5', negociação:'07/05/2021', valor:'R$131,55'}, + { id: 4, ativo: 'Oi', sigla: 'OIBR3', ordem: 'Compra' , quantidade:'6', negociação:'09/09/2021', valor:'R$3,18'}, + { id: 5, ativo: 'Petrobras', sigla: 'PETR4', ordem: 'Venda' , quantidade:'7', negociação:'09/10/2021', valor:'R$223,37'}, + { id: 6, ativo: 'Vale', sigla: 'VALE3', ordem: 'Compra' , quantidade:'5', negociação:'15/11/2021', valor:'R$326,20'}, + { id: 7, ativo: 'Ambev', sigla: 'ABEV3', ordem: 'Venda' , quantidade:'4', negociação:'06/12/2021', valor:'R$61,56'}, + { id: 8, ativo: 'Vale', sigla: 'VALE3', ordem: 'Venda', quantidade:'3', negociação:'07/05/2021', valor:'R$195,72'}, + { id: 9, ativo: 'Americanas', sigla: 'AMER3', ordem: 'Compra' , quantidade:'1', negociação:'06/01/2022', valor:'R$16,82'}, + { id: 10, ativo: 'Vale', sigla: 'VALE3', ordem: 'Venda', quantidade:'3', negociação:'07/05/2021', valor:'R$195,72'}, + { id: 11, ativo: 'Petrobras', sigla: 'PETR4', ordem: 'Venda', quantidade:'3', negociação:'07/05/2021', valor:'R$95,73'}, +]; const HistoricoDeAcoes = () => { @@ -10,234 +37,14 @@ return (

    Histórico de Ativos

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    AtivoSiglaOrdemQuant.ValorEditarExcluir
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    --------------
    -
    -
    - +
    +
    From 658b79b882f563428b8bd0573aefb8520de8c629 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 31 Aug 2022 11:22:11 -0300 Subject: [PATCH 093/146] ajustando algumas cores e posicionamentos --- Front/src/pages/CarteiraUsuario/Carteira.css | 24 ++++++++++---------- Front/src/pages/CarteiraUsuario/Carteira.tsx | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Front/src/pages/CarteiraUsuario/Carteira.css b/Front/src/pages/CarteiraUsuario/Carteira.css index 527da21..1e53b8b 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.css +++ b/Front/src/pages/CarteiraUsuario/Carteira.css @@ -19,8 +19,8 @@ flex-direction: column; padding: 2.5%; width: 60%; - height: 25%; - background-color: #cacaca; + height: 30%; + background-color: #A9A9A9; border-radius: 40px; color: white; margin-bottom: 1.2%; @@ -32,38 +32,38 @@ margin-bottom: 0.5em; color: white; font-weight: bold; - margin-top: 2.5%; + margin-top: 3.5%; } .div-titulo-patrimonio{ - margin-top: -1.6em; + margin-top: -1.2em; margin-left: 2.5em; display: flex; flex-direction: row; - font-size: 1.3em; + font-size: 1.5em; color: rgb(255, 255, 255); font-weight: bold; } .div-ativos{ - color: black; + margin-left: 0.5em; display: flex; flex-direction: row; - padding: 2.5%; + padding: 1.5%; margin-top: 1.4em; width: 55 em; - height: 9em; - background-color: #D9D9D9; + height: 20em; + background-color: #dcdcdc; border-radius: 40px; } .div-barra { background-color: #241453; - margin-top: -1.4em; + margin-top: 0.3em; margin-left: -2.6em; width: 0.5em; - height: 11.9em; + height: 9.9em; } .div-rentabilidade{ @@ -72,7 +72,7 @@ padding: 2.5%; width: 60%; height: 25%; - background-color: #cacaca; + background-color: #A9A9A9; border-radius: 40px; color: white; } \ No newline at end of file diff --git a/Front/src/pages/CarteiraUsuario/Carteira.tsx b/Front/src/pages/CarteiraUsuario/Carteira.tsx index e47de69..8bf3ccc 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.tsx +++ b/Front/src/pages/CarteiraUsuario/Carteira.tsx @@ -1,3 +1,5 @@ +//Amanda disse que vai implementar o esquema de tabela p dentro da div ver com ela dps. +//O CSS vai ter que ser um pouco refatorado pois estamos usando muito em e isso pode dar ruim dependendo da tela. import './Carteira.css'; const Carteira = () => { From 7b1eb32bf9c314ff937ab4866fc2b68ff42779b0 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Wed, 31 Aug 2022 12:32:30 -0300 Subject: [PATCH 094/146] =?UTF-8?q?refactor:=20estiliza=C3=A7=C3=A3o=20da?= =?UTF-8?q?=20sidebar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Sidebar/Sidebar.css | 11 ++++++++++- Front/src/pages/Sidebar/Sidebar.tsx | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Front/src/pages/Sidebar/Sidebar.css b/Front/src/pages/Sidebar/Sidebar.css index a8dd83f..05eab59 100644 --- a/Front/src/pages/Sidebar/Sidebar.css +++ b/Front/src/pages/Sidebar/Sidebar.css @@ -52,6 +52,7 @@ align-items: center; padding: 0 16px; border-radius: 4px; + cursor: pointer; } .nav-link:hover { background-color: #1a83ff; @@ -72,6 +73,14 @@ align-items: center; } -span { +.container span { margin-left: 16px; +} + +.icon-hover:hover{ + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -o-transform: scale(1.1); + -ms-transform: scale(1.1); + transform: scale(1.1); } \ No newline at end of file diff --git a/Front/src/pages/Sidebar/Sidebar.tsx b/Front/src/pages/Sidebar/Sidebar.tsx index 0b97763..04fd8f2 100644 --- a/Front/src/pages/Sidebar/Sidebar.tsx +++ b/Front/src/pages/Sidebar/Sidebar.tsx @@ -29,14 +29,14 @@ export const Sidebar = () => {
    - +
    From ccf703c368b460d40f1457284002598bc550ba33 Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Wed, 31 Aug 2022 14:57:22 -0300 Subject: [PATCH 097/146] =?UTF-8?q?Algumas=20altera=C3=A7=C3=B5es=20no=20c?= =?UTF-8?q?ss=20e=20adi=C3=A7=C3=A3o=20de=20=C3=ADcones=20-=20Patrim=C3=B4?= =?UTF-8?q?nio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/CarteiraUsuario/Carteira.css | 26 ++++++++++++++------ Front/src/pages/CarteiraUsuario/Carteira.tsx | 17 ++++++++----- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Front/src/pages/CarteiraUsuario/Carteira.css b/Front/src/pages/CarteiraUsuario/Carteira.css index 1e53b8b..55bee3f 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.css +++ b/Front/src/pages/CarteiraUsuario/Carteira.css @@ -26,6 +26,16 @@ margin-bottom: 1.2%; } +.icon { + padding-right: 1%; + color: white; +} +.eye{ + padding-left: 1%; + color: black; + cursor: pointer; +} + .titulo-carteira{ text-align: center; font-size: 2.5em; @@ -36,8 +46,8 @@ } .div-titulo-patrimonio{ - margin-top: -1.2em; - margin-left: 2.5em; + margin-top: -1.6em; + margin-left: 1%; display: flex; flex-direction: row; font-size: 1.5em; @@ -45,8 +55,7 @@ font-weight: bold; } -.div-ativos{ - +.div-ativos { margin-left: 0.5em; display: flex; flex-direction: row; @@ -55,15 +64,18 @@ width: 55 em; height: 20em; background-color: #dcdcdc; + border: 2px solid; + border-color: black; border-radius: 40px; + } -.div-barra { +.barra { background-color: #241453; - margin-top: 0.3em; + margin-top: 0.4em; margin-left: -2.6em; width: 0.5em; - height: 9.9em; + height: 95%; } .div-rentabilidade{ diff --git a/Front/src/pages/CarteiraUsuario/Carteira.tsx b/Front/src/pages/CarteiraUsuario/Carteira.tsx index 8bf3ccc..0b7c7b8 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.tsx +++ b/Front/src/pages/CarteiraUsuario/Carteira.tsx @@ -1,23 +1,28 @@ //Amanda disse que vai implementar o esquema de tabela p dentro da div ver com ela dps. //O CSS vai ter que ser um pouco refatorado pois estamos usando muito em e isso pode dar ruim dependendo da tela. import './Carteira.css'; +import { useState } from "react"; +import {FaMoneyBillWave} from 'react-icons/fa'; +import {BsEye, BsEyeSlash} from 'react-icons/bs'; const Carteira = () => { - - + + return (

    Invext - Minha Carteira

    - + +

    Patrimônio

    +
    -
    - -
    + + +
    From 16b17e96c427520d1ac081284d7f5d53f5bed19f Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Wed, 31 Aug 2022 15:26:55 -0300 Subject: [PATCH 098/146] =?UTF-8?q?adicionando=20os=20=C3=ADcones=20e=20a?= =?UTF-8?q?=20onde=20ficar=C3=A3o=20os=20ativos=20na=20parte=20da=20rentab?= =?UTF-8?q?ilidade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/CarteiraUsuario/Carteira.css | 36 +++++++++++++++++--- Front/src/pages/CarteiraUsuario/Carteira.tsx | 20 ++++++++--- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Front/src/pages/CarteiraUsuario/Carteira.css b/Front/src/pages/CarteiraUsuario/Carteira.css index 55bee3f..39eda5a 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.css +++ b/Front/src/pages/CarteiraUsuario/Carteira.css @@ -55,13 +55,12 @@ font-weight: bold; } -.div-ativos { +.div-ativos-patrimonio { margin-left: 0.5em; display: flex; flex-direction: row; padding: 1.5%; - margin-top: 1.4em; - width: 55 em; + margin-top: 1.4em; height: 20em; background-color: #dcdcdc; border: 2px solid; @@ -70,10 +69,11 @@ } -.barra { +.barra-patrimonio { background-color: #241453; margin-top: 0.4em; margin-left: -2.6em; + margin-right: 5%; width: 0.5em; height: 95%; } @@ -87,4 +87,30 @@ background-color: #A9A9A9; border-radius: 40px; color: white; -} \ No newline at end of file +} + + +.div-titulo-rentabilidade{ + margin-top: -1.6em; + margin-left: 1%; + display: flex; + flex-direction: row; + font-size: 1.5em; + color: rgb(255, 255, 255); + font-weight: bold; +} + +.div-ativos-rentabilidade { + margin-left: 66%; + display: flex; + flex-direction: row; + padding: 1.5%; + margin-top: 1.4em; + width: 30%; + height: 100%; + background-color: #dcdcdc; + border: 2px solid; + border-color: black; + border-radius: 40px; +} + diff --git a/Front/src/pages/CarteiraUsuario/Carteira.tsx b/Front/src/pages/CarteiraUsuario/Carteira.tsx index 0b7c7b8..2492422 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.tsx +++ b/Front/src/pages/CarteiraUsuario/Carteira.tsx @@ -4,6 +4,7 @@ import './Carteira.css'; import { useState } from "react"; import {FaMoneyBillWave} from 'react-icons/fa'; import {BsEye, BsEyeSlash} from 'react-icons/bs'; +import {AiOutlineRise} from 'react-icons/ai' const Carteira = () => { @@ -15,20 +16,31 @@ return (
    -

    Patrimônio

    +

    Patrimônio

    -
    - +
    + + -
    +
    + + +

    Rentabilidade

    + +
    +
    + + + +
    ) From 8236f4e64b557a0c450d76ced972cd2db23078ee Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Wed, 31 Aug 2022 16:51:34 -0300 Subject: [PATCH 099/146] =?UTF-8?q?corrigindo=20espa=C3=A7amentos=20e=20me?= =?UTF-8?q?lhorando=20o=20css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/CarteiraUsuario/Carteira.css | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Front/src/pages/CarteiraUsuario/Carteira.css b/Front/src/pages/CarteiraUsuario/Carteira.css index 39eda5a..d6f2114 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.css +++ b/Front/src/pages/CarteiraUsuario/Carteira.css @@ -19,7 +19,7 @@ flex-direction: column; padding: 2.5%; width: 60%; - height: 30%; + height: 25%; background-color: #A9A9A9; border-radius: 40px; color: white; @@ -42,11 +42,11 @@ margin-bottom: 0.5em; color: white; font-weight: bold; - margin-top: 3.5%; + margin-top: 2.5%; } .div-titulo-patrimonio{ - margin-top: -1.6em; + margin-top: -1.6px; margin-left: 1%; display: flex; flex-direction: row; @@ -60,8 +60,8 @@ display: flex; flex-direction: row; padding: 1.5%; - margin-top: 1.4em; - height: 20em; + margin-top: 1.0em; + height: 22em; background-color: #dcdcdc; border: 2px solid; border-color: black; @@ -91,7 +91,7 @@ .div-titulo-rentabilidade{ - margin-top: -1.6em; + margin-top: -1.6px; margin-left: 1%; display: flex; flex-direction: row; From f8e91cec99bd923a4eb242e81e72bdb43a848901 Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Wed, 31 Aug 2022 18:15:46 -0300 Subject: [PATCH 100/146] =?UTF-8?q?adicionando=20imports=20que=20ser=C3=A3?= =?UTF-8?q?o=20utilizados=20posteriormente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/HistoricoDeAcoes/historico.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index e1328ac..c9fddb9 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -1,8 +1,7 @@ import { Link } from 'react-router-dom'; +import { useEffect, useState } from 'react'; +import axios from 'axios'; import './historico.css'; -import * as FaIcons from 'react-icons/fa'; -import * as AiIcons from 'react-icons/ai'; -import * as React from 'react'; import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; const columns: GridColDef[] = [ @@ -30,7 +29,12 @@ const rows = [ { id: 11, ativo: 'Petrobras', sigla: 'PETR4', ordem: 'Venda', quantidade:'3', negociação:'07/05/2021', valor:'R$95,73'}, ]; + + const HistoricoDeAcoes = () => { + + + return ( From 498daa4d7eeabf5ddb87789ac74eb81ff8a21c7e Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Wed, 31 Aug 2022 21:26:00 -0300 Subject: [PATCH 101/146] Adicionando indices Selic e CDI para compor futuros graficos --- Back/src/util/IndicesUtil.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Back/src/util/IndicesUtil.js diff --git a/Back/src/util/IndicesUtil.js b/Back/src/util/IndicesUtil.js new file mode 100644 index 0000000..c91a944 --- /dev/null +++ b/Back/src/util/IndicesUtil.js @@ -0,0 +1,27 @@ +const Axios = require("axios"); + +exports.indiceSelic = async function () { + var lista = []; + // Pega os dados da taxa selic + await Axios.get("http://api.bcb.gov.br/dados/serie/bcdata.sgs.432/dados?formato=json", { + }).then(function(res){ + lista.push(res.data); + return lista; + }).catch(function(err){ + console.log(err); + return lista; + }); +} + +exports.indiceCDI = async function () { + var lista = []; + // Pega os dados da taxa selic + await Axios.get("http://api.bcb.gov.br/dados/serie/bcdata.sgs.12/dados?formato=json", { + }).then(function(res){ + lista.push(res.data); + return lista; + }).catch(function(err){ + console.log(err); + return lista; + }); +} \ No newline at end of file From 807a00c0fca037076e4f84d3d92d3e04f9cf89ea Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Thu, 1 Sep 2022 00:50:09 -0300 Subject: [PATCH 102/146] Adicioanando a logica para o patrimonio --- Back/src/app.js | 9 ++-- Back/src/controller/AtivoController.js | 33 ++++++++++++++ Back/src/util/AtivosB3Util.js | 63 ++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 4 deletions(-) diff --git a/Back/src/app.js b/Back/src/app.js index 5abc79f..2ad58eb 100755 --- a/Back/src/app.js +++ b/Back/src/app.js @@ -3,8 +3,9 @@ const app = express(); const bodyParser = require("body-parser"); const cors = require("cors"); -const userControler = require('../src/controller/UserController.js'); -const ativoControler = require('./controller/AtivoController.js'); +const userController = require('../src/controller/UserController.js'); +const ativoController = require('./controller/AtivoController.js'); + app.use(express.json()); app.use(bodyParser.urlencoded({extended: false})); @@ -17,7 +18,7 @@ app.get("/", (req, res) => { }); }); -app.use('/usuario', userControler); -app.use('/ativo', ativoControler); +app.use('/usuario', userController); +app.use('/ativo', ativoController); module.exports = app; \ No newline at end of file diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 78dce54..ed6e6a3 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -7,6 +7,8 @@ const auth = require("../middleware/auth"); const Ativo = require("../models/Ativo"); const AtivosB3 = require("../models/AtivosB3"); +const ativosB3Util = require("../util/AtivosB3Util"); + router.post("/cadastrar", auth, async (req, res) => { const novo_ativo = { id_usuario: req.usuario.id, @@ -129,6 +131,37 @@ router.get("/historico", auth, async (req,res) => { }) +// Rota que envia o patrimonio do usuario +router.get("/patrimonio", auth, async (req, res) => { + await Ativo.findAll({ + attributes: [ + [sequelize.fn('DISTINCT', sequelize.col('sigla')), 'sigla'], + ], + where: { + "id_usuario": req.usuario.id + }, + }).then(async (ativos) => { + let siglas = [] + for (let ativo of ativos) { + siglas.push(ativo.dataValues.sigla); + } + + const patrimonio = await ativosB3Util.calculaPatrimonio(siglas, req.usuario.id); + + return res.json({ + erro: false, + ativos: patrimonio + }); + + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + ativos: [] + }) + }); +}); + router.post("/editar", auth, async (req,res) => { const { id } = req.body; const { sigla } = req.body; diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index bba6ffe..c82138f 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -1,5 +1,6 @@ const Axios = require("axios"); const AtivosB3 = require("../models/AtivosB3") +const Ativo = require("../models/Ativo"); exports.updateAtivosB3 = async function () { let dt_ultimo_pregao; @@ -38,4 +39,66 @@ exports.updateAtivosB3 = async function () { }).catch(function(err){ console.log(err); }); +} + +exports.calculaPatrimonio = async function (siglas, id_usuario) { + var lista = []; + for (let sigla of siglas) { + await Ativo.findAll({ + attributes: [ + "nomeAtivo", + "sigla", + "preco", + "quantidade", + "data", + "execucao", + ], + where: { + "id_usuario": id_usuario, + "sigla": sigla + }, + }).then(async (res) => { + let pPrecoMedio = 0, pQuantidade = 0, pTotal = 0; + let pNomeAtivo, pSigla; + for (let result of res) { + const { nomeAtivo } = result; + const { sigla } = result; + const { preco } = result; + const { quantidade } = result; + const { execucao } = result; + const { data } = result; + + pNomeAtivo = nomeAtivo; + pSigla = sigla; + if (execucao === "compra") { + pTotal += parseFloat(preco) * parseInt(quantidade); + pQuantidade += parseInt(quantidade); + } else { + pTotal += (-1) * parseFloat(preco) * quantidade; + pQuantidade += (-1) * parseInt(quantidade); + } + pPrecoMedio = pTotal / pQuantidade; + } + + const precoAtual = await AtivosB3.findAll({ + attributes: ['valor_fechamento'], + where: { + "codigo_acao": sigla + } + }); + + const patrimonio = { + nomeAtivo: pNomeAtivo, + sigla: pSigla, + porcentagem: 0, // falta calcular + quantidade: pQuantidade, + precoAtual: precoAtual[0].valor_fechamento, + precoMedio: parseFloat(pPrecoMedio.toFixed(2)), + diferenca: 0, // falta calcular + valorTotal: pTotal + } + lista.push(patrimonio); + }); + } + return lista; } \ No newline at end of file From ed359038b5a6551938e1dbcfe9c7d59a2cf562dc Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Thu, 1 Sep 2022 13:00:37 -0300 Subject: [PATCH 103/146] =?UTF-8?q?feat:=20Integra=C3=A7=C3=A3o=20front/ba?= =?UTF-8?q?ck=20historico=20ativos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Back/src/controller/AtivoController.js | 8 +- Front/src/App.tsx | 10 +- .../src/pages/HistoricoDeAcoes/historico.tsx | 123 ++++++++++++------ 3 files changed, 92 insertions(+), 49 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index 78dce54..e738c8e 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -108,11 +108,11 @@ router.post("/vender", auth, async (req,res) => { }); // Rota que envia o historico da acao do usuario -router.get("/historico", auth, async (req,res) => { +router.post("/historico", auth, async (req,res) => { const dadoHistorico = await Ativo.findAll({ attributes: [ - "id_usuario", + "id", "nomeAtivo", "sigla", "preco", @@ -125,7 +125,9 @@ router.get("/historico", auth, async (req,res) => { "id_usuario": req.usuario.id }, }) - console.log(dadoHistorico); + return res.json({ + historico: dadoHistorico + }) }) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 5e9025a..c093680 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -1,10 +1,10 @@ import './App.css' import CadastroUsuario from './pages/CadastroUsuario/Cadastro'; import LoginUsuario from './pages/LoginUsuario/Login'; -import HistoricoDeAcoes from './pages/HistoricoDeAcoes/historico'; +import { HistoricoDeAcoes } from './pages/HistoricoDeAcoes/historico'; import { Route, Routes } from "react-router-dom"; import { CadastroAcoes } from './pages/Cadastro de Ações/Açoes'; -import { AuthProvider} from './services/Provider'; +import { AuthProvider } from './services/Provider'; import { RequireAuth } from './services/requireAuth'; import { Sidebar } from './pages/Sidebar/Sidebar'; import { PublicRoute } from './services/publicRoute'; @@ -15,10 +15,10 @@ function App() {
    - + }> } /> - } /> + } /> } /> } /> - +
    diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index c9fddb9..b2ec2a2 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -1,8 +1,12 @@ -import { Link } from 'react-router-dom'; -import { useEffect, useState } from 'react'; -import axios from 'axios'; import './historico.css'; -import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; +import * as FaIcons from 'react-icons/fa'; +import * as AiIcons from 'react-icons/ai'; +import { DataGrid, GridColDef} from '@mui/x-data-grid'; +import { useAuth } from '../../services/Provider'; +import { useEffect, useState} from 'react'; +import Axios from 'axios'; +import { capitalize } from '@mui/material'; +import { format } from 'date-fns'; const columns: GridColDef[] = [ { field: 'id', headerName: 'ID', width: 70 }, @@ -12,49 +16,86 @@ const columns: GridColDef[] = [ { field: 'quantidade', headerName: 'Quantidade', width: 130 }, { field: 'negociação', headerName: 'Negociação', width: 130 }, { field: 'valor', headerName: 'Valor', width: 130 }, - -]; -const rows = [ - { id: 1, ativo: 'Americanas', sigla: 'AMER3', ordem: 'Compra', quantidade:'1', negociação:'06/05/2021', valor:'R$16,82'}, - { id: 2, ativo: 'Magazine Luiza', sigla: 'MGLU3', ordem: 'Venda' , quantidade:'2', negociação:'06/05/2021', valor:'R$8,96'}, - { id: 3, ativo: 'Itaú', sigla: 'ITUB4', ordem: 'Compra' , quantidade:'5', negociação:'07/05/2021', valor:'R$131,55'}, - { id: 4, ativo: 'Oi', sigla: 'OIBR3', ordem: 'Compra' , quantidade:'6', negociação:'09/09/2021', valor:'R$3,18'}, - { id: 5, ativo: 'Petrobras', sigla: 'PETR4', ordem: 'Venda' , quantidade:'7', negociação:'09/10/2021', valor:'R$223,37'}, - { id: 6, ativo: 'Vale', sigla: 'VALE3', ordem: 'Compra' , quantidade:'5', negociação:'15/11/2021', valor:'R$326,20'}, - { id: 7, ativo: 'Ambev', sigla: 'ABEV3', ordem: 'Venda' , quantidade:'4', negociação:'06/12/2021', valor:'R$61,56'}, - { id: 8, ativo: 'Vale', sigla: 'VALE3', ordem: 'Venda', quantidade:'3', negociação:'07/05/2021', valor:'R$195,72'}, - { id: 9, ativo: 'Americanas', sigla: 'AMER3', ordem: 'Compra' , quantidade:'1', negociação:'06/01/2022', valor:'R$16,82'}, - { id: 10, ativo: 'Vale', sigla: 'VALE3', ordem: 'Venda', quantidade:'3', negociação:'07/05/2021', valor:'R$195,72'}, - { id: 11, ativo: 'Petrobras', sigla: 'PETR4', ordem: 'Venda', quantidade:'3', negociação:'07/05/2021', valor:'R$95,73'}, ]; +// São os registros que vem do banco de dados +interface DBHistoric { + id: number, + nomeAtivo: string, + sigla: string, + execucao: string, + quantidade: number, + data: string, + preco: number +} +// Registro que sera mostrado para o usuario +interface Historic { + id: number, + ativo: string, // == nomeAtivo + sigla: string, + ordem: string, // == execucao + quantidade: number, + negociação: string, // == data + valor: string // == preco +} -const HistoricoDeAcoes = () => { - - +export const HistoricoDeAcoes = () => { - -return ( - -
    -

    Histórico de Ativos

    -
    -
    - -
    -
    -
    -) + const auth = useAuth(); + const token = auth.getToken(); + const [historic, setHistoric] = useState(); -} + // Altera a forma de visualização dos dados que vem do banco + const refactorHistoric = (dbHistoric: DBHistoric[]) => { + if(dbHistoric){ + return dbHistoric.map((ativo:DBHistoric) => ({ + id: ativo.id, + ativo: ativo.nomeAtivo, + sigla: ativo.sigla, + ordem: capitalize(ativo.execucao), + quantidade: ativo.quantidade, + negociação: format(new Date(ativo.data), 'dd/MM/yyyy'), + valor: `R$ ${ativo.preco.toFixed(2)}` + })) + + } else{ + return []; + } + } + + const getHistoric = () => { + Axios.post("/ativo/historico",{ + token: token + } + ).then(function(response){ + setHistoric(refactorHistoric(response.data.historico)); + }).catch(function (error) { + console.log(error); + }) + } -export default HistoricoDeAcoes; + useEffect(() => { + getHistoric(); + }, [ ]) + return ( +
    +

    Histórico de Ativos

    +
    +
    + {historic ? + + :null} +
    +
    +
    + ) +} From 811e7b4aa728effe21f30fc4e68d1eb23006b934 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Thu, 1 Sep 2022 17:44:41 -0300 Subject: [PATCH 104/146] =?UTF-8?q?inicializando=20a=20integra=C3=A7=C3=A3?= =?UTF-8?q?o=20da=20carteira=20com=20o=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/CarteiraUsuario/Carteira.tsx | 82 ++++++++++++++++++-- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/Front/src/pages/CarteiraUsuario/Carteira.tsx b/Front/src/pages/CarteiraUsuario/Carteira.tsx index 2492422..56954c8 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.tsx +++ b/Front/src/pages/CarteiraUsuario/Carteira.tsx @@ -1,14 +1,77 @@ -//Amanda disse que vai implementar o esquema de tabela p dentro da div ver com ela dps. -//O CSS vai ter que ser um pouco refatorado pois estamos usando muito em e isso pode dar ruim dependendo da tela. import './Carteira.css'; -import { useState } from "react"; +import { useState,useEffect } from "react"; import {FaMoneyBillWave} from 'react-icons/fa'; import {BsEye, BsEyeSlash} from 'react-icons/bs'; import {AiOutlineRise} from 'react-icons/ai' +import Axios from 'axios'; +//preciso verificar todas as importaçoes restantes e corrigir essa importação +import { DataGrid, GridColDef} from '@mui/x-data-grid'; +import { useAuth } from '../../services/Provider'; + +//base da tabela...estou usando tudo que tava no prototipo +const columns: GridColDef[] = [ + { field: 'id', headerName: 'ID', width: 35 }, + { field: 'acoes', headerName: 'Ações', width: 65 }, + { field: 'sigla', headerName: 'Sigla', width: 65 }, + { field: 'porc', headerName: 'Porc.', width: 65 }, + { field: 'quantidade', headerName: 'Quantidade', width: 65 }, + { field: 'precoAtual', headerName: 'Preço atual', width: 65 }, + { field: 'precoMedio', headerName: 'Preço médio', width: 65 }, + { field: 'diferenca', headerName: 'Diferença', width: 65 }, + { field: 'valorTotal', headerName: 'Valor total', width: 65 }, + + ]; + + // São os registros que vem do banco de dados + interface DBHistoric { //trouxe da tela de historico + id: number, + nomeAtivo: string, + sigla: string, + execucao: string, + quantidade: number, + data: string, + preco: number + } + + //passo tudo que esta em field para essa interface...verificar se esta ok os nomes e os tipos. + interface Carteir { + id: number, + ativo: string, + sigla: string, + porc:number, + quantidade: number, + precoAtual: number, + precoMedio: number, + diferenca: number, + valorTotal:number, + } + + + +export const Carteira = () => { + + const auth = useAuth(); + const token = auth.getToken(); + const [carteir, setCarteir] = useState(); + + //vamos ter que mexer na forma como esses dados vem do banco...estou um pouco incerto dessa parte + + const getCarteir = () => { + //estou puxando os mesmos dados do historico + Axios.post("/ativo/historico",{ + token: token + } + ).then(function(response){ + setCarteir(response.data.historico); + }).catch(function (error) { + console.log(error); + }) + } + + useEffect(() => { + getCarteir(); + }, [ ]) -const Carteira = () => { - - return (

    Invext - Minha Carteira

    @@ -21,6 +84,13 @@ return (
    + From 07cbc26f196f25e28e8a19efa4f19fc9f1703fbd Mon Sep 17 00:00:00 2001 From: LeonardoPadre Date: Thu, 1 Sep 2022 18:25:10 -0300 Subject: [PATCH 105/146] fix: Diminuindo o tempo de login Co-authored-by: zjosuez --- Back/src/controller/UserController.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Back/src/controller/UserController.js b/Back/src/controller/UserController.js index f5eb600..81b016a 100755 --- a/Back/src/controller/UserController.js +++ b/Back/src/controller/UserController.js @@ -71,8 +71,8 @@ router.post("/login", async (req, res) => { // Quando o usuario fizer login, o banco de dados // com todos os ativos eh atualizado - await AtivosB3.updateAtivosB3(). - then(async () => { + //await AtivosB3.updateAtivosB3(). + /*then(async () => { return res.json({ erro: false, message: "Login realizado com sucesso!", @@ -83,8 +83,14 @@ router.post("/login", async (req, res) => { erro: true, message: "Login nao realizado com sucesso!!" }); - }); + });*/ + AtivosB3.updateAtivosB3(); + return res.json({ + erro: false, + message: "Login realizado com sucesso!", + token + }); } } }); From 4055421e7388546e2de7f4acdb7bb507db3194e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Thu, 1 Sep 2022 18:42:24 -0300 Subject: [PATCH 106/146] fix: corrigido bug na venda de ativos Co-authored-by: LeonardoPadre --- Back/src/controller/AtivoController.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index ed6e6a3..7fcc51f 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -69,12 +69,23 @@ router.post("/vender", auth, async (req,res) => { }, }) - if (ativo_vendido[0] == null) { - var totalQuantidade = ativo_comprado[0].total - 0; + + if (ativo_comprado[0] == null) { + return res.status(400).json({ + erro: true, + message: "Não existe ativo para vender" + }) } else { - var totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; + if (ativo_vendido[0] == null) { + var totalQuantidade = ativo_comprado[0].total - 0; + } else { + var totalQuantidade = ativo_comprado[0].total - ativo_vendido[0].total; + } } + + + const nova_venda = { id_usuario: req.usuario.id, nomeAtivo: req.body.nomeAtivo, From 57dfa55c61cd37b2bc43ece82dd206eead56e01b Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Thu, 1 Sep 2022 19:47:30 -0300 Subject: [PATCH 107/146] puxando os dados do back Co-authored-by: Luciano Freitas --- Back/src/controller/AtivoController.js | 2 +- Front/package.json | 4 + Front/src/pages/CarteiraUsuario/Carteira.css | 14 +- Front/src/pages/CarteiraUsuario/Carteira.tsx | 198 ++++++++++--------- 4 files changed, 117 insertions(+), 101 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index ed6e6a3..6157c03 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -132,7 +132,7 @@ router.get("/historico", auth, async (req,res) => { }) // Rota que envia o patrimonio do usuario -router.get("/patrimonio", auth, async (req, res) => { +router.post("/patrimonio", auth, async (req, res) => { await Ativo.findAll({ attributes: [ [sequelize.fn('DISTINCT', sequelize.col('sigla')), 'sigla'], diff --git a/Front/package.json b/Front/package.json index 60c3b2e..4b6cdd4 100644 --- a/Front/package.json +++ b/Front/package.json @@ -9,6 +9,10 @@ "preview": "vite preview" }, "dependencies": { + "@emotion/react": "^11.10.4", + "@emotion/styled": "^11.10.4", + "@mui/material": "^5.10.3", + "@mui/x-data-grid": "^5.16.0", "axios": "^0.27.2", "date-fns": "^2.29.1", "module-alias": "^2.2.2", diff --git a/Front/src/pages/CarteiraUsuario/Carteira.css b/Front/src/pages/CarteiraUsuario/Carteira.css index d6f2114..edd5838 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.css +++ b/Front/src/pages/CarteiraUsuario/Carteira.css @@ -54,11 +54,19 @@ color: rgb(255, 255, 255); font-weight: bold; } +.div-ativos-patrimonio ul { + color: #000000; + padding-right: 10px; + display: flex; +} +.div-ativos-patrimonio li{ + padding: 10px; +} -.div-ativos-patrimonio { +.div-grid-patrimonio { + height: 100px; + width: 100%; margin-left: 0.5em; - display: flex; - flex-direction: row; padding: 1.5%; margin-top: 1.0em; height: 22em; diff --git a/Front/src/pages/CarteiraUsuario/Carteira.tsx b/Front/src/pages/CarteiraUsuario/Carteira.tsx index 56954c8..5f41c64 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.tsx +++ b/Front/src/pages/CarteiraUsuario/Carteira.tsx @@ -1,120 +1,124 @@ -import './Carteira.css'; -import { useState,useEffect } from "react"; -import {FaMoneyBillWave} from 'react-icons/fa'; -import {BsEye, BsEyeSlash} from 'react-icons/bs'; -import {AiOutlineRise} from 'react-icons/ai' -import Axios from 'axios'; -//preciso verificar todas as importaçoes restantes e corrigir essa importação -import { DataGrid, GridColDef} from '@mui/x-data-grid'; -import { useAuth } from '../../services/Provider'; +import "./Carteira.css"; +import { useState, useEffect } from "react"; +import { FaMoneyBillWave } from "react-icons/fa"; +import { BsEye, BsEyeSlash } from "react-icons/bs"; +import { AiOutlineRise } from "react-icons/ai"; +import Axios from "axios"; +import { DataGrid, GridColDef } from "@mui/x-data-grid"; +import { useAuth } from "../../services/Provider"; //base da tabela...estou usando tudo que tava no prototipo const columns: GridColDef[] = [ - { field: 'id', headerName: 'ID', width: 35 }, - { field: 'acoes', headerName: 'Ações', width: 65 }, - { field: 'sigla', headerName: 'Sigla', width: 65 }, - { field: 'porc', headerName: 'Porc.', width: 65 }, - { field: 'quantidade', headerName: 'Quantidade', width: 65 }, - { field: 'precoAtual', headerName: 'Preço atual', width: 65 }, - { field: 'precoMedio', headerName: 'Preço médio', width: 65 }, - { field: 'diferenca', headerName: 'Diferença', width: 65 }, - { field: 'valorTotal', headerName: 'Valor total', width: 65 }, - - ]; - - // São os registros que vem do banco de dados - interface DBHistoric { //trouxe da tela de historico - id: number, - nomeAtivo: string, - sigla: string, - execucao: string, - quantidade: number, - data: string, - preco: number - } - - //passo tudo que esta em field para essa interface...verificar se esta ok os nomes e os tipos. - interface Carteir { - id: number, - ativo: string, - sigla: string, - porc:number, - quantidade: number, - precoAtual: number, - precoMedio: number, - diferenca: number, - valorTotal:number, - } + //{ field: "id", headerName: "ID", width: 35 }, + { field: "nomeAtivo", headerName: "Ações", width: 100 }, + { field: "sigla", headerName: "Sigla", width: 100 }, + { field: "porcentagem", headerName: "Porc.", width: 100 }, + { field: "quantidade", headerName: "Quantidade", width: 100 }, + { field: "precoAtual", headerName: "Preço atual", width: 100 }, + { field: "precoMedio", headerName: "Preço médio", width: 100 }, + { field: "diferenca", headerName: "Diferença", width: 100 }, + { field: "valorTotal", headerName: "Valor total", width: 100 }, +]; +// São os registros que vem do banco de dados +interface DBHistoric { + //trouxe da tela de historico + id: number; + nomeAtivo: string; + sigla: string; + execucao: string; + quantidade: number; + data: string; + preco: number; +} +//passo tudo que esta em field para essa interface...verificar se esta ok os nomes e os tipos. +interface Carteir { + id: number; + nomeAtivo: string; + sigla: string; + porcentagem: number; + quantidade: number; + precoAtual: number; + precoMedio: number; + diferenca: number; + valorTotal: number; +} export const Carteira = () => { + const auth = useAuth(); + const token = auth.getToken(); + const [carteir, setCarteir] = useState(); - const auth = useAuth(); - const token = auth.getToken(); - const [carteir, setCarteir] = useState(); - - //vamos ter que mexer na forma como esses dados vem do banco...estou um pouco incerto dessa parte + //vamos ter que mexer na forma como esses dados vem do banco...estou um pouco incerto dessa parte - const getCarteir = () => { - //estou puxando os mesmos dados do historico - Axios.post("/ativo/historico",{ - token: token - } - ).then(function(response){ - setCarteir(response.data.historico); - }).catch(function (error) { - console.log(error); - }) - } + - useEffect(() => { - getCarteir(); - }, [ ]) + const getCarteir = () => { + //estou puxando os mesmos dados do historico + Axios.post("/ativo/patrimonio", { + token: token, + }) + .then(function (response) { + setCarteir(response.data.ativos.map((ativo:Carteir, index:number) => ({ + id: index, + nomeAtivo: ativo.nomeAtivo, + sigla: ativo.sigla, + porcentagem: ativo.porcentagem, + quantidade: ativo.quantidade, + precoAtual: ativo.precoAtual, + precoMedio: ativo.precoMedio, + diferenca: ativo.diferenca, + valorTotal: ativo.valorTotal, + }))); + console.log(response.data.ativos) + }) + .catch(function (error) { + console.log(error); + }); + + }; -return ( -
    -

    Invext - Minha Carteira

    -
    -
    - - -

    Patrimônio

    - + useEffect(() => { + getCarteir(); + }, []); -
    -
    + return ( +
    +

    Invext - Minha Carteira

    +
    +
    + +

    Patrimônio

    + +
    +
    + + +
    + {carteir ? ( - - - + /> + ) : null} +
    -
    +
    -
    -
    - - -

    Rentabilidade

    - - -
    -
    - - - -
    +
    +
    + +

    Rentabilidade

    +
    +
    +
    -) - -} + ); +}; -export default Carteira \ No newline at end of file +export default Carteira; From e28503c06a83aa58569473776e4690cd3b8cfcac Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Thu, 1 Sep 2022 23:18:46 -0300 Subject: [PATCH 108/146] Conserta bug na tela Carteira. --- Front/src/pages/CarteiraUsuario/Carteira.css | 26 ++++++++++---------- Front/src/pages/CarteiraUsuario/Carteira.tsx | 16 ++++++------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Front/src/pages/CarteiraUsuario/Carteira.css b/Front/src/pages/CarteiraUsuario/Carteira.css index edd5838..21c807c 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.css +++ b/Front/src/pages/CarteiraUsuario/Carteira.css @@ -15,6 +15,7 @@ .div-patrimonio{ + overflow: scroll; display: flex; flex-direction: column; padding: 2.5%; @@ -64,16 +65,16 @@ } .div-grid-patrimonio { - height: 100px; - width: 100%; - margin-left: 0.5em; - padding: 1.5%; - margin-top: 1.0em; - height: 22em; + height: 70%; + width: 90%; + margin-left: 1.5em; + padding: 2.0%; + margin-top: 0.5em; + height: 30em; background-color: #dcdcdc; border: 2px solid; - border-color: black; - border-radius: 40px; + border-color: #0000; + border-radius: 25px; } @@ -112,13 +113,12 @@ margin-left: 66%; display: flex; flex-direction: row; - padding: 1.5%; - margin-top: 1.4em; + padding: 2.0%; + margin-top: 0.8em; width: 30%; height: 100%; background-color: #dcdcdc; - border: 2px solid; - border-color: black; - border-radius: 40px; + border: 2px; + border-radius: 25px; } diff --git a/Front/src/pages/CarteiraUsuario/Carteira.tsx b/Front/src/pages/CarteiraUsuario/Carteira.tsx index 5f41c64..44085a4 100644 --- a/Front/src/pages/CarteiraUsuario/Carteira.tsx +++ b/Front/src/pages/CarteiraUsuario/Carteira.tsx @@ -10,14 +10,14 @@ import { useAuth } from "../../services/Provider"; //base da tabela...estou usando tudo que tava no prototipo const columns: GridColDef[] = [ //{ field: "id", headerName: "ID", width: 35 }, - { field: "nomeAtivo", headerName: "Ações", width: 100 }, - { field: "sigla", headerName: "Sigla", width: 100 }, - { field: "porcentagem", headerName: "Porc.", width: 100 }, - { field: "quantidade", headerName: "Quantidade", width: 100 }, + { field: "nomeAtivo", headerName: "Ações", width: 80 }, + { field: "sigla", headerName: "Sigla", width: 80 }, + { field: "porcentagem", headerName: "Porc.", width: 80 }, + { field: "quantidade", headerName: "Quant.", width: 80 }, { field: "precoAtual", headerName: "Preço atual", width: 100 }, { field: "precoMedio", headerName: "Preço médio", width: 100 }, - { field: "diferenca", headerName: "Diferença", width: 100 }, - { field: "valorTotal", headerName: "Valor total", width: 100 }, + { field: "diferenca", headerName: "Diferença", width: 80 }, + { field: "valorTotal", headerName: "Valor total", width: 80 }, ]; // São os registros que vem do banco de dados @@ -100,8 +100,8 @@ export const Carteira = () => { ) : null} From a78d57dc7efe4002defd56a06f37394cdd1ac363 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 2 Sep 2022 12:02:51 -0300 Subject: [PATCH 109/146] =?UTF-8?q?inicio=20da=20manipula=C3=A7=C3=A3o=20d?= =?UTF-8?q?a=20sidebar=20e=20cria=C3=A7=C3=A3o=20de=20rota=20p=20nova=20te?= =?UTF-8?q?la?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Rentabilidade/rentabilidade.css | 0 Front/src/pages/Rentabilidade/rentabilidade.tsx | 15 +++++++++++++++ Front/src/pages/Sidebar/SidebarData.tsx | 9 +++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Front/src/pages/Rentabilidade/rentabilidade.css create mode 100644 Front/src/pages/Rentabilidade/rentabilidade.tsx diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css new file mode 100644 index 0000000..e69de29 diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx new file mode 100644 index 0000000..01eb533 --- /dev/null +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -0,0 +1,15 @@ +import "../rentabilidade.css"; +import { useState, useEffect } from "react"; +import { FaMoneyBillWave } from "react-icons/fa"; +import { BsEye, BsEyeSlash } from "react-icons/bs"; +import { AiOutlineRise } from "react-icons/ai"; +import Axios from "axios"; +import { DataGrid, GridColDef } from "@mui/x-data-grid"; +import { useAuth } from "../../services/Provider"; + +export const Rentabilidade = () => { + const auth = useAuth(); + const token = auth.getToken(); +} + +export default Rentabilidade; \ No newline at end of file diff --git a/Front/src/pages/Sidebar/SidebarData.tsx b/Front/src/pages/Sidebar/SidebarData.tsx index 31ef065..5f50e2a 100644 --- a/Front/src/pages/Sidebar/SidebarData.tsx +++ b/Front/src/pages/Sidebar/SidebarData.tsx @@ -5,8 +5,13 @@ import * as IoIcons from 'react-icons/io' export const SidebarData = [ { - title:'Carteira', - path:'carteira', + title:'Patrimônio', + path:'patrimonio', + icon: , + }, + { + title:'Rentabilidade', + path:'rentabilidade', icon: , }, { From 6475d4ce4d72c362df06fa400e41a72b0d112e4e Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Fri, 2 Sep 2022 12:57:17 -0300 Subject: [PATCH 110/146] feat: excluir registro de ativo --- .../pages/HistoricoDeAcoes/excluirAtivo.tsx | 20 +++++ .../src/pages/HistoricoDeAcoes/historico.tsx | 86 +++++++++++-------- 2 files changed, 72 insertions(+), 34 deletions(-) create mode 100644 Front/src/pages/HistoricoDeAcoes/excluirAtivo.tsx diff --git a/Front/src/pages/HistoricoDeAcoes/excluirAtivo.tsx b/Front/src/pages/HistoricoDeAcoes/excluirAtivo.tsx new file mode 100644 index 0000000..48af30d --- /dev/null +++ b/Front/src/pages/HistoricoDeAcoes/excluirAtivo.tsx @@ -0,0 +1,20 @@ +import axios from "axios" +import { returnToken } from "../../services/authToken" + +export const excluirAtivo = (id:string) => { + const token = returnToken(); + + if(confirm('Deseja realmente excluir esse ativo?')){ + + axios.post('/ativo/excluir', { + token: token, + id: id + }).then(function(response){ + alert(response.data.message); + + }).catch(function(error){ + alert(error.response.data.message); + }) + } + +} \ No newline at end of file diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index b2ec2a2..f003715 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -1,12 +1,13 @@ import './historico.css'; -import * as FaIcons from 'react-icons/fa'; -import * as AiIcons from 'react-icons/ai'; -import { DataGrid, GridColDef} from '@mui/x-data-grid'; +import { BiEdit } from 'react-icons/bi'; +import { RiDeleteBinLine } from 'react-icons/ri' +import { DataGrid, GridActionsCellItem, GridColDef } from '@mui/x-data-grid'; import { useAuth } from '../../services/Provider'; -import { useEffect, useState} from 'react'; +import { useEffect, useState } from 'react'; import Axios from 'axios'; import { capitalize } from '@mui/material'; import { format } from 'date-fns'; +import { excluirAtivo } from './excluirAtivo'; const columns: GridColDef[] = [ { field: 'id', headerName: 'ID', width: 70 }, @@ -16,7 +17,28 @@ const columns: GridColDef[] = [ { field: 'quantidade', headerName: 'Quantidade', width: 130 }, { field: 'negociação', headerName: 'Negociação', width: 130 }, { field: 'valor', headerName: 'Valor', width: 130 }, + { + field: 'edit-column', + headerName: ' ', + sortable: false, + disableColumnMenu: true, + width: 80, + renderCell: (params) => [ +
    + } + label='Editar' + onClick={() => null} + /> + } + label='Deletar' + onClick={() => excluirAtivo(params.id.toString())} + /> +
    + ], + }, ]; // São os registros que vem do banco de dados @@ -42,58 +64,54 @@ interface Historic { } export const HistoricoDeAcoes = () => { - + const auth = useAuth(); const token = auth.getToken(); - const [historic, setHistoric] = useState(); + const [historic, setHistoric] = useState(); // Altera a forma de visualização dos dados que vem do banco const refactorHistoric = (dbHistoric: DBHistoric[]) => { - if(dbHistoric){ - return dbHistoric.map((ativo:DBHistoric) => ({ + if (dbHistoric) { + return dbHistoric.map((ativo: DBHistoric) => ({ id: ativo.id, ativo: ativo.nomeAtivo, sigla: ativo.sigla, ordem: capitalize(ativo.execucao), quantidade: ativo.quantidade, negociação: format(new Date(ativo.data), 'dd/MM/yyyy'), - valor: `R$ ${ativo.preco.toFixed(2)}` + valor: `R$ ${ativo.preco.toFixed(2)}` })) - - } else{ + + } else { return []; } } - - const getHistoric = () => { - Axios.post("/ativo/historico",{ + // Pega o historico do usuario quando o componente é renderizado + useEffect(() => { + Axios.post("/ativo/historico", { token: token - } - ).then(function(response){ - setHistoric(refactorHistoric(response.data.historico)); - }).catch(function (error) { - console.log(error); + } + ).then(function (response) { + setHistoric(refactorHistoric(response.data.historico)); + }).catch(function (error) { + console.log(error); }) - } - - useEffect(() => { - getHistoric(); - }, [ ]) + }) return (

    Histórico de Ativos

    -
    - {historic ? - - :null} +
    + {historic ? + false} + /> + : null}
    From 5fd5cfa81742574a7b911d4bac4f30ffa5cfac88 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 2 Sep 2022 14:50:36 -0300 Subject: [PATCH 111/146] ajustando a sidebar e a rota de rentabilidade Co-authored-by: Luciano Freitas --- Front/src/App.css | 1 + 1 file changed, 1 insertion(+) diff --git a/Front/src/App.css b/Front/src/App.css index d99a300..aed8d42 100644 --- a/Front/src/App.css +++ b/Front/src/App.css @@ -4,3 +4,4 @@ font-style: normal; font-weight: 400; } + From 4f5ffbc6c8e34ac6d82e5946f56d0480d7dfe205 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 2 Sep 2022 14:54:26 -0300 Subject: [PATCH 112/146] =?UTF-8?q?ajustando=20a=20sidebar=20e=20tra=C3=A7?= =?UTF-8?q?ando=20as=20rotas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/App.tsx | 2 ++ Front/src/pages/Rentabilidade/rentabilidade.tsx | 16 ++++------------ Front/src/pages/Sidebar/SidebarData.tsx | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index 5e9025a..a4f7256 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -8,6 +8,7 @@ import { AuthProvider} from './services/Provider'; import { RequireAuth } from './services/requireAuth'; import { Sidebar } from './pages/Sidebar/Sidebar'; import { PublicRoute } from './services/publicRoute'; +import { Rentabilidade } from './pages/Rentabilidade/rentabilidade'; function App() { @@ -28,6 +29,7 @@ function App() { }> } /> } /> + } /> diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index 01eb533..ca179c6 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,15 +1,7 @@ -import "../rentabilidade.css"; -import { useState, useEffect } from "react"; -import { FaMoneyBillWave } from "react-icons/fa"; -import { BsEye, BsEyeSlash } from "react-icons/bs"; -import { AiOutlineRise } from "react-icons/ai"; -import Axios from "axios"; -import { DataGrid, GridColDef } from "@mui/x-data-grid"; -import { useAuth } from "../../services/Provider"; + export const Rentabilidade = () => { - const auth = useAuth(); - const token = auth.getToken(); + return( + <> + ); } - -export default Rentabilidade; \ No newline at end of file diff --git a/Front/src/pages/Sidebar/SidebarData.tsx b/Front/src/pages/Sidebar/SidebarData.tsx index 5f50e2a..a45b5f5 100644 --- a/Front/src/pages/Sidebar/SidebarData.tsx +++ b/Front/src/pages/Sidebar/SidebarData.tsx @@ -7,12 +7,12 @@ export const SidebarData = [ { title:'Patrimônio', path:'patrimonio', - icon: , + icon: , }, { title:'Rentabilidade', path:'rentabilidade', - icon: , + icon: , }, { title:'Ações', From f6f22ab948d0be6f8a3dd79cff320bebf820816b Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 2 Sep 2022 16:21:03 -0300 Subject: [PATCH 113/146] =?UTF-8?q?iniciando=20a=20base=20da=20estiliza?= =?UTF-8?q?=C3=A7=C3=A3o=20da=20tela=20de=20rentabilidade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Rentabilidade/rentabilidade.css | 56 +++++++++++++++++++ .../src/pages/Rentabilidade/rentabilidade.tsx | 14 ++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css index e69de29..a7a8bbc 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.css +++ b/Front/src/pages/Rentabilidade/rentabilidade.css @@ -0,0 +1,56 @@ +.background-img-rentabilidade { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + position: absolute; + height: 100vh; + width:100vw; + background-image: url('../../assets/background.jpeg'); + background-size: cover; + background-repeat: no-repeat; + font-family: 'Roboto Flex'; +} + +.div-rentabilidade{ + overflow: scroll; + display: flex; + flex-direction: column; + padding: 2.5%; + width: 70%; + height: 55%; + background-color: #A9A9A9; + border-radius: 40px; + margin-bottom: 1.2%; +} + +.titulo-rentabilidade{ + text-align: center; + font-size: 2.5em; + margin-bottom: 0.5em; + color: white; + font-weight: bold; +} + +.div-grid-rentabilidade { + height: 100%; + width: 40%; + height: 20em; + margin-left: 1.5em; + padding: 2.0%; + margin-top: 0.5em; + background-color: #dcdcdc; + border: 2px solid; + border-color: #0000; + border-radius: 25px; + +} + +.barra-rentabilidade { + background-color: #241453; + margin-top: 0.4em; + margin-left: -2.6em; + margin-right: 5%; + width: 0.5em; + height: 95%; +} \ No newline at end of file diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index ca179c6..f368cc3 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,7 +1,19 @@ +import "./rentabilidade.css"; export const Rentabilidade = () => { return( - <> +
    +

    Rentabilidade

    +
    + +
    + + +
    +
    +
    +
    +
    ); } From f8d1a0a55d614147cfc0ec536ce0f2830bd74067 Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 2 Sep 2022 16:33:07 -0300 Subject: [PATCH 114/146] corrigindo a rota de patrimonio --- Front/src/App.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Front/src/App.tsx b/Front/src/App.tsx index a4f7256..6af8675 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -9,6 +9,7 @@ import { RequireAuth } from './services/requireAuth'; import { Sidebar } from './pages/Sidebar/Sidebar'; import { PublicRoute } from './services/publicRoute'; import { Rentabilidade } from './pages/Rentabilidade/rentabilidade'; +import { Patrimonio } from './pages/Patrimonio/Patrimonio'; function App() { @@ -30,6 +31,7 @@ function App() { } /> } /> } /> + } /> From 631cc80ab68eb4dc649e42fca1ce3729a9c9b71e Mon Sep 17 00:00:00 2001 From: Lucas Felipe Date: Fri, 2 Sep 2022 17:41:09 -0300 Subject: [PATCH 115/146] montando a base da tela de rentabilidade --- .../src/pages/Rentabilidade/rentabilidade.css | 41 +++++++++---------- .../src/pages/Rentabilidade/rentabilidade.tsx | 13 ++---- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css index a7a8bbc..15be273 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.css +++ b/Front/src/pages/Rentabilidade/rentabilidade.css @@ -13,44 +13,41 @@ } .div-rentabilidade{ - overflow: scroll; display: flex; flex-direction: column; - padding: 2.5%; + padding: 2%; width: 70%; - height: 55%; + height: 65%; background-color: #A9A9A9; - border-radius: 40px; - margin-bottom: 1.2%; + border-radius: 1cm; + margin-top: 0.5%; } .titulo-rentabilidade{ text-align: center; font-size: 2.5em; - margin-bottom: 0.5em; + margin-bottom: 0.3em; color: white; - font-weight: bold; + font-weight: bold; + margin-top: 5%; } -.div-grid-rentabilidade { - height: 100%; - width: 40%; - height: 20em; - margin-left: 1.5em; - padding: 2.0%; - margin-top: 0.5em; +.div-grid-rentabilidade { + width: 30%; + height: 25em; + margin-left: 65%; + margin-top: 2%; + padding: 2.0%; background-color: #dcdcdc; - border: 2px solid; - border-color: #0000; - border-radius: 25px; - + border: 2px solid black; + border-color:black; + border-radius: 15%; } .barra-rentabilidade { background-color: #241453; - margin-top: 0.4em; - margin-left: -2.6em; - margin-right: 5%; + margin-top: 2em; + margin-left: -5%; width: 0.5em; - height: 95%; + height: 15em; } \ No newline at end of file diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index f368cc3..9a2c990 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -4,16 +4,11 @@ import "./rentabilidade.css"; export const Rentabilidade = () => { return(
    -

    Rentabilidade

    -
    - -
    - - -
    -
    +

    Rentabilidade

    +
    +
    +
    -
    ); } From ac73e6aeca7e829bfe2e23b7fffd8d9796c60de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Teixeira?= Date: Fri, 2 Sep 2022 17:58:00 -0300 Subject: [PATCH 116/146] =?UTF-8?q?feat:=20implementado=20porcentagem=20e?= =?UTF-8?q?=20diferen=C3=A7a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: LeonardoPadre --- Back/src/util/AtivosB3Util.js | 38 +++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index c82138f..9fcee57 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -1,6 +1,7 @@ const Axios = require("axios"); const AtivosB3 = require("../models/AtivosB3") const Ativo = require("../models/Ativo"); +const sequelize = require('sequelize'); exports.updateAtivosB3 = async function () { let dt_ultimo_pregao; @@ -43,6 +44,7 @@ exports.updateAtivosB3 = async function () { exports.calculaPatrimonio = async function (siglas, id_usuario) { var lista = []; + var vTotal = 0; for (let sigla of siglas) { await Ativo.findAll({ attributes: [ @@ -58,8 +60,15 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { "sigla": sigla }, }).then(async (res) => { - let pPrecoMedio = 0, pQuantidade = 0, pTotal = 0; + let pPrecoMedio = 0, pQuantidade = 0, pTotal = 0, pDiferenca = 0, pTotalatt = 0; let pNomeAtivo, pSigla; + const precoAtual = await AtivosB3.findAll({ + attributes: ['valor_fechamento'], + where: { + "codigo_acao": sigla + } + }); + precoAtt = precoAtual[0].valor_fechamento; for (let result of res) { const { nomeAtivo } = result; const { sigla } = result; @@ -71,33 +80,36 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { pNomeAtivo = nomeAtivo; pSigla = sigla; if (execucao === "compra") { - pTotal += parseFloat(preco) * parseInt(quantidade); + pTotal += parseFloat(preco) * parseInt(quantidade); + pTotalatt += parseFloat(precoAtt) * parseInt(quantidade); pQuantidade += parseInt(quantidade); } else { - pTotal += (-1) * parseFloat(preco) * quantidade; + pTotal += (-1) * parseFloat(preco) * parseInt(quantidade); + pTotalatt += (-1) * parseFloat(preco) * parseInt(quantidade); pQuantidade += (-1) * parseInt(quantidade); } pPrecoMedio = pTotal / pQuantidade; } - - const precoAtual = await AtivosB3.findAll({ - attributes: ['valor_fechamento'], - where: { - "codigo_acao": sigla - } - }); + vTotal += pTotalatt; const patrimonio = { nomeAtivo: pNomeAtivo, sigla: pSigla, - porcentagem: 0, // falta calcular + porcentagem: ((pTotalatt / vTotal)*100).toFixed(2), // falta calcular quantidade: pQuantidade, precoAtual: precoAtual[0].valor_fechamento, precoMedio: parseFloat(pPrecoMedio.toFixed(2)), - diferenca: 0, // falta calcular - valorTotal: pTotal + diferenca: (pTotalatt - pTotal).toFixed(2), + valorTotal: pTotalatt } + lista.push(patrimonio); + + // Percorre os valores da lista e calcula a porcentagem. + for (let x of lista) { + const calculo = ((x.valorTotal / vTotal)*100).toFixed(2); + x.porcentagem = calculo; + } }); } return lista; From 3258a3288387ab6998530e20e29f4bde93b38b75 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Fri, 2 Sep 2022 21:14:05 -0300 Subject: [PATCH 117/146] refactor: tabela de historico --- .../src/pages/HistoricoDeAcoes/historico.tsx | 133 +++++++++--------- 1 file changed, 64 insertions(+), 69 deletions(-) diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index f003715..48b39fd 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -5,55 +5,14 @@ import { DataGrid, GridActionsCellItem, GridColDef } from '@mui/x-data-grid'; import { useAuth } from '../../services/Provider'; import { useEffect, useState } from 'react'; import Axios from 'axios'; -import { capitalize } from '@mui/material'; import { format } from 'date-fns'; import { excluirAtivo } from './excluirAtivo'; +import { parse } from 'date-fns/esm'; -const columns: GridColDef[] = [ - { field: 'id', headerName: 'ID', width: 70 }, - { field: 'ativo', headerName: 'Ativo', width: 130 }, - { field: 'sigla', headerName: 'Sigla', width: 130 }, - { field: 'ordem', headerName: 'Ordem', width: 130 }, - { field: 'quantidade', headerName: 'Quantidade', width: 130 }, - { field: 'negociação', headerName: 'Negociação', width: 130 }, - { field: 'valor', headerName: 'Valor', width: 130 }, - { - field: 'edit-column', - headerName: ' ', - sortable: false, - disableColumnMenu: true, - width: 80, - renderCell: (params) => [ -
    - } - label='Editar' - onClick={() => null} - /> - } - label='Deletar' - onClick={() => excluirAtivo(params.id.toString())} - /> -
    - - ], - }, -]; -// São os registros que vem do banco de dados -interface DBHistoric { - id: number, - nomeAtivo: string, - sigla: string, - execucao: string, - quantidade: number, - data: string, - preco: number -} // Registro que sera mostrado para o usuario -interface Historic { +interface Register { id: number, ativo: string, // == nomeAtivo sigla: string, @@ -67,36 +26,72 @@ export const HistoricoDeAcoes = () => { const auth = useAuth(); const token = auth.getToken(); - const [historic, setHistoric] = useState(); + // Todo o historico de compra e venda de ativos + const [historic, setHistoric] = useState(); + // Dita quando o historico deve ser puxado do backend + const [renderData, setRenderData] = useState(true); - // Altera a forma de visualização dos dados que vem do banco - const refactorHistoric = (dbHistoric: DBHistoric[]) => { - if (dbHistoric) { - return dbHistoric.map((ativo: DBHistoric) => ({ - id: ativo.id, - ativo: ativo.nomeAtivo, - sigla: ativo.sigla, - ordem: capitalize(ativo.execucao), - quantidade: ativo.quantidade, - negociação: format(new Date(ativo.data), 'dd/MM/yyyy'), - valor: `R$ ${ativo.preco.toFixed(2)}` - })) - } else { - return []; - } - } - // Pega o historico do usuario quando o componente é renderizado + // Pega o historico do usuario do backend useEffect(() => { - Axios.post("/ativo/historico", { - token: token + if (renderData) { + setRenderData(false); + Axios.post("/ativo/historico", { + token: token + } + ).then(function (response) { + setHistoric(response.data.historico); + }).catch(function (error) { + console.log(error); + }) } - ).then(function (response) { - setHistoric(refactorHistoric(response.data.historico)); - }).catch(function (error) { - console.log(error); - }) - }) + },[renderData]) + + + const columns: GridColDef[] = [ + { field: 'id', headerName: 'ID', width: 70 }, + { field: 'nomeAtivo', headerName: 'Ativo', width: 130 }, + { field: 'sigla', headerName: 'Sigla', width: 130 }, + { field: 'execucao', headerName: 'Ordem', width: 130 }, + { field: 'quantidade', headerName: 'Quantidade', width: 130 }, + { + field: 'data', + headerName: 'Negociação', + width: 130, + valueFormatter: (params) => format(parse(params.value,'yyyy-MM-dd',new Date),"dd/MM/yyyy") + }, + { + field: 'preco', + type: 'number', + headerName: 'Valor', + width: 130, + valueFormatter: (params) => `R$ ${params.value.toFixed(2)}` + }, + { + field: 'edit-column', + headerName: ' ', + sortable: false, + disableColumnMenu: true, + width: 80, + renderCell: (params) => [ +
    + } + label='Editar' + onClick={() => null} + /> + } + label='Deletar' + onClick={() => { + excluirAtivo(params.id.toString()); + setRenderData(true); + }} + /> +
    + ], + }, + ]; return (
    From 17a72c0246de75e688c7cfc23e5db7a960168eb2 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Fri, 2 Sep 2022 21:36:52 -0300 Subject: [PATCH 118/146] refactor: busca com valor pre definido --- .../src/components/BuscaAtivos/Busca.css | 0 .../src/components/BuscaAtivos/Busca.tsx | 14 +++++++++++--- .../A\303\247oes.tsx" | 3 ++- Front/src/pages/HistoricoDeAcoes/historico.tsx | 8 ++++---- 4 files changed, 17 insertions(+), 8 deletions(-) rename "Front/src/pages/Cadastro de A\303\247\303\265es/Busca.css" => Front/src/components/BuscaAtivos/Busca.css (100%) rename "Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" => Front/src/components/BuscaAtivos/Busca.tsx (83%) diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.css" b/Front/src/components/BuscaAtivos/Busca.css similarity index 100% rename from "Front/src/pages/Cadastro de A\303\247\303\265es/Busca.css" rename to Front/src/components/BuscaAtivos/Busca.css diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" b/Front/src/components/BuscaAtivos/Busca.tsx similarity index 83% rename from "Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" rename to Front/src/components/BuscaAtivos/Busca.tsx index 233e7f4..c2a20c6 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/Busca.tsx" +++ b/Front/src/components/BuscaAtivos/Busca.tsx @@ -12,6 +12,7 @@ interface Option { label: string } interface Props { + value: Assets, setValue: Function } @@ -32,8 +33,8 @@ export const BuscaAtivo = (props: Props) => { }, []); - const handleChange = (e:unknown) =>{ - if(e){ + const handleChange = (e: unknown) => { + if (e) { const option = e as Option; props.setValue(option.value); @@ -53,7 +54,14 @@ export const BuscaAtivo = (props: Props) => { isClearable components={{ DropdownIndicator: () => null, IndicatorSeparator: () => null }} onChange={handleChange} - + value={props.value ? + { + value: props.value, + label: props.value.nome.concat(' - ', props.value.sigla) + } + : + null + } /> ); } diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index b0d5372..75d8f68 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -6,7 +6,7 @@ import { useState } from "react"; import Axios from "axios"; import { useAuth } from '../../services/Provider'; import { useNavigate } from 'react-router-dom'; -import { BuscaAtivo } from './Busca'; +import { BuscaAtivo } from '../../components/BuscaAtivos/Busca'; interface Assets { nome: string, @@ -70,6 +70,7 @@ export const CadastroAcoes = () => {
    diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index 48b39fd..b6ca453 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -14,12 +14,12 @@ import { parse } from 'date-fns/esm'; // Registro que sera mostrado para o usuario interface Register { id: number, - ativo: string, // == nomeAtivo + nomeAtivo: string, sigla: string, - ordem: string, // == execucao + execucao: string, quantidade: number, - negociação: string, // == data - valor: string // == preco + data: string, + preco: string } export const HistoricoDeAcoes = () => { From 2d9ae730bf2300be3791d990f042e364833d7a2d Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Sat, 3 Sep 2022 09:58:34 -0300 Subject: [PATCH 119/146] =?UTF-8?q?altera=C3=A7=C3=B5es=20nos=20elementos?= =?UTF-8?q?=20da=20tabela?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Patrimonio/Patrimonio.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Front/src/pages/Patrimonio/Patrimonio.tsx b/Front/src/pages/Patrimonio/Patrimonio.tsx index 56f90b3..ed79eed 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.tsx +++ b/Front/src/pages/Patrimonio/Patrimonio.tsx @@ -10,14 +10,14 @@ import { useAuth } from "../../services/Provider"; //base da tabela...estou usando tudo que tava no prototipo const columns: GridColDef[] = [ //{ field: "id", headerName: "ID", width: 35 }, - { field: "nomeAtivo", headerName: "Ações", width: 80 }, + { field: "nomeAtivo", headerName: "Ações", width: 100 }, { field: "sigla", headerName: "Sigla", width: 80 }, { field: "porcentagem", headerName: "Porc.", width: 80 }, { field: "quantidade", headerName: "Quant.", width: 80 }, { field: "precoAtual", headerName: "Preço atual", width: 100 }, { field: "precoMedio", headerName: "Preço médio", width: 100 }, { field: "diferenca", headerName: "Diferença", width: 80 }, - { field: "valorTotal", headerName: "Valor total", width: 80 }, + { field: "valorTotal", headerName: "Valor total", width: 150 }, ]; //passo tudo que esta em field para essa interface...verificar se esta ok os nomes e os tipos. @@ -54,10 +54,10 @@ export const Patrimonio = () => { sigla: ativo.sigla, porcentagem: ativo.porcentagem, quantidade: ativo.quantidade, - precoAtual: ativo.precoAtual, - precoMedio: ativo.precoMedio, + precoAtual: `R$ ${ativo.precoAtual.toFixed(2)}`, + precoMedio: `R$ ${ativo.precoMedio.toFixed(2)}`, diferenca: ativo.diferenca, - valorTotal: ativo.valorTotal, + valorTotal: `R$ ${ativo.valorTotal.toFixed(2)}`, }))); console.log(response.data.ativos) }) From a6fb0f63b236863a2b1ad5016279ae73370f787f Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Sat, 3 Sep 2022 11:09:21 -0300 Subject: [PATCH 120/146] =?UTF-8?q?Altera=C3=A7=C3=B5es=20no=20css=20e=20n?= =?UTF-8?q?a=20tabela?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Patrimonio/Patrimonio.css | 25 ++++------------------- Front/src/pages/Patrimonio/Patrimonio.tsx | 20 +++++++++--------- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/Front/src/pages/Patrimonio/Patrimonio.css b/Front/src/pages/Patrimonio/Patrimonio.css index 9062325..40c530e 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.css +++ b/Front/src/pages/Patrimonio/Patrimonio.css @@ -13,18 +13,14 @@ } - .div-patrimonio{ - overflow: scroll; display: flex; flex-direction: column; padding: 2.5%; width: 60%; - height: 25%; + height: 50%; background-color: #A9A9A9; border-radius: 40px; - color: white; - margin-bottom: 1.2%; } .icon { @@ -43,18 +39,8 @@ margin-bottom: 0.5em; color: white; font-weight: bold; - margin-top: 2.5%; } -.div-titulo-patrimonio{ - margin-top: -1.6px; - margin-left: 1%; - display: flex; - flex-direction: row; - font-size: 1.5em; - color: rgb(255, 255, 255); - font-weight: bold; -} .div-ativos-patrimonio ul { color: #000000; padding-right: 10px; @@ -65,17 +51,14 @@ } .div-grid-patrimonio { - height: 70%; + height: 60%; width: 90%; - margin-left: 1.5em; + margin-left: 1.7em; padding: 2.0%; margin-top: 0.5em; - height: 30em; + height: 25em; background-color: #dcdcdc; - border: 2px solid; - border-color: #0000; border-radius: 25px; - } .barra-patrimonio { diff --git a/Front/src/pages/Patrimonio/Patrimonio.tsx b/Front/src/pages/Patrimonio/Patrimonio.tsx index ed79eed..0227abd 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.tsx +++ b/Front/src/pages/Patrimonio/Patrimonio.tsx @@ -10,14 +10,14 @@ import { useAuth } from "../../services/Provider"; //base da tabela...estou usando tudo que tava no prototipo const columns: GridColDef[] = [ //{ field: "id", headerName: "ID", width: 35 }, - { field: "nomeAtivo", headerName: "Ações", width: 100 }, - { field: "sigla", headerName: "Sigla", width: 80 }, + { field: "nomeAtivo", headerName: "Ações", width: 120 }, + { field: "sigla", headerName: "Sigla", width: 80}, { field: "porcentagem", headerName: "Porc.", width: 80 }, { field: "quantidade", headerName: "Quant.", width: 80 }, - { field: "precoAtual", headerName: "Preço atual", width: 100 }, - { field: "precoMedio", headerName: "Preço médio", width: 100 }, + { field: "precoAtual", headerName: "Preço atual", width: 100, type: 'number',valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align: 'center'}, + { field: "precoMedio", headerName: "Preço médio", width: 100, type: 'number', valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align: 'left'}, { field: "diferenca", headerName: "Diferença", width: 80 }, - { field: "valorTotal", headerName: "Valor total", width: 150 }, + { field: "valorTotal", headerName: "Valor total", width: 100, type: 'number', valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align:'left' }, ]; //passo tudo que esta em field para essa interface...verificar se esta ok os nomes e os tipos. @@ -33,7 +33,7 @@ interface Ativo { valorTotal: number; } -export const Patrimonio = () => { +export const Patrimonio = () => { const auth = useAuth(); const token = auth.getToken(); const [patrimonio, setPatrimonio] = useState(); @@ -54,10 +54,10 @@ export const Patrimonio = () => { sigla: ativo.sigla, porcentagem: ativo.porcentagem, quantidade: ativo.quantidade, - precoAtual: `R$ ${ativo.precoAtual.toFixed(2)}`, - precoMedio: `R$ ${ativo.precoMedio.toFixed(2)}`, + precoAtual: ativo.precoAtual, + precoMedio: ativo.precoMedio, diferenca: ativo.diferenca, - valorTotal: `R$ ${ativo.valorTotal.toFixed(2)}`, + valorTotal: ativo.valorTotal, }))); console.log(response.data.ativos) }) @@ -73,9 +73,9 @@ export const Patrimonio = () => { return (
    +

    Patrimônio

    -
    From 5bb7ac63adf749d000bc1251de69848849c6063a Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 5 Sep 2022 08:21:24 -0300 Subject: [PATCH 121/146] feat: modal editar ativo --- Front/src/components/BuscaAtivos/Busca.css | 1 - .../PopoverEditarAtivo/editarAtivo.css | 89 +++++++++++++++ .../PopoverEditarAtivo/editarAtivo.tsx | 103 ++++++++++++++++++ .../A\303\247oes.tsx" | 2 +- .../src/pages/HistoricoDeAcoes/historico.tsx | 61 +++++++---- 5 files changed, 231 insertions(+), 25 deletions(-) create mode 100644 Front/src/components/PopoverEditarAtivo/editarAtivo.css create mode 100644 Front/src/components/PopoverEditarAtivo/editarAtivo.tsx diff --git a/Front/src/components/BuscaAtivos/Busca.css b/Front/src/components/BuscaAtivos/Busca.css index a74d7e5..ea9e28c 100644 --- a/Front/src/components/BuscaAtivos/Busca.css +++ b/Front/src/components/BuscaAtivos/Busca.css @@ -1,5 +1,4 @@ .select{ - display: flex; text-align: center; color:black; font-size: 1.5em; diff --git a/Front/src/components/PopoverEditarAtivo/editarAtivo.css b/Front/src/components/PopoverEditarAtivo/editarAtivo.css new file mode 100644 index 0000000..0a48431 --- /dev/null +++ b/Front/src/components/PopoverEditarAtivo/editarAtivo.css @@ -0,0 +1,89 @@ +.MuiDialogContent-root{ + background-color: #060b26; + display: flex; + flex-direction: column; + padding: 10%; + +} + +.modalEdit{ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + color: white; + gap:1.25em; + padding: 2.5% 5%; + padding-bottom: 7.5%; +} +.modalEdit h2{ + width: 100%; + text-align: center; + font-size: 2em; + color: white; + font-weight: bold; +} +.busca-ativo{ + width: 100%; + font-size: 1em; + color:gray; + font-family: 'Roboto'; +} +.modalEdit-linebox { + width: 100%; + display: flex; + justify-content: space-between; +} +.modalEdit input{ + width: 45%; + background-color:white; + color:black; + border: none; + border-radius: 40px; + font-size: 1.2em; + text-align: center; + font-weight: bold; + padding: 0.5em; + +} +.modalEdit input::placeholder{ + color:gray; + font-family: 'Roboto'; + font-size: 1em; +} + +.data-input{ + font-size: 0.5em; +} +.MuiInputBase-root{ + font-family: 'Roboto'!important; + width: 48%!important; + border: none !important; + border-radius: 40px !important; +} +.MuiSelect-select{ + background-color:white !important; + color:black; + border: none !important; + border-radius: 40px !important; + font-size: 1.2em!important; + text-align: center; + font-weight: bold !important; + padding: 0.5em !important; + min-height: 0 !important; +} + +.modalEdit button{ + color:white; + border: none; + border-radius:70px; + font-size: 1em; + text-align: center; + padding: 0.5em 1.5em; + cursor: pointer; + transition: 0.25s; +} +.modalEdit button:hover{ + background: white; + color: black; +} diff --git a/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx b/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx new file mode 100644 index 0000000..192cb03 --- /dev/null +++ b/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx @@ -0,0 +1,103 @@ +import { Dialog, DialogContent, Button, Select, MenuItem } from "@mui/material" +import { useState } from "react"; +import { IMaskInput } from "react-imask"; +import { Register } from "../../pages/HistoricoDeAcoes/historico"; +import { BuscaAtivo } from "../BuscaAtivos/Busca" +import './editarAtivo.css' +interface Assets { + nome: string, + sigla: string +} + +interface Props { + isOpen: boolean, + setIsOpen: (isOpen: boolean) => void + initialValues: Register + callback: () => void +} +export const EditarAtivo = (p: Props) => { + + const initialAssets:Assets = {nome: p.initialValues.nomeAtivo, sigla:p.initialValues.sigla}; + const [assets, setAssets] = useState(initialAssets); // É o ativo + const [stockPrice, setStockPrice] = useState(p.initialValues.preco.toString()); //preço das ações + const [date, setDate] = useState(p.initialValues.data); + const [quantity, setQuantity] = useState(p.initialValues.quantidade.toString()); + const [type, setType] = useState(p.initialValues.execucao); // compra ou venda + //para a formatar a data + const [inputType, setInputType] = useState("text"); + + const closeModal = () => { + p.setIsOpen(false); + } + return ( + + + +

    Editar Ativo

    +
    + +
    +
    + ) => + setStockPrice(e.target.value)} + /> + ) => + setQuantity(e.target.value)} + /> +
    +
    + ) => + setDate(e.currentTarget.value)} + onFocus={() => setInputType("date")} + onBlur={() => setInputType("text")} + /> + +
    +
    + + +
    + +
    + +
    + ) +} + diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index 75d8f68..b1a4a2a 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -101,7 +101,7 @@ export const CadastroAcoes = () => { setQuantity(e.target.value)} />
    -
    +
    { @@ -31,6 +32,8 @@ export const HistoricoDeAcoes = () => { // Dita quando o historico deve ser puxado do backend const [renderData, setRenderData] = useState(true); + const [openEditModal, setEditModalOpen] = useState(false); + const [selectedRow, setSelectedRow] = useState(); // Pega o historico do usuario do backend useEffect(() => { @@ -45,7 +48,7 @@ export const HistoricoDeAcoes = () => { console.log(error); }) } - },[renderData]) + }, [renderData]) const columns: GridColDef[] = [ @@ -58,12 +61,12 @@ export const HistoricoDeAcoes = () => { field: 'data', headerName: 'Negociação', width: 130, - valueFormatter: (params) => format(parse(params.value,'yyyy-MM-dd',new Date),"dd/MM/yyyy") + valueFormatter: (params) => format(parse(params.value, 'yyyy-MM-dd', new Date), "dd/MM/yyyy") }, - { - field: 'preco', + { + field: 'preco', type: 'number', - headerName: 'Valor', + headerName: 'Valor', width: 130, valueFormatter: (params) => `R$ ${params.value.toFixed(2)}` }, @@ -78,7 +81,10 @@ export const HistoricoDeAcoes = () => { } label='Editar' - onClick={() => null} + onClick={() => { + setSelectedRow(params.row); + setEditModalOpen(true); + }} /> } @@ -94,21 +100,30 @@ export const HistoricoDeAcoes = () => { ]; return ( -
    -

    Histórico de Ativos

    -
    -
    - {historic ? - false} - /> - : null} + <> +
    +

    Histórico de Ativos

    +
    +
    + {historic ? + false} + /> + : null} +
    -
    + {openEditModal && + setRenderData(true)} + />} + ) } From 7b70eb3061d9ac01ddaece0903ed1a52beac0f60 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 5 Sep 2022 09:11:46 -0300 Subject: [PATCH 122/146] =?UTF-8?q?feat:=20integra=C3=A7=C3=A3o=20de=20edi?= =?UTF-8?q?tar=20ativo=20com=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PopoverEditarAtivo/editarAtivo.tsx | 53 ++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx b/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx index 192cb03..d515008 100644 --- a/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx +++ b/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx @@ -1,7 +1,9 @@ import { Dialog, DialogContent, Button, Select, MenuItem } from "@mui/material" +import axios from "axios"; import { useState } from "react"; import { IMaskInput } from "react-imask"; import { Register } from "../../pages/HistoricoDeAcoes/historico"; +import { returnToken } from "../../services/authToken"; import { BuscaAtivo } from "../BuscaAtivos/Busca" import './editarAtivo.css' interface Assets { @@ -17,7 +19,10 @@ interface Props { } export const EditarAtivo = (p: Props) => { - const initialAssets:Assets = {nome: p.initialValues.nomeAtivo, sigla:p.initialValues.sigla}; + const token = returnToken(); + const [error, setError] = useState(""); + + const initialAssets: Assets = { nome: p.initialValues.nomeAtivo, sigla: p.initialValues.sigla }; const [assets, setAssets] = useState(initialAssets); // É o ativo const [stockPrice, setStockPrice] = useState(p.initialValues.preco.toString()); //preço das ações const [date, setDate] = useState(p.initialValues.data); @@ -25,14 +30,50 @@ export const EditarAtivo = (p: Props) => { const [type, setType] = useState(p.initialValues.execucao); // compra ou venda //para a formatar a data const [inputType, setInputType] = useState("text"); - + const closeModal = () => { p.setIsOpen(false); } + + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + + setError(""); + if (!assets) { + setError("Selecione um ativo"); + + } else if (parseInt(quantity) <= 0) { + setError("É necessário inserir uma quantidade válida"); + + } else if (parseInt(stockPrice) <= 0) { + setError("É necessário inserir um valor válido"); + + } else{ + axios.post("/ativo/editar", + { + token: token, + id: p.initialValues.id, + sigla: assets.sigla, + preco: stockPrice, + quantidade: quantity + + }).then(function (response) { + alert(response.data.message); + p.callback(); + closeModal(); + + }).catch(function (error) { + const message = error.response.data.message; + setError(message); + }) + } + } + return ( -
    +

    Editar Ativo

    { value={type} onChange={(e) => setType(e.target.value)} placeholder="Ordem" - > Compra Venda
    - - + +
    + {error &&

    {error}

    }
    From a477cd949061eb2ac6173aa133da863cde487441 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 5 Sep 2022 11:01:04 -0300 Subject: [PATCH 123/146] =?UTF-8?q?bug:=20estiliza=C3=A7=C3=A3o=20busca=20?= =?UTF-8?q?ativo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/components/BuscaAtivos/Busca.css | 3 --- Front/src/components/PopoverEditarAtivo/editarAtivo.css | 9 ++++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Front/src/components/BuscaAtivos/Busca.css b/Front/src/components/BuscaAtivos/Busca.css index ea9e28c..5608140 100644 --- a/Front/src/components/BuscaAtivos/Busca.css +++ b/Front/src/components/BuscaAtivos/Busca.css @@ -15,9 +15,6 @@ margin-left: 10%; width: 90% !important; cursor: text; - display: flex; - justify-content: center; - align-items: center; } .react-select__indicators{ diff --git a/Front/src/components/PopoverEditarAtivo/editarAtivo.css b/Front/src/components/PopoverEditarAtivo/editarAtivo.css index 0a48431..2bf4ed2 100644 --- a/Front/src/components/PopoverEditarAtivo/editarAtivo.css +++ b/Front/src/components/PopoverEditarAtivo/editarAtivo.css @@ -2,7 +2,6 @@ background-color: #060b26; display: flex; flex-direction: column; - padding: 10%; } @@ -14,7 +13,7 @@ color: white; gap:1.25em; padding: 2.5% 5%; - padding-bottom: 7.5%; + padding-bottom: 5%; } .modalEdit h2{ width: 100%; @@ -24,9 +23,9 @@ font-weight: bold; } .busca-ativo{ - width: 100%; - font-size: 1em; - color:gray; + display: block !important; + width: 100% !important; + font-size: 0.8em !important; font-family: 'Roboto'; } .modalEdit-linebox { From af936ddb7cae99f751aeeee143fb79f3a213101b Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 5 Sep 2022 16:39:57 -0300 Subject: [PATCH 124/146] refactor: titulo editar ativo --- Front/src/components/PopoverEditarAtivo/editarAtivo.css | 1 + 1 file changed, 1 insertion(+) diff --git a/Front/src/components/PopoverEditarAtivo/editarAtivo.css b/Front/src/components/PopoverEditarAtivo/editarAtivo.css index 2bf4ed2..bfbdd93 100644 --- a/Front/src/components/PopoverEditarAtivo/editarAtivo.css +++ b/Front/src/components/PopoverEditarAtivo/editarAtivo.css @@ -16,6 +16,7 @@ padding-bottom: 5%; } .modalEdit h2{ + font-family: 'Roboto Flex'; width: 100%; text-align: center; font-size: 2em; From 97680068b1e171a58fa0cc1b1ca7817975e0e72a Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Mon, 5 Sep 2022 17:35:16 -0300 Subject: [PATCH 125/146] =?UTF-8?q?altera=C3=A7=C3=B5es=20no=20css=20e=20e?= =?UTF-8?q?xclus=C3=A3o=20de=20algumas=20coisas=20que=20n=C3=A3o=20estavam?= =?UTF-8?q?=20sendo=20utilizadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Patrimonio/Patrimonio.css | 34 ++++++----------------- Front/src/pages/Patrimonio/Patrimonio.tsx | 25 +++++++---------- 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/Front/src/pages/Patrimonio/Patrimonio.css b/Front/src/pages/Patrimonio/Patrimonio.css index 40c530e..f349c36 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.css +++ b/Front/src/pages/Patrimonio/Patrimonio.css @@ -19,20 +19,10 @@ padding: 2.5%; width: 60%; height: 50%; - background-color: #A9A9A9; + background-color: rgba(10, 17, 79, 0.904); border-radius: 40px; } -.icon { - padding-right: 1%; - color: white; -} -.eye{ - padding-left: 1%; - color: black; - cursor: pointer; -} - .titulo-patrimonio{ text-align: center; font-size: 2.5em; @@ -50,22 +40,16 @@ padding: 10px; } -.div-grid-patrimonio { +.div-grid-patrimonio { + border: 2px solid; + border-color: black; height: 60%; - width: 90%; - margin-left: 1.7em; - padding: 2.0%; - margin-top: 0.5em; + width: 70%; + margin-left: 50%; + margin-top: 3%; + transform: translate(-50%); + padding: 2.0%; height: 25em; background-color: #dcdcdc; border-radius: 25px; } - -.barra-patrimonio { - background-color: #241453; - margin-top: 0.4em; - margin-left: -2.6em; - margin-right: 5%; - width: 0.5em; - height: 95%; -} diff --git a/Front/src/pages/Patrimonio/Patrimonio.tsx b/Front/src/pages/Patrimonio/Patrimonio.tsx index 0227abd..55a11d3 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.tsx +++ b/Front/src/pages/Patrimonio/Patrimonio.tsx @@ -1,8 +1,5 @@ import "./Patrimonio.css"; import { useState, useEffect } from "react"; -import { FaMoneyBillWave } from "react-icons/fa"; -import { BsEye, BsEyeSlash } from "react-icons/bs"; -import { AiOutlineRise } from "react-icons/ai"; import Axios from "axios"; import { DataGrid, GridColDef } from "@mui/x-data-grid"; import { useAuth } from "../../services/Provider"; @@ -77,18 +74,16 @@ export const Patrimonio = () => {

    Patrimônio

    - - -
    - {patrimonio ? ( - - ) : null} - +
    + {patrimonio ? ( + + ) : null} +
    From 1e029f6ba6a6eee3e0d2308bb7fad687419565fa Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Mon, 5 Sep 2022 22:43:16 -0300 Subject: [PATCH 126/146] =?UTF-8?q?Resolve=20o=20bug=20da=20tela=20de=20Pa?= =?UTF-8?q?trim=C3=B4nio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Patrimonio/Patrimonio.css | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Front/src/pages/Patrimonio/Patrimonio.css b/Front/src/pages/Patrimonio/Patrimonio.css index f349c36..01ecf47 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.css +++ b/Front/src/pages/Patrimonio/Patrimonio.css @@ -16,15 +16,16 @@ .div-patrimonio{ display: flex; flex-direction: column; - padding: 2.5%; - width: 60%; - height: 50%; + padding: 1.0%; + width: 70%; + height: 70%; background-color: rgba(10, 17, 79, 0.904); border-radius: 40px; } .titulo-patrimonio{ text-align: center; + margin-top: 1.0em; font-size: 2.5em; margin-bottom: 0.5em; color: white; @@ -32,21 +33,20 @@ } .div-ativos-patrimonio ul { + margin-top: auto; color: #000000; - padding-right: 10px; + padding-right: 5px; display: flex; } .div-ativos-patrimonio li{ - padding: 10px; + padding: 5px; } .div-grid-patrimonio { - border: 2px solid; - border-color: black; + border-color: #ffff; height: 60%; - width: 70%; + width: 85%; margin-left: 50%; - margin-top: 3%; transform: translate(-50%); padding: 2.0%; height: 25em; From 4616f8379cf91627326cb4631e7a121bfe6e4d58 Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Mon, 5 Sep 2022 22:53:12 -0300 Subject: [PATCH 127/146] =?UTF-8?q?Finaliza=20tela=20hist=C3=B3rico.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/HistoricoDeAcoes/historico.css | 2 +- Front/src/pages/HistoricoDeAcoes/historico.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Front/src/pages/HistoricoDeAcoes/historico.css b/Front/src/pages/HistoricoDeAcoes/historico.css index 44c17c5..74e49d9 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.css +++ b/Front/src/pages/HistoricoDeAcoes/historico.css @@ -31,7 +31,7 @@ display: flex; flex-direction: column; padding: 2%; - width: 80%; + width: 72%; background-color: #cacacaf1; border-radius: 0.5cm; color: white; diff --git a/Front/src/pages/HistoricoDeAcoes/historico.tsx b/Front/src/pages/HistoricoDeAcoes/historico.tsx index 701ceb0..7f8e0d6 100644 --- a/Front/src/pages/HistoricoDeAcoes/historico.tsx +++ b/Front/src/pages/HistoricoDeAcoes/historico.tsx @@ -75,7 +75,7 @@ export const HistoricoDeAcoes = () => { headerName: ' ', sortable: false, disableColumnMenu: true, - width: 80, + width: 60, renderCell: (params) => [
    Date: Mon, 5 Sep 2022 23:31:57 -0300 Subject: [PATCH 128/146] Adiciona tabela grid na tela de rentabilidade. --- .../src/pages/Rentabilidade/rentabilidade.css | 10 ++++----- .../src/pages/Rentabilidade/rentabilidade.tsx | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css index 15be273..4be150f 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.css +++ b/Front/src/pages/Rentabilidade/rentabilidade.css @@ -38,16 +38,16 @@ margin-left: 65%; margin-top: 2%; padding: 2.0%; - background-color: #dcdcdc; - border: 2px solid black; - border-color:black; - border-radius: 15%; + background-color: #dcdcdcd3; + border: 1px solid; + border-color:#fff; + border-radius: 1cm; } .barra-rentabilidade { background-color: #241453; margin-top: 2em; - margin-left: -5%; + margin-left: -50%; width: 0.5em; height: 15em; } \ No newline at end of file diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index 9a2c990..4148982 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,4 +1,17 @@ import "./rentabilidade.css"; +import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; + +const columns: GridColDef[] = [ + { field: 'ativo', headerName: 'Ativo', width:120}, + { field: 'sigla', headerName: 'Sigla', width:120}, +]; + +const rows = [ + { id: 1, ativo: 'Americanas', sigla: 'AMER3' }, + { id: 2, ativo: 'OI', sigla: 'OIBR4' }, + { id: 3, ativo: 'Petrobras', sigla: 'PETR4'}, + { id: 4, ativo: 'Vale', sigla: 'VALE3'}, +]; export const Rentabilidade = () => { @@ -7,6 +20,14 @@ export const Rentabilidade = () => {

    Rentabilidade

    +
    + +
    From e68297b4ed8c4b15c2765950177e7f5f763506a5 Mon Sep 17 00:00:00 2001 From: amanda-noda Date: Tue, 6 Sep 2022 12:51:17 -0300 Subject: [PATCH 129/146] Cria tabela Rentabilidade --- Front/package.json | 3 ++- .../src/pages/Rentabilidade/rentabilidade.css | 21 +++++++++++-------- .../src/pages/Rentabilidade/rentabilidade.tsx | 21 +++++++++++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Front/package.json b/Front/package.json index 4b6cdd4..816678e 100644 --- a/Front/package.json +++ b/Front/package.json @@ -24,7 +24,8 @@ "react-router-dom": "^6.3.0", "react-select": "^5.4.0", "react-window": "^1.8.7", - "react-windowed-select": "^5.1.0" + "react-windowed-select": "^5.1.0", + "victory": "^36.6.6" }, "devDependencies": { "@types/module-alias": "^2.0.1", diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css index 4be150f..5ab15e9 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.css +++ b/Front/src/pages/Rentabilidade/rentabilidade.css @@ -33,10 +33,10 @@ } .div-grid-rentabilidade { - width: 30%; + width: 20%; height: 25em; - margin-left: 65%; - margin-top: 2%; + margin-top: 0cm; + margin-left: 70%; padding: 2.0%; background-color: #dcdcdcd3; border: 1px solid; @@ -44,10 +44,13 @@ border-radius: 1cm; } -.barra-rentabilidade { - background-color: #241453; - margin-top: 2em; - margin-left: -50%; - width: 0.5em; - height: 15em; +.div-chart-rentabilidade{ + width: 50%; + height: -25em; + margin-left: 3%; + margin-top: 2%; + padding: 2.0%; + background-color: #dcdcdcb0; + border-color:#fff; + border-radius: 1cm; } \ No newline at end of file diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index 4148982..af8e9e7 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,5 +1,6 @@ import "./rentabilidade.css"; import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; +import { VictoryChart, VictoryLine, VictoryTheme} from 'victory'; const columns: GridColDef[] = [ { field: 'ativo', headerName: 'Ativo', width:120}, @@ -19,6 +20,26 @@ export const Rentabilidade = () => {

    Rentabilidade

    +
    +
    + + + +
    +
    Date: Tue, 6 Sep 2022 13:09:42 -0300 Subject: [PATCH 130/146] Intervalos naturais no grafico --- Front/src/pages/Rentabilidade/rentabilidade.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index af8e9e7..81d7675 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -26,6 +26,7 @@ export const Rentabilidade = () => { theme={VictoryTheme.material} > Date: Thu, 8 Sep 2022 17:28:21 -0300 Subject: [PATCH 131/146] fix: Correcao nos calculos do patrimonio --- Back/src/util/AtivosB3Util.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index 9fcee57..1b6898e 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -60,7 +60,7 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { "sigla": sigla }, }).then(async (res) => { - let pPrecoMedio = 0, pQuantidade = 0, pTotal = 0, pDiferenca = 0, pTotalatt = 0; + let pPrecoMedio = 0, pQuantidade = 0, pTotal = 0, pDiferenca = 0, pTotalatt = 0, pTotalPM = 0, pQuantidadePM = 0; let pNomeAtivo, pSigla; const precoAtual = await AtivosB3.findAll({ attributes: ['valor_fechamento'], @@ -80,34 +80,39 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { pNomeAtivo = nomeAtivo; pSigla = sigla; if (execucao === "compra") { + pTotalPM += parseFloat(preco) * parseInt(quantidade); pTotal += parseFloat(preco) * parseInt(quantidade); pTotalatt += parseFloat(precoAtt) * parseInt(quantidade); + pQuantidadePM += parseInt(quantidade); pQuantidade += parseInt(quantidade); } else { - pTotal += (-1) * parseFloat(preco) * parseInt(quantidade); + //pTotal += (-1) * parseFloat(preco) * parseInt(quantidade); pTotalatt += (-1) * parseFloat(preco) * parseInt(quantidade); pQuantidade += (-1) * parseInt(quantidade); } - pPrecoMedio = pTotal / pQuantidade; } vTotal += pTotalatt; + pPrecoMedio = pTotalPM / pQuantidadePM; + console.log(pTotalatt); + console.log(pTotal); + const patrimonio = { nomeAtivo: pNomeAtivo, sigla: pSigla, - porcentagem: ((pTotalatt / vTotal)*100).toFixed(2), // falta calcular + porcentagem: ((pTotalatt / vTotal)*100).toFixed(2), quantidade: pQuantidade, precoAtual: precoAtual[0].valor_fechamento, precoMedio: parseFloat(pPrecoMedio.toFixed(2)), - diferenca: (pTotalatt - pTotal).toFixed(2), - valorTotal: pTotalatt + diferenca: (precoAtual[0].valor_fechamento*pQuantidade - pTotal).toFixed(2), + valorTotal: (precoAtual[0].valor_fechamento*pQuantidade).toFixed(2) } lista.push(patrimonio); // Percorre os valores da lista e calcula a porcentagem. for (let x of lista) { - const calculo = ((x.valorTotal / vTotal)*100).toFixed(2); + const calculo = ((pTotalatt / vTotal)*100).toFixed(2); x.porcentagem = calculo; } }); From 23143e369d80a39a3f9ac2e9545efef13d6ae0d3 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Thu, 8 Sep 2022 20:10:58 -0300 Subject: [PATCH 132/146] Adicionando rota de rentabilidade --- Back/src/controller/AtivoController.js | 28 ++++++++++++++ Back/src/util/AtivosB3Util.js | 52 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index cb7f5c5..a8e02ac 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -175,6 +175,34 @@ router.post("/patrimonio", auth, async (req, res) => { }); }); +// Rota que envia a Rentabilidade do usuario +router.post("/rentabilidade", auth, async (req, res) => { + const sc = new sequelize("usuario", "root", "12345678", { + host: 'localhost', + dialect: 'mysql' + }); + + await sc.query(`SELECT DISTINCT(SUBSTRING_INDEX(data, '-', 2)) as data FROM ativos WHERE id_usuario = ${req.usuario.id}`).then(async (results) => { + let datas = [] + for (let data of results[0]) { + datas.push(data.data); + } + const rentabilidade = await ativosB3Util.calculaRentabilidade(datas, req.usuario.id); + + return res.json({ + erro: false, + rentabilidade: rentabilidade + }); + + }).catch((error) => { + console.log(error); + return res.status(400).json({ + erro: true, + ativos: [] + }) + }); +}); + router.post("/editar", auth, async (req,res) => { const { id } = req.body; const { sigla } = req.body; diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index 9fcee57..2a4ef4b 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -113,4 +113,56 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { }); } return lista; +} + +exports.calculaRentabilidade = async function (datas, id_usuario) { + const sc = new sequelize("usuario", "root", "12345678", { + host: 'localhost', + dialect: 'mysql' + }); + + var lista = []; + for (let data of datas) { + var vTotal = 0; + await sc.query(`SELECT * FROM ativos WHERE data LIKE '${data}%' AND id_usuario = ${id_usuario}`).then(async (res) => { + // console.log(res); + let pTotal = 0, pTotalatt = 0; + for (var i = 0; i < res.length; i++) { + for (let result of res[i]) { + // console.log(result, i); + const { sigla } = result; + const { preco } = result; + const { quantidade } = result; + const { execucao } = result; + + let precoAtual = await AtivosB3.findAll({ + attributes: ['valor_fechamento'], + where: { + "codigo_acao": sigla + } + }); + precoAtual = precoAtual[0].valor_fechamento; + + if (execucao === "compra") { + pTotal = parseFloat(preco) * parseInt(quantidade); + pTotalatt = parseFloat(precoAtual) * parseInt(quantidade); + } else { + pTotal = (-1) * parseFloat(preco) * parseInt(quantidade); + pTotalatt = (-1) * parseFloat(precoAtual) * parseInt(quantidade); + } + vTotal += pTotal; + // console.log(execucao, preco, quantidade, precoAtual, vTotal); + } + // console.log(vTotal, data, i); + } + + const rentabilidade = { + data: data, + valor: vTotal, + } + + lista.push(rentabilidade); + }); + } + return lista; } \ No newline at end of file From 21c6262613d4148eb84d8ddea3bf92db7de1c2c3 Mon Sep 17 00:00:00 2001 From: antonioleaojr Date: Sat, 10 Sep 2022 13:24:48 -0300 Subject: [PATCH 133/146] =?UTF-8?q?adicionando=20a=20borda=20na=20div=20do?= =?UTF-8?q?=20gr=C3=A1fico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Rentabilidade/rentabilidade.css | 1 + 1 file changed, 1 insertion(+) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css index 5ab15e9..cf30632 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.css +++ b/Front/src/pages/Rentabilidade/rentabilidade.css @@ -51,6 +51,7 @@ margin-top: 2%; padding: 2.0%; background-color: #dcdcdcb0; + border: 1px solid; border-color:#fff; border-radius: 1cm; } \ No newline at end of file From f0c33f7b9e308e056e8e6746cec73a69679c28fd Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Sun, 11 Sep 2022 20:06:47 -0300 Subject: [PATCH 134/146] refactor: editar ativo somente para qtd, preco e data --- Back/src/controller/AtivoController.js | 6 +-- .../PopoverEditarAtivo/editarAtivo.css | 36 +++++-------- .../PopoverEditarAtivo/editarAtivo.tsx | 52 +++++++------------ .../A\303\247oes.tsx" | 1 - 4 files changed, 34 insertions(+), 61 deletions(-) diff --git a/Back/src/controller/AtivoController.js b/Back/src/controller/AtivoController.js index a8e02ac..70f1e3c 100755 --- a/Back/src/controller/AtivoController.js +++ b/Back/src/controller/AtivoController.js @@ -205,14 +205,14 @@ router.post("/rentabilidade", auth, async (req, res) => { router.post("/editar", auth, async (req,res) => { const { id } = req.body; - const { sigla } = req.body; + const { data } = req.body; const { preco } = req.body; const { quantidade } = req.body; try { - if (sigla !== null) { + if (data !== null) { await Ativo.update( - { sigla: sigla }, + { data: data }, { where: {id: id}} ); } diff --git a/Front/src/components/PopoverEditarAtivo/editarAtivo.css b/Front/src/components/PopoverEditarAtivo/editarAtivo.css index bfbdd93..717eadf 100644 --- a/Front/src/components/PopoverEditarAtivo/editarAtivo.css +++ b/Front/src/components/PopoverEditarAtivo/editarAtivo.css @@ -23,12 +23,8 @@ color: white; font-weight: bold; } -.busca-ativo{ - display: block !important; - width: 100% !important; - font-size: 0.8em !important; - font-family: 'Roboto'; -} + + .modalEdit-linebox { width: 100%; display: flex; @@ -43,34 +39,26 @@ font-size: 1.2em; text-align: center; font-weight: bold; - padding: 0.5em; + padding: 0.5em 0; } + .modalEdit input::placeholder{ color:gray; font-family: 'Roboto'; font-size: 1em; } -.data-input{ - font-size: 0.5em; +.modalEdit input:disabled{ + background-color: lightgray; } -.MuiInputBase-root{ - font-family: 'Roboto'!important; - width: 48%!important; - border: none !important; - border-radius: 40px !important; + +.busca-ativo{ + width: 100% !important; } -.MuiSelect-select{ - background-color:white !important; - color:black; - border: none !important; - border-radius: 40px !important; - font-size: 1.2em!important; - text-align: center; - font-weight: bold !important; - padding: 0.5em !important; - min-height: 0 !important; + +.data-input{ + font-size: 0.5em; } .modalEdit button{ diff --git a/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx b/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx index d515008..714cc8f 100644 --- a/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx +++ b/Front/src/components/PopoverEditarAtivo/editarAtivo.tsx @@ -1,15 +1,10 @@ -import { Dialog, DialogContent, Button, Select, MenuItem } from "@mui/material" +import { Dialog, DialogContent, Button } from "@mui/material" import axios from "axios"; import { useState } from "react"; import { IMaskInput } from "react-imask"; import { Register } from "../../pages/HistoricoDeAcoes/historico"; import { returnToken } from "../../services/authToken"; -import { BuscaAtivo } from "../BuscaAtivos/Busca" import './editarAtivo.css' -interface Assets { - nome: string, - sigla: string -} interface Props { isOpen: boolean, @@ -22,12 +17,10 @@ export const EditarAtivo = (p: Props) => { const token = returnToken(); const [error, setError] = useState(""); - const initialAssets: Assets = { nome: p.initialValues.nomeAtivo, sigla: p.initialValues.sigla }; - const [assets, setAssets] = useState(initialAssets); // É o ativo const [stockPrice, setStockPrice] = useState(p.initialValues.preco.toString()); //preço das ações const [date, setDate] = useState(p.initialValues.data); const [quantity, setQuantity] = useState(p.initialValues.quantidade.toString()); - const [type, setType] = useState(p.initialValues.execucao); // compra ou venda + //para a formatar a data const [inputType, setInputType] = useState("text"); @@ -35,33 +28,29 @@ export const EditarAtivo = (p: Props) => { p.setIsOpen(false); } - const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); setError(""); - if (!assets) { - setError("Selecione um ativo"); - - } else if (parseInt(quantity) <= 0) { + if (parseInt(quantity) <= 0) { setError("É necessário inserir uma quantidade válida"); } else if (parseInt(stockPrice) <= 0) { setError("É necessário inserir um valor válido"); - } else{ + } else { axios.post("/ativo/editar", { token: token, id: p.initialValues.id, - sigla: assets.sigla, + data: date, preco: stockPrice, quantidade: quantity - + }).then(function (response) { alert(response.data.message); p.callback(); - closeModal(); + closeModal(); }).catch(function (error) { const message = error.response.data.message; @@ -75,18 +64,18 @@ export const EditarAtivo = (p: Props) => {

    Editar Ativo

    -
    - -
    + + +
    { onFocus={() => setInputType("date")} onBlur={() => setInputType("text")} /> - - Compra - Venda - + /> +
    diff --git "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" index b1a4a2a..6aa1392 100644 --- "a/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" +++ "b/Front/src/pages/Cadastro de A\303\247\303\265es/A\303\247oes.tsx" @@ -79,7 +79,6 @@ export const CadastroAcoes = () => { mask={Number} scale={2} name="preco" - max={999.99} radix="." mapToRadix={[',']} padFractionalZeros={true} From 6da7000c4d47b0b3269285a20223d2346daf99c5 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Sun, 11 Sep 2022 20:20:22 -0300 Subject: [PATCH 135/146] bug: tela patrimonio dando erro --- Front/src/pages/Patrimonio/Patrimonio.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Front/src/pages/Patrimonio/Patrimonio.tsx b/Front/src/pages/Patrimonio/Patrimonio.tsx index 55a11d3..6a471c8 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.tsx +++ b/Front/src/pages/Patrimonio/Patrimonio.tsx @@ -14,7 +14,7 @@ const columns: GridColDef[] = [ { field: "precoAtual", headerName: "Preço atual", width: 100, type: 'number',valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align: 'center'}, { field: "precoMedio", headerName: "Preço médio", width: 100, type: 'number', valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align: 'left'}, { field: "diferenca", headerName: "Diferença", width: 80 }, - { field: "valorTotal", headerName: "Valor total", width: 100, type: 'number', valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align:'left' }, + { field: "valorTotal", headerName: "Valor total", width: 100, type: 'number', valueFormatter: (params) => `R$ ${params.value}`, align:'left' }, ]; //passo tudo que esta em field para essa interface...verificar se esta ok os nomes e os tipos. From bda54b8a4d03a6a3dd90143cf5150e6ca8a73c31 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Sun, 11 Sep 2022 20:52:27 -0300 Subject: [PATCH 136/146] refactor: ajuste das rotas, para iniciar com o patrimonio --- Front/src/App.tsx | 15 +++++++++------ .../src/components/PageNotFound/PageNotFound.tsx | 15 +++++++++++++++ Front/src/pages/LoginUsuario/Login.tsx | 2 +- Front/src/services/publicRoute.tsx | 2 +- Front/src/services/requireAuth.tsx | 2 +- 5 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 Front/src/components/PageNotFound/PageNotFound.tsx diff --git a/Front/src/App.tsx b/Front/src/App.tsx index c0b370d..2b689a3 100644 --- a/Front/src/App.tsx +++ b/Front/src/App.tsx @@ -10,6 +10,7 @@ import { Sidebar } from './pages/Sidebar/Sidebar'; import { PublicRoute } from './services/publicRoute'; import { Rentabilidade } from './pages/Rentabilidade/rentabilidade'; import { Patrimonio } from './pages/Patrimonio/Patrimonio'; +import { PageNotFound } from './components/PageNotFound/PageNotFound'; function App() { @@ -23,16 +24,18 @@ function App() { } /> - }> - } /> - } /> - } /> - } /> - + } /> + } /> + } /> + } /> + + + } />
    diff --git a/Front/src/components/PageNotFound/PageNotFound.tsx b/Front/src/components/PageNotFound/PageNotFound.tsx new file mode 100644 index 0000000..e765864 --- /dev/null +++ b/Front/src/components/PageNotFound/PageNotFound.tsx @@ -0,0 +1,15 @@ + +export const PageNotFound = () => { + + return ( +
    +

    Página não encontrada!

    +
    + ); +} \ No newline at end of file diff --git a/Front/src/pages/LoginUsuario/Login.tsx b/Front/src/pages/LoginUsuario/Login.tsx index 99d6069..4e364a0 100644 --- a/Front/src/pages/LoginUsuario/Login.tsx +++ b/Front/src/pages/LoginUsuario/Login.tsx @@ -27,7 +27,7 @@ const LoginUsuario = () => { const token = response.data.token; auth.login(token, () => { - navigate("/index", { replace: true }); + navigate("/patrimonio", { replace: true }); }); }).catch(function (response) { diff --git a/Front/src/services/publicRoute.tsx b/Front/src/services/publicRoute.tsx index 4797993..83c5071 100644 --- a/Front/src/services/publicRoute.tsx +++ b/Front/src/services/publicRoute.tsx @@ -12,5 +12,5 @@ export const PublicRoute = ( ) => { } // Caso ele esteja logado, ele é redirecionado para o ultimo local // que ele estava antes de tentar deslogar - return ; + return ; } \ No newline at end of file diff --git a/Front/src/services/requireAuth.tsx b/Front/src/services/requireAuth.tsx index a8641f2..4e4583f 100644 --- a/Front/src/services/requireAuth.tsx +++ b/Front/src/services/requireAuth.tsx @@ -12,7 +12,7 @@ export const RequireAuth = ( { children }: { children: JSX.Element } ) => { // trying to go to when they were redirected. This allows us to send them // along to that page after they login, which is a nicer user experience // than dropping them off on the home page. - return ; + return ; } return children; } \ No newline at end of file From 3ce546550b3fba890c892666e800a21be369aad3 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Sun, 11 Sep 2022 21:01:03 -0300 Subject: [PATCH 137/146] =?UTF-8?q?refactor:=20desabilitar=20bot=C3=B5es?= =?UTF-8?q?=20n=C3=A3o=20usados=20sidebar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Sidebar/Sidebar.css | 5 +++++ Front/src/pages/Sidebar/Sidebar.tsx | 4 ++-- Front/src/pages/Sidebar/SidebarData.tsx | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Front/src/pages/Sidebar/Sidebar.css b/Front/src/pages/Sidebar/Sidebar.css index 05eab59..c665a8a 100644 --- a/Front/src/pages/Sidebar/Sidebar.css +++ b/Front/src/pages/Sidebar/Sidebar.css @@ -58,6 +58,11 @@ background-color: #1a83ff; } +.nav-link.disabled{ + pointer-events: none; + color: gray; +} + .nav-menu-items { width: 100%; display: flex; diff --git a/Front/src/pages/Sidebar/Sidebar.tsx b/Front/src/pages/Sidebar/Sidebar.tsx index 04fd8f2..91a9005 100644 --- a/Front/src/pages/Sidebar/Sidebar.tsx +++ b/Front/src/pages/Sidebar/Sidebar.tsx @@ -42,14 +42,14 @@ export const Sidebar = () => { {SidebarData.map((item, index) => { return item.path === "sair" ? (
  • logout()}> -
    +
    {item.icon} {item.title}
  • ) : (
  • - + {item.icon} {item.title} diff --git a/Front/src/pages/Sidebar/SidebarData.tsx b/Front/src/pages/Sidebar/SidebarData.tsx index a45b5f5..beff4d5 100644 --- a/Front/src/pages/Sidebar/SidebarData.tsx +++ b/Front/src/pages/Sidebar/SidebarData.tsx @@ -1,4 +1,3 @@ -import React from 'react' import * as FaIcons from 'react-icons/fa' import * as AiIcons from 'react-icons/ai' import * as IoIcons from 'react-icons/io' @@ -8,35 +7,42 @@ export const SidebarData = [ title:'Patrimônio', path:'patrimonio', icon: , + className: "nav-link" }, { title:'Rentabilidade', path:'rentabilidade', icon: , + className: "nav-link" }, { title:'Ações', path:'acoes', icon: , + className: "nav-link" }, { title:'Histórico', path:'historico', icon: , + className: "nav-link" }, { title:'Perfil', path:'perfil', icon: , + className: "nav-link disabled" }, { title:'Sair', path:'sair', icon: , + className: "nav-link" }, { title:'Ajuda', path:'ajuda', icon: , + className: "nav-link disabled" }, ]; \ No newline at end of file From b538d237db533ac9221b47b9a30b674c2d08e199 Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 12 Sep 2022 10:52:50 -0300 Subject: [PATCH 138/146] refactor: css Rentabilidade Co-authored-by: Lucas Felipe Soares --- .../src/pages/Rentabilidade/rentabilidade.css | 12 +-- .../src/pages/Rentabilidade/rentabilidade.tsx | 80 +++++++++---------- 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css index cf30632..417ce47 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.css +++ b/Front/src/pages/Rentabilidade/rentabilidade.css @@ -14,13 +14,12 @@ .div-rentabilidade{ display: flex; - flex-direction: column; + justify-content: space-between; padding: 2%; width: 70%; height: 65%; background-color: #A9A9A9; border-radius: 1cm; - margin-top: 0.5%; } .titulo-rentabilidade{ @@ -33,10 +32,9 @@ } .div-grid-rentabilidade { - width: 20%; - height: 25em; + width: 30%; + height: 90%; margin-top: 0cm; - margin-left: 70%; padding: 2.0%; background-color: #dcdcdcd3; border: 1px solid; @@ -45,10 +43,8 @@ } .div-chart-rentabilidade{ - width: 50%; + width: 60%; height: -25em; - margin-left: 3%; - margin-top: 2%; padding: 2.0%; background-color: #dcdcdcb0; border: 1px solid; diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index 81d7675..dd0cad7 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,57 +1,57 @@ import "./rentabilidade.css"; import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; -import { VictoryChart, VictoryLine, VictoryTheme} from 'victory'; +import { VictoryChart, VictoryLine, VictoryTheme } from 'victory'; const columns: GridColDef[] = [ - { field: 'ativo', headerName: 'Ativo', width:120}, - { field: 'sigla', headerName: 'Sigla', width:120}, + { field: 'ativo', headerName: 'Ativo', width: 120 }, + { field: 'sigla', headerName: 'Sigla', width: 120 }, ]; const rows = [ { id: 1, ativo: 'Americanas', sigla: 'AMER3' }, { id: 2, ativo: 'OI', sigla: 'OIBR4' }, - { id: 3, ativo: 'Petrobras', sigla: 'PETR4'}, - { id: 4, ativo: 'Vale', sigla: 'VALE3'}, + { id: 3, ativo: 'Petrobras', sigla: 'PETR4' }, + { id: 4, ativo: 'Vale', sigla: 'VALE3' }, ]; export const Rentabilidade = () => { - return( -
    -

    Rentabilidade

    -
    -
    -
    - - +

    Rentabilidade

    +
    +
    +
    + + - -
    -
    -
    -
    - -
    -
    + style={{ + data: { stroke: "#fafafa" }, + }} + data={[ + { x: 0, y: 0 }, + { x: 5, y: 10 }, + { x: 6, y: 20 }, + { x: 10, y: 30 }, + { x: 1, y: 40 } + ]} + /> +
    +
    +
    +
    + +
    +
    - ); +
    + ); } From 5c7d585e4fe0f2f5364e403091fc321b91f6c6cf Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 12 Sep 2022 13:56:25 -0300 Subject: [PATCH 139/146] =?UTF-8?q?feat:=20gr=C3=A1fico=20conectado=20com?= =?UTF-8?q?=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Rentabilidade/rentabilidade.tsx | 50 +++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index dd0cad7..ca25f75 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,6 +1,11 @@ import "./rentabilidade.css"; import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; import { VictoryChart, VictoryLine, VictoryTheme } from 'victory'; +import { useAuth } from "../../services/Provider"; +import { useEffect, useState } from "react"; +import Axios from "axios"; +import {format, parse} from "date-fns"; +import ptBR from 'date-fns/locale/pt-BR'; const columns: GridColDef[] = [ { field: 'ativo', headerName: 'Ativo', width: 120 }, @@ -14,8 +19,39 @@ const rows = [ { id: 4, ativo: 'Vale', sigla: 'VALE3' }, ]; +interface Rentabilidade { + x: Date, + y: number +} export const Rentabilidade = () => { + + const token = useAuth().getToken(); + const [data, setData] = useState([]); + + console.log(data); + const getData = () => { + + Axios.post('/ativo/rentabilidade', { + token: token + }).then(function (response) { + setData(response.data.rentabilidade.map( + (item: any) => ({ + x: format(parse(item.data, 'yyyy-MM', new Date()),"MMM/yyyy", {locale: ptBR}), + y: item.valor + })) + ); + + }).catch(function (error) { + console.log(error.message); + }) + } + + useEffect(() => { + getData(); + + }, []); + return (

    Rentabilidade

    @@ -26,17 +62,13 @@ export const Rentabilidade = () => { theme={VictoryTheme.material} >
    From d9fe12f23b3f6ff89fe22b3ff3e3ca6d8f1811ca Mon Sep 17 00:00:00 2001 From: LeonardoPadre Date: Mon, 12 Sep 2022 19:26:48 -0300 Subject: [PATCH 140/146] fix: Calculo da porcentagem no patrimonio --- Back/src/util/AtivosB3Util.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index 11b7474..e87e94b 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -96,6 +96,7 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { console.log(pTotalatt); console.log(pTotal); + console.log(vTotal); const patrimonio = { nomeAtivo: pNomeAtivo, @@ -110,13 +111,13 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { lista.push(patrimonio); - // Percorre os valores da lista e calcula a porcentagem. - for (let x of lista) { - const calculo = ((pTotalatt / vTotal)*100).toFixed(2); - x.porcentagem = calculo; - } }); } + // Percorre os valores da lista e calcula a porcentagem. + for (let x of lista) { + x.porcentagem = ((x.valorTotal / vTotal)*100).toFixed(2); + } + return lista; } From bf5aeb15cf25fe70532c0df3d14633627607878c Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Mon, 12 Sep 2022 23:09:30 -0300 Subject: [PATCH 141/146] =?UTF-8?q?refactor:=20remo=C3=A7=C3=A3o=20tabela?= =?UTF-8?q?=20e=20ajuste=20gr=C3=A1fico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Front/src/pages/Patrimonio/Patrimonio.tsx | 2 +- .../src/pages/Rentabilidade/rentabilidade.css | 13 +---- .../src/pages/Rentabilidade/rentabilidade.tsx | 49 ++++++++----------- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/Front/src/pages/Patrimonio/Patrimonio.tsx b/Front/src/pages/Patrimonio/Patrimonio.tsx index 6a471c8..acace82 100644 --- a/Front/src/pages/Patrimonio/Patrimonio.tsx +++ b/Front/src/pages/Patrimonio/Patrimonio.tsx @@ -9,11 +9,11 @@ const columns: GridColDef[] = [ //{ field: "id", headerName: "ID", width: 35 }, { field: "nomeAtivo", headerName: "Ações", width: 120 }, { field: "sigla", headerName: "Sigla", width: 80}, - { field: "porcentagem", headerName: "Porc.", width: 80 }, { field: "quantidade", headerName: "Quant.", width: 80 }, { field: "precoAtual", headerName: "Preço atual", width: 100, type: 'number',valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align: 'center'}, { field: "precoMedio", headerName: "Preço médio", width: 100, type: 'number', valueFormatter: (params) => `R$ ${params.value.toFixed(2)}`, align: 'left'}, { field: "diferenca", headerName: "Diferença", width: 80 }, + { field: "porcentagem", headerName: "Porc.", width: 80 }, { field: "valorTotal", headerName: "Valor total", width: 100, type: 'number', valueFormatter: (params) => `R$ ${params.value}`, align:'left' }, ]; diff --git a/Front/src/pages/Rentabilidade/rentabilidade.css b/Front/src/pages/Rentabilidade/rentabilidade.css index 417ce47..f948471 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.css +++ b/Front/src/pages/Rentabilidade/rentabilidade.css @@ -31,19 +31,8 @@ margin-top: 5%; } -.div-grid-rentabilidade { - width: 30%; - height: 90%; - margin-top: 0cm; - padding: 2.0%; - background-color: #dcdcdcd3; - border: 1px solid; - border-color:#fff; - border-radius: 1cm; -} - .div-chart-rentabilidade{ - width: 60%; + width: 100%; height: -25em; padding: 2.0%; background-color: #dcdcdcb0; diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index ca25f75..2729f6b 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,10 +1,10 @@ import "./rentabilidade.css"; import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; -import { VictoryChart, VictoryLine, VictoryTheme } from 'victory'; +import { VictoryChart, VictoryLabel, VictoryLine, VictoryTheme, VictoryZoomContainer } from 'victory'; import { useAuth } from "../../services/Provider"; import { useEffect, useState } from "react"; import Axios from "axios"; -import {format, parse} from "date-fns"; +import { format, parse } from "date-fns"; import ptBR from 'date-fns/locale/pt-BR'; const columns: GridColDef[] = [ @@ -37,8 +37,8 @@ export const Rentabilidade = () => { }).then(function (response) { setData(response.data.rentabilidade.map( (item: any) => ({ - x: format(parse(item.data, 'yyyy-MM', new Date()),"MMM/yyyy", {locale: ptBR}), - y: item.valor + x: parse(item.data, 'yyyy-MM', new Date(), { locale: ptBR }), + y: Number(item.valor) })) ); @@ -57,31 +57,24 @@ export const Rentabilidade = () => {

    Rentabilidade

    -
    - - - -
    -
    -
    -
    - } + > + -
    +
    From 68d107105ae3ad9ac65e6d68b88ab5f5e2c87bea Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Tue, 13 Sep 2022 01:00:53 -0300 Subject: [PATCH 142/146] Modificando calculo inicial da rentabilidade --- Back/src/util/AtivosB3Util.js | 84 +++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index e87e94b..5172989 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -122,53 +122,79 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { } exports.calculaRentabilidade = async function (datas, id_usuario) { + console.log(datas); const sc = new sequelize("usuario", "root", "12345678", { host: 'localhost', dialect: 'mysql' }); - var lista = []; + let lista = []; for (let data of datas) { - var vTotal = 0; - await sc.query(`SELECT * FROM ativos WHERE data LIKE '${data}%' AND id_usuario = ${id_usuario}`).then(async (res) => { - // console.log(res); - let pTotal = 0, pTotalatt = 0; - for (var i = 0; i < res.length; i++) { - for (let result of res[i]) { - // console.log(result, i); - const { sigla } = result; - const { preco } = result; - const { quantidade } = result; - const { execucao } = result; - - let precoAtual = await AtivosB3.findAll({ - attributes: ['valor_fechamento'], - where: { - "codigo_acao": sigla + let lucro = 0; + await sc.query(`SELECT DISTINCT(sigla) FROM ativos WHERE data LIKE '${data}%' AND id_usuario = ${id_usuario}`).then(async (res) => { + for (let ativo of res[0]) { + await sc.query(`SELECT * FROM ativos WHERE data LIKE '${data}%' AND id_usuario = ${id_usuario} AND sigla = '${ativo.sigla}'`).then(async (res2) => { + let pTotal = 0, precoMedio = 0, sigla; + let qtCompras = 0, qtVendida = 0, qtComprada = 0, qtTotal = 0; + for (let result of res2[0]) { + // console.log(result, i); + sigla = result.sigla; + const { preco } = result; + const { quantidade } = result; + const { execucao } = result; + + qtTotal += quantidade; + if (execucao === "compra") { + qtCompras++; + qtComprada += quantidade; + pTotal = parseFloat(preco) * parseInt(quantidade); + precoMedio += parseFloat(preco) * parseInt(quantidade); + } else { + qtVendida += quantidade; + pTotal = (-1) * parseFloat(preco) * parseInt(quantidade); } - }); - precoAtual = precoAtual[0].valor_fechamento; + } - if (execucao === "compra") { - pTotal = parseFloat(preco) * parseInt(quantidade); - pTotalatt = parseFloat(precoAtual) * parseInt(quantidade); + const pregao = `${data.split("-")[0]}${data.split("-")[1]}` + // ultimo dia util do mes + const precoAtual = await calculaPrecoAtual(pregao, sigla); + + precoMedio = precoMedio / qtComprada; + if (qtCompras === res2[0].length) { // somente compra + lucro += qtComprada * (precoAtual - precoMedio); // somente a valorizacao do ativo } else { - pTotal = (-1) * parseFloat(preco) * parseInt(quantidade); - pTotalatt = (-1) * parseFloat(precoAtual) * parseInt(quantidade); + if (qtVendida === (qtTotal - qtComprada)) { // venda total + lucro += pTotal; + } else { // venda parcial + lucro += pTotal + qtComprada * (precoAtual - precoMedio); + } } - vTotal += pTotal; - // console.log(execucao, preco, quantidade, precoAtual, vTotal); - } - // console.log(vTotal, data, i); + }); } const rentabilidade = { data: data, - valor: vTotal, + valor: lucro, } lista.push(rentabilidade); }); } return lista; +} + +async function calculaPrecoAtual(data, sigla) { + return new Promise((resolve, reject) => { + Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/cd_acao/${sigla}/100`, { + }).then(function(res) { + for (let pregao of res.data) { + const { dt_pregao } = pregao; + if (JSON.stringify(dt_pregao).includes(data)) { + return resolve(pregao.vl_fechamento); + } + } + }).catch(function(err) { + console.log(err); + }); + }); } \ No newline at end of file From 90a1ee7656e09ae34b665c8282a5fc2b841d3750 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Tue, 13 Sep 2022 01:04:45 -0300 Subject: [PATCH 143/146] Adicionando comentarios --- Back/src/util/AtivosB3Util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index 5172989..9be386d 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -155,8 +155,9 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { } } + // cria a string da data do pregao do mes const pregao = `${data.split("-")[0]}${data.split("-")[1]}` - // ultimo dia util do mes + // descobre qual o preco de fechamento do ultimo dia do mes em especifico que teve pregao const precoAtual = await calculaPrecoAtual(pregao, sigla); precoMedio = precoMedio / qtComprada; @@ -185,7 +186,7 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { async function calculaPrecoAtual(data, sigla) { return new Promise((resolve, reject) => { - Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/cd_acao/${sigla}/100`, { + Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/cd_acao/${sigla}/100`, { // devolve os ultimos 100 pregoes desse ativo }).then(function(res) { for (let pregao of res.data) { const { dt_pregao } = pregao; From ef69196425c994c9f5d0ea2a7b75381b09e1ef07 Mon Sep 17 00:00:00 2001 From: LeonardoPadre Date: Wed, 14 Sep 2022 01:03:38 -0300 Subject: [PATCH 144/146] fix: Calculo rentabilidade Co-authored-by: lucasgcaldas --- Back/src/util/AtivosB3Util.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index 9be386d..dcb9505 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -94,9 +94,9 @@ exports.calculaPatrimonio = async function (siglas, id_usuario) { vTotal += pTotalatt; pPrecoMedio = pTotalPM / pQuantidadePM; - console.log(pTotalatt); - console.log(pTotal); - console.log(vTotal); + //console.log(pTotalatt); + //console.log(pTotal); + //console.log(vTotal); const patrimonio = { nomeAtivo: pNomeAtivo, @@ -130,7 +130,7 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { let lista = []; for (let data of datas) { - let lucro = 0; + let lucro = 0, gastoTotal = 0; await sc.query(`SELECT DISTINCT(sigla) FROM ativos WHERE data LIKE '${data}%' AND id_usuario = ${id_usuario}`).then(async (res) => { for (let ativo of res[0]) { await sc.query(`SELECT * FROM ativos WHERE data LIKE '${data}%' AND id_usuario = ${id_usuario} AND sigla = '${ativo.sigla}'`).then(async (res2) => { @@ -147,11 +147,12 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { if (execucao === "compra") { qtCompras++; qtComprada += quantidade; - pTotal = parseFloat(preco) * parseInt(quantidade); + pTotal += (-1) * parseFloat(preco) * parseInt(quantidade); + gastoTotal += parseFloat(preco) * parseInt(quantidade); precoMedio += parseFloat(preco) * parseInt(quantidade); } else { qtVendida += quantidade; - pTotal = (-1) * parseFloat(preco) * parseInt(quantidade); + pTotal += parseFloat(preco) * parseInt(quantidade); } } @@ -162,12 +163,14 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { precoMedio = precoMedio / qtComprada; if (qtCompras === res2[0].length) { // somente compra + console.log(1); lucro += qtComprada * (precoAtual - precoMedio); // somente a valorizacao do ativo } else { - if (qtVendida === (qtTotal - qtComprada)) { // venda total + if (qtVendida === qtComprada) { // venda total + console.log(2); lucro += pTotal; } else { // venda parcial - lucro += pTotal + qtComprada * (precoAtual - precoMedio); + lucro += ((qtComprada - qtVendida) * precoAtual) + pTotal; } } }); @@ -175,7 +178,7 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { const rentabilidade = { data: data, - valor: lucro, + valor: ((lucro/gastoTotal)*100).toFixed(2), } lista.push(rentabilidade); @@ -186,7 +189,7 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { async function calculaPrecoAtual(data, sigla) { return new Promise((resolve, reject) => { - Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/cd_acao/${sigla}/100`, { // devolve os ultimos 100 pregoes desse ativo + Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/cd_acao/${sigla}/10`, { // devolve os ultimos 100 pregoes desse ativo }).then(function(res) { for (let pregao of res.data) { const { dt_pregao } = pregao; From 7697e2e04ca17ce04c34cb768c1534a8c6a5e1b8 Mon Sep 17 00:00:00 2001 From: Lucas Gomes Date: Wed, 14 Sep 2022 20:22:07 -0300 Subject: [PATCH 145/146] Mudando o valor do total de pregoes analisados para retornar os ultimos 100 pregoes do ativo --- Back/src/util/AtivosB3Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Back/src/util/AtivosB3Util.js b/Back/src/util/AtivosB3Util.js index dcb9505..fe55e7a 100644 --- a/Back/src/util/AtivosB3Util.js +++ b/Back/src/util/AtivosB3Util.js @@ -189,7 +189,7 @@ exports.calculaRentabilidade = async function (datas, id_usuario) { async function calculaPrecoAtual(data, sigla) { return new Promise((resolve, reject) => { - Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/cd_acao/${sigla}/10`, { // devolve os ultimos 100 pregoes desse ativo + Axios.get(`https://api-cotacao-b3.labdo.it/api/cotacao/cd_acao/${sigla}/100`, { // devolve os ultimos 100 pregoes desse ativo }).then(function(res) { for (let pregao of res.data) { const { dt_pregao } = pregao; From 3980fb5c121bd1a3e51d61fcf011319b96aca01e Mon Sep 17 00:00:00 2001 From: luciano-freitas-melo <202016847@aluno.unb.br> Date: Wed, 14 Sep 2022 22:06:35 -0300 Subject: [PATCH 146/146] =?UTF-8?q?refactor:=20gr=C3=A1fico=20da=20rentabi?= =?UTF-8?q?lidade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Rentabilidade/rentabilidade.tsx | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/Front/src/pages/Rentabilidade/rentabilidade.tsx b/Front/src/pages/Rentabilidade/rentabilidade.tsx index 2729f6b..0691ae6 100644 --- a/Front/src/pages/Rentabilidade/rentabilidade.tsx +++ b/Front/src/pages/Rentabilidade/rentabilidade.tsx @@ -1,24 +1,11 @@ import "./rentabilidade.css"; -import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid'; -import { VictoryChart, VictoryLabel, VictoryLine, VictoryTheme, VictoryZoomContainer } from 'victory'; +import { VictoryAxis, VictoryChart, VictoryLabel, VictoryLine, VictoryScatter, VictoryTheme, VictoryZoomContainer } from 'victory'; import { useAuth } from "../../services/Provider"; import { useEffect, useState } from "react"; import Axios from "axios"; import { format, parse } from "date-fns"; import ptBR from 'date-fns/locale/pt-BR'; -const columns: GridColDef[] = [ - { field: 'ativo', headerName: 'Ativo', width: 120 }, - { field: 'sigla', headerName: 'Sigla', width: 120 }, -]; - -const rows = [ - { id: 1, ativo: 'Americanas', sigla: 'AMER3' }, - { id: 2, ativo: 'OI', sigla: 'OIBR4' }, - { id: 3, ativo: 'Petrobras', sigla: 'PETR4' }, - { id: 4, ativo: 'Vale', sigla: 'VALE3' }, -]; - interface Rentabilidade { x: Date, y: number @@ -35,15 +22,17 @@ export const Rentabilidade = () => { Axios.post('/ativo/rentabilidade', { token: token }).then(function (response) { + console.log(response.data) setData(response.data.rentabilidade.map( (item: any) => ({ x: parse(item.data, 'yyyy-MM', new Date(), { locale: ptBR }), y: Number(item.valor) + })) ); }).catch(function (error) { - console.log(error.message); + console.log(error); }) } @@ -61,19 +50,37 @@ export const Rentabilidade = () => { theme={VictoryTheme.material} width={900} height={420} - padding={{top: 20, bottom: 50, left: 70, right: 40}} - scale={{x:'time'}} - containerComponent={ - } + padding={{ top: 20, bottom: 50, left: 70, right: 40 }} + scale={{ x: 'time', y: 'linear' }} > + + + + item.x)} + tickFormat={(x) => { + return format(x, "MMM/yyyy", { locale: ptBR }); + }} + /> + + item.y)),[0])} + tickFormat={(y) => { + return `${y}%` + }} + style={{axisLabel: {padding: 50} }} + />