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, parabéns pelo trabalho de vocês 😄

Vocês mandaram muito bem nos requisitos obrigatórios e no desafio!

Uma sugestão de melhoria é que vocês poderiam ter componentizado mais, por exemplo, criando um componente para o carrinho e um para os filtros.
Também deixei umas correções em relação à organização de código.

Parabéns, continuem evoluindo 🚀 🚀 🚀

super(props)
this.state ={
ordem: "Crescente" ,
quantidade: JSON.parse(localStorage.getItem("quantidade")) || [0,0,0,0,0,0,0] ,
Copy link
Author

Choose a reason for hiding this comment

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

Muito bom 👏

display:flex;
flex-wrap:wrap;
`
const lista = [
Copy link
Author

Choose a reason for hiding this comment

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

Seria bom utilizar um nome mais significativo para essa lista

filtroNome: ''
}
}
somar = () => {
Copy link
Author

Choose a reason for hiding this comment

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

Essa função poderia ter um nome mais significativo 😉

)
}
removerItem = (event) => {
const copy = this.state.quantidade.map((quant, i) => {
Copy link
Author

Choose a reason for hiding this comment

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

copy não é um bom nome de variável

filtrosMin: event.target.value
})
}}
></input><br/>
Copy link
Author

Choose a reason for hiding this comment

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

Não utilize <br>! Prefira usar o CSS para espaçamentos :)

if (this.state.quantidade[i] > 0)
return (
<div id={produto.id} key={produto.id}>
{produto.nome + ":" + " " + this.state.quantidade[i]}
Copy link
Author

Choose a reason for hiding this comment

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

Isso poderia ser feito com template string, dessa forma:

`${produto.nome}: ${this.state.quantidade[i]}`


}
<strong>Total: </strong>
{this.somar ()}
Copy link
Author

Choose a reason for hiding this comment

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

Essa função não deveria estar perdida aqui no meio do render. Seria melhor que algum evento ou método de lifecycle a chamasse

Comment on lines +177 to +202
{this.state.ordem === "Crescente" ?
lista.filter((produto)=>
produto.preco > this.state.filtrosMin && produto.preco < this.state.filtrosMax && produto.nome.includes(this.state.filtroNome)
).map((produto)=>
<Produto
id={produto.id}
key={produto.id}
imagem={produto.imagem}
preco={produto.preco}
nome={produto.nome}
passarId={this.adicionarItem}
/>
)
:
lista.filter((produto)=>
produto.preco > this.state.filtrosMin && produto.preco < this.state.filtrosMax && produto.nome.includes(this.state.filtroNome)
).map((produto)=>
<Produto
id={produto.id}
imagem={produto.imagem}
preco={produto.preco}
nome={produto.nome}
passarId={this.adicionarItem}
/>
).reverse()
}
Copy link
Author

Choose a reason for hiding this comment

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

Evite deixar lógicas no meio do JSX. Além disso, evite usar ternário para respostas muito grandes, pois dificulta a leitura e manutenção do código. Nesse caso, seria melhor criar uma função com um if/else.

Comment on lines +4 to +22
const Div = styled.div`
width: 200px;
border: 1px solid black;
margin: 10px;
display:flex;
flex-direction:column;
justify-content:space-between;
font-size: 15px;
`
const Button = styled.button`
width: 200px;
color:white;
background-color:midnightblue;
`

const Img = styled.img`
width: 200px;
height: 150px;
`
Copy link
Author

Choose a reason for hiding this comment

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

Essas variáveis poderiam ter nomes mais específicos

<Div id={props.id} >
<Img src={props.imagem}></Img>
<span>{props.nome}</span><br/>
<span>{"R$"}{props.preco}{",00"}</span>
Copy link
Author

Choose a reason for hiding this comment

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

Aqui poderia ser feito dessa forma:

<span>R${props.preco},00</span>

Copy link
Author

Choose a reason for hiding this comment

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

Cuidado que isso não funcionaria para valores quebrados! Nesse caso, seria melhor utilizar

<span>R${props.preco.toFixed(2)}</span>

@vaugustineli vaugustineli merged commit 978fefb into correcao Apr 22, 2020
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