-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Definindo tela de listagem de componentes #33
- Loading branch information
1 parent
ae6d70e
commit 0896ed7
Showing
6 changed files
with
185 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/entrypoints/web/wise-builder/pages/listar-componente.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { | ||
List, | ||
ListItem, | ||
ListIcon, | ||
Flex, | ||
Stack, | ||
Heading, | ||
useColorModeValue, | ||
Divider, | ||
} from "@chakra-ui/react"; | ||
import { AddIcon, CheckCircleIcon } from "@chakra-ui/icons"; | ||
import Tabela from '../src/components/Tabela/tabela-listagem'; | ||
|
||
/* async function getItems() { | ||
const response = await fetch('https://sua-api.com/items'); | ||
const data = await response.json(); | ||
return data; | ||
} | ||
function ItemList() { | ||
const [items, setItems] = useState([]); | ||
useEffect(() => { | ||
async function fetchData() { | ||
const data = await getItems(); | ||
setItems(data); | ||
} | ||
fetchData(); | ||
}, []); */ | ||
|
||
const mockItems = [ | ||
{ | ||
id: 1, | ||
name: 'Item 1' | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Item 2' | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Item 3' | ||
} | ||
]; | ||
|
||
function ItemList() { | ||
const [items, setItems] = useState(mockItems); | ||
|
||
return ( | ||
<Flex | ||
minH={'100vh'} | ||
align={'center'} | ||
justify={'center'} | ||
bg={useColorModeValue('gray.50', 'gray.800')}> | ||
<Stack | ||
spacing={4} | ||
w={'full'} | ||
maxW={'80%'} | ||
bg={useColorModeValue('white', 'gray.700')} | ||
rounded={'xl'} | ||
boxShadow={'lg'} | ||
p={6} | ||
my={12}> | ||
<Heading lineHeight={1.1} fontSize={{ base: '2xl', sm: '3xl' }}> | ||
Listar Componentes | ||
</Heading> | ||
<Divider orientation='horizontal' /> | ||
<Tabela titulo="Componentes" link="/cadastrar-componente"/> | ||
<List spacing={3}> | ||
{items.map((item) => ( | ||
<ListItem key={item.id}> | ||
<ListIcon as={CheckCircleIcon} color="green.500" /> | ||
{item.name} | ||
</ListItem> | ||
))} | ||
</List> | ||
</Stack> | ||
</Flex> | ||
)}; | ||
|
||
export default ItemList; |
29 changes: 29 additions & 0 deletions
29
src/entrypoints/web/wise-builder/src/components/Botão/acoes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
IconButton, | ||
Button, | ||
Stack, | ||
} from '@chakra-ui/react'; | ||
|
||
import { DeleteIcon, EditIcon } from '@chakra-ui/icons'; | ||
|
||
export default function ServerSecondaryOptions() { | ||
return ( | ||
<Stack direction='row' spacing={4}> | ||
<IconButton | ||
bg='gray.200' | ||
color ='gray.900' | ||
aria-label="Editar" | ||
icon={<EditIcon />} | ||
size="xs" | ||
variant="solid" | ||
/> | ||
<IconButton | ||
bg='red' | ||
color ='white' | ||
aria-label="Deletar" | ||
icon={<DeleteIcon />} | ||
size="xs" | ||
variant="solid" | ||
/> | ||
</Stack> | ||
)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/entrypoints/web/wise-builder/src/components/Tabela/tabela-listagem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { | ||
Table, | ||
Thead, | ||
Tbody, | ||
Tfoot, | ||
Tr, | ||
Th, | ||
Td, | ||
TableContainer, | ||
Button, | ||
Stack, | ||
} from '@chakra-ui/react'; | ||
import { Card, Heading, CardBody } from '@chakra-ui/react'; | ||
import { AddIcon } from "@chakra-ui/icons"; | ||
import Acoes from '../Botão/acoes' | ||
import { TabelaProps } from '../../types/propsTable'; | ||
import { useRouter } from "next/router"; | ||
|
||
export default function tabela (props: TabelaProps) { | ||
const router = useRouter(); | ||
function handleClick() { | ||
router.push("/cadastrar-componente"); | ||
} | ||
return( | ||
<TableContainer> | ||
<Card size='sm'> | ||
<CardBody> | ||
<Stack direction="row" align="center" justify="space-between"> | ||
<Heading size={'md'}>{props.titulo}</Heading> | ||
<Button onClick={handleClick} size={'sm'} colorScheme='blue' aria-label='Adicionar Componente' leftIcon={<AddIcon />}>Adicionar</Button> | ||
</Stack> | ||
</CardBody> | ||
</Card> | ||
<Table variant='striped' size='md'> | ||
<Thead> | ||
<Tr> | ||
<Th isNumeric> ID </Th> | ||
<Th>Tipo do Componente</Th> | ||
<Th>Fabricante</Th> | ||
<Th>Modelo</Th> | ||
<Th>Ações</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
<Tr> | ||
<Td isNumeric>1</Td> | ||
<Td>Placa de Vídeo</Td> | ||
<Td>Zotac</Td> | ||
<Td>RTX 3070</Td> | ||
<Td><Acoes /></Td> | ||
</Tr> | ||
<Tr> | ||
<Td isNumeric>2</Td> | ||
<Td>Placa de Vídeo</Td> | ||
<Td>Asus</Td> | ||
<Td>GTX 1060</Td> | ||
<Td><Acoes /></Td> | ||
</Tr> | ||
</Tbody> | ||
</Table> | ||
</TableContainer>); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TabelaProps { | ||
titulo: string, | ||
link: string, | ||
}; |