Skip to content

Conversation

@paula-aribeiro
Copy link

No description provided.

Copy link
Author

@paula-aribeiro paula-aribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oi pessoal, ficou animal o projeto de vocês 😍

Vocês souberam implementar os requisitos que pedimos e componentizaram bem as seções do site. Erraram apenas alguns detalhes.

Parabéns pelo trabalho em equipe e continuem assim 👏 🚀

Comment on lines +143 to +154
removerCarrinho = (idProduto) => {
const novoCarrinho = [...this.state.carrinho]
const IndexProdutoRemover = this.state.carrinho.findIndex((objeto) => objeto.id === idProduto)
const ProdutoCarrinho = novoCarrinho.find((item) => item.id === idProduto)

novoCarrinho.splice(IndexProdutoRemover,1)
ProdutoCarrinho.quantidade = 1

this.setState({
carrinho: novoCarrinho,
})
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O único problema dessa função é que, se o produto tiver uma quantidade maior do que 1, ao clicar no X ela exclui o produto todo, e não diminui a quantidade do produto.

Comment on lines +157 to +219
atualizarFiltroMin = (valorMin) => {
this.setState({
filtroMin: valorMin,
})
}


atualizarFiltroMax = (valorMax) => {
if (valorMax === 0) {
this.setState({
filtroMax: Infinity,
})
} else {
this.setState({
filtroMax: valorMax,
})
}
}


atualizarFiltroTexto = (valorTexto) => {
this.setState({
filtroTexto: valorTexto,
})
}


atualizarSeletorOrdem = (ordem) => {
const ordenado = ordem
this.setState({ordem: ordenado,})
}


ordenaProdutosDaLista = (itemA, itemB) => {
if (this.state.ordem === 'crescente') {
return itemA.valor - itemB.valor
} else if (this.state.ordem === 'decrescente') {
return itemB.valor - itemA.valor
}
}


filtroListaDeProduto = () => {
return listaProdutos.filter((item) => {
if(item.valor > this.state.filtroMin) {
return true
}else{
return false
}
}).filter((item) => {
if(item.valor < this.state.filtroMax) {
return true
}else{
return false
}
}).filter((texto) => {
if(texto.nomeDoProduto.includes(this.state.filtroTexto)) {
return true
}else{
return false
}
})
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essas funções poderiam estar no componente de filtro


return (
<MainContainer>
<SideBar titulo="Filtros:">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interessante criar um componente para as barras laterais!

Comment on lines +22 to +37
const filtroMin = (event) => {
const valorMin = Number(event.target.value)
props.atualizarFiltroMin(valorMin)
}


const filtroMax = (event) => {
const valorMax = Number(event.target.value)
props.atualizarFiltroMax(valorMax)
}


const filtroTexto = (event) => {
const valorTexto = (event.target.value)
props.atualizarFiltroTexto(valorTexto)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essas funções deveriam ter nomes com verbos no infinitivo. Ex: atualizarFiltroMin

Comment on lines +20 to +37
function Filtro(props) {

const filtroMin = (event) => {
const valorMin = Number(event.target.value)
props.atualizarFiltroMin(valorMin)
}


const filtroMax = (event) => {
const valorMax = Number(event.target.value)
props.atualizarFiltroMax(valorMax)
}


const filtroTexto = (event) => {
const valorTexto = (event.target.value)
props.atualizarFiltroTexto(valorTexto)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seria melhor se esse componente Filtro fosse de classe, assim ele poderia guardar em seu state todas as informações sobre os filtros e apenas notificar o App sobre essa mudança. Assim, as responsabilidades ficam melhor separadas.

`


function Section(props) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esse componente poderia ter um nome mais específico

Comment on lines +21 to +24
<SideBarArea>
<Titulo>{props.titulo}</Titulo>
{props.children}
</SideBarArea>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegante 👏

Comment on lines +22 to +23
const ContainerCarrinho = styled.div `
`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 🤔 🤔

Comment on lines +33 to +43
return (
<ContainerCarrinho>
{props.listaCarrinho.map(item => {
const enviarId = () => {
props.removerCarrinho(item.id)
}
return <ItemCarrinho>{item.quantidade}x {item.nomeDoProduto}
<BotaoRemover onClick={enviarId}> X</BotaoRemover></ItemCarrinho>
})}
<Total>Total: R${soma}</Total>
</ContainerCarrinho>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uma forma mais enxuta de fazer esse map seria:

{props.listaCarrinho.map(item => (
	<ItemCarrinho>{item.quantidade}x {item.nomeDoProduto}<BotaoRemover onClick={() => {props.removerCarrinho(item.id)}> X</BotaoRemover></ItemCarrinho>
))}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants