Entrega do Desafio #1

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

View File

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

View File

@ -0,0 +1,29 @@
import React from "react";
import { useProduct } from "vtex.product-context";
const InstallmentProduct = () => {
const product = useProduct();
const productWithInstallments = {
numberOfInstallments:
product?.selectedItem?.sellers[0].commertialOffer.Installments[10]
.NumberOfInstallments,
value:
product?.selectedItem?.sellers[0].commertialOffer.Installments[10].Value,
};
return (
<p className="vtex-flex-layout-0-x-PriceContent">
<strong>
{productWithInstallments.numberOfInstallments}x&nbsp;
</strong>
de&nbsp;
<strong>
R$&nbsp;
{productWithInstallments.value?.toFixed(2).toString().replace(".", ",")}
</strong> sem juros
</p>
);
};
export default InstallmentProduct;

View File

@ -5,5 +5,8 @@
"html": { "html": {
"component": "html", "component": "html",
"composition": "children" "composition": "children"
},
"installment-product-component": {
"component": "InstallmentProduct"
} }
} }