import React from "react"; import styles from "./_PixCustomInstallments.module.css"; import { useProduct } from "vtex.product-context"; import { sanatizeColor } from "./_ComponentsFunctions"; interface IPixCustomInstallmentsProps { label: string; percent: number; } export function PixCustomInstallments({ label = "de desconto", percent = 10, }: IPixCustomInstallmentsProps) { const data = useProduct(); const calculationPercent = ( percent: number | undefined, value: number | undefined ) => { if (value && percent) { const newPercent = percent / 100; const discount = value * newPercent; const newValue = value - discount; return newValue.toFixed(2).toString().replace(".", ","); } return ""; }; console.log(data); return (
Promoção de pagamento com o PIX

{`R$ ${calculationPercent( percent, data?.product?.priceRange.sellingPrice.highPrice )}`}

{`${percent}% ${label}`}

); } PixCustomInstallments.schema = { title: "Promoção de pagamento com o PIX", type: "object", properties: { label: { type: "string", }, percent: { type: "number", }, }, };