2023-02-05 16:42:44 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useProduct } from "vtex.product-context";
|
|
|
|
import styles from "./styles.css";
|
|
|
|
// import { useQuery } from "react-apollo";
|
|
|
|
// import pixPrice from "../../graphql/pixPrice.graphql";
|
|
|
|
|
|
|
|
const PixDiscount = () => {
|
|
|
|
const productContextValue = useProduct();
|
|
|
|
|
|
|
|
const sellingPrice =
|
|
|
|
productContextValue?.product?.priceRange?.sellingPrice?.highPrice;
|
|
|
|
|
|
|
|
const pixPrice = (sellingPrice! * 0.9).toLocaleString(undefined, {
|
|
|
|
minimumFractionDigits: 2,
|
|
|
|
maximumFractionDigits: 2,
|
|
|
|
});
|
|
|
|
|
2023-02-10 22:03:36 +00:00
|
|
|
// console.log(productContextValue);
|
2023-02-05 16:42:44 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<p className={styles.pixDiscount}>{`R$ ${pixPrice}`}</p>
|
|
|
|
{/* <p>{testingApi}</p> */}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PixDiscount;
|
|
|
|
|
|
|
|
// "vtex.search-graphql": "0.x"
|
|
|
|
|
|
|
|
// const { data } = useQuery(pixPrice, {
|
|
|
|
// variables: {
|
|
|
|
// slug: productContextValue?.product?.productName,
|
|
|
|
// },
|
|
|
|
// ssr: false,
|
|
|
|
// });
|
|
|
|
|
|
|
|
// const testingApi = fetch(
|
|
|
|
// "https://agenciamagma.dev.com.br/api/checkout/pub/orderForms/simulation"
|
|
|
|
// )
|
|
|
|
// .then((response) => response.json())
|
|
|
|
// .then((data) => console.log(data));
|