2023-01-30 19:23:41 +00:00
|
|
|
import React, { useEffect } from "react";
|
2023-01-30 19:15:00 +00:00
|
|
|
|
|
|
|
import { useProduct } from "vtex.product-context";
|
|
|
|
import styles from "./style.module.css";
|
|
|
|
|
|
|
|
const Pix = () => {
|
2023-01-30 19:23:41 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const cepInput = document.querySelector(".vtex-address-form-4-x-input");
|
|
|
|
|
|
|
|
cepInput?.setAttribute("placeholder", "Digite seu CEP");
|
|
|
|
|
|
|
|
console.log(cepInput);
|
|
|
|
});
|
|
|
|
|
2023-01-30 19:15:00 +00:00
|
|
|
const productContextValue = useProduct();
|
|
|
|
|
|
|
|
const productPrice = productContextValue?.product?.priceRange?.sellingPrice?.lowPrice;
|
|
|
|
|
|
|
|
const discountValue = (Number(productPrice) * 10) / 100;
|
|
|
|
|
|
|
|
const totalValue = Number(productPrice) - Number(discountValue);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles["wrapper"]}>
|
2023-01-31 21:43:32 +00:00
|
|
|
<div className={styles["container-flex"]}>
|
2023-01-30 19:15:00 +00:00
|
|
|
<div className={styles["image"]}>
|
|
|
|
<img src="https://agenciamagma.vtexassets.com/arquivos/pix-logo-vitor-soares.png" alt="desconto" />
|
|
|
|
</div>
|
|
|
|
<div className={styles["discount"]}>
|
|
|
|
<p className={styles["value"]}>R${totalValue.toFixed(2)}</p>
|
|
|
|
<p className={styles["text"]}>10 % de desconto</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Pix;
|