From abb0fbbb80e9b4682779ac0caf5e00f37be5a505 Mon Sep 17 00:00:00 2001 From: Lucas Schoenfelder <les17@inf.ufpr.br> Date: Thu, 20 Feb 2020 11:59:57 -0300 Subject: [PATCH] pagina de requisicao professor quase pronta --- src/Components/ModalConfirmarProfessor.js | 2 +- .../PageProfessorComponents/PartThree.js | 1 + .../PageProfessorComponents/PartTwo.js | 6 +-- src/Pages/PageProfessor.js | 46 ++++++++++--------- src/env.js | 2 +- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/Components/ModalConfirmarProfessor.js b/src/Components/ModalConfirmarProfessor.js index 361a391c..3cbb4e79 100644 --- a/src/Components/ModalConfirmarProfessor.js +++ b/src/Components/ModalConfirmarProfessor.js @@ -65,7 +65,7 @@ export default function ModalConfirmarProfessor (props){ <DialogContentDiv> <ContainerCentralized> - <p><strong>MunicÃpio - UF:</strong> {props.info.school_uf.abbreviation} - {props.info.school_city.name} </p> + <p><strong>MunicÃpio - UF:</strong> {props.info.school_uf.name} - {props.info.school_city} </p> <p><strong>Escola:</strong> {props.info.school_name}</p> <p><strong>Telefone da Escola:</strong> {props.info.school_phone}</p> <p><strong>Seu CPF:</strong> {props.info.teacher_cpf}</p> diff --git a/src/Components/PageProfessorComponents/PartThree.js b/src/Components/PageProfessorComponents/PartThree.js index d5dcdbfc..2ee7c262 100644 --- a/src/Components/PageProfessorComponents/PartThree.js +++ b/src/Components/PageProfessorComponents/PartThree.js @@ -44,6 +44,7 @@ export default function PartThree (props) { return ( <> + {console.log(props)} <Content> <h4>Vamos localizar o seu cadastro:</h4> <Stepper items={props.stepper}/> diff --git a/src/Components/PageProfessorComponents/PartTwo.js b/src/Components/PageProfessorComponents/PartTwo.js index 64113b9d..a4e68d4a 100644 --- a/src/Components/PageProfessorComponents/PartTwo.js +++ b/src/Components/PageProfessorComponents/PartTwo.js @@ -14,8 +14,8 @@ export default function PartTwo (props) { useEffect ( () => { const code = (props.info.inep_code || '') - const uf = (props.info.school_uf.id || '') - const municipio = (props.info.school_City.id || '') + const uf = (props.info.school_uf.abbreviation || '') + const municipio = (props.info.school_city || '') //console.log(code, uf, municipio) //if user searched by inep code @@ -26,7 +26,7 @@ export default function PartTwo (props) { }, (error) => console.log('erro ao dar get na escola por inep code') )} else if (uf !== '' && municipio !== '') { - axios.get((`${simcaqAPIurl}/school?filter=state:"` + uf + '",city:"' + municipio + '",year:2017') + axios.get((`${simcaqAPIurl}/school?search=state_name:"` + uf + '",city_name:"' + municipio + '"&filter=year:2017') ).then((response)=> { //console.log(response.data.result) setSchoolList(sortDict(response.data.result)) diff --git a/src/Pages/PageProfessor.js b/src/Pages/PageProfessor.js index 6660e976..e729721e 100644 --- a/src/Pages/PageProfessor.js +++ b/src/Pages/PageProfessor.js @@ -48,8 +48,8 @@ export default function PageProfessor (props) { ) } - const handleBuscarParteUM = (ufAbbreviation, ufName, nomeMunicipio, inep) => { - console.log('handleBuscarParteUM: ', ufAbbreviation, ufName, nomeMunicipio, inep) + const handleBuscarParteUm = (ufAbbreviation, ufName, nomeMunicipio, inep) => { + console.log('handleBuscarParteUm: ', ufAbbreviation, ufName, nomeMunicipio, inep) setRegisterInformation({...registerInformation, school_uf : { abbreviation: (ufAbbreviation ? ufAbbreviation : ''), @@ -62,27 +62,23 @@ export default function PageProfessor (props) { } const handleBuscarParteDois = (city_name, inep, school_name, state_name) => { - const uf_id = registerInformation.school_uf.id - const school_city_id = registerInformation.school_city.id - const prev_state_name = registerInformation.school_uf.abbreviation + const uf_abbreviation = registerInformation.school_uf.abbreviation + const prev_state_name = registerInformation.school_uf.name const prev_city_name = registerInformation.school_city.name setRegisterInformation({...registerInformation, school_uf : { - id : uf_id, - abbreviation: (state_name ? state_name : prev_state_name) - }, - school_city : { - id : school_city_id, - name : (city_name ? city_name : prev_city_name) + abbreviation : uf_abbreviation, + name: (state_name ? state_name : prev_state_name) }, + school_city :(city_name ? city_name : prev_city_name), school_name: (school_name ? school_name : ''), inep_code : (inep ? inep : '') }) toggleStepper(false, false, true) } - const handleSubmit = (phone, cpf) => { + const handleParteTres = (phone, cpf) => { setRegisterInformation({...registerInformation, teacher_cpf: (phone ? phone : ''), school_phone: (cpf ? cpf : ''), @@ -96,14 +92,20 @@ export default function PageProfessor (props) { const handleFinalSubmit = () => { //adicionar headers de accessToken - axios.post( (`${apiUrl}/users/teacher_request`), { - 'city' : registerInformation.school_city.name, - 'cpf' : registerInformation.teacher_cpf, - 'inep_id' : registerInformation.inep_code, - 'phone' : registerInformation.school_phone, - 'school' : registerInformation.school_name, - 'uf' : registerInformation.school_uf.abbreviation - }) + axios.post( `${apiUrl}/users/teacher_request`, { + city : registerInformation.school_city.name, + cpf : registerInformation.teacher_cpf, + inep_id : registerInformation.inep_code, + phone : registerInformation.school_phone, + school : registerInformation.school_name, + uf : registerInformation.school_uf.name + }, + { headers : { + 'Access-Token': sessionStorage.getItem('@portalmec/accessToken'), + 'Client': sessionStorage.getItem('@portalmec/clientToken'), + 'Uid': sessionStorage.getItem('@portalmec/uid') + }} + ) .then( (response) => { console.log(response.data) }, (error) => console.log('deu erro') @@ -125,7 +127,7 @@ export default function PageProfessor (props) { <Paper elevation={3} style= {{width:"max-content"}}> <div style={{paddingRight:"15px", paddingLeft:"15px"}}> {stepper[0].selected && - <PartOne stepper={stepper} handleBuscar={handleBuscarParteUM} + <PartOne stepper={stepper} handleBuscar={handleBuscarParteUm} handleCancelar={handleCancelar} /> } @@ -138,7 +140,7 @@ export default function PageProfessor (props) { {stepper[2].selected && <PartThree stepper={stepper} goBack={toggleStepper} handleCancelar={handleCancelar} info={registerInformation} - handleSubmit={handleSubmit} + handleSubmit={handleParteTres} /> } </div> diff --git a/src/env.js b/src/env.js index 1f221ee7..2450da0f 100644 --- a/src/env.js +++ b/src/env.js @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/ -var apiDomain = 'https://api.portalmec.c3sl.ufpr.br', +var apiDomain = 'https://api.portalmectest.c3sl.ufpr.br', apiVersion = 'v1', apiUrl = apiDomain + '/' + apiVersion; -- GitLab