import React from "react";
import { useProduct } from "vtex.product-context";
import styles from "./styles.css";

const PixDiscount = () => {
  const productContextValue = useProduct();

  const sellingPrice =
    productContextValue?.product?.priceRange?.sellingPrice?.highPrice;

  const pixPrice = (sellingPrice! * 0.9).toLocaleString(undefined, {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
  });

  return (
    <>
      <p className={styles.pixDiscount}>{`R$ ${pixPrice}`}</p>
    </>
  );
};

export default PixDiscount;
