34 lines
847 B
TypeScript
34 lines
847 B
TypeScript
"use client"
|
|
|
|
import { HttpTypes } from "@medusajs/types"
|
|
import { cn } from "@/lib/utils"
|
|
import Item from "@modules/cart/components/item"
|
|
|
|
type ItemsTemplateProps = {
|
|
cart: HttpTypes.StoreCart
|
|
}
|
|
|
|
/** Compact item list for the checkout summary */
|
|
const ItemsPreviewTemplate = ({ cart }: ItemsTemplateProps) => {
|
|
const items = [...(cart.items ?? [])].sort((a, b) =>
|
|
(a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1
|
|
)
|
|
const hasOverflow = items.length > 4
|
|
|
|
return (
|
|
<ul
|
|
className={cn(
|
|
"divide-y divide-border/70",
|
|
hasOverflow && "max-h-[420px] overflow-y-auto no-scrollbar"
|
|
)}
|
|
data-testid="items-table"
|
|
>
|
|
{items.map((item) => (
|
|
<Item key={item.id} item={item} type="preview" currencyCode={cart.currency_code} />
|
|
))}
|
|
</ul>
|
|
)
|
|
}
|
|
|
|
export default ItemsPreviewTemplate
|