import type { GetStaticPropsContext } from 'next' import { getConfig } from '@bigcommerce/storefront-data-hooks/api' import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import useCart from '@bigcommerce/storefront-data-hooks/cart/use-cart' import usePrice from '@bigcommerce/storefront-data-hooks/use-price' import { Layout } from '@components/core' import { Button } from '@components/ui' import { Bag, Cross, Check } from '@components/icons' import { CartItem } from '@components/cart' import { Text } from '@components/ui' export async function getStaticProps({ preview, locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) const { pages } = await getAllPages({ config, preview }) return { props: { pages }, } } export default function Cart() { const { data, error, isEmpty } = useCart() const isLoading = data === undefined const { price: subTotal } = usePrice( data && { amount: data.base_amount, currencyCode: data.currency.code, } ) const { price: total } = usePrice( data && { amount: data.cart_amount, currencyCode: data.currency.code, } ) const items = data?.line_items.physical_items ?? [] return (
My Cart {error &&
Failed to load
} {isLoading &&
Loading...
} {isEmpty ? (

Your cart is empty

Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake.

) : (
Review your Order
    {items.map((item) => ( ))}
  • Subtotal {subTotal}
  • Taxes Calculated at checkout
  • Estimated Shipping FREE
Total {total}
{isEmpty ? ( ) : ( )}
)}
) } Cart.Layout = Layout