import type { GetStaticPropsContext } from 'next'; import useCart from '@framework/cart/use-cart'; import usePrice from '@framework/product/use-price'; import commerce from '@lib/api/commerce'; import { Layout } from '@components/common'; import { Button, Text, Container } from '@components/ui'; import { Bag, Cross, Check, MapPin, CreditCard } from '@components/icons'; import { CartItem } from '@components/cart'; import { useUI } from '@components/ui/context'; export async function getStaticProps({ preview, locale, locales, }: GetStaticPropsContext) { const config = { locale, locales }; const pagesPromise = commerce.getAllPages({ config, preview }); const siteInfoPromise = commerce.getSiteInfo({ config, preview }); const { pages } = await pagesPromise; const { categories } = await siteInfoPromise; return { props: { pages, categories }, }; } export default function Cart() { const error = null; const success = null; const { data, isLoading, isEmpty } = useCart(); const { openSidebar, setSidebarView } = useUI(); const { price: subTotal } = usePrice( data && { amount: Number(data.subtotalPrice), currencyCode: data.currency.code, } ); const { price: total } = usePrice( data && { amount: Number(data.totalPrice), currencyCode: data.currency.code, } ); const goToCheckout = () => { openSidebar(); setSidebarView('CHECKOUT_VIEW'); }; return (
{isLoading || isEmpty ? (

Your cart is empty

Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake.

) : error ? (

We couldn’t process the purchase. Please check your card information and try again.

) : success ? (

Thank you for your order.

) : (
My Cart Review your Order
    {data!.lineItems.map((item: any) => ( ))}
Before you leave, take a look at these items. We picked them just for you
{[1, 2, 3, 4, 5, 6].map((x) => (
))}
)}
{process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED && ( <> {/* Shipping Address */} {/* Only available with customCheckout set to true - Meaning that the provider does offer checkout functionality. */}
+ Add Shipping Address {/* 1046 Kearny Street.
San Franssisco, California
*/}
{/* Payment Method */} {/* Only available with customCheckout set to true - Meaning that the provider does offer checkout functionality. */}
+ Add Payment Method {/* VISA #### #### #### 2345 */}
)}
  • Subtotal {subTotal}
  • Taxes Calculated at checkout
  • Estimated Shipping FREE
Total {total}
{isEmpty ? ( ) : ( <> {process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED ? ( ) : ( )} )}
); } Cart.Layout = Layout;