Entrega do Desafio #1

Merged
anacarolinaduartecavalcante merged 93 commits from feature/challenge-vtex-io into develop 2023-02-03 17:14:03 +00:00
5 changed files with 61 additions and 0 deletions
Showing only changes of commit f6d0f2d94a - Show all commits

3
react/Pix.tsx Normal file
View File

@ -0,0 +1,3 @@
import Pix from "./components/Pix/Pix";
export default Pix;

View File

@ -0,0 +1,32 @@
import React from "react";
import { useProduct } from "vtex.product-context";
import styles from "./styles.css";
const Pix = () => {
const product = useProduct();
const pix = {
pix: Number(
product?.selectedItem?.sellers[0].commertialOffer.Installments[0].Value
),
};
const discount = pix.pix * 0.1;
const pixPrice = pix.pix - discount;
return (
<div className={styles.PixContent}>
<img
className={styles.ImgPixContent}
src="https://agenciamagma.vteximg.com.br/arquivos/icon-pix-anacarolinaduartecavalcante-m3academy.svg"
alt="logo pix"
/>
<div className={styles.PixDiscount}>
<strong>
R$&nbsp;{pixPrice?.toFixed(2).toString().replace(".", ",")}
</strong>
<span>10 % de desconto</span>
</div>
</div>
);
};
export default Pix;

View File

@ -0,0 +1,16 @@
.PixContent {
margin-top: 8px;
height: 24px;
display: flex;
column-gap: 26px;
}
.ImgPixContent{
width: 66.01px;
height: 24px;
}
.PixDiscount{
display: flex;
flex-direction: column;
}

View File

@ -111,6 +111,7 @@
"product-rating-summary", "product-rating-summary",
"flex-layout.row#selling-price", "flex-layout.row#selling-price",
"installment-product-component", "installment-product-component",
"html#pix-component",
"product-separator", "product-separator",
"sku-selector", "sku-selector",
"product-quantity", "product-quantity",
@ -122,6 +123,12 @@
"share#default" "share#default"
] ]
}, },
"html#pix-component": {
"props": {
"testId": "pix-price"
},
"children": ["pix-component"]
},
"flex-layout.row#product-name": { "flex-layout.row#product-name": {
"props": { "props": {
"marginBottom": 3 "marginBottom": 3

View File

@ -8,5 +8,8 @@
}, },
"installment-product-component": { "installment-product-component": {
"component": "InstallmentProduct" "component": "InstallmentProduct"
},
"pix-component": {
"component": "Pix"
} }
} }