From 8692940413ebe6feb84b61a075ef454faebc6dbe Mon Sep 17 00:00:00 2001 From: Rallenson Date: Fri, 10 Feb 2023 07:13:15 -0300 Subject: [PATCH] feat(pix):add schema de desconto e finalizando projeto --- react/components/ProductContext/Pix.tsx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/react/components/ProductContext/Pix.tsx b/react/components/ProductContext/Pix.tsx index dd63cfa..7a70488 100644 --- a/react/components/ProductContext/Pix.tsx +++ b/react/components/ProductContext/Pix.tsx @@ -1,12 +1,14 @@ import React from 'react'; import { useProduct } from 'vtex.product-context'; -const Pix = () => { - +type price = { + discountRate:number +} +const Pix = ({ discountRate}:price) => { const { product } = useProduct() let pixprice = product?.priceRange.sellingPrice.lowPrice - let desconto = 10 + let desconto = discountRate >= 0 ? discountRate : 10; let finalprice = pixprice - (pixprice/desconto) let RoundedNumber = Number(Math.round(finalprice * 100) / 100); const formattedNumber = RoundedNumber.toLocaleString('pt-BR', { @@ -25,5 +27,17 @@ const Pix = () => { ) } - +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