diff --git a/templates/profile/invitation.html b/templates/profile/invitation.html index c9b0a6c..c269adf 100644 --- a/templates/profile/invitation.html +++ b/templates/profile/invitation.html @@ -29,8 +29,18 @@ data-post-id="{{ doc._id }}" onchange="selectPost(this)" > - Выбрать + Принять + +

...

@@ -145,7 +155,6 @@ const postId = String(checkbox.dataset.postId || ''); if (!postId) return; - // делаем из текущего состояния множества (устойчиво к дублям и т.п.) const ids = loadSelectedIds(); const set = new Set(ids); @@ -159,6 +168,36 @@ updateSelectedCount(); } + function uSelectPost(checkbox) { + if (!checkbox || !checkbox.dataset) return; + + const postId = String(checkbox.dataset.postId || ''); + if (!postId) return; + + // Reject: remove from selected and uncheck any accept checkbox for same post + const ids = loadSelectedIds(); + const set = new Set(ids); + set.delete(postId); + saveSelectedIds(Array.from(set)); + + // Uncheck the "Принять" checkbox for this post + const figure = checkbox.closest('figure'); + if (figure) { + const acceptBoxes = figure.querySelectorAll('.offer-checkbox'); + acceptBoxes.forEach(cb => { + if (cb !== checkbox) { + cb.checked = false; + setStateUI(cb); + } + }); + } + + setStateUI(checkbox); + updateSelectedCount(); + } + + + async function accept_inv(inv_id) { const ids = loadSelectedIds(); @@ -181,8 +220,6 @@ showToast({ message: 'Приглашение принято. Перенаправляем на страницу доставки' }); - - setTimeout(() => { localStorage.removeItem(LS_KEY); window.location.href = '/profile/delivery#main?exhibition_id={{doc.get("exhibition_id")}}'; @@ -193,7 +230,6 @@ } } - // загрузка состояния при открытии страницы document.addEventListener('DOMContentLoaded', () => { setAllCheckboxesFromStorage(); });