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 (
+
+
+
+
+ )
+}
+
+
+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
+
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
-
+
+
)
}
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
-
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
+
+
+
+
+)
+
+}
+
+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(
+
+ // <>
+ // {assets && S
+ //
+ // {buscaAtivos(assets).map((item) => (
+ // - {item}
+ // ))}
+ //
+ // }
+ // >
+ );
+}
\ No newline at end of file
From d4ec5f004f1aaed0f7e797c67a040b2d44c6563e Mon Sep 17 00:00:00 2001
From: luciano-freitas-melo <202016847@aluno.unb.br>
Date: Sat, 20 Aug 2022 20:44:13 -0300
Subject: [PATCH 055/146] feat: search bar
---
.../A\303\247oes.tsx" | 32 ++++++---------
.../A\303\247\303\265es.css" | 5 ---
.../Busca.css" | 33 ++++++++++++++++
.../Busca.tsx" | 39 +++++++++----------
4 files changed, 63 insertions(+), 46 deletions(-)
create mode 100644 "Front/src/pages/Cadastro de A\303\247\303\265es/Busca.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"
index 288a034..c922f68 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,16 +3,11 @@
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';
import {BuscaAtivo} from './Busca';
-//templante da função onde será feita a busca de ativos que verei com o luciano
-
-
export const CadastroAcoes = () => {
const [error, setError] = useState("");
@@ -21,16 +16,17 @@ export const CadastroAcoes = () => {
const [date, setDate] = useState("");
const [quantity,setQuantity] = useState("");
+ const auth = useAuth();
+
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 ){
+ if (!assets){
+ setError("Selecione um ativo")
+
+ }else if (quantity.length < 0 ){
setError("É necessário inserir uma quantidade válida")
}else if (stockPrice.length < 0 ) {
@@ -74,17 +70,11 @@ export const CadastroAcoes = () => {
Compra/Venda de Ativos
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 (
-- |
-- |
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+ -- |
+ -- |
+ -- |
+ -- |
+ -- |
+
+
+
+