Replace use-cart with the new hook

This commit is contained in:
Luis Alvarez
2021-02-08 10:52:35 -05:00
parent 2c9b8b100d
commit aab2e7f7cc
8 changed files with 66 additions and 109 deletions

View File

@@ -1,7 +1,10 @@
import { FC } from 'react'
import Link from 'next/link'
import cn from 'classnames'
import type { BigcommerceProvider } from '@framework'
import { LineItem } from '@framework/types'
import useCart from '@framework/cart/use-cart'
import useFake from '@commerce/cart/use-fake'
import useCustomer from '@framework/customer/use-customer'
import { Heart, Bag } from '@components/icons'
import { useUI } from '@components/ui/context'
@@ -15,12 +18,14 @@ interface Props {
const countItem = (count: number, item: LineItem) => count + item.quantity
const UserNav: FC<Props> = ({ className, children }) => {
const UserNav: FC<Props> = ({ className }) => {
const { data } = useCart()
const { data: customer } = useCustomer()
const { toggleSidebar, closeSidebarIfPresent, openModal } = useUI()
const itemsCount = data?.lineItems.reduce(countItem, 0) ?? 0
const x = useFake<BigcommerceProvider>()
return (
<nav className={cn(s.root, className)}>
<div className={s.mainContainer}>