diff --git a/package-lock.json b/package-lock.json index 25ba83f..16a367f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7385,7 +7385,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -7403,11 +7404,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7420,15 +7423,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7531,7 +7537,8 @@ }, "inherits": { "version": "2.0.4", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7541,6 +7548,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7553,17 +7561,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.5", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7580,6 +7591,7 @@ "mkdirp": { "version": "0.5.3", "bundled": true, + "optional": true, "requires": { "minimist": "^1.2.5" } @@ -7635,7 +7647,8 @@ }, "npm-normalize-package-bin": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "npm-packlist": { "version": "1.4.8", @@ -7660,7 +7673,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7670,6 +7684,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7738,7 +7753,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -7768,6 +7784,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7785,6 +7802,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7823,11 +7841,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.1.1", - "bundled": true + "bundled": true, + "optional": true } } } @@ -13852,7 +13872,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -13870,11 +13891,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -13887,15 +13910,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -13998,7 +14024,8 @@ }, "inherits": { "version": "2.0.4", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -14008,6 +14035,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -14020,17 +14048,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.5", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -14047,6 +14078,7 @@ "mkdirp": { "version": "0.5.3", "bundled": true, + "optional": true, "requires": { "minimist": "^1.2.5" } @@ -14102,7 +14134,8 @@ }, "npm-normalize-package-bin": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "npm-packlist": { "version": "1.4.8", @@ -14127,7 +14160,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -14137,6 +14171,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -14205,7 +14240,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -14235,6 +14271,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -14252,6 +14289,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -14290,11 +14328,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.1.1", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -14619,7 +14659,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -14637,11 +14678,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -14654,15 +14697,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -14765,7 +14811,8 @@ }, "inherits": { "version": "2.0.4", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -14775,6 +14822,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -14787,17 +14835,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.5", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -14814,6 +14865,7 @@ "mkdirp": { "version": "0.5.3", "bundled": true, + "optional": true, "requires": { "minimist": "^1.2.5" } @@ -14869,7 +14921,8 @@ }, "npm-normalize-package-bin": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "npm-packlist": { "version": "1.4.8", @@ -14894,7 +14947,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -14904,6 +14958,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -14972,7 +15027,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -15002,6 +15058,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -15019,6 +15076,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -15057,11 +15115,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.1.1", - "bundled": true + "bundled": true, + "optional": true } } }, diff --git a/src/components/AppContainer.js b/src/components/AppContainer.js index a0b7945..69e9777 100644 --- a/src/components/AppContainer.js +++ b/src/components/AppContainer.js @@ -1,11 +1,65 @@ import React, { Component } from 'react' +import Home from './Home' +import Header from './Header' +import CriacaoDeServicos from './CriacaoDeServicos' +import Servicos from './servicos/Servicos' +import Footer from './Footer' +import styled from 'styled-components' + +const ContainerRenderiza = styled.div` + position:relative; + margin-bottom: 80px; +` export class AppContainer extends Component { + + state = { + paginaSelecionada: "home" + } + + onClickVoltar = () => { + this.setState({paginaSelecionada: "home"}) + } + + onClickCriarServico = () => { + this.setState({paginaSelecionada: "criacaodeservicos"}) + } + + onClickServicos = () => { + this.setState({paginaSelecionada: "servicos"}) + } + render() { + + const renderizaNaTela = () => { + + switch (this.state.paginaSelecionada) { + case "home": + return + case "servicos": + return + case "criacaodeservicos": + return + } + } + return (
- +
+ {renderizaNaTela()} +
) + } } diff --git a/src/components/CriacaoDeServicos.js b/src/components/CriacaoDeServicos.js new file mode 100644 index 0000000..62cdef1 --- /dev/null +++ b/src/components/CriacaoDeServicos.js @@ -0,0 +1,184 @@ +import React from 'react' +import styled from 'styled-components' +import axios from 'axios' +import CheckBox from '@material-ui/core/Checkbox' +import TextField from '@material-ui/core/TextField' +import FormGroup from '@material-ui/core/FormGroup' +import FormControlLabel from '@material-ui/core/FormControlLabel' +import FormLabel from '@material-ui/core/FormLabel' +import FormControl from '@material-ui/core/FormControl' + + +const ContainerInputs = styled.div` + display: flex; + justify-content: center; + width: 50vw; + margin: 8px auto; +` +const ContainerButtons = styled.div` + width: 10vw; + display: flex; + justify-content:space-between; + margin: 0 auto; +` +const StyledTextField = styled(TextField)` + width: 30vw; +` +const ContainerServicos = styled.div` + border: 1px solid black; + width: 50vw; + padding: 16px; + margin: 16px auto; + border-radius: 20px; +` +export const ButtonCriacao = styled.button` + margin: 16px; + height: 40px; + width: 200px; + background-color: black; + color: #FFF; + border: none; + border-radius: 10px; + cursor: pointer; + outline:none; + :hover{ + background-color: #FFEA52; + color: #474117; + } +` +class CriacaoDeServicos extends React.Component { + + state = { + inputTitulo: "", + inputDescricao: "", + inputValorDaRemuneracao: "", + inputPrazo: "", + metodosPag: [] + } + + onChangeInputTitulo = (event) => { + this.setState({inputTitulo: event.target.value}) + } + + onChangeInputDescricao = (event) => { + this.setState({inputDescricao: event.target.value}) + } + + onChangeInputValorDaRemuneracao = (event) => { + this.setState({inputValorDaRemuneracao: event.target.value}) + } + + onChangeInputPrazo = (event) => { + this.setState({inputPrazo: event.target.value}) + } + + onChangeChecked = (event) => { + let metodosPag = [...this.state.metodosPag, event.target.id] + if(this.state.metodosPag.includes(event.target.id)){ + metodosPag = metodosPag.filter(metodo => metodo !== event.target.id) + } + this.setState({ + metodosPag: metodosPag + }) + + } + + cadastroServico = () => { + const body = { + "title": this.state.inputTitulo, + "description": this.state.inputDescricao, + "value": this.state.inputValorDaRemuneracao, + "paymentMethods": this.state.metodosPag, + "dueDate": this.state.inputPrazo + } + axios.post('https://us-central1-labenu-apis.cloudfunctions.net/futureNinjasOne/jobs', body).then( + alert("Serviço cadastrado com sucesso!"), + this.setState({inputTitulo: "", inputDescricao: "", inputValorDaRemuneracao: "", inputPrazo: "", metodosPag: []}) + ).catch(err => { + console.log(err) + }) + } + + render () { + console.log(this.state.metodosPag) + return ( + + + + + + + + + + + + + + + + Formas de Pagamento + + + } + label="Transferência Bancária" + /> + + } + label="Cartão de débito" + /> + + } + label="Cartão de Crédito" + /> + + } + label="Dinheiro" + /> + + } + label="Cartão de Crédito" + /> + + + + + Cadastrar + Voltar + + + ) + } +} + +export default CriacaoDeServicos \ No newline at end of file diff --git a/src/components/Footer.js b/src/components/Footer.js new file mode 100644 index 0000000..b8347c1 --- /dev/null +++ b/src/components/Footer.js @@ -0,0 +1,25 @@ +import React from 'react' +import styled from 'styled-components' + +const ContainerFooter = styled.div` +height: 50px; +position: fixed; +bottom: 0; +background-color: #2B2D2F; +color: #FFF; +width: 100vw; +text-align: center; +font-size: 0.7em; +` + +class Footer extends React.Component { + render () { + return ( + +

Designed and created by Future Ninjas

+
+ ) + } +} + +export default Footer \ No newline at end of file diff --git a/src/components/Header.js b/src/components/Header.js new file mode 100644 index 0000000..dfc9b9f --- /dev/null +++ b/src/components/Header.js @@ -0,0 +1,53 @@ +import React from 'react' +import styled from 'styled-components' +import Button from '@material-ui/core/Button' + +const H1Header = styled.h1` + margin: 0; + padding: 0; + font-family: Andale Mono, monospace; + cursor: pointer; +` + +const ContainerHeader = styled.div` + height: 10vh; + display: flex; + justify-content: space-between; + border-bottom: 1px solid grey; + padding: 8px; + align-items: center; + padding: 0 32px; +` + +export const ButtonHeader = styled.button` + margin: 16px; + height: 40px; + width: 200px; + background-color: black; + color: #FFF; + border: none; + border-radius: 10px; + cursor: pointer; + outline:none; + :hover{ + background-color: #FFEA52; + color: #474117; + } +` + +class Servicos extends React.Component { + render () { + return ( + + Future Ninjas +
+ PROCURE SERVIÇOS! + SEJA UM PROFISSIONAL! +
+ +
+ ) + } +} + +export default Servicos \ No newline at end of file diff --git a/src/components/Home.js b/src/components/Home.js new file mode 100644 index 0000000..915a24f --- /dev/null +++ b/src/components/Home.js @@ -0,0 +1,84 @@ +import React from 'react' +import styled from 'styled-components' +import axios from 'axios' + + +const AreaHome = styled.div` + width: 100vw; + height: 38vh; + display: grid; + grid-template-columns: 0.5fr 1fr 1fr 1fr; + grid-template-rows: 1fr 1fr ; + grid-gap: 0px 0px; +` +const H2 = styled.h2` + font-size: 40px; + font-family: helvetica''; + /* margin: 45px 0 0 25px;*/ + display: grid; + grid-column: 2/3; + font-weight: lighter; + align-items: center; +` + +const H4 = styled.h4` + font-weight: lighter; + font-size: 16px; + font-family: 'helvetica'; + display: grid; + grid-column: 2/4; + grid-row: 2/4; + +` + +const ButtonHeader = styled.button` + height: 80px; + width: 400px; + font-size: 1.2em; + font-weight: bold; + align-items: center; + background-color: #FF7F50; + color: #2B2D2F; + border: none; + border-radius: 5px; + cursor: pointer; + outline:none; + :hover{ + background-color: #F83F2C; + color: #FFF; + } + display: grid; + grid-column: 4/5; + grid-row: 1/3; + padding: 4px; + align-self: center; +` + +class Home extends React.Component { + + state = { + + } + + render () { + + + return ( +
+ +

O jeito mais esperto de contratar um serviço!

+

Fale o que precisa, receba orçamentos e escolha o melhor.

+ QUERO UM PROFISSIONAL AGORA! +
+
+ +

Você é profissional?

+

Venha, faça seu anúncio gratuito e amplie seus negócios e sua atuação no mercado.

+ CADASTRAR MEUS SERVIÇOS! +
+
+ ) + } +} + +export default Home \ No newline at end of file diff --git a/src/components/servicos/CardServico.js b/src/components/servicos/CardServico.js new file mode 100644 index 0000000..13a835c --- /dev/null +++ b/src/components/servicos/CardServico.js @@ -0,0 +1,145 @@ +import React from 'react' +import styled from 'styled-components' +import axios from 'axios' +//import {ButtonCriacao} from '../CriacaoDeServicos' + +const ContainerCard = styled.div` +border: 1px solid #b2aeae; +padding: 16px; +width: 90%; +height: 100%; +margin: 0 auto; +display: grid; +grid-row: repeat(7, 1fr); +` + +const H2Card = styled.h2` +margin: 0; +padding: 0; +padding-bottom: 10px; +border-bottom: 1px solid black; +text-align: center; +` + +const H3Card = styled.h3` +margin: 0; +padding: 0; +padding-bottom: 15px; +padding-top: 8px; +font-size: 16px; +font-weight: 600; +` + +const ButtonCr = styled.button` + margin: 0 auto; + grid-row: 7/8; + height: 40px; + width: 200px; + background-color: ${props => props.cor}; + color: ${props => props.texto}; + border: ${props => props.border}; + border-radius: ${props => props.borderRadius}; + cursor: pointer; + outline:none; + :hover{ + background-color: ${props => props.hover}; + color: ${props => props.txt}; + /*color: #474117;*/ + } + +` +const ContainerCardServico = styled.div` + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr; + gap: 16px; + padding:8px; + width: 100%; + margin: 16px 0; +` + +class CardServico extends React.Component { + + state = { + teste: false, + nomeBotao: "" + } + + componentDidMount = () => { + this.props.atualiza() + } + + onClickCandidatar = (Identificador) => { + console.log(this.state.teste) + axios.put(`https://us-central1-labenu-apis.cloudfunctions.net/futureNinjasOne/jobs/${Identificador}/take`,) + .then((response) => { + alert("Você se candidatou na vaga") + this.componentDidMount() + }) + .catch((error) => { + console.log(error.message) + }) + this.setState({teste: !this.state.teste}) + console.log(this.state.teste) + } + + onClickDescandidatar = (Identificador) => { + console.log(this.state.teste) + axios.put(`https://us-central1-labenu-apis.cloudfunctions.net/futureNinjasOne/jobs/${Identificador}/giveup`,) + .then((response) => { + alert("Voce se descandidatou desta vaga") + this.componentDidMount() + }) + .catch((error) => { + console.log(error.message) + }) + this.setState({teste: !this.state.teste}) + console.log(this.state.teste) + } + + render () { + + + return( + + + {this.props.lista.map((servico) => { + + const renderizaBotao = servico.taken === true ? "DESCANDIDATAR-ME" : "CANDIDATAR-ME" + + if (servico.taken) { + return ( + + {servico.title} + Descrição: {servico.description} +

