From 057f1ff1ee6c6deb3daf8c9a00d7c86840e3cafb Mon Sep 17 00:00:00 2001 From: "diana.dolgolyova" Date: Tue, 24 Mar 2026 16:54:47 +0300 Subject: [PATCH] fix: MC tab shows 'all archived' instead of misleading filter counts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When all booking groups are archived (e.g. past MC events), the filter pills no longer show 'Новая 5' etc. Instead shows 'Все записи в архиве' with archive auto-expanded. Filter counts now exclude archived items. --- .../admin/bookings/GenericBookingsList.tsx | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/app/admin/bookings/GenericBookingsList.tsx b/src/app/admin/bookings/GenericBookingsList.tsx index 4edf095..fb281c4 100644 --- a/src/app/admin/bookings/GenericBookingsList.tsx +++ b/src/app/admin/bookings/GenericBookingsList.tsx @@ -113,6 +113,14 @@ export function GenericBookingsList({ const activeGroups = filteredGroups.filter((g) => !g.isArchived); const archivedGroups = filteredGroups.filter((g) => g.isArchived); const archivedCount = archivedGroups.reduce((sum, g) => sum + g.items.length, 0); + const allArchived = activeGroups.length === 0 && archivedCount > 0; + + // Count only active (non-archived) items for filter pills + const activeItems = items.filter((item) => { + const group = groups.find((g) => g.items.some((gi) => gi.id === item.id)); + return group && !group.isArchived; + }); + const activeCounts = countStatuses(activeItems); function renderGroup(group: BookingGroup) { const isOpen = expanded[group.key] ?? !group.isArchived; @@ -158,11 +166,17 @@ export function GenericBookingsList({ return (
- -
- {activeGroups.length === 0 && archivedGroups.length === 0 && } - {activeGroups.map(renderGroup)} -
+ {allArchived ? ( +

Все записи в архиве

+ ) : ( + <> + +
+ {activeGroups.length === 0 && archivedGroups.length === 0 && } + {activeGroups.map(renderGroup)} +
+ + )} {archivedCount > 0 && (
- {showArchived && ( + {(showArchived || allArchived) && (
{archivedGroups.map(renderGroup)}