frontend: Hotfix loading

This commit is contained in:
Divlo 2020-03-25 18:46:23 +01:00
parent 7d49422108
commit 96af78f967
2 changed files with 6 additions and 6 deletions

View File

@ -11,25 +11,22 @@ const FunctionForm = (props) => {
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = (event) => {
setIsLoading(true);
event.preventDefault();
api.post(`/functions/${props.slug}`, inputState)
.then((response) => {
setMessage(response.data.resultHTML);
setIsLoading(false);
})
.catch((error) => {
setMessage(error.response.data.message);
setIsLoading(false);
});
setIsLoading(false);
}
const handleChange = (event) => {
const inputStateNew = { ...inputState };
inputStateNew[event.target.name] = event.target.value;
if (event.target.value !== "") {
setIsLoading(true);
} else {
setIsLoading(false);
}
setInputState(inputStateNew);
}

View File

@ -18,13 +18,16 @@ const Register = () => {
}
const handleSubmit = (event) => {
setIsLoading(true);
event.preventDefault();
api.post('/users/register', inputState)
.then(({ data }) => {
setMessage(`<p class="form-success"><b>Succès:</b> ${data.result}</p>`);
setIsLoading(false);
})
.catch((error) => {
setMessage(`<p class="form-error"><b>Erreur:</b> ${error.response.data.message}</p>`);
setIsLoading(false);
});
}