Skip to content
Snippets Groups Projects
Commit 6ff6610f authored by Lucas Eduardo Schoenfelder's avatar Lucas Eduardo Schoenfelder
Browse files

fix api call

parent e721247c
No related branches found
No related tags found
4 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!40merge admin into develop,!37Merge sistema_admin into Update_Admin_System
...@@ -21,7 +21,9 @@ import TextField from '@material-ui/core/TextField'; ...@@ -21,7 +21,9 @@ import TextField from '@material-ui/core/TextField';
import Button from "@material-ui/core/Button"; import Button from "@material-ui/core/Button";
import SaveIcon from "@material-ui/icons/Save"; import SaveIcon from "@material-ui/icons/Save";
import { Store } from '../../../../Store'; import { Store } from '../../../../Store';
// import { apiUrl } from '../../../../env'; import { apiUrl } from '../../../../env';
import axios from 'axios'
import {getAxiosConfig} from '../../../../Components/HelperFunctions/getAxiosConfig'
const InstitutionsInputs = (props) => { const InstitutionsInputs = (props) => {
...@@ -31,9 +33,10 @@ const InstitutionsInputs = (props) => { ...@@ -31,9 +33,10 @@ const InstitutionsInputs = (props) => {
const [adress, setAdress] = useState(props.editInfo.adress) const [adress, setAdress] = useState(props.editInfo.adress)
const [city, setCity] = useState(props.editInfo.city) const [city, setCity] = useState(props.editInfo.city)
const [country, setCountry] = useState(props.editInfo.country) const [country, setCountry] = useState(props.editInfo.country)
const api = 'https://api.portalmectest.c3sl.ufpr.br/v1/institutions'; //Api const api = 'https://api.portalmec.c3sl.ufpr.br/v1/institutions'; //Api
const SubmitHandler = () => { const SubmitHandler = (e) => {
e.preventDefault()
fetch(api + '/' + props.editInfo.id, { fetch(api + '/' + props.editInfo.id, {
method: 'PUT', method: 'PUT',
headers: { headers: {
...@@ -41,16 +44,16 @@ const InstitutionsInputs = (props) => { ...@@ -41,16 +44,16 @@ const InstitutionsInputs = (props) => {
'Content-Type': 'application/json; charset=utf-8', 'Content-Type': 'application/json; charset=utf-8',
'access-token': sessionStorage.getItem('@portalmec/accessToken'), 'access-token': sessionStorage.getItem('@portalmec/accessToken'),
'client': sessionStorage.getItem('@portalmec/clientToken'), 'client': sessionStorage.getItem('@portalmec/clientToken'),
'uid': sessionStorage.getItem('@portalmec/uid'), 'uid': sessionStorage.getItem('@portalmec/uid'),
'If-None-Match': null 'If-None-Match': null
}, },
body: JSON.stringify({ body: JSON.stringify({"institution" : {
'name': name, 'name': name,
'description': '', 'description': '',
'address': adress, 'address': adress,
'city': city, 'city': city,
'country': country, 'country': country,
}) }})
}).then(response => { }).then(response => {
if(response.status === 200) { if(response.status === 200) {
console.log('ok') console.log('ok')
...@@ -63,13 +66,13 @@ const InstitutionsInputs = (props) => { ...@@ -63,13 +66,13 @@ const InstitutionsInputs = (props) => {
console.log(api + '/' + props.editInfo.id); console.log(api + '/' + props.editInfo.id);
return ( return (
<form style={{ width: '25%', display: 'flex', flexDirection: 'column' }}> <form style={{ width: '25%', display: 'flex', flexDirection: 'column' }} onSubmit={SubmitHandler}>
<TextField <TextField
id="outlined-input" id="outlined-input"
label="ID *não pode mudar" label="ID *não pode mudar"
defaultValue={props.editInfo.id} //valor recebido por prop defaultValue={props.editInfo.id} //valor recebido por prop
variant="outlined" variant="outlined"
disabled={true} disabled={true}
/> />
<div style={{ height: '1em' }} /> <div style={{ height: '1em' }} />
...@@ -108,7 +111,7 @@ const InstitutionsInputs = (props) => { ...@@ -108,7 +111,7 @@ const InstitutionsInputs = (props) => {
variant="outlined" variant="outlined"
/> />
<div style={{ height: '1em' }} /> <div style={{ height: '1em' }} />
<Button size="small" style={{ display: 'flex', justifyContent: 'flex-start', alignItems: 'center' }} onClick={SubmitHandler}> <Button size="small" style={{ display: 'flex', justifyContent: 'flex-start', alignItems: 'center' }} type="submit">
<SaveIcon style={{ fill: "#6959CD" }} /> <SaveIcon style={{ fill: "#6959CD" }} />
Salvar Salvar
</Button> </Button>
...@@ -116,4 +119,4 @@ const InstitutionsInputs = (props) => { ...@@ -116,4 +119,4 @@ const InstitutionsInputs = (props) => {
) )
} }
export default InstitutionsInputs; export default InstitutionsInputs;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment