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,

O ECommerce de vocês está bem caprichado no layout, porém faltou a interação entre componentes para implementar as funcionalidades que pedimos.

Continuem evoluindo e não deixem de procurar ajuda em caso de dúvidas.

Comment on lines +2 to +26
import logo from './logo.svg';
import './App.css';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}

export default App;
Copy link
Author

Choose a reason for hiding this comment

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

Já que os componentes da pasta future-commerce não seriam utilizados, ela deveria ter sido apagada.

Comment on lines +78 to +139
constructor(props){
super(props);
this.state = {
inputValorMinimo: 0,
inputValorMaximo: Infinity,
carrinhoCompras: props.valorProduto,
carrinhoCompras: [],
buscarCompras: '',


}

}


controleMinimo = (event) => {
this.setState({
inputValorMinimo: event.target.value,
})
}

controleMaximo = (event) => {
this.setState({
inputValorMaximo: event.target.value,
})
}

controleBusca = (event) => {
this.setState({
buscarCompras: event.target.value,
})
}



atualizarFiltro = () => {
this.setState({

})
}




colocarCarrinho = (produtos) => {
const itensComprados = [...this.state.carrinhoCompras]
const produtosIndex = this.state.carrinhoCompras.findIndex((item) => item.produtos.id === produtos.id)

if (produtosIndex > -1) {
itensComprados[produtosIndex].quantity += 1
} else {
itensComprados.push({ produto: produtos, quantity: 1 })
}

this.setState({
arrayProdutos: itensComprados,

})

console.log(itensComprados)

}
Copy link
Author

Choose a reason for hiding this comment

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

Cuidado com indentação, as funções estão cada uma em um nível.

Comment on lines +113 to +117
atualizarFiltro = () => {
this.setState({

})
}
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 +83 to +84
carrinhoCompras: props.valorProduto,
carrinhoCompras: [],
Copy link
Author

@paula-aribeiro paula-aribeiro Dec 11, 2019

Choose a reason for hiding this comment

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

Isso não faz sentido, pois o state carrinhoCompras está duplicado e essa props valorProduto não está sendo passada.

Comment on lines +144 to +168
// filtrar = () => {
// const listaFiltrada = props.lista.filter((valor) => {
// if (valor.valorProduto >= this.state.inputValorMinimo && valor.valorProduto <= this.state.inputValorMaximo){
// return true
// }
// else{
// return false
// }
// })}

let funcaoMinimo = ProdutosLoja.filter((produtos => {
if(produtos.valorProduto > this.state.inputValorMinimo){
return produtos.valorProduto;

}


}))

let filtroBuscar = ProdutosLoja.filter((produtos) => {
return produtos.nomeProduto.toLowerCase().includes(this.state.buscarCompras.toLowerCase())

})

console.log(this.state.buscarCompras)
Copy link
Author

Choose a reason for hiding this comment

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

Essa lógica dos filtros deveria estar dentro de um componente de filtro e não no render do App

Comment on lines +22 to +50
class Filtro extends React.Component{
constructor(props){
super(props);
this.state = {

}

}




render(){

return(
<FiltroDiv>
<ContainerDiv>
<h2>Filtros</h2>
<label>Valor Mínimo:</label>
<input value={this.props.valueControleMinimo} onChange={this.props.controleMinimo} type="number"></input>
<label>Valor Máximo:</label>
<input value={this.props.valueControleMaximo} onChange={this.props.controleMaximo} type="number"></input>
<label>Buscar Produto</label>
<input value={this.props.valueBuscarProduto} onChange={this.props.controleBusca}></input>
</ContainerDiv>
</FiltroDiv>
)
}
}
Copy link
Author

Choose a reason for hiding this comment

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

Toda a lógica de filtragem deveria ser feita nesse componente, passando para o pai apenas o resultado do filtro, para que ele apenas selecionasse os produtos a serem mostrados. Dessa forma as responsabilidades ficam melhor separadas.

Comment on lines +52 to +66
function Produtos(props) {

return(

<ProdutosMainDiv>
<ProdutosDiv>
<ImagemProduto src={props.imagemProduto}></ImagemProduto>
<CampoDeNome>{props.nome}</CampoDeNome>
<CampoValor><label>R$</label>{props.valor} </CampoValor>
<ButtonComprar onClick={props.colocarCarrinho}>Comprar</ButtonComprar>

</ProdutosDiv>
</ProdutosMainDiv>
);
}
Copy link
Author

Choose a reason for hiding this comment

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

Faria mais sentido o nome desse componente (e de todos os styled components) estar no singular, pois ele representa apenas um produto.

<ImagemProduto src={props.imagemProduto}></ImagemProduto>
<CampoDeNome>{props.nome}</CampoDeNome>
<CampoValor><label>R$</label>{props.valor} </CampoValor>
<ButtonComprar onClick={props.colocarCarrinho}>Comprar</ButtonComprar>
Copy link
Author

Choose a reason for hiding this comment

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

Essa props colocarCarrinho não foi passada quando o componente Produtos foi utilizado no App

Comment on lines +28 to +58
class Carrinho extends React.Component{
constructor(props){
super(props);
this.state = {
}
}







render(){
return(
<CarrinhoDiv>
<TitleDiv>
<h2>Carrinho</h2>
</TitleDiv>
<DivDoArryCarrinho>

</DivDoArryCarrinho>
<DivDoTotal>
<label>R$</label>
</DivDoTotal>
</CarrinhoDiv>
)
}


}
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 está estático

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.

4 participants