From 72128a72c4c7737d6854033cee9d1cb0f547fbac Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Sat, 13 Jul 2024 19:53:52 +0200 Subject: [PATCH] feat: add variant ids to new subscription plans --- packages/webapp/src/constants/subscriptionModels.tsx | 10 ++++++++++ .../Setup/SetupSubscription/SubscriptionPlan.tsx | 11 ++++++++++- .../Setup/SetupSubscription/SubscriptionPlans.tsx | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/webapp/src/constants/subscriptionModels.tsx b/packages/webapp/src/constants/subscriptionModels.tsx index 37b2d0ef9..ab16d07ed 100644 --- a/packages/webapp/src/constants/subscriptionModels.tsx +++ b/packages/webapp/src/constants/subscriptionModels.tsx @@ -14,6 +14,8 @@ interface SubscriptionPlan { monthlyPriceLabel: string; annuallyPrice: string; annuallyPriceLabel: string; + monthlyVariantId: string; + annuallyVariantId: string; } export const SubscriptionPlans = [ @@ -39,6 +41,8 @@ export const SubscriptionPlans = [ monthlyPriceLabel: 'Per month', annuallyPrice: '$7.5', annuallyPriceLabel: 'Per month', + monthlyVariantId: '446152', + annuallyVariantId: '446153', }, { name: 'Capital Essential', @@ -57,6 +61,8 @@ export const SubscriptionPlans = [ monthlyPriceLabel: 'Per month', annuallyPrice: '$15', annuallyPriceLabel: 'Per month', + monthlyVariantId: '446165', + annuallyVariantId: '446164', }, { name: 'Capital Plus', @@ -74,6 +80,8 @@ export const SubscriptionPlans = [ annuallyPrice: '$18', annuallyPriceLabel: 'Per month', featured: true, + monthlyVariantId: '446165', + annuallyVariantId: '446164', }, { name: 'Capital Big', @@ -88,5 +96,7 @@ export const SubscriptionPlans = [ monthlyPriceLabel: 'Per month', annuallyPrice: '$30', annuallyPriceLabel: 'Per month', + monthlyVariantId: '446167', + annuallyVariantId: '446168', }, ] as SubscriptionPlan[]; diff --git a/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlan.tsx b/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlan.tsx index 598462531..4ebb88d5f 100644 --- a/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlan.tsx +++ b/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlan.tsx @@ -27,6 +27,8 @@ interface SubscriptionPricingProps { monthlyPriceLabel: string; annuallyPrice: string; annuallyPriceLabel: string; + monthlyVariantId?: string; + annuallyVariantId?: string; } interface SubscriptionPricingCombinedProps @@ -42,6 +44,8 @@ function SubscriptionPlanRoot({ monthlyPriceLabel, annuallyPrice, annuallyPriceLabel, + monthlyVariantId, + annuallyVariantId, // #withPlans plansPeriod, @@ -50,7 +54,12 @@ function SubscriptionPlanRoot({ useGetLemonSqueezyCheckout(); const handleClick = () => { - getLemonCheckout({ variantId: '338516' }) + const variantId = + SubscriptionPlansPeriod.Monthly === plansPeriod + ? monthlyVariantId + : annuallyVariantId; + + getLemonCheckout({ variantId }) .then((res) => { const checkoutUrl = res.data.data.attributes.url; window.LemonSqueezy.Url.Open(checkoutUrl); diff --git a/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlans.tsx b/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlans.tsx index aab0bb8ce..7fa489f0e 100644 --- a/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlans.tsx +++ b/packages/webapp/src/containers/Setup/SetupSubscription/SubscriptionPlans.tsx @@ -19,6 +19,8 @@ export function SubscriptionPlans() { monthlyPriceLabel={plan.monthlyPriceLabel} annuallyPrice={plan.annuallyPrice} annuallyPriceLabel={plan.annuallyPriceLabel} + monthlyVariantId={plan.monthlyVariantId} + annuallyVariantId={plan.annuallyVariantId} /> ))}