Skip to content
Snippets Groups Projects
Commit f823a9a5 authored by lfr20's avatar lfr20
Browse files

Added a if to detect erros

parent ea9133d4
Branches
Tags
2 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...
Showing with 33 additions and 1 deletion
......@@ -138,6 +138,9 @@ const CreateInstitution = (props) => {
if (data.id)
HandleSnack('A instituição foi criada com sucesso', true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.name) {
let nameError = "";
data.name.map((msg) => (
......
......@@ -128,6 +128,9 @@ const CreateLanguage = (props) => {
if (data.id)
HandleSnack('A linguagem foi criada com sucesso', true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.name) {
let nameError = "";
data.name.map((msg) => (
......
......@@ -124,6 +124,9 @@ const CreateRole = (props) => {
if (data.id)
HandleSnack('A role foi criada com sucesso!', true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.name) {
let errorName = "";
data.name.map((err) => (
......
......@@ -159,7 +159,12 @@ const EditCollection = ({ match }) => {
api,
body,
(data) => {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
else{
HandleSnack('A Coleção foi alterada com sucesso', true, 'success', '#228B22')
}
setIsLoading(false)
},
(error) => {
......
......@@ -276,6 +276,9 @@ const EditEducationalObject = ({ match }) => {
"#228B22"
);
} else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.author) {
let authorError = "";
data.author.map((msg) => (authorError = authorError + msg + " e "));
......
......@@ -186,6 +186,9 @@ const EditLanguage = ({ match }) => {
if (data.id)
HandleSnack('A linguagem foi alterada com sucesso!', true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.name) {
let errorName = "";
data.name.map((err) => (
......
......@@ -163,6 +163,9 @@ const EditLanguage = ({ match }) => {
if (data.id)
HandleSnack('A role foi alterada com sucesso', true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.name) {
let errorName = "";
data.name.map((err) => (
......
......@@ -329,6 +329,9 @@ const EditUser = ({ match }) => {
if (data.id)
HandleSnack(`O usuário: ${name} foi atualizado`, true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.email) {
let emailError = "";
data.email.map((msg) => (
......
......@@ -150,6 +150,9 @@ const EditInstitution = ({ match }) => {
if (data.id)
HandleSnack('A instituição foi criada com sucesso!', true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.name) {
let errorName = "";
data.name.map((err) => (
......
......@@ -170,6 +170,9 @@ const NoteVarInputs = ({ match }) => {
if (data.id)
HandleSnack('A variável de nota foi atualizada com sucesso!', true, 'success', '#228B22')
else {
if(data.errors){
HandleSnack(`${data.errors[0]}`, true, 'warning', '#FA8072')
}
if (data.name) {
let errorName = "";
data.name.map((err) => (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment