import cn from 'classnames' import Link from 'next/link' import { FC } from 'react' import s from './CartSidebarView.module.css' import useCheckout from '@framework/checkout/use-checkout' import CartItem from '../CartItem' import { Button, Text } from '@components/ui' import { useUI } from '@components/ui/context' import { Bag, Cross, Check } from '@components/icons' import useCart from '@framework/cart/use-cart' import usePrice from '@framework/product/use-price' import SidebarLayout from '@components/common/SidebarLayout' import GetTaxationWidget from '@components/checkout/GetTaxationWidget' import ShowTaxationWidget from '@components/checkout/ShowTaxWidget' import ShippingRatesWidget from '@components/checkout/ShippingRatesWidget' import useGetTax from '@framework/tax/get-tax' import useShowTax from '@framework/tax/show-tax' const CartSidebarView: FC = () => { const { closeSidebar, setSidebarView, sidebarView } = useUI() const { data, isLoading, isEmpty } = useCart() const { data: checkoutData, submit: onCheckout } = useCheckout() // if(sidebarView == 'GET_TAXATION_VIEW'){ // const getTax = useGetTax() // console.log(getTax) // } // else if(sidebarView == 'SHOW_TAXATION_VIEW'){ // const showTax = useShowTax() // } // else if(sidebarView == 'SHIPPING_RATES_WIDGET'){ // const shippingRates = useShippingRates() // } async function handleSubmit(event: any) { event.preventDefault() setSidebarView('CHECKOUT_VIEW') } 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 handleClose = () => closeSidebar() const goToCheckout = () => setSidebarView('CHECKOUT_VIEW') const error = null const success = null 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
setSidebarView('GET_TAXATION_VIEW')} />
setSidebarView('SHOW_TAXATION_VIEW')} />
setSidebarView('SHIPPING_RATES_WIDGET')} />
Total {total}
{process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED ? ( ) : ( )}
)}
) } export default CartSidebarView