47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import ItemsTemplate from "./items"
|
||
import Summary from "./summary"
|
||
import EmptyCartMessage from "../components/empty-cart-message"
|
||
import SignInPrompt from "../components/sign-in-prompt"
|
||
import { HttpTypes } from "@medusajs/types"
|
||
|
||
const CartTemplate = ({
|
||
cart,
|
||
customer,
|
||
}: {
|
||
cart: HttpTypes.StoreCart | null
|
||
customer: HttpTypes.StoreCustomer | null
|
||
}) => {
|
||
const count = cart?.items?.reduce((sum, i) => sum + i.quantity, 0) ?? 0
|
||
|
||
return (
|
||
<div className="content-container pb-20 sm:pb-28" data-testid="cart-container">
|
||
{cart?.items?.length ? (
|
||
<>
|
||
<header className="pt-14 sm:pt-20 pb-10 sm:pb-14 text-center">
|
||
<p className="eyebrow">Korpa</p>
|
||
<h1 className="display-heading mt-5 text-4xl sm:text-6xl text-foreground">Vaša korpa</h1>
|
||
<p className="mt-4 text-sm text-muted-foreground">
|
||
{count % 10 === 1 && count % 100 !== 11 ? `${count} artikal` : `${count} artikala`} · Dostava za
|
||
24–48h širom BiH ili preuzimanje u Gračanici
|
||
</p>
|
||
</header>
|
||
|
||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-10 lg:gap-16 items-start">
|
||
<div className="lg:col-span-7 xl:col-span-8 flex flex-col gap-8">
|
||
<ItemsTemplate cart={cart} />
|
||
{!customer && <SignInPrompt />}
|
||
</div>
|
||
<aside className="lg:col-span-5 xl:col-span-4 lg:sticky lg:top-28">
|
||
{cart.region && <Summary cart={cart} />}
|
||
</aside>
|
||
</div>
|
||
</>
|
||
) : (
|
||
<EmptyCartMessage />
|
||
)}
|
||
</div>
|
||
)
|
||
}
|
||
|
||
export default CartTemplate
|