import cn from 'classnames'
import Link from 'next/link'
import { FC } from 'react'
import s from './CheckoutSidebarView.module.css'
import CartItem from '@components/cart/CartItem'
import { Button } from '@components/ui'
import { UserNav } from '@components/common'
import { useUI } from '@components/ui/context'
import {
Bag,
Cross,
Check,
MapPin,
CreditCard,
ChevronLeft,
ChevronRight,
} from '@components/icons'
import useCart from '@framework/cart/use-cart'
import usePrice from '@framework/product/use-price'
const CheckoutSidebarView: FC = () => {
const { closeSidebar, setSidebarView } = useUI()
const { data, isLoading, isEmpty } = useCart()
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 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.
) : (
<>
Checkout
{/* Payment Method */}
{/* Only available with checkout set to true - Meaning that the provider does offer checkout functionality. */}
setSidebarView('PAYMENT_VIEW')}
className="border border-accent-2 px-6 py-5 mb-4 text-center flex items-center cursor-pointer hover:border-accent-4"
>
Add Payment Method
{/* VISA #### #### #### 2345 */}
{/* Shipping Address */}
{/* Only available with checkout set to true - Meaning that the provider does offer checkout functionality. */}
setSidebarView('SHIPPING_VIEW')}
className="border border-accent-2 px-6 py-5 mb-4 text-center flex items-center cursor-pointer hover:border-accent-4"
>
Add Shipping Address
{/*
1046 Kearny Street.
San Franssisco, California
*/}
{data!.lineItems.map((item: any) => (
))}
-
Subtotal
{subTotal}
-
Taxes
Calculated at checkout
-
Shipping
FREE
Total
{total}
{/* Once data is correcly filled */}
{/* */}
>
)}
)
}
export default CheckoutSidebarView