feat(чат): категории жалоб и attention

This commit is contained in:
anor
2026-11-06 22:45:33 +10:00
parent 45102c3dde
commit 4f3d47926a
6 changed files with 100 additions and 11 deletions
+7 -4
View File
@@ -2101,8 +2101,10 @@ function openFeedbackForm(btn, answerText) {
btn._fbForm = form;
form.innerHTML =
'<div class="fb-cats">' +
'<button type="button" class="fb-cat" data-c="Ответ неверный">Ответ неверный</button>' +
'<button type="button" class="fb-cat" data-c="Другое">Другое</button></div>' +
'<button type="button" class="fb-cat" data-c="wrong_answer">Ответ неверный</button>' +
'<button type="button" class="fb-cat" data-c="off_topic">Не по делу</button>' +
'<button type="button" class="fb-cat" data-c="failure">Сбой</button>' +
'<button type="button" class="fb-cat" data-c="praise">Похвала</button></div>' +
'<textarea class="fb-text" placeholder="Что не так? (можно кратко)" aria-label="Комментарий"></textarea>' +
'<div class="fb-actions"><button type="button" class="fb-send">Отправить</button>' +
'<button type="button" class="fb-cancel">Отмена</button></div>';
@@ -2127,11 +2129,12 @@ function openFeedbackForm(btn, answerText) {
return;
}
sendBtnFb.disabled = true;
const comment = (cat ? cat + ': ' : '') + ta.value.trim();
const comment = ta.value.trim();
try {
const r = await authFetch('/api/feedback', {
method: 'POST', headers: {'Content-Type': 'application/json'},
body: JSON.stringify({comment: comment, answer: answerText})});
body: JSON.stringify({comment: comment, answer: answerText,
category: cat || null, source: 'chat'})});
close();
btn.textContent = r.ok ? 'Спасибо, отправлено' : 'Ошибка отправки';
if (r.ok) btn.classList.add('copied');