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

@@ -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);

View File

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