challenge-vtex-io-josecarlo.../react/components/descont-pix/index.tsx

23 lines
771 B
TypeScript

import React, { FC } from 'react'
import { useProduct } from 'vtex.product-context'
import styles from "./styles.css";
export const DescontPix: FC = () => {
const productContextValue = useProduct();
let sellingPrice = Number(productContextValue?.product?.priceRange.sellingPrice.lowPrice);
sellingPrice = (sellingPrice - (sellingPrice/10));
return (
<div className={styles.containerDescontPix}>
<img src="https://agenciamagma.vteximg.com.br/arquivos/logoPixjosecarloslins.png" alt="Logo PIX" />
<div className={styles.containerDescontPixPrice}>
<p className={styles.priceDescontPix}>R$ {sellingPrice.toFixed(2).replace(".", ",")}</p>
<p className={styles.descontDescontPix}>10 % de desconto</p>
</div>
</div>
);
}