import React from "react";

import { useProduct } from "vtex.product-context";

export function PixDiscount() {
  const productContext = useProduct();
  const price =
    productContext?.selectedItem?.sellers[0]?.commertialOffer?.Price;
  console.log(productContext);

  function discount() {
    if (price) {
      const discountedPrice = price - price * 0.1;
      return discountedPrice.toLocaleString("pt-BR", {
        style: "currency",
        currency: "BRL",
      });
    } else {
      return "...";
    }
  }
  return (
    <div>
      <img src="" alt="" />
      {discount()}
      <span>10% de desconto</span>
    </div>
  );
}
