feat(product): adicionando component pix

This commit is contained in:
Bernardo Cunha Ernani Waldhelm 2023-01-25 14:39:37 -03:00
parent 86add06fbb
commit ddd74225a2
7 changed files with 92 additions and 2 deletions

2
react/PixDiscount.tsx Normal file
View File

@ -0,0 +1,2 @@
import PixDiscount from "./components/PixDiscount/index";
export default PixDiscount;

View File

@ -6,7 +6,7 @@ const Installment = () => {
const skuProduct = useProduct(); const skuProduct = useProduct();
console.log(skuProduct); console.log(skuProduct);
const productInstallment = { const productInstallment: any = {
numberOfInstallment: numberOfInstallment:
skuProduct?.selectedItem?.sellers[0].commertialOffer.Installments[3] skuProduct?.selectedItem?.sellers[0].commertialOffer.Installments[3]
.NumberOfInstallments, .NumberOfInstallments,

View File

@ -0,0 +1,38 @@
.pixContainer {
display: flex;
justify-content: flex-start;
align-items: center;
height: 39px;
column-gap: 26px;
margin-top: 8px;
}
.pixContainer__img {
width: 66px;
height: 24px;
}
.pixContainer__discount {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
}
.pixContainer__priceFinal {
font-family: 'Open Sans', sans-serif;
font-style: normal;
font-weight: 700;
font-size: 18px;
line-height: 25px;
color: rgba(0, 0, 0, 0.58);
}
.pixContainer__discount__value {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
font-size: 13px;
line-height: 18px;
color: #929292;
}

View File

@ -0,0 +1,37 @@
import React from "react";
import { useProduct } from "vtex.product-context";
import styles from "./PixDiscount.module.css";
const PixDiscount = () => {
const skuProduct = useProduct();
const productPrice = {
price: Number(
skuProduct?.selectedItem?.sellers[0]?.commertialOffer?.Price.toFixed(2)
),
};
const discount = productPrice.price * 0.1;
const pixPrice = productPrice.price - discount;
console.log(pixPrice);
return (
<div className={styles["pixContainer"]}>
<img
src="https://agenciamagma.vteximg.com.br/arquivos/icon-pix-bernardoWaldhelm-m3academy.svg"
alt="Pix"
className={styles["pixContainer__img"]}
/>
<div className={styles["pixContainer__discount"]}>
<span className={styles["pixContainer__priceFinal"]}>
R$&nbsp;{pixPrice?.toFixed(2).toString().replace(".", ",")}
</span>
<span className={styles["pixContainer__discount__value"]}>
10% de desconto
</span>
</div>
</div>
);
};
export default PixDiscount;

1
react/index.d.ts vendored
View File

@ -1 +1,2 @@
declare module "*.module.css"; declare module "*.module.css";
declare module "*.svg";

View File

@ -113,7 +113,8 @@
// "flex-layout.row#list-price-savings", preço com promoção vindo vtex // "flex-layout.row#list-price-savings", preço com promoção vindo vtex
"flex-layout.row#selling-price", "flex-layout.row#selling-price",
"installment-component", "installment-component",
"product-separator", "html#pix-component",
// "product-separator", //linha que separa preço de skus
"sku-selector", "sku-selector",
"product-quantity", "product-quantity",
"product-assembly-options", "product-assembly-options",
@ -141,6 +142,14 @@
} }
}, },
"html#pix-component": {
"props": {
"tag": "section",
"testId": "pix-price"
},
"children": ["pix-component"]
},
"flex-layout.row#buy-button": { "flex-layout.row#buy-button": {
"props": { "props": {
"marginTop": 4, "marginTop": 4,

View File

@ -8,6 +8,9 @@
}, },
"installment-component": { "installment-component": {
"component": "Installment" "component": "Installment"
},
"pix-component": {
"component": "PixDiscount"
} }
} }