Skip to content

Commit

Permalink
atualizacao dos posts
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasvduarte committed Nov 15, 2019
1 parent 4c8e933 commit 9ab6f7d
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/screen/choices/allChoices/AllChoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function AllChoices() {
setRequest(true)
})

}, [])
}, [data.length])

const choicesInformation = () => {
const choicesInformation = data.map((obj) => {
Expand Down
11 changes: 6 additions & 5 deletions src/screen/choices/myChoices/CreateChoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ function CreateChoicesForm() {
}
}

const postCreateChoices = () => {
ChoicesApi.postChoicesApi(values).then(res => {
const postCreateChoices = async (event) => {
event.preventDefault();
await ChoicesApi.postChoicesApi(values).then(res => {
}).catch(error => {
console.log(error.response)
}).finally(
history.replace("/quiz/meus-quizes")
)
})
setTimeout(() => history.replace("/quiz/meus-quizes"), 10)

}

const advancedOptions = (
Expand Down
2 changes: 1 addition & 1 deletion src/screen/choices/myChoices/MyChoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Choices() {
setRequest(true)
})

}, [])
}, [data.length])

const choicesInformation = () => {
const choicesInformation = data.map((obj) => {
Expand Down
2 changes: 1 addition & 1 deletion src/screen/missions/allMission/AllMissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function AllMissions() {
setRequest(true)
})

}, [])
}, [data.length])

const missionsInformation = () => {
const missionsInformation = data.map((obj) => {
Expand Down
11 changes: 6 additions & 5 deletions src/screen/missions/myMission/CreateMission.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ function CreateMissionForm() {
}
}

const postCreateMission = () => {
MissionsApi.postMissionsApi(values).then(res => {
const postCreateMission = async (event) => {
event.preventDefault();
await MissionsApi.postMissionsApi(values).then(res => {
}).catch(error => {
console.log(error.response)
}).finally(
history.replace("/missoes/minhas-missoes")
)
})

setTimeout(() => history.replace("/missoes/minhas-missoes"), 10)
}

const advancedOptions = (
Expand Down
2 changes: 1 addition & 1 deletion src/screen/missions/myMission/MyMissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function MyMissions() {
setRequest(true)
})

}, [])
}, [data.length])

const missionsInformation = () => {
const missionsInformation = data.map((obj) => {
Expand Down
4 changes: 3 additions & 1 deletion src/screen/person/Person.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ function Person() {
setRequest(true)
})

}, [])
}, [data.length])

console.log(data.length)

const personInformation = () => {
const personInformation = data.map((obj) => {
Expand Down
17 changes: 9 additions & 8 deletions src/screen/person/RegisterPerson.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Button from '@material-ui/core/Button'
import MenuItem from '@material-ui/core/MenuItem'
import { RenderTextField, SelectField } from '../../components/form/Form'
import { useHistory } from "react-router-dom"

var buttonSubmitValidate = false

const validate = values => {
Expand Down Expand Up @@ -43,20 +42,22 @@ function RegisterPersonForm() {

}

const postNewUser = () => {
const postNewUser = async (event) => {
event.preventDefault();
const person = {
name: values.name,
email: values.email,
password: values.password,
type: values.type,
institution: (values.type === 'gestor' || values.type === 'usuarioComum') ? '' : values.institution
}
PersonApi.postPersonApi(person).then(res => {
await PersonApi.postPersonApi(person).then(res => {
}).catch(error => {
console.log(error)
}).finally(
history.replace("/pessoas")
)
})

setTimeout(() => history.replace("/pessoas"), 10)

}

const disabledButton = () => {
Expand All @@ -66,7 +67,7 @@ function RegisterPersonForm() {
}

return (
<form id='form'>
<form id='form' onSubmit={postNewUser}>
<Field onChange={handleChange('name')} name="name" component={RenderTextField} type='text' label="Full Name" />
<Field onChange={handleChange('email')} name="email" component={RenderTextField} type='email' label="Email" />
<Field onChange={handleChange('password')} name="password" component={RenderTextField} type='password' label="Password" />
Expand All @@ -80,7 +81,7 @@ function RegisterPersonForm() {
{(values.type === 'professor' || values.type === 'estudante') &&
<Field onChange={handleChange('institution')} name="institution" component={RenderTextField} type='text' label="institution" />
}
<Button variant="contained" color="secondary" disabled={!(!disabledButton() && buttonSubmitValidate)} onClick={postNewUser}>Cadastrar</Button>
<Button type='submit' variant="contained" color="secondary" disabled={!(!disabledButton() && buttonSubmitValidate)}>Cadastrar</Button>
</form>
)
}
Expand Down

0 comments on commit 9ab6f7d

Please sign in to comment.