2023-02-07 22:27:44 +00:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
import styles from "./_PixCustomInstallments.module.css";
|
|
|
|
|
|
|
|
import { useProduct } from "vtex.product-context";
|
2023-02-09 11:07:31 +00:00
|
|
|
import { calculationPercent, sanatizeColor } from "./_ComponentsFunctions";
|
2023-02-07 22:27:44 +00:00
|
|
|
|
|
|
|
interface IPixCustomInstallmentsProps {
|
|
|
|
label: string;
|
|
|
|
percent: number;
|
2023-02-09 11:07:31 +00:00
|
|
|
color: string;
|
2023-02-07 22:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function PixCustomInstallments({
|
|
|
|
label = "de desconto",
|
|
|
|
percent = 10,
|
2023-02-09 11:07:31 +00:00
|
|
|
color = "c-on-base",
|
2023-02-07 22:27:44 +00:00
|
|
|
}: IPixCustomInstallmentsProps) {
|
|
|
|
const data = useProduct();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={`${styles["pix"]} flex`}>
|
|
|
|
<img
|
|
|
|
src="https://agenciamagma.vteximg.com.br/arquivos/pix-m3academy-henrquesantos-2023.svg"
|
|
|
|
alt="Promoção de pagamento com o PIX"
|
|
|
|
/>
|
2023-02-09 11:07:31 +00:00
|
|
|
<div>
|
|
|
|
<p className={styles["pix__priceValue"]}>
|
2023-02-07 22:27:44 +00:00
|
|
|
{`R$ ${calculationPercent(
|
|
|
|
percent,
|
|
|
|
data?.product?.priceRange.sellingPrice.highPrice
|
|
|
|
)}`}
|
2023-02-09 11:07:31 +00:00
|
|
|
</p>
|
|
|
|
<p className={`${styles["pix__label"]} ${sanatizeColor(color)}`}>
|
2023-02-07 22:27:44 +00:00
|
|
|
{`${percent}% ${label}`}
|
2023-02-09 11:07:31 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
2023-02-07 22:27:44 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
PixCustomInstallments.schema = {
|
|
|
|
title: "Promoção de pagamento com o PIX",
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
label: {
|
|
|
|
type: "string",
|
|
|
|
},
|
|
|
|
percent: {
|
|
|
|
type: "number",
|
|
|
|
},
|
2023-02-09 11:07:31 +00:00
|
|
|
|
|
|
|
color: {
|
|
|
|
type: "string",
|
|
|
|
},
|
2023-02-07 22:27:44 +00:00
|
|
|
},
|
|
|
|
};
|