first commit
This commit is contained in:
48
apps/suman-bosna/src/modules/cart/templates/summary.tsx
Normal file
48
apps/suman-bosna/src/modules/cart/templates/summary.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
"use client"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import CartTotals from "@modules/common/components/cart-totals"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import DiscountCode from "@modules/checkout/components/discount-code"
|
||||
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
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="flex flex-col gap-4">
|
||||
<h2 className="text-xl font-bold tracking-tight text-foreground">
|
||||
Pregled Narudžbe
|
||||
</h2>
|
||||
<DiscountCode cart={cart} />
|
||||
<Separator />
|
||||
<CartTotals totals={cart} />
|
||||
<LocalizedClientLink
|
||||
href={"/checkout?step=" + step}
|
||||
data-testid="checkout-button"
|
||||
className="w-full"
|
||||
>
|
||||
<Button className="w-full h-11 text-base font-semibold">
|
||||
Nastavi na plaćanje
|
||||
</Button>
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Summary
|
||||
Reference in New Issue
Block a user