import { FC } from 'react' import cn from 'classnames' import { UserNav } from '@components/core' import { Button } from '@components/ui' import { ArrowLeft, Bag, Cross, Check } from '@components/icon' import { useUI } from '@components/ui/context' import useCart from '@lib/bigcommerce/cart/use-cart' import usePrice from '@lib/bigcommerce/use-price' import CartItem from '../CartItem' import useOpenCheckout from '@lib/bigcommerce/cart/use-open-checkout' const CartSidebarView: FC = () => { const { data, isEmpty } = useCart() 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 openCheckout = useOpenCheckout() const { closeSidebar } = useUI() const handleClose = () => closeSidebar() const items = data?.line_items.physical_items ?? [] console.log('CART', data, isEmpty) // This should come from the API via hook I guess const error = null const success = null return (
{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

  • Subtotal {subTotal}
  • Taxes Calculated at checkout
  • Estimated Shipping FREE
Total {total}
)}
) } export default CartSidebarView