2023-02-01 01:16:13 +00:00
|
|
|
import React from "react";
|
2023-02-01 23:50:50 +00:00
|
|
|
import { useCssHandles } from "vtex.css-handles";
|
2023-02-04 17:50:58 +00:00
|
|
|
import { useProduct } from "vtex.product-context";
|
|
|
|
import "./styles.css";
|
2023-02-01 01:16:13 +00:00
|
|
|
|
2023-02-01 23:50:50 +00:00
|
|
|
const Pix = () => {
|
2023-02-04 17:50:58 +00:00
|
|
|
const productContext = useProduct();
|
2023-02-06 22:37:37 +00:00
|
|
|
const price = productContext?.product?.priceRange.sellingPrice.highPrice;
|
|
|
|
const CSS_HANDLES = [
|
|
|
|
"pix",
|
|
|
|
"pixImage",
|
|
|
|
"containerPix",
|
|
|
|
"imagePix",
|
|
|
|
"pricePix",
|
|
|
|
"textPix",
|
|
|
|
];
|
2023-02-04 17:50:58 +00:00
|
|
|
const { handles } = useCssHandles(CSS_HANDLES);
|
2023-02-01 23:50:50 +00:00
|
|
|
|
2023-02-06 22:37:37 +00:00
|
|
|
let pixPrice;
|
2023-02-01 23:50:50 +00:00
|
|
|
|
|
|
|
if (price !== undefined) {
|
2023-02-04 17:50:58 +00:00
|
|
|
const value = (price / 100) * 10;
|
2023-02-06 22:37:37 +00:00
|
|
|
const valuePix = price - value;
|
|
|
|
pixPrice = "R$ " + valuePix.toFixed(2).toString().replace(".", ",");
|
2023-02-01 23:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2023-02-06 22:37:37 +00:00
|
|
|
<section className={handles.pix}>
|
|
|
|
<img
|
|
|
|
className={handles.pixImage}
|
|
|
|
src="https://agenciamagma.vtexassets.com/assets/vtex.file-manager-graphql/images/d5b39cd0-ca30-48ea-98f0-47655b4a7d79___cbd3e3c1bc0541759327951dd21c6a45.png"
|
|
|
|
alt=""
|
|
|
|
/>
|
2023-02-04 17:50:58 +00:00
|
|
|
<div className={handles.containerPix}>
|
2023-02-06 22:37:37 +00:00
|
|
|
<span className={handles.pricePix}>{pixPrice}</span>
|
2023-02-04 17:50:58 +00:00
|
|
|
<p className={handles.textPix}>10% de desconto</p>
|
|
|
|
</div>
|
2023-02-06 22:37:37 +00:00
|
|
|
</section>
|
2023-02-01 23:50:50 +00:00
|
|
|
);
|
2023-02-01 01:16:13 +00:00
|
|
|
};
|
|
|
|
|
2023-02-01 23:50:50 +00:00
|
|
|
export default Pix;
|