From d0f5d235fb55b1b6ab67ce2b04b9be59dc159a07 Mon Sep 17 00:00:00 2001 From: decobot Date: Mon, 4 Nov 2024 13:18:23 -0300 Subject: [PATCH] fix plans and credit card fields --- actions/getPlans.ts | 4 +++- components/ui/CheckoutUpsellModal.tsx | 10 ++++++---- components/ui/ChoosePlanSignup.tsx | 3 ++- components/ui/MyAccount.tsx | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/actions/getPlans.ts b/actions/getPlans.ts index a133a40..827ce58 100644 --- a/actions/getPlans.ts +++ b/actions/getPlans.ts @@ -1,7 +1,9 @@ +import { API_URL } from "deco-sites/ecannadeco/sdk/constants.ts"; + const getPlans = async (_req: Request): Promise => { try { const response = await fetch( - "https://api.ecanna.com.br/products/subscriptions", + API_URL + "/products/subscriptions", { method: "GET", headers: { diff --git a/components/ui/CheckoutUpsellModal.tsx b/components/ui/CheckoutUpsellModal.tsx index 500e60a..63b30bf 100644 --- a/components/ui/CheckoutUpsellModal.tsx +++ b/components/ui/CheckoutUpsellModal.tsx @@ -168,7 +168,7 @@ const CheckoutUpsellModal = (props: Props) => { paramsCheckoutV2.voucher = voucher; } - if (isCreditCard) { + if (isCreditCard || plan) { paramsCheckoutV2.credit_card = { holder: holderName, number: creditCardNumber, @@ -359,6 +359,7 @@ const CheckoutUpsellModal = (props: Props) => { function ConfirmOrder() { const currentPrice = plan ? plan.price : product ? product.price : 0; + return ( <>

@@ -373,7 +374,7 @@ const CheckoutUpsellModal = (props: Props) => { {plan ? plan.name : product && product.name} - {discount !== 1 + {!discount || discount !== 1 ? ( {plan @@ -446,7 +447,7 @@ const CheckoutUpsellModal = (props: Props) => { {/* Cartão de crédito */} - {isCreditCard && ( + {(isCreditCard || plan) && ( <>
{ @@ -498,7 +499,8 @@ const CheckoutUpsellModal = (props: Props) => { })} */ }
- {discount !== 1 + + {!discount || discount !== 1 ? (
diff --git a/components/ui/ChoosePlanSignup.tsx b/components/ui/ChoosePlanSignup.tsx index 57116a7..b856792 100644 --- a/components/ui/ChoosePlanSignup.tsx +++ b/components/ui/ChoosePlanSignup.tsx @@ -4,6 +4,7 @@ import Slider from "../../components/ui/Slider.tsx"; import { Plan } from "../../components/ui/Checkout.tsx"; import Icon from "../../components/ui/Icon.tsx"; import { IS_BROWSER } from "$fresh/runtime.ts"; +import { API_URL } from "deco-sites/ecannadeco/sdk/constants.ts"; function ConfirmSignup() { const [newPlan, setNewPlan] = useState(); @@ -12,7 +13,7 @@ function ConfirmSignup() { useEffect(() => { try { const _params = fetch( - `https://api.ecanna.com.br/v1/products/subscriptions?isPrescriber=false`, + `${API_URL}/v1/products/subscriptions?isPrescriber=false`, ).then(async (r) => { const c = await r.json(); console.log({ plans: c.docs }); diff --git a/components/ui/MyAccount.tsx b/components/ui/MyAccount.tsx index 8529690..253bf1d 100644 --- a/components/ui/MyAccount.tsx +++ b/components/ui/MyAccount.tsx @@ -16,6 +16,7 @@ import { useUI } from "../../sdk/useUI.ts"; import { IS_BROWSER } from "$fresh/runtime.ts"; import { useHolderInfo } from "deco-sites/ecannadeco/sdk/useHolderInfo.ts"; import { UserData } from "deco-sites/ecannadeco/components/ui/EcannaCardPage.tsx"; +import { API_URL } from "deco-sites/ecannadeco/sdk/constants.ts"; export type Address = { cep: string; @@ -115,7 +116,7 @@ function MyAccount() { }); fetch( - `https://api.ecanna.com.br/v1/products/subscriptions?isPrescriber=false`, + `${API_URL}/v1/products/subscriptions?isPrescriber=false`, ).then(async (r) => { const c = await r.json(); const plansList = c.docs as Plan[];