Skip to content

Commit

Permalink
Merge pull request #47 from bntzio/use-price-hook-on-slug
Browse files Browse the repository at this point in the history
Properly format items pricing
  • Loading branch information
lfades committed Oct 29, 2020
2 parents 629df7a + cd82988 commit b4bc5b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/product/ProductView/ProductView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Swatch, ProductSlider } from '@components/product'
import { Button, Container } from '@components/ui'
import { HTMLContent } from '@components/core'

import usePrice from '@bigcommerce/storefront-data-hooks/use-price'
import useAddItem from '@bigcommerce/storefront-data-hooks/cart/use-add-item'
import type { ProductNode } from '@bigcommerce/storefront-data-hooks/api/operations/get-product'
import {
Expand All @@ -26,6 +27,11 @@ interface Props {

const ProductView: FC<Props> = ({ product }) => {
const addItem = useAddItem()
const { price } = usePrice({
amount: product.prices?.price?.value,
baseAmount: product.prices?.retailPrice?.value,
currencyCode: product.prices?.price?.currencyCode!,
})
const { openSidebar } = useUI()
const options = getProductOptions(product)
const [loading, setLoading] = useState(false)
Expand Down Expand Up @@ -74,7 +80,7 @@ const ProductView: FC<Props> = ({ product }) => {
<div className={s.nameBox}>
<h1 className={s.name}>{product.name}</h1>
<div className={s.price}>
{product.prices?.price.value}
{price}
{` `}
{product.prices?.price.currencyCode}
</div>
Expand Down

1 comment on commit b4bc5b4

@vercel
Copy link

@vercel vercel bot commented on b4bc5b4 Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.