Valor: R$ {servico.value}

+

Data de Vencimento: {servico.dueDate}

+

Pagamento: {servico.paymentMethods.map((metodo) => { + return (`${metodo}; `) + })}

+ this.onClickDescandidatar(servico.id)}> {renderizaBotao} +
+ ) + } else { + return ( + + {servico.title} + Descrição: {servico.description} +

Valor: R$ {servico.value}

+

Data de Vencimento: {servico.dueDate}

+

Pagamento: {servico.paymentMethods.map((metodo) => { + return (`${metodo}; `) + })}

+ this.onClickCandidatar(servico.id)}> {renderizaBotao} +
+ ) + } + })} + +
+ ) + + } + +} + +export default CardServico \ No newline at end of file diff --git a/src/components/servicos/Servicos.js b/src/components/servicos/Servicos.js new file mode 100644 index 0000000..dc77a0c --- /dev/null +++ b/src/components/servicos/Servicos.js @@ -0,0 +1,220 @@ +import React from 'react' +import styled from 'styled-components' +import axios from 'axios' +import CardServico from './CardServico' +import Input from '@material-ui/core/TextField' +import Select from '@material-ui/core/NativeSelect' + +const ButtonCriacao = styled.button` + margin: 12.5px; + height: 40px; + width: 100px; + background-color: black; + color: #FFF; + border: none; + border-radius: 10px; + cursor: pointer; + outline:none; + :hover{ + background-color: #FFEA52; + color: #474117; + } +` + +const Option = styled(Select)` + color: #737373; +` + +const DivFiltro = styled.div` + margin-left: 35px; +` + +class Servicos extends React.Component { + + state = { + inputValorMaximo: "", + inputValorMinimo: "", + inputTitulo: "", + inputDescricao: "", + selectOrdem: "", + listaDeServicos: [], + listaFiltrada: [] + } + + componentDidMount = () => { + this.atualizaEstado() + } + + atualizaEstado = () => { + axios.get('https://us-central1-labenu-apis.cloudfunctions.net/futureNinjasOne/jobs',) + .then((response) => { + this.setState({listaDeServicos: response.data.jobs, listaFiltrada: response.data.jobs} ) + }).catch((error) => { + console.log(error.message) + }) + } + + onChangeValorMaximo = (event) => { + this.setState({inputValorMaximo: event.target.value}) + } + + onChangeValorMinimo = (event) => { + this.setState({inputValorMinimo: event.target.value}) + } + + onChangeTitulo = (event) => { + this.setState({inputTitulo: event.target.value}) + } + + onChangeDescricao = (event) => { + this.setState({inputDescricao: event.target.value}) + } + + onChangeSelectOrdem = (event) => { + this.setState({selectOrdem: event.target.value}) + } + + onClickFiltro = () => { + + if (this.state.inputValorMinimo !== "" || this.state.inputValorMaximo !== "") { + const novaListaFiltrada = this.state.listaDeServicos.filter((servico) => { + if (this.state.inputValorMinimo !== "" && this.state.inputValorMaximo !== "") { + if (Number(servico.value) >= this.state.inputValorMinimo && Number(servico.value) <= this.state.inputValorMaximo) { + return true + } + } else if (this.state.inputValorMinimo === "") { + if (Number(servico.value) <= this.state.inputValorMaximo) { + return true + } + } else if (this.state.inputValorMaximo === "") { + if (Number(servico.value) >= this.state.inputValorMinimo) { + return true + } + } + }) + this.setState({listaFiltrada: novaListaFiltrada, inputValorMinimo: "", inputValorMaximo: ""}) + } else { + const novaListaFiltrada2 = this.state.listaDeServicos.filter((servico) => { + return true + }) + this.setState({listaFiltrada: novaListaFiltrada2}) + } + + if (this.state.inputTitulo !== "" && this.state.inputDescricao === "") { + const novaListaFiltrada3 = this.state.listaDeServicos.filter((servico) => { + if (this.state.inputTitulo === servico.title) { + return true + } + }) + this.setState({listaFiltrada: novaListaFiltrada3, inputTitulo: ""}) + } + + if (this.state.inputDescricao !== "" && this.state.inputTitulo === "") { + const novaListaFiltrada4 = this.state.listaDeServicos.filter((servico) => { + if (this.state.inputDescricao === servico.description) { + return true + } + }) + this.setState({listaFiltrada: novaListaFiltrada4, inputDescricao: ""}) + } + } + + render () { + + function ordenaTituloAZ(a,b){ + return (a.title > b.title) ? 1 : ((b.title > a.title) ? -1 : 0); + } + function ordenaTituloZA(a,b){ + return (b.title > a.title) ? 1 : ((a.title > b.title) ? -1 : 0); + } + + function ordenaPrecoMenor (a,b){ + return a.value - b.value + } + function ordenaPrecoMaior (a,b){ + return b.value - a.value + } + + function ordenaPrazoMenor (a,b){ + return (a.dueDate > b.dueDate) ? 1 : ((b.dueDate > a.dueDate) ? -1 : 0); + } + function ordenaPrazoMaior (a,b){ + return (b.dueDate > a.dueDate) ? 1 : ((a.dueDate > b.dueDate) ? -1 : 0); + } + + switch(this.state.selectOrdem){ + case 'OrdemAZ': + this.state.listaDeServicos.sort(ordenaTituloAZ) + this.state.listaFiltrada.sort(ordenaTituloAZ) + break; + case 'OrdemZA': + this.state.listaDeServicos.sort(ordenaTituloZA) + this.state.listaFiltrada.sort(ordenaTituloZA) + break; + case 'MenorPreco': + this.state.listaDeServicos.sort(ordenaPrecoMenor) + this.state.listaFiltrada.sort(ordenaPrecoMenor) + break; + case 'MaiorPreco': + this.state.listaDeServicos.sort(ordenaPrecoMaior) + this.state.listaFiltrada.sort(ordenaPrecoMaior) + break; + case 'MenorPrazo': + this.state.listaDeServicos.sort(ordenaPrazoMenor) + this.state.listaFiltrada.sort(ordenaPrazoMenor) + break; + case 'MaiorPrazo': + this.state.listaDeServicos.sort(ordenaPrazoMaior) + this.state.listaFiltrada.sort(ordenaPrazoMaior) + break; + default: ; + } + + return ( +
+ + + + + + + + + + + + + + Filtrar + +
+ +
+ Voltar +
+ ) + } + +} + +export default Servicos \ No newline at end of file