2023-02-10 09:05:16 +00:00
|
|
|
import React from 'react'
|
|
|
|
import { useProduct } from 'vtex.product-context'
|
2023-02-10 19:02:54 +00:00
|
|
|
// import { useCssHandles } from 'vtex.css-handles'
|
|
|
|
import styles from "./styles.css"
|
|
|
|
|
2023-02-10 09:05:16 +00:00
|
|
|
|
|
|
|
const Pix = () => {
|
|
|
|
const product = useProduct()
|
2023-02-10 19:02:54 +00:00
|
|
|
let pixValueTotal:any = product?.product?.priceRange?.sellingPrice?.lowPrice;
|
|
|
|
let pixValueTotalNumber = parseFloat(pixValueTotal);
|
|
|
|
let porcentagemDesconto = 10;
|
|
|
|
let desconto = (pixValueTotalNumber / 100)* porcentagemDesconto;
|
|
|
|
let pixValueDesconto = (pixValueTotal - desconto).toFixed(2);
|
|
|
|
let pixValueDescontoVirgula = pixValueDesconto.replace(".", ",")
|
|
|
|
|
|
|
|
// const CSS_HANDLES = [
|
|
|
|
// "wrapperComponentPix",
|
|
|
|
// "imagePix",
|
|
|
|
// "wrapperTexts",
|
|
|
|
// "wrapperTexts__value",
|
|
|
|
// "wrapperTexts__descontoPorcentagem",
|
|
|
|
// ]
|
|
|
|
|
|
|
|
// const handles = useCssHandles(CSS_HANDLES)
|
|
|
|
|
2023-02-11 02:11:22 +00:00
|
|
|
if (typeof document !== "undefined") {
|
|
|
|
const input = document.querySelector(".vtex-address-form-4-x-input");
|
|
|
|
input?.setAttribute("placeholder", "Digite seu CEP");
|
|
|
|
}
|
|
|
|
|
2023-02-10 09:05:16 +00:00
|
|
|
return (
|
2023-02-10 19:02:54 +00:00
|
|
|
<div className={styles.wrapperComponentPix}>
|
|
|
|
<img className={styles.imagePix} src="https://agenciamagma.vteximg.com.br/arquivos/PixImg-RhayllonDaudt.png" alt="PixIcon" />
|
|
|
|
<div className={styles.wrapperTexts}>
|
|
|
|
<p className={styles.wrapperTexts__value}>R$ {pixValueDescontoVirgula} </p>
|
|
|
|
<p className={styles.wrapperTexts__descontoPorcentagem}>10% de desconto</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-10 09:05:16 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Pix
|