challenge-vtex-io-amanda-al.../react/components/pix/ValuePix.tsx

20 lines
510 B
TypeScript

import { useProduct } from "vtex.product-context";
const Pix = () => {
const productContextValue = useProduct();
console.log(productContextValue);
const price = productContextValue?.product?.priceRange.listPrice.highPrice;
console.log(price);
if (price !== undefined) {
const pix = (price / 100) * 10;
console.log(pix, "valor lido");
const valuePix = price - pix;
console.log(valuePix);
return valuePix;
} else {
return "valor não encontrado";
}
};
export default Pix;