fix: MC tab shows 'all archived' instead of misleading filter counts
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.
This commit is contained in:
@@ -113,6 +113,14 @@ export function GenericBookingsList<T extends BaseBooking>({
|
|||||||
const activeGroups = filteredGroups.filter((g) => !g.isArchived);
|
const activeGroups = filteredGroups.filter((g) => !g.isArchived);
|
||||||
const archivedGroups = filteredGroups.filter((g) => g.isArchived);
|
const archivedGroups = filteredGroups.filter((g) => g.isArchived);
|
||||||
const archivedCount = archivedGroups.reduce((sum, g) => sum + g.items.length, 0);
|
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<T>) {
|
function renderGroup(group: BookingGroup<T>) {
|
||||||
const isOpen = expanded[group.key] ?? !group.isArchived;
|
const isOpen = expanded[group.key] ?? !group.isArchived;
|
||||||
@@ -158,11 +166,17 @@ export function GenericBookingsList<T extends BaseBooking>({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<FilterTabs filter={filter} counts={counts} total={items.length} onFilter={setFilter} />
|
{allArchived ? (
|
||||||
|
<p className="text-sm text-neutral-500 py-4">Все записи в архиве</p>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<FilterTabs filter={filter} counts={activeCounts} total={activeItems.length} onFilter={setFilter} />
|
||||||
<div className="mt-3 space-y-2">
|
<div className="mt-3 space-y-2">
|
||||||
{activeGroups.length === 0 && archivedGroups.length === 0 && <EmptyState total={items.length} />}
|
{activeGroups.length === 0 && archivedGroups.length === 0 && <EmptyState total={items.length} />}
|
||||||
{activeGroups.map(renderGroup)}
|
{activeGroups.map(renderGroup)}
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{archivedCount > 0 && (
|
{archivedCount > 0 && (
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<button
|
<button
|
||||||
@@ -170,10 +184,10 @@ export function GenericBookingsList<T extends BaseBooking>({
|
|||||||
className="flex items-center gap-2 text-xs text-neutral-500 hover:text-neutral-300 transition-colors"
|
className="flex items-center gap-2 text-xs text-neutral-500 hover:text-neutral-300 transition-colors"
|
||||||
>
|
>
|
||||||
<Archive size={13} />
|
<Archive size={13} />
|
||||||
{showArchived ? "Скрыть архив" : `Архив (${archivedCount} записей)`}
|
{(showArchived || allArchived) ? "Скрыть архив" : `Архив (${archivedCount} записей)`}
|
||||||
{showArchived ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
|
{(showArchived || allArchived) ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
|
||||||
</button>
|
</button>
|
||||||
{showArchived && (
|
{(showArchived || allArchived) && (
|
||||||
<div className="mt-2 space-y-2">
|
<div className="mt-2 space-y-2">
|
||||||
{archivedGroups.map(renderGroup)}
|
{archivedGroups.map(renderGroup)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user