Skip to content

Commit

Permalink
Fix counter (#922)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Neander <[email protected]>
  • Loading branch information
timuric and zaiste authored Oct 10, 2023
1 parent 36cfbdf commit fd54357
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ui/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export async function Nav() {
const checkoutId = cookies().get("checkoutId")?.value || "";

const checkout = await Checkout.find(checkoutId);
const lines = checkout ? checkout.lines : [];

const lineCount = checkout ? checkout.lines.reduce((result, line) => result + line.quantity, 0) : 0;

return (
<div className="sticky top-0 z-20 border-b bg-gray-100/75 backdrop-blur-md">
Expand All @@ -36,7 +37,7 @@ export async function Nav() {
<div className="">
<Link href="/cart" className="group -m-2 flex items-center p-2">
<ShoppingBagIcon className="h-6 w-6 flex-shrink-0 " aria-hidden="true" />
<span className="ml-2 text-sm font-medium ">{lines.length}</span>
<span className="ml-2 text-sm font-medium ">{lineCount || ""}</span>
<span className="sr-only">items in cart, view bag</span>
</Link>
</div>
Expand Down

1 comment on commit fd54357

@vercel
Copy link

@vercel vercel bot commented on fd54357 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.