From 7f70cfd868c6224e293061e8ba4158d9bd92fe28 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Thu, 14 Jan 2021 12:58:41 -0300 Subject: [PATCH] Changes --- components/cart/CartItem/CartItem.tsx | 15 ++++--- .../cart/CartSidebarView/CartSidebarView.tsx | 8 ++-- .../product/ProductView/ProductView.tsx | 2 +- .../api/catalog/handlers/get-products.ts | 12 +++-- framework/bigcommerce/api/catalog/products.ts | 4 +- .../api/operations/get-all-products.ts | 2 +- .../bigcommerce/api/operations/get-product.ts | 2 +- framework/bigcommerce/lib/normalize.ts | 44 +++++++++++++++++-- framework/types.d.ts | 19 ++++++-- package.json | 1 + pages/cart.tsx | 26 +++++------ pages/index2.tsx | 7 --- pages/search.tsx | 42 ++++++++++-------- tsconfig.json | 2 +- yarn.lock | 5 +++ 15 files changed, 124 insertions(+), 67 deletions(-) delete mode 100644 pages/index2.tsx diff --git a/components/cart/CartItem/CartItem.tsx b/components/cart/CartItem/CartItem.tsx index ac78d1849..2337c871c 100644 --- a/components/cart/CartItem/CartItem.tsx +++ b/components/cart/CartItem/CartItem.tsx @@ -12,7 +12,7 @@ const CartItem = ({ item, currencyCode, }: { - item: any + item: CartItem currencyCode: string }) => { const { price } = usePrice({ @@ -55,7 +55,7 @@ const CartItem = ({ try { // If this action succeeds then there's no need to do `setRemoving(true)` // because the component will be removed from the view - await removeItem({ id: item.id }) + await removeItem({ id: String(item.id) }) } catch (error) { setRemoving(false) } @@ -77,16 +77,14 @@ const CartItem = ({
Product Image
- {/** TODO: Replace this. No `path` found at Cart */} {item.name} @@ -115,7 +113,10 @@ const CartItem = ({
{price} -
diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx index 466ef15b6..19c6964d7 100644 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ b/components/cart/CartSidebarView/CartSidebarView.tsx @@ -16,19 +16,17 @@ const CartSidebarView: FC = () => { const { price: subTotal } = usePrice( data && { amount: data.base_amount, - currencyCode: data.currency.code, + currencyCode: data.currency?.code || 'USD', } ) const { price: total } = usePrice( data && { amount: data.cart_amount, - currencyCode: data.currency.code, + currencyCode: data.currency?.code || 'USD', } ) const handleClose = () => closeSidebar() - const items = data?.line_items.physical_items ?? [] - const error = null const success = null @@ -95,7 +93,7 @@ const CartSidebarView: FC = () => { My Cart