feat: show bought items in a collapsible section for the current day only
Some checks failed
CI / Verify (push) Has been cancelled

Bought items now move down to a 'Comprados hoy' collapsible section
(expanded by default) below the pending ones, and are only visible on
the local day they were bought. Items bought on previous days stay
completed in the database but are hidden from the list.
This commit is contained in:
Jose Selesan
2026-10-16 11:08:42 -03:00
parent c4f6b8bc85
commit 4ff864a557
9 changed files with 344 additions and 44 deletions

View File

@@ -0,0 +1,36 @@
import type { ListItem } from '@superlist/shared'
import { ChevronDownIcon } from 'lucide-react'
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
import type { useUpdateItem } from '@/hooks/use-items'
import { ItemRow } from './item-row'
type BoughtItemListProps = {
items: ListItem[]
updateItem: ReturnType<typeof useUpdateItem>
}
/**
* Collapsible "Comprados hoy" section below the pending items. Expanded by
* default so marking an item visibly moves it down; the user can fold it.
* Tapping an item here un-buys it and it returns to the pending list.
*/
export function BoughtItemList({ items, updateItem }: BoughtItemListProps) {
return (
<Collapsible defaultOpen>
<CollapsibleTrigger className="group flex w-full items-center gap-1.5 py-1 text-left">
<ChevronDownIcon className="text-muted-foreground size-4 transition-transform group-data-[state=closed]:-rotate-90" />
<span className="text-muted-foreground text-sm font-medium">Comprados hoy</span>
<span className="text-muted-foreground text-sm">({items.length})</span>
</CollapsibleTrigger>
<CollapsibleContent>
<ul className="flex flex-col gap-2 pt-2">
{items.map((item) => (
<ItemRow key={item.id} item={item} updateItem={updateItem} />
))}
</ul>
</CollapsibleContent>
</Collapsible>
)
}