Remove use of @rails/ujs in report dialog handler

This commit is contained in:
Karina Kwiatek 2023-01-03 14:59:53 +01:00 committed by Andreas Nedbal
parent 5735ba888c
commit 7fa548b613
1 changed files with 12 additions and 14 deletions

View File

@ -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';
@ -20,21 +20,19 @@ export function reportDialog(type: string, target: string): void {
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'));
}); });
}); });
} }