feat: add variant ids to new subscription plans

This commit is contained in:
Ahmed Bouhuolia
2024-07-13 19:53:52 +02:00
parent eb3f23554f
commit 72128a72c4
3 changed files with 22 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ interface SubscriptionPlan {
monthlyPriceLabel: string; monthlyPriceLabel: string;
annuallyPrice: string; annuallyPrice: string;
annuallyPriceLabel: string; annuallyPriceLabel: string;
monthlyVariantId: string;
annuallyVariantId: string;
} }
export const SubscriptionPlans = [ export const SubscriptionPlans = [
@@ -39,6 +41,8 @@ export const SubscriptionPlans = [
monthlyPriceLabel: 'Per month', monthlyPriceLabel: 'Per month',
annuallyPrice: '$7.5', annuallyPrice: '$7.5',
annuallyPriceLabel: 'Per month', annuallyPriceLabel: 'Per month',
monthlyVariantId: '446152',
annuallyVariantId: '446153',
}, },
{ {
name: 'Capital Essential', name: 'Capital Essential',
@@ -57,6 +61,8 @@ export const SubscriptionPlans = [
monthlyPriceLabel: 'Per month', monthlyPriceLabel: 'Per month',
annuallyPrice: '$15', annuallyPrice: '$15',
annuallyPriceLabel: 'Per month', annuallyPriceLabel: 'Per month',
monthlyVariantId: '446165',
annuallyVariantId: '446164',
}, },
{ {
name: 'Capital Plus', name: 'Capital Plus',
@@ -74,6 +80,8 @@ export const SubscriptionPlans = [
annuallyPrice: '$18', annuallyPrice: '$18',
annuallyPriceLabel: 'Per month', annuallyPriceLabel: 'Per month',
featured: true, featured: true,
monthlyVariantId: '446165',
annuallyVariantId: '446164',
}, },
{ {
name: 'Capital Big', name: 'Capital Big',
@@ -88,5 +96,7 @@ export const SubscriptionPlans = [
monthlyPriceLabel: 'Per month', monthlyPriceLabel: 'Per month',
annuallyPrice: '$30', annuallyPrice: '$30',
annuallyPriceLabel: 'Per month', annuallyPriceLabel: 'Per month',
monthlyVariantId: '446167',
annuallyVariantId: '446168',
}, },
] as SubscriptionPlan[]; ] as SubscriptionPlan[];

View File

@@ -27,6 +27,8 @@ interface SubscriptionPricingProps {
monthlyPriceLabel: string; monthlyPriceLabel: string;
annuallyPrice: string; annuallyPrice: string;
annuallyPriceLabel: string; annuallyPriceLabel: string;
monthlyVariantId?: string;
annuallyVariantId?: string;
} }
interface SubscriptionPricingCombinedProps interface SubscriptionPricingCombinedProps
@@ -42,6 +44,8 @@ function SubscriptionPlanRoot({
monthlyPriceLabel, monthlyPriceLabel,
annuallyPrice, annuallyPrice,
annuallyPriceLabel, annuallyPriceLabel,
monthlyVariantId,
annuallyVariantId,
// #withPlans // #withPlans
plansPeriod, plansPeriod,
@@ -50,7 +54,12 @@ function SubscriptionPlanRoot({
useGetLemonSqueezyCheckout(); useGetLemonSqueezyCheckout();
const handleClick = () => { const handleClick = () => {
getLemonCheckout({ variantId: '338516' }) const variantId =
SubscriptionPlansPeriod.Monthly === plansPeriod
? monthlyVariantId
: annuallyVariantId;
getLemonCheckout({ variantId })
.then((res) => { .then((res) => {
const checkoutUrl = res.data.data.attributes.url; const checkoutUrl = res.data.data.attributes.url;
window.LemonSqueezy.Url.Open(checkoutUrl); window.LemonSqueezy.Url.Open(checkoutUrl);

View File

@@ -19,6 +19,8 @@ export function SubscriptionPlans() {
monthlyPriceLabel={plan.monthlyPriceLabel} monthlyPriceLabel={plan.monthlyPriceLabel}
annuallyPrice={plan.annuallyPrice} annuallyPrice={plan.annuallyPrice}
annuallyPriceLabel={plan.annuallyPriceLabel} annuallyPriceLabel={plan.annuallyPriceLabel}
monthlyVariantId={plan.monthlyVariantId}
annuallyVariantId={plan.annuallyVariantId}
/> />
))} ))}
</Group> </Group>