diff --git a/src/App.js b/src/App.js index ca93521..2cd54b8 100644 --- a/src/App.js +++ b/src/App.js @@ -77,7 +77,8 @@ export default class App extends Component { }, ], - textoInput: '' + textoInput: '', + inputCrescente: "Crescente" } @@ -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) ) @@ -114,7 +135,8 @@ export default class App extends Component { return( - + {componentProduto} diff --git a/src/Components/Filtro/Filtro.js b/src/Components/Filtro/Filtro.js index 4e1f36c..a7a2c0c 100644 --- a/src/Components/Filtro/Filtro.js +++ b/src/Components/Filtro/Filtro.js @@ -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` @@ -21,11 +20,25 @@ export default class Filtro extends React.Component {

Filtros

- + + {/* */} + +

Quantidade de produtos: {this.props.quantidade}

+ + + + + + + + + + this.props.filtraProdutosBusca(e)} /> +
) } diff --git a/src/Components/Filtro/FiltroMinMax.js b/src/Components/Filtro/FiltroMinMax.js deleted file mode 100644 index e7effba..0000000 --- a/src/Components/Filtro/FiltroMinMax.js +++ /dev/null @@ -1,22 +0,0 @@ -import React, { Component } from 'react' -import styled from 'styled-components' - -const valMinMax = styled.div` -margin: flex;` - - - -export default class FiltroMinMax extends Component { - render() { - return ( - - - - - - - - - ) - } -} \ No newline at end of file