Files
Suman/apps/suman-bosna/src/modules/cart/templates/summary.tsx
Nermin Karic ada6fd857c design upgrade
2026-11-23 00:59:47 +01:00

48 lines
1.4 KiB
TypeScript

"use client"
import CartTotals from "@modules/common/components/cart-totals"
import DiscountCode from "@modules/checkout/components/discount-code"
import LocalizedClientLink from "@modules/common/components/localized-client-link"
import { HttpTypes } from "@medusajs/types"
import { ArrowRight } from "lucide-react"
type SummaryProps = {
cart: HttpTypes.StoreCart
}
function getCheckoutStep(cart: HttpTypes.StoreCart) {
if (!cart?.shipping_address?.address_1 || !cart.email) {
return "address"
} else if (cart?.shipping_methods?.length === 0) {
return "delivery"
} else {
return "payment"
}
}
const Summary = ({ cart }: SummaryProps) => {
const step = getCheckoutStep(cart)
return (
<div className="rounded-2xl bg-muted p-6 sm:p-8">
<p className="eyebrow text-muted-foreground">Pregled narudžbe</p>
<div className="mt-6">
<CartTotals totals={cart} />
</div>
<LocalizedClientLink
href={"/checkout?step=" + step}
data-testid="checkout-button"
className="mt-6 flex h-12 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground transition-colors hover:bg-primary/90"
>
Nastavite na plaćanje
<ArrowRight className="h-4 w-4" />
</LocalizedClientLink>
<div className="mt-6 border-t border-border pt-6">
<DiscountCode cart={cart} />
</div>
</div>
)
}
export default Summary