diff --git a/src/Admin/Components/Components/Inputs/IntitutionsInputs.js b/src/Admin/Components/Components/Inputs/IntitutionsInputs.js index f123c236195af749e0f19d35762b4ab4e089735d..3b8378815198c9fc13b464982fea2740e993b4b6 100644 --- a/src/Admin/Components/Components/Inputs/IntitutionsInputs.js +++ b/src/Admin/Components/Components/Inputs/IntitutionsInputs.js @@ -21,7 +21,9 @@ import TextField from '@material-ui/core/TextField'; import Button from "@material-ui/core/Button"; import SaveIcon from "@material-ui/icons/Save"; 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) => { @@ -31,9 +33,10 @@ const InstitutionsInputs = (props) => { const [adress, setAdress] = useState(props.editInfo.adress) const [city, setCity] = useState(props.editInfo.city) 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, { method: 'PUT', headers: { @@ -41,16 +44,16 @@ const InstitutionsInputs = (props) => { 'Content-Type': 'application/json; charset=utf-8', 'access-token': sessionStorage.getItem('@portalmec/accessToken'), 'client': sessionStorage.getItem('@portalmec/clientToken'), - 'uid': sessionStorage.getItem('@portalmec/uid'), + 'uid': sessionStorage.getItem('@portalmec/uid'), 'If-None-Match': null }, - body: JSON.stringify({ + body: JSON.stringify({"institution" : { 'name': name, 'description': '', 'address': adress, 'city': city, 'country': country, - }) + }}) }).then(response => { if(response.status === 200) { console.log('ok') @@ -63,13 +66,13 @@ const InstitutionsInputs = (props) => { console.log(api + '/' + props.editInfo.id); return ( - <form style={{ width: '25%', display: 'flex', flexDirection: 'column' }}> + <form style={{ width: '25%', display: 'flex', flexDirection: 'column' }} onSubmit={SubmitHandler}> <TextField id="outlined-input" label="ID *não pode mudar" defaultValue={props.editInfo.id} //valor recebido por prop variant="outlined" - disabled={true} + disabled={true} /> <div style={{ height: '1em' }} /> @@ -108,7 +111,7 @@ const InstitutionsInputs = (props) => { variant="outlined" /> <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" }} /> Salvar </Button> @@ -116,4 +119,4 @@ const InstitutionsInputs = (props) => { ) } -export default InstitutionsInputs; \ No newline at end of file +export default InstitutionsInputs;