Remove use of @rails/ujs in report dialog handler
This commit is contained in:
parent
5735ba888c
commit
7fa548b613
|
@ -1,4 +1,4 @@
|
||||||
import Rails from '@rails/ujs';
|
import { post } from '@rails/request.js';
|
||||||
import swal from 'sweetalert';
|
import swal from 'sweetalert';
|
||||||
|
|
||||||
import I18n from 'retrospring/i18n';
|
import I18n from 'retrospring/i18n';
|
||||||
|
@ -19,22 +19,20 @@ export function reportDialog(type: string, target: string): void {
|
||||||
if (returnValue === false) {
|
if (returnValue === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rails.ajax({
|
post('/ajax/report', {
|
||||||
url: '/ajax/report',
|
body: {
|
||||||
type: 'POST',
|
|
||||||
data: new URLSearchParams({
|
|
||||||
id: String(target),
|
id: String(target),
|
||||||
type: type,
|
type: type,
|
||||||
reason: returnValue
|
reason: returnValue
|
||||||
}).toString(),
|
|
||||||
success: (data) => {
|
|
||||||
showNotification(data.message);
|
|
||||||
},
|
|
||||||
error: (data, status, xhr) => {
|
|
||||||
console.log(data, status, xhr);
|
|
||||||
showErrorNotification(I18n.translate('frontend.error.message'));
|
|
||||||
}
|
}
|
||||||
|
}).then(async response => {
|
||||||
|
const data = await response.json;
|
||||||
|
|
||||||
|
showNotification(data.message, data.success);
|
||||||
|
}).catch(e => {
|
||||||
|
console.error("Failed to submit report", e);
|
||||||
|
showErrorNotification(I18n.translate('frontend.error.message'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue