2023-01-25 20:47:56 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useProduct } from "vtex.product-context";
|
2023-02-05 15:57:44 +00:00
|
|
|
import styles from "./styles.css";
|
2023-01-25 20:47:56 +00:00
|
|
|
|
|
|
|
const Pix = () => {
|
|
|
|
const product = useProduct();
|
|
|
|
console.log(product);
|
|
|
|
|
2023-02-05 15:57:44 +00:00
|
|
|
const pix = {
|
|
|
|
pixValue: Number(
|
|
|
|
product?.selectedItem?.sellers[0].commertialOffer.Installments[3]
|
|
|
|
.TotalValuePlusInterestRate
|
|
|
|
),
|
|
|
|
};
|
|
|
|
|
|
|
|
const priceTimes =
|
|
|
|
product?.selectedItem?.sellers[0].commertialOffer.Installments[3]
|
|
|
|
.NumberOfInstallments;
|
|
|
|
const valueTotal = product?.selectedItem?.sellers[0].commertialOffer.Installments[3].Value.toFixed(
|
|
|
|
2
|
|
|
|
)
|
|
|
|
.toString()
|
|
|
|
.replace(".", ",");
|
|
|
|
|
|
|
|
const pixPrice = (pix.pixValue = pix.pixValue * 0.9)
|
|
|
|
.toFixed(2)
|
|
|
|
.toString()
|
|
|
|
.replace(".", ",");
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<span className={styles.AllPriceTimesText}>
|
|
|
|
<span className={styles.PriceTimes}>{priceTimes} x</span> de
|
|
|
|
<span className={styles.PriceTimes}> R$ {valueTotal}</span> sem juros
|
|
|
|
</span>
|
|
|
|
<div className={styles.PricesWrapperRow}>
|
|
|
|
<figure>
|
|
|
|
<img
|
|
|
|
src="https://agenciamagma.vteximg.com.br/arquivos/logo-pix-carloswinter.svg"
|
|
|
|
alt="Imagem Pix"
|
|
|
|
/>
|
|
|
|
</figure>
|
|
|
|
<div className={styles.PricesCol}>
|
|
|
|
<span className={styles.PixFullValue}>R${pixPrice}</span>
|
|
|
|
<span className={styles.PixPercent}>10% de desconto</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
2023-01-25 20:47:56 +00:00
|
|
|
|
|
|
|
// return <button className={styles.PixButton}>Pix</button>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Pix;
|