Port inbox question generation functionality to TypeScript

This commit is contained in:
Andreas Nedbal 2022-01-03 03:28:21 +01:00 committed by Andreas Nedbal
parent 8797652746
commit 721ff425b2
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import Rails from '@rails/ujs';
import I18n from '../../../legacy/i18n';
import { updateDeleteButton } from './delete';
import { showErrorNotification } from 'utilities/notifications';
export function generateQuestionHandler(): void {
Rails.ajax({
url: '/ajax/generate_question',
type: 'POST',
dataType: 'json',
success: (data) => {
if (!data.success) return false;
document.querySelector('#entries').insertAdjacentHTML('afterbegin', data.render);
updateDeleteButton();
},
error: (data, status, xhr) => {
console.log(data, status, xhr);
showErrorNotification(I18n.t('frontend.error.message'));
}
});
}