Skip to content

Commit 918afef

Browse files
laemtlAlexandraLivadas
authored andcommitted
[Publications] Error and swal fix (aces#7326)
Small changes following the comment made in aces#7315 - Fix missing error message - Fix missing swal callback change (aces#6195 regression) previously in aces#7091 Replace aces#7091
1 parent 4d51754 commit 918afef

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

modules/publication/jsx/uploadForm.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class PublicationUploadForm extends React.Component {
4242
}).then((response) => {
4343
if (!response.ok) {
4444
console.error(response.status);
45+
this.setState({
46+
loadError: 'An error occurred when loading the form!',
47+
});
4548
return;
4649
}
4750

@@ -52,6 +55,7 @@ class PublicationUploadForm extends React.Component {
5255
})
5356
);
5457
}).catch((error) => {
58+
// Network error
5559
console.error(error);
5660
this.setState({
5761
loadError: 'An error occurred when loading the form!',
@@ -165,6 +169,10 @@ class PublicationUploadForm extends React.Component {
165169
}).then((response) => {
166170
if (!response.ok) {
167171
console.error(response.status);
172+
response.json().then((data) => {
173+
let message = (data && data.message) || '';
174+
swal.fire('Something went wrong!', message, 'error');
175+
});
168176
return;
169177
}
170178

@@ -178,12 +186,11 @@ class PublicationUploadForm extends React.Component {
178186
{
179187
title: 'Submission Successful!',
180188
type: 'success',
181-
},
182-
function() {
189+
}).then(function() {
183190
window.location.replace(loris.BaseURL + '/publication/');
184-
}
185-
);
191+
});
186192
}).catch((error) => {
193+
// Network error
187194
console.error(error);
188195
swal.fire('Something went wrong!', '', 'error');
189196
});

modules/publication/jsx/viewProject.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,16 @@ class ViewProject extends React.Component {
6565
}).then((response) => {
6666
if (!response.ok) {
6767
console.error(response.status);
68+
response.json().then((data) => {
69+
let message = (data && data.message) || 'Something went wrong!';
70+
swal.fire('Edit failed!', message, 'error');
71+
});
6872
return;
6973
}
74+
7075
swal.fire('Edit Successful!', '', 'success');
7176
}).catch((error) => {
77+
// Network error
7278
console.error(error);
7379
swal.fire('Edit failed!', 'Something went wrong!', 'error');
7480
});
@@ -83,6 +89,9 @@ class ViewProject extends React.Component {
8389
}).then((response) => {
8490
if (!response.ok) {
8591
console.error(response.status);
92+
this.setState({
93+
error: 'An error occurred when loading the form!',
94+
});
8695
return;
8796
}
8897

@@ -134,6 +143,7 @@ class ViewProject extends React.Component {
134143
});
135144
});
136145
}).catch((error) => {
146+
// Network error
137147
console.error(error);
138148
this.setState({
139149
error: 'An error occurred when loading the form!',

0 commit comments

Comments
 (0)