4
0
forked from crowetic/commerce

Added new normalizer for the cart to the UI

This commit is contained in:
Luis Alvarez
2021-01-28 15:54:17 -05:00
parent 7cf1ace9fb
commit 3e27b80658
5 changed files with 49 additions and 80 deletions

View File

@@ -14,14 +14,14 @@ const Item = ({
currencyCode,
...rest
}: {
item: CartItem
item: LineItem
currencyCode: string
}) => {
const { closeSidebarIfPresent } = useUI()
const { price } = usePrice({
amount: item.extended_sale_price,
baseAmount: item.extended_list_price,
amount: item.variant.price * item.quantity,
baseAmount: item.variant.listPrice * item.quantity,
currencyCode,
})
@@ -87,13 +87,13 @@ const Item = ({
className={s.productImage}
width={150}
height={150}
src={item.images[0].url}
alt={item.images[0].alt}
src={item.variant.image.url}
alt={item.variant.image.altText}
unoptimized
/>
</div>
<div className="flex-1 flex flex-col text-base">
<Link href={`/product/${item.url.split('/')[3]}`}>
<Link href={`/product/${item.path}`}>
<span
className="font-bold mb-5 text-lg cursor-pointer"
onClick={() => closeSidebarIfPresent()}

View File

@@ -15,15 +15,14 @@ const CartSidebarView: FC = () => {
const { price: subTotal } = usePrice(
data && {
amount: Number(data.subTotal),
currencyCode: data.currency?.code || 'USD',
amount: Number(data.subtotalPrice),
currencyCode: data.currency.code,
}
)
const { price: total } = usePrice(
data && {
amount: Number(data.total),
currencyCode: data.currency?.code || 'USD',
amount: Number(data.totalPrice),
currencyCode: data.currency.code,
}
)
const handleClose = () => closeSidebar()