// @ts-nocheck import { Intent } from '@blueprintjs/core'; import * as R from 'ramda'; import { AppToaster } from '@/components'; import { useGetLemonSqueezyCheckout } from '@/hooks/query'; import { PricingPlan } from '@/components/PricingPlan/PricingPlan'; import { SubscriptionPlansPeriod } from '@/store/plans/plans.reducer'; import { WithPlansProps, withPlans, } from '@/containers/Subscriptions/withPlans'; interface SubscriptionPricingFeature { text: string; hint?: string; hintLabel?: string; style?: Record; } interface SubscriptionPricingProps { slug: string; label: string; description: string; features?: Array; featured?: boolean; monthlyPrice: string; monthlyPriceLabel: string; annuallyPrice: string; annuallyPriceLabel: string; monthlyVariantId?: string; annuallyVariantId?: string; onSubscribe?: (variantId: number) => void; } interface SubscriptionPricingCombinedProps extends SubscriptionPricingProps, WithPlansProps {} function SubscriptionPlanRoot({ label, description, featured, features, monthlyPrice, monthlyPriceLabel, annuallyPrice, annuallyPriceLabel, monthlyVariantId, annuallyVariantId, onSubscribe, // #withPlans plansPeriod, }: SubscriptionPricingCombinedProps) { const { mutateAsync: getLemonCheckout, isLoading } = useGetLemonSqueezyCheckout(); const handleClick = () => { const variantId = SubscriptionPlansPeriod.Monthly === plansPeriod ? monthlyVariantId : annuallyVariantId; onSubscribe && onSubscribe(variantId); // getLemonCheckout({ variantId }) // .then((res) => { // const checkoutUrl = res.data.data.attributes.url; // window.LemonSqueezy.Url.Open(checkoutUrl); // }) // .catch(() => { // AppToaster.show({ // message: 'Something went wrong!', // intent: Intent.DANGER, // }); // }); }; return ( {featured && Most Popular} {plansPeriod === SubscriptionPlansPeriod.Monthly ? ( ) : ( )} Subscribe {features?.map((feature) => ( {feature.text} ))} ); } export const SubscriptionPlan = R.compose( withPlans(({ plansPeriod }) => ({ plansPeriod })), )(SubscriptionPlanRoot);