diff --git a/src/Components/ModalConfirmarProfessor.js b/src/Components/ModalConfirmarProfessor.js index 1a07d031b70faf22709397cb7aba937ad2cac3c0..361a391ceafa6d4e0fe97deed38524a48c7e606d 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.abbreviation} - {props.info.school_city.name} </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/PartOne.js b/src/Components/PageProfessorComponents/PartOne.js index 1602ed72bdea6d0ef20a94f3afd5c11651b9d41f..6fe3e70cb933c64da77e923804f69fe375fbc580 100644 --- a/src/Components/PageProfessorComponents/PartOne.js +++ b/src/Components/PageProfessorComponents/PartOne.js @@ -11,7 +11,6 @@ import Divider from '@material-ui/core/Divider'; import {ButtonCancelar} from './PartTwo.js' import axios from 'axios' import FormInput from '../FormInput.js' -import {simcaqAPIurl} from '../../env' export function sortDict (dict) { const newDict = dict.sort((a, b) => (a.name) > (b.name) ? 1 : -1) @@ -19,6 +18,18 @@ export function sortDict (dict) { } +const extractUFInfo = (ufs, name) => { + var id = '' + var abbreviation = '' + for (const obj of ufs) { + if (obj.name === name) { + id = obj.id + abbreviation = obj.abbreviation + } + } + return {id : id, abbreviation : abbreviation} +} + export default function PartOne (props) { //stores initial get response (list of states, sorted alphabetically) const [ufList, setStates] = useState([]) @@ -32,7 +43,6 @@ export default function PartOne (props) { const [uf, setUF] = useState( { algumFoiEscolhido : false, - selected : '', //id name : '', abbreviation : '' } @@ -42,7 +52,6 @@ export default function PartOne (props) { const [municipio, setMunicipio] = useState( { algumFoiEscolhido : false, - selected : '', name : '' } ) @@ -50,62 +59,62 @@ export default function PartOne (props) { const [codigoINEP, setCodigoINEP] = useState( { codigoInvalido : false, - selected : '' + value : '' } ) + const handleCodigoINEP = (event) => { const code = event.target.value setCodigoINEP({...codigoINEP, codigoInvalido : false, - selected : code + value : code }) } const validateINEP = () => { - const code = codigoINEP.selected + const code = codigoINEP.value - axios.get((`${simcaqAPIurl}/portal_mec_inep?filter=school_cod:` + code) + axios.get(('https://www.simcaq.c3sl.ufpr.br/api/v1/portal_mec_inep?filter=school_cod:' + code) ).then( (response) => { - console.log('code ', code, ' is valid') handleSubmit() }, (error) => { setCodigoINEP({...codigoINEP, codigoInvalido : true, - selected : '' + value : '' }) } ) } const handleSubmit = () => { - //console.log('handle submit : ', uf.abbreviation, uf.selected, municipio.name, municipio.selected, codigoINEP.selected) - props.handleBuscar(uf.name, uf.selected, municipio.name, municipio.selected, codigoINEP.selected) + console.log('handle submit : ', uf.abbreviation, uf.name, municipio.name, codigoINEP.value) + props.handleBuscar(uf.abbreviation, uf.name, municipio.name, codigoINEP.value) } //on render component, call simcaq api and update ufList useEffect ( () => { axios.get(('https://simcaq.c3sl.ufpr.br/api/v1/state') ).then( (response) => { + console.log(sortDict(response.data.result)) handleSetStates(sortDict(response.data.result)) - console.log(response.data.result) }, (error) => console.log('erro acessando api do simcaq (estados)')) }, []) const handleChooseUF = (event) => { - const ufID = event.target.value.ufID - const ufAbbreviation = event.target.value.abbreviation - const ufName = event.target.value.name + const ufName = event.target.value + const {id, abbreviation} = extractUFInfo(ufList, ufName) + console.log(id, abbreviation) + setUF({...uf, algumFoiEscolhido : true, - selected : ufID, name : ufName, - abbreviation : ufAbbreviation + abbreviation : abbreviation } ) - axios.get(('https://simcaq.c3sl.ufpr.br/api/v1/city?filter=state:' + ufID) + axios.get(('https://simcaq.c3sl.ufpr.br/api/v1/city?filter=state:' + id) ).then( (response) => { handleSetMunicipioList(sortDict(response.data.result)) }, (error) => console.log('erro acessando api do simcaq (cidades)') @@ -113,11 +122,10 @@ export default function PartOne (props) { } const handleChooseCity = (event) => { - const cityID = event.target.value.id - const cityName = event.target.value.name + const cityName = event.target.value + console.log(cityName) setMunicipio({...municipio, algumFoiEscolhido : true, - selected : cityID, name : cityName } ) @@ -141,7 +149,7 @@ export default function PartOne (props) { > { ufList.map( (ufs)=> - <MenuItem key={ufs.id} value={{abbreviation : ufs.abbreviation, ufID : ufs.id, name : ufs.name}}>{ufs.name}</MenuItem> + <MenuItem key={ufs.name} value={ufs.name}>{ufs.name}</MenuItem> ) } </Select> @@ -156,7 +164,7 @@ export default function PartOne (props) { > { municipioList.map( (cidades)=> - <MenuItem value={{id : cidades.id, name : cidades.name}}>{cidades.name}</MenuItem> + <MenuItem key={cidades.name} value={cidades.name}>{cidades.name}</MenuItem> ) } </Select> @@ -182,7 +190,7 @@ export default function PartOne (props) { <FormInput inputType={'text'} name={'Código INEP'} - value={codigoINEP.selected} + value={codigoINEP.value} handleChange = {handleCodigoINEP} placeholder={'Código INEP'} required={true} diff --git a/src/Components/PageProfessorComponents/PartTwo.js b/src/Components/PageProfessorComponents/PartTwo.js index 8dd0d5b309756fea5a8ea1ee9c219e8e8ee713c5..64113b9d719a86d396eb9c0f36e3e06d2a9ee7f3 100644 --- a/src/Components/PageProfessorComponents/PartTwo.js +++ b/src/Components/PageProfessorComponents/PartTwo.js @@ -40,6 +40,7 @@ export default function PartTwo (props) { return ( <> + {console.log(props)} <Content> <h4>Vamos localizar o seu cadastro:</h4> <Stepper items={props.stepper}/> diff --git a/src/Components/TabPanels/TabPanelRede.js b/src/Components/TabPanels/TabPanelRede.js index 2eb21b00a20c7d6f60a05d7be75a118d022ba823..d31f2bcfa480803f3476f05242bdb01d5eb631e2 100644 --- a/src/Components/TabPanels/TabPanelRede.js +++ b/src/Components/TabPanels/TabPanelRede.js @@ -17,7 +17,7 @@ export default function TabPanelRede (props) { const [followingListLength, setFollowingLength] = useState(0) const [followersList, setFollowers] = useState([]) - const [followersListLength, setFollowersLength] = useState(1) + const [followersListLength, setFollowersLength] = useState(0) useEffect( () => { axios.all([ diff --git a/src/Components/Table.js b/src/Components/Table.js index 295b1bb105050bf1579bd98e55d1ecdea8733039..773a5fffb85387a8a4571b6e80b087c85104c944 100644 --- a/src/Components/Table.js +++ b/src/Components/Table.js @@ -62,6 +62,7 @@ export default function CustomizedTables(props) { <TableBody> {props.rows.map(row => ( <> + {console.log(row)} <StyledTableRow onClick={() => onClick(row)} key={row.id}> <StyledTableCell component="th" scope="row"> {row.id} diff --git a/src/Pages/PageProfessor.js b/src/Pages/PageProfessor.js index 6dc177da2322a524f6ffad2c9222fd47ac25acfc..6660e9767468edb046b521c4fe28049cbd422254 100644 --- a/src/Pages/PageProfessor.js +++ b/src/Pages/PageProfessor.js @@ -26,13 +26,10 @@ export default function PageProfessor (props) { teacher_cpf: '', school_phone: '', school_name: '', - school_City : { - id : '', - name : '' - }, + school_city : '', school_uf : { - id : '', - abbreviation : '' + abbreviation : '', + name : '' }, inep_code: '' } @@ -51,17 +48,14 @@ export default function PageProfessor (props) { ) } - const handleBuscarParteUM = (ufAbbreviation, ufID, nomeMunicipio, idMunicipio, inep) => { - //console.log('handleBuscarParteUM: ', ufAbbreviation, ufID, nomeMunicipio, idMunicipio, inep) + const handleBuscarParteUM = (ufAbbreviation, ufName, nomeMunicipio, inep) => { + console.log('handleBuscarParteUM: ', ufAbbreviation, ufName, nomeMunicipio, inep) setRegisterInformation({...registerInformation, school_uf : { - id : (ufID ? ufID : ''), - abbreviation: (ufAbbreviation ? ufAbbreviation : '') - }, - school_City : { - id : (idMunicipio ? idMunicipio : ''), - name : (nomeMunicipio ? nomeMunicipio : '') + abbreviation: (ufAbbreviation ? ufAbbreviation : ''), + name : (ufName ? ufName : '') }, + school_city : (nomeMunicipio ? nomeMunicipio : ''), inep_code : (inep ? inep : '') }) toggleStepper(false, true, false) @@ -69,16 +63,16 @@ 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 school_city_id = registerInformation.school_city.id const prev_state_name = registerInformation.school_uf.abbreviation - const prev_city_name = registerInformation.school_City.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 : { + school_city : { id : school_city_id, name : (city_name ? city_name : prev_city_name) }, @@ -103,7 +97,7 @@ export default function PageProfessor (props) { const handleFinalSubmit = () => { //adicionar headers de accessToken axios.post( (`${apiUrl}/users/teacher_request`), { - 'city' : registerInformation.school_City.name, + 'city' : registerInformation.school_city.name, 'cpf' : registerInformation.teacher_cpf, 'inep_id' : registerInformation.inep_code, 'phone' : registerInformation.school_phone, diff --git a/src/Pages/UserPage.js b/src/Pages/UserPage.js index f4457ff84c9103662748498b3a7ddd17e2d4b365..420912ac87e511bb2c1c2dd0576d882053437518 100644 --- a/src/Pages/UserPage.js +++ b/src/Pages/UserPage.js @@ -50,8 +50,8 @@ export default function UserPage (props){ const [tabs, setTabs] = useState([ 'Atividades', 'Meus Recursos', 'Favoritos', 'Coleções', 'Rede' ]) - const user = localStorage.getItem('@portalmec/username') - const id = localStorage.getItem('@portalmec/id') + const user = sessionStorage.getItem('@portalmec/username') + const id = sessionStorage.getItem('@portalmec/id') const [modalOpen, handleModal] = useState(false) const config = { diff --git a/src/Store.js b/src/Store.js index 539aecb69d34a136c08d8ba1cd0a742ae3da3b42..d57a0cde937ebbd0457934f9f8964f1308e211b5 100644 --- a/src/Store.js +++ b/src/Store.js @@ -22,7 +22,7 @@ export const Store = React.createContext() const initialState = { searchOpen: false, - userIsLoggedIn : true, + userIsLoggedIn : false, userAgreedToPublicationTerms: true, userAgreedToPublicationPermissions: false, modalColaborarPlataformaOpen : false,