challenge-vtex-io-nicolly-v.../react/components/Installments/index.tsx

30 lines
749 B
TypeScript
Raw Normal View History

import React from "react";
import { useProduct } from "vtex.product-context";
import styles from "./styles.css";
const Installments = () => {
const product = useProduct();
const installment = {
numberOfInstallments:
product?.selectedItem?.sellers[0].commertialOffer?.Installments[10]
.NumberOfInstallments,
value:
product?.selectedItem?.sellers[0].commertialOffer?.Installments[10].Value,
};
return (
<p className={styles.parcelas}>
<strong>
{installment.numberOfInstallments} x{" "}
</strong>
de
<strong>
{" "}
R$ {installment.value?.toFixed(2).toString().replace(".", ",")}
</strong>{" "}
sem juros
</p>
);
};
export default Installments;