feat(pix):add schema de desconto e finalizando projeto

This commit is contained in:
Gustavo Rallenson Gonçalves Da Silva 2023-02-10 07:13:15 -03:00
parent ba3ac378f9
commit 8692940413

View File

@ -1,12 +1,14 @@
import React from 'react'; import React from 'react';
import { useProduct } from 'vtex.product-context'; import { useProduct } from 'vtex.product-context';
const Pix = () => { type price = {
discountRate:number
}
const Pix = ({ discountRate}:price) => {
const { product } = useProduct() const { product } = useProduct()
let pixprice = product?.priceRange.sellingPrice.lowPrice let pixprice = product?.priceRange.sellingPrice.lowPrice
let desconto = 10 let desconto = discountRate >= 0 ? discountRate : 10;
let finalprice = pixprice - (pixprice/desconto) let finalprice = pixprice - (pixprice/desconto)
let RoundedNumber = Number(Math.round(finalprice * 100) / 100); let RoundedNumber = Number(Math.round(finalprice * 100) / 100);
const formattedNumber = RoundedNumber.toLocaleString('pt-BR', { const formattedNumber = RoundedNumber.toLocaleString('pt-BR', {
@ -25,5 +27,17 @@ const Pix = () => {
</div> </div>
) )
} }
Pix.schema = {
title:"Pix-Price",
description:"quantos % o pagamento via pix irá proporcionar",
type:"object",
properties:{
discountRate:{
title: "Pix-Price",
description:"quantos % o pagamento via pix irá proporcionar",
type:"number",
default:10
}
}
}
export default Pix export default Pix