Refactor global anon blocks to use request.js
This commit is contained in:
parent
6639519905
commit
389e1271d7
|
@ -1,4 +1,4 @@
|
|||
import Rails from '@rails/ujs';
|
||||
import { post } from '@rails/request.js';
|
||||
import swal from 'sweetalert';
|
||||
|
||||
import { showErrorNotification, showNotification } from "utilities/notifications";
|
||||
|
@ -28,19 +28,20 @@ export function blockAnonEventHandler(event: Event): void {
|
|||
global: 'true'
|
||||
};
|
||||
|
||||
Rails.ajax({
|
||||
url: '/ajax/block_anon',
|
||||
type: 'POST',
|
||||
data: new URLSearchParams(data).toString(),
|
||||
success: (data) => {
|
||||
post('/ajax/block_anon', {
|
||||
body: data,
|
||||
contentType: 'application/json'
|
||||
})
|
||||
.then(async response => {
|
||||
const data = await response.json;
|
||||
|
||||
if (!data.success) return false;
|
||||
|
||||
showNotification(data.message);
|
||||
},
|
||||
error: (data, status, xhr) => {
|
||||
console.log(data, status, xhr);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
showErrorNotification(I18n.translate('frontend.error.message'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue