This commit is contained in:
Vladislav 2026-07-28 10:10:21 -04:00
parent 70a97da790
commit 01eba5aa1e

View File

@ -29,8 +29,18 @@
data-post-id="{{ doc._id }}"
onchange="selectPost(this)"
>
<span class="offer-text">Выбрать</span>
<span class="offer-text">Принять</span>
</label>
<label class="offer-label">
<input
type="checkbox"
class="offer-checkbox"
data-post-id="{{ doc._id }}"
onchange="uSelectPost(this)"
>
<span class="offer-text">Отклонить</span>
</label>
<p class="b_6spaf">...</p>
</figcaption>
@ -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();
});