challenge-vtex-io-ramon-dia.../react/components/Pix/Pix.tsx

33 lines
714 B
TypeScript

import React from "react";
import { useProduct } from "vtex.product-context";
const Pix = () => {
const productContextValue = useProduct()?.product?.priceRange?.sellingPrice
?.highPrice;
return (
<>
<div>
<img src="https://agenciamagma.vtexassets.com/arquivos/pix-ramon.svg" alt="Pix" />
<div>
<p>
{`R$ ${(productContextValue! - productContextValue! * 0.1)
.toFixed(2)
.replace(".", ",")}`
}
</p>
<p>
10% de desconto
</p>
</div>
</div>
</>
);
};
export default Pix;