Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default class App extends Component {
},
],

textoInput: ''
textoInput: '',
inputCrescente: "Crescente"

}

Expand All @@ -87,7 +88,27 @@ export default class App extends Component {
console.log('TEXTO INPUT', this.state.textoInput)
}


onChangeCrescente = (e) => {
this.setState({ inputCrescente: e.target.value });
switch (this.state.inputCrescente) {
case "Crescente":
return this.setState({
ListaProdutos: this.state.produtos.sort(function (a, b) {
return b.value - a.value;
}),
});
case "Decrescente":
return this.setState({
ListaProdutos: this.state.produtos.sort(function (a, b) {
return a.value - b.value;
}),
});
default:
return true;
}

}

filtraProdutosBusca = () => {

return this.state.produtos.filter(produto => produto.name.includes(this.state.textoInput) )
Expand All @@ -114,7 +135,8 @@ export default class App extends Component {
return(
<Loja>

<Filtro filtraProdutosBusca={this.onChangeTextoInput} textoInput={this.state.textoInput}/>
<Filtro quantidade = {listaFiltrada.length}
filtraProdutosBusca={this.onChangeTextoInput} textoInput={this.state.textoInput}/>

<ContainerProdutos>
{componentProduto}
Expand Down
19 changes: 16 additions & 3 deletions src/Components/Filtro/Filtro.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from 'react'
import styled from 'styled-components'
// import FiltroBuscaProd from './FiltroBuscaProd'
import FiltroMinMax from './FiltroMinMax'



const BoxFiltro = styled.div`
Expand All @@ -21,11 +20,25 @@ export default class Filtro extends React.Component {
<BoxFiltro>
<h2>Filtros</h2>

<FiltroMinMax />

{/* <FiltroMinMax /> */}

<p>Quantidade de produtos: {this.props.quantidade}</p>


<valMinMax>
<label for="VMin" > Valor Mínimo: </label>
<input id="VMin" type="number" onChange="" />

<label for="VMax"> Valor Máximo: </label>
<input id="VMax" type="number" onChange="" />

</valMinMax>

<label for="BuscaProd"> Buscar Produto: </label>
<input id="BuscaProd" type="text" value= {this.props.textoInput} onChange={(e)=>this.props.filtraProdutosBusca(e)} />


</BoxFiltro>
)
}
Expand Down
22 changes: 0 additions & 22 deletions src/Components/Filtro/FiltroMinMax.js

This file was deleted.