From 46c86fce31ecb5ac95291b05b83449e4f90757e6 Mon Sep 17 00:00:00 2001 From: Lucas Bandeira Date: Mon, 13 Mar 2023 17:49:50 -0300 Subject: [PATCH 1/9] Adicionando o framework nextjs ao projeto para controle de rotas #48 --- src/entrypoints/web/wise-builder/.gitignore | 1 + src/entrypoints/web/wise-builder/next-env.d.ts | 5 +++++ src/entrypoints/web/wise-builder/package.json | 11 ++++------- src/entrypoints/web/wise-builder/pages/_app.tsx | 17 +++++++++++++++++ .../cadastrar-componente.tsx} | 0 .../{src/pages/Busca.tsx => pages/index.tsx} | 0 .../src/components/MenuNav/menuNav.tsx | 13 +++++++++---- src/entrypoints/web/wise-builder/src/index.tsx | 17 ----------------- .../web/wise-builder/src/react-app-env.d.ts | 1 - src/entrypoints/web/wise-builder/tsconfig.json | 9 +++++++-- 10 files changed, 43 insertions(+), 31 deletions(-) create mode 100644 src/entrypoints/web/wise-builder/next-env.d.ts create mode 100644 src/entrypoints/web/wise-builder/pages/_app.tsx rename src/entrypoints/web/wise-builder/{src/pages/CadastroComp.tsx => pages/cadastrar-componente.tsx} (100%) rename src/entrypoints/web/wise-builder/{src/pages/Busca.tsx => pages/index.tsx} (100%) delete mode 100644 src/entrypoints/web/wise-builder/src/index.tsx delete mode 100644 src/entrypoints/web/wise-builder/src/react-app-env.d.ts diff --git a/src/entrypoints/web/wise-builder/.gitignore b/src/entrypoints/web/wise-builder/.gitignore index 54dfea7..b82aed8 100644 --- a/src/entrypoints/web/wise-builder/.gitignore +++ b/src/entrypoints/web/wise-builder/.gitignore @@ -5,6 +5,7 @@ package-lock.json /node_modules /.pnp .pnp.js +.next/ # testing /coverage diff --git a/src/entrypoints/web/wise-builder/next-env.d.ts b/src/entrypoints/web/wise-builder/next-env.d.ts new file mode 100644 index 0000000..4f11a03 --- /dev/null +++ b/src/entrypoints/web/wise-builder/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/src/entrypoints/web/wise-builder/package.json b/src/entrypoints/web/wise-builder/package.json index 8be239c..4c3ca1e 100644 --- a/src/entrypoints/web/wise-builder/package.json +++ b/src/entrypoints/web/wise-builder/package.json @@ -15,18 +15,16 @@ "@types/react": "^18.0.27", "@types/react-dom": "^18.0.10", "framer-motion": "^8.5.5", + "next": "^13.2.4", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-scripts": "5.0.1", "typescript": "^4.9.4", - "uuid": "^8.3.2", "web-vitals": "^2.1.4" }, "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" + "dev": "next dev", + "build": "next build", + "start": "next start" }, "eslintConfig": { "extends": [ @@ -47,7 +45,6 @@ ] }, "devDependencies": { - "@types/uuid": "^8.3.1", "sass": "^1.57.1", "typescript-plugin-css-modules": "^3.4.0" } diff --git a/src/entrypoints/web/wise-builder/pages/_app.tsx b/src/entrypoints/web/wise-builder/pages/_app.tsx new file mode 100644 index 0000000..32b81f5 --- /dev/null +++ b/src/entrypoints/web/wise-builder/pages/_app.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { ChakraProvider } from '@chakra-ui/react'; +import MenuNav from '../src/components/MenuNav/menuNav'; + +function App(props: { Component: any; pageProps: any; }) { + const { Component, pageProps } = props; + return ( + + + + + ) +} + +export default App + + diff --git a/src/entrypoints/web/wise-builder/src/pages/CadastroComp.tsx b/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx similarity index 100% rename from src/entrypoints/web/wise-builder/src/pages/CadastroComp.tsx rename to src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx diff --git a/src/entrypoints/web/wise-builder/src/pages/Busca.tsx b/src/entrypoints/web/wise-builder/pages/index.tsx similarity index 100% rename from src/entrypoints/web/wise-builder/src/pages/Busca.tsx rename to src/entrypoints/web/wise-builder/pages/index.tsx diff --git a/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx b/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx index bb5fcc2..e58fff3 100644 --- a/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx +++ b/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx @@ -253,15 +253,20 @@ import { const NAV_ITEMS: Array = [ { label: 'Buscador', - href: '#', + href: '/', }, { - label: 'Administrador', + label: 'Componentes', children: [ + { + label: 'Listar Componentes', + subLabel: 'Veja a lista de todos componentes cadastrados no Wise Builder.', + href: '/cadastrar-componente', + }, { label: 'Cadastrar Componentes', - subLabel: 'Adicione novos componentes ao site', - href: '#', + subLabel: 'Adicione novos componentes ao site.', + href: '/cadastrar-componente', }, ], }, diff --git a/src/entrypoints/web/wise-builder/src/index.tsx b/src/entrypoints/web/wise-builder/src/index.tsx deleted file mode 100644 index aeaa3ec..0000000 --- a/src/entrypoints/web/wise-builder/src/index.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import App from './pages/Busca'; -import Comp from './pages/CadastroComp'; -import MenuNav from './components/MenuNav/menuNav'; -import { ChakraProvider } from '@chakra-ui/react' - -ReactDOM.render( - - - - - - - , - document.getElementById('root') -); diff --git a/src/entrypoints/web/wise-builder/src/react-app-env.d.ts b/src/entrypoints/web/wise-builder/src/react-app-env.d.ts deleted file mode 100644 index 6431bc5..0000000 --- a/src/entrypoints/web/wise-builder/src/react-app-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/src/entrypoints/web/wise-builder/tsconfig.json b/src/entrypoints/web/wise-builder/tsconfig.json index a273b0c..ae9d500 100644 --- a/src/entrypoints/web/wise-builder/tsconfig.json +++ b/src/entrypoints/web/wise-builder/tsconfig.json @@ -18,9 +18,14 @@ "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx" + "jsx": "preserve", + "incremental": true }, "include": [ - "src" + "src", + "pages" + ], + "exclude": [ + "node_modules" ] } From 0896ed7968af500fec711b20a4deb5a44d17bdc9 Mon Sep 17 00:00:00 2001 From: Lucas Bandeira Date: Mon, 13 Mar 2023 20:30:07 -0300 Subject: [PATCH 2/9] Definindo tela de listagem de componentes #33 --- .../pages/cadastrar-componente.tsx | 7 ++ .../wise-builder/pages/listar-componente.tsx | 82 +++++++++++++++++++ .../src/components/Bot\303\243o/acoes.tsx" | 29 +++++++ .../src/components/MenuNav/menuNav.tsx | 2 +- .../src/components/Tabela/tabela-listagem.tsx | 62 ++++++++++++++ .../web/wise-builder/src/types/propsTable.tsx | 4 + 6 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 src/entrypoints/web/wise-builder/pages/listar-componente.tsx create mode 100644 "src/entrypoints/web/wise-builder/src/components/Bot\303\243o/acoes.tsx" create mode 100644 src/entrypoints/web/wise-builder/src/components/Tabela/tabela-listagem.tsx create mode 100644 src/entrypoints/web/wise-builder/src/types/propsTable.tsx diff --git a/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx b/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx index 75d7829..a457a77 100644 --- a/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx +++ b/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx @@ -18,6 +18,7 @@ import { Stack, useColorModeValue, } from '@chakra-ui/react'; +import { useRouter } from "next/router"; function CadastroComp() { const [tipo, setTipo] = useState(""); @@ -51,6 +52,11 @@ function CadastroComp() { const [generation, setGeneration] = useState(""); const [frequency, setFrequency] = useState(0); + const router = useRouter(); + function handleClick() { + router.push("/listar-componente"); + } + /* const send = () => { const data: Ram = { fabricante:fabricante, @@ -453,6 +459,7 @@ function CadastroComp() { )} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID Tipo do ComponenteFabricanteModeloAções
1Placa de VídeoZotacRTX 3070
2Placa de VídeoAsusGTX 1060
+ ); +}; \ No newline at end of file diff --git a/src/entrypoints/web/wise-builder/src/types/propsTable.tsx b/src/entrypoints/web/wise-builder/src/types/propsTable.tsx new file mode 100644 index 0000000..c48426c --- /dev/null +++ b/src/entrypoints/web/wise-builder/src/types/propsTable.tsx @@ -0,0 +1,4 @@ +export interface TabelaProps { + titulo: string, + link: string, +}; \ No newline at end of file From aa7ca9ef7382ecb53f10d3ca7fc932c45a8d1205 Mon Sep 17 00:00:00 2001 From: Lucas Bandeira Date: Mon, 13 Mar 2023 20:39:17 -0300 Subject: [PATCH 3/9] Adicionando logo do site ao menu --- .../wise-builder/src/components/MenuNav/menuNav.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx b/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx index b39bf67..7bd42d2 100644 --- a/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx +++ b/src/entrypoints/web/wise-builder/src/components/MenuNav/menuNav.tsx @@ -14,6 +14,7 @@ import { useColorModeValue, useBreakpointValue, useDisclosure, + Avatar, } from '@chakra-ui/react'; import { HamburgerIcon, @@ -51,13 +52,9 @@ import { /> - - Logo - - + From d676ac49f16025036d27dba413365e2721e8d6ac Mon Sep 17 00:00:00 2001 From: Lucas Bandeira Date: Mon, 13 Mar 2023 20:45:05 -0300 Subject: [PATCH 4/9] =?UTF-8?q?Adicionando=20=C3=ADcone=20a=20aba=20do=20p?= =?UTF-8?q?rojeto=20#33?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/wise-builder/public/favicon.ico | Bin 3870 -> 8447 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/entrypoints/web/wise-builder/public/favicon.ico b/src/entrypoints/web/wise-builder/public/favicon.ico index a11777cc471a4344702741ab1c8a588998b1311a..103f979f33c4da491d48318a9b799713c5e265ab 100644 GIT binary patch literal 8447 zcmZ{Kc|25a^#8rr4931MA(LI!4=O~aQpj4A>{7yqD5fYibCHrPB}>bMs79$Ml~!}D zl^BtfrDjw@Sw^;tYvy--zQ5n^_4@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{)X12nbF`*7#ecO7I)Q$uZsV+xS4E7aUn+U(K baj7?x%VD!5Cxk2YbYLNVeiXvvpMCWYo=by@ From 8f9419a22b30fcfad065a249adef66690b29059c Mon Sep 17 00:00:00 2001 From: Lucas Bandeira Date: Tue, 14 Mar 2023 23:06:53 -0300 Subject: [PATCH 5/9] =?UTF-8?q?Defini=C3=A7=C3=A3o=20das=20fun=C3=A7=C3=B5?= =?UTF-8?q?es=20de=20integra=C3=A7=C3=A3o=20da=20API=20#22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/cadastrar-componente.tsx | 193 +++++++++++++----- .../wise-builder/pages/listar-componente.tsx | 35 ++-- .../src/components/Bot\303\243o/acoes.tsx" | 16 +- .../src/components/Tabela/tabela-listagem.tsx | 47 ++--- .../web/wise-builder/src/types/componente.ts | 33 +++ .../types/{propsTable.tsx => propsTable.ts} | 3 + 6 files changed, 237 insertions(+), 90 deletions(-) create mode 100644 src/entrypoints/web/wise-builder/src/types/componente.ts rename src/entrypoints/web/wise-builder/src/types/{propsTable.tsx => propsTable.ts} (51%) diff --git a/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx b/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx index a457a77..827ec3f 100644 --- a/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx +++ b/src/entrypoints/web/wise-builder/pages/cadastrar-componente.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Input } from '@chakra-ui/react' +import { Input, useToast } from '@chakra-ui/react' import { Heading } from '@chakra-ui/react' import { Select } from '@chakra-ui/react' import { Button } from '@chakra-ui/react' @@ -19,57 +19,158 @@ import { useColorModeValue, } from '@chakra-ui/react'; import { useRouter } from "next/router"; +import { Componente } from '../src/types/componente'; +import { Ram } from '../src/types/ram'; -function CadastroComp() { - const [tipo, setTipo] = useState(""); - const [fabricante, setFabricante] = useState(""); - const [socket, setSocket] = useState(0); - const [cores, setCores] = useState(0); - const [chipset, setChipset] = useState(0); - const [tamanho, setTamanho] = useState(0); - const [slotsRam, setSlotsRam] = useState(0); - const [usb2, setUsb2] = useState(0); - const [usb3, setUsb3] = useState(0); - const [vga, setVga] = useState(0); - const [display, setDisplay] = useState(0); - const [hdmi, setHdmi] = useState(0); - const [pciGen, setPciGen] = useState(0); - const [pci1, setPci1] = useState(0); - const [pci4, setPci4] = useState(0); - const [pci8, setPci8] = useState(0); - const [pci16, setPci16] = useState(0); - const [volts, setVolts] = useState(0); - const [eficiency, setEficiency] = useState(0); - const [modular, setModular] = useState(0); - const [baseClock, setBaseClock] = useState(0); - const [boostClock, setBoostClock] = useState(0); - const [consumo, setConsumo] = useState(0); - const [gpuIntegrada, setGpuIntegrada] = useState(""); - const [overclock, setOverclock] = useState(false); - const [vram, setVram] = useState(0); - const [vramSpd, setVramSpd] = useState(0); - const [modelo, setModelo] = useState(""); - const [generation, setGeneration] = useState(""); - const [frequency, setFrequency] = useState(0); +interface Props { + componente?: Componente, + editar?: boolean, +} + +function CadastroComp({ componente, editar }: Props) { + const toast = useToast(); + const [tipo, setTipo] = useState(componente?.tipo || ""); + const [fabricante, setFabricante] = useState(componente?.fabricante || ""); + const [socket, setSocket] = useState(componente?.socket || 0); + const [cores, setCores] = useState(componente?.cores || 0); + const [chipset, setChipset] = useState(componente?.chipset || 0); + const [tamanho, setTamanho] = useState(componente?.tamanho || 0); + const [slotsRam, setSlotsRam] = useState(componente?.slotsRam || 0); + const [usb2, setUsb2] = useState(componente?.usb2 || 0); + const [usb3, setUsb3] = useState(componente?.usb3 || 0); + const [vga, setVga] = useState(componente?.vga || 0); + const [display, setDisplay] = useState(componente?.display || 0); + const [hdmi, setHdmi] = useState(componente?.hdmi || 0); + const [pciGen, setPciGen] = useState(componente?.pciGen || 0); + const [pci1, setPci1] = useState(componente?.pci1 || 0); + const [pci4, setPci4] = useState(componente?.pci4 || 0); + const [pci8, setPci8] = useState(componente?.pci8 || 0); + const [pci16, setPci16] = useState(componente?.pci16 || 0); + const [volts, setVolts] = useState(componente?.volts || 0); + const [eficiency, setEficiency] = useState(componente?.eficiency || 0); + const [modular, setModular] = useState(componente?.modular || 0); + const [baseClock, setBaseClock] = useState(componente?.baseClock || 0); + const [boostClock, setBoostClock] = useState(componente?.boostClock || 0); + const [consumo, setConsumo] = useState(componente?.consumo || 0); + const [gpuIntegrada, setGpuIntegrada] = useState(componente?.gpuIntegrada || ""); + const [overclock, setOverclock] = useState(componente?.overclock || false); + const [vram, setVram] = useState(componente?.vram || 0); + const [vramSpd, setVramSpd] = useState(componente?.vramSpd || 0); + const [modelo, setModelo] = useState(componente?.modelo || ""); + const [generation, setGeneration] = useState(componente?.generation || ""); + const [frequency, setFrequency] = useState(componente?.frequency || 0); const router = useRouter(); function handleClick() { router.push("/listar-componente"); } - /* const send = () => { - const data: Ram = { - fabricante:fabricante, - modelo: modelo, - generation: generation, - frequency: frequency + const send = () => { + let data; + let url = ""; + + switch (tipo) { + case "CPU": + data = { + fabricante: fabricante, + modelo: modelo, + socket: socket, + cores: cores, + baseClock: baseClock, + boostClock: boostClock, + vramSpd: vramSpd, + consumo: consumo, + gpuIntegrada: gpuIntegrada, + overclock: overclock + }; + url = "https://api.npms.io/v2/search?q=ram"; + break; + case "GPU": + data = { + fabricante: fabricante, + modelo: modelo, + consumo: consumo, + vram: vram, + vramSpd: vramSpd + }; + url = "https://api.npms.io/v2/search?q=hd"; + break; + case "Placa Mãe": + data = { + fabricante: fabricante, + modelo: modelo, + chipset: chipset, + tamanho: tamanho, + slotsRam: slotsRam, + consumo: consumo, + usb2: usb2, + usb3: usb3, + vga: vga, + hdmi: hdmi, + display: display, + pciGen: pciGen, + pci1: pci1, + pci4: pci4, + pci8: pci8, + pci16: pci16, + socket: socket, + }; + url = "https://api.npms.io/v2/search?q=placa+de+video"; + break; + case "Memória RAM": + data = { + fabricante: fabricante, + modelo: modelo, + generation: generation, + frequency: frequency + }; + url = "https://api.npms.io/v2/search?q=processador"; + break; + case "Fonte": + data = { + fabricante: fabricante, + modelo: modelo, + volts: volts, + eficiency: eficiency, + modular: modular + }; + url = "https://api.npms.io/v2/search?q=processador"; + break; + default: + console.log("Tipo de componente inválido"); + return; } - - fetch('https://api.npms.io/v2/search?q=react', {method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) - .then() //evento que vai ocorrer se a requisição der certo - .catch(); //lógica para tratar erro - - } */ + + fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data) }) + .then((response) => { //evento que vai ocorrer se a requisição der certo + if (response.ok) { + toast({ + position: 'top', + title: "Salvo com Sucesso!", + status: "success", + duration: 3000, + isClosable: true, + }); + } else { + toast({ + position: 'top', + title: "Erro ao Salvar", + status: "error", + duration: 3000, + isClosable: true, + }); + } + }) + .catch((error) => { //lógica para tratar erro + toast({ + position: 'top', + title: "Erro ao Salvar", + status: "error", + duration: 3000, + isClosable: true, + }); + }); + }; return ( Capacidade da Memória RAM da CPU setVram(+value)}> - + @@ -469,7 +570,7 @@ function CadastroComp() { Cancel