-
Notifications
You must be signed in to change notification settings - Fork 0
PR para correção e comentários #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: correcao
Are you sure you want to change the base?
Conversation
Projeto Futurecommerce
Projeto E-Commerce
Adicionar ao carrinho funcionando
Carrinho finalizado e filtro finalizado
Iniciamos a funcionalidade de ordenação.
Finalizei o layout e ajustei as funcionalidades.
Link do Surge no README.
paula-aribeiro
left a comment
There was a problem hiding this 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 👏 🚀
| 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, | ||
| }) | ||
| } |
There was a problem hiding this comment.
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.
| 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 | ||
| } | ||
| }) | ||
| } |
There was a problem hiding this comment.
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:"> |
There was a problem hiding this comment.
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!
| 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) | ||
| } |
There was a problem hiding this comment.
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
| 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) | ||
| } |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
| <SideBarArea> | ||
| <Titulo>{props.titulo}</Titulo> | ||
| {props.children} | ||
| </SideBarArea> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elegante 👏
| const ContainerCarrinho = styled.div ` | ||
| ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 🤔 🤔
| 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> |
There was a problem hiding this comment.
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>
))}
No description provided.