import {AnimatePresence, m} from 'framer-motion'; import {Fragment} from 'react'; import {opacityAnimation} from '@common/ui/animation/opacity-animation'; import {Skeleton} from '@common/ui/skeleton/skeleton'; import {useProducts} from '@common/billing/pricing-table/use-products'; import {Product} from '@common/billing/product'; import { findBestPrice, UpsellBillingCycle, } from '@common/billing/pricing-table/find-best-price'; import {useAuth} from '@common/auth/use-auth'; import clsx from 'clsx'; import {Chip} from '@common/ui/forms/input-field/chip-field/chip'; import {Trans} from '@common/i18n/trans'; import {FormattedPrice} from '@common/i18n/formatted-price'; import {Button} from '@common/ui/buttons/button'; import {Link} from 'react-router-dom'; import {setInLocalStorage} from '@common/utils/hooks/local-storage'; import {ProductFeatureList} from '@common/billing/pricing-table/product-feature-list'; interface PricingTableProps { selectedCycle: UpsellBillingCycle; className?: string; productLoader?: string; } export function PricingTable({ selectedCycle, className, productLoader, }: PricingTableProps) { const query = useProducts(productLoader); return (
{query.data ? ( ) : ( )}
); } interface PlanListProps { plans: Product[]; selectedPeriod: UpsellBillingCycle; } function PlanList({plans, selectedPeriod}: PlanListProps) { const {isLoggedIn, isSubscribed} = useAuth(); const filteredPlans = plans.filter(plan => !plan.hidden); return ( {filteredPlans.map((plan, index) => { const isFirst = index === 0; const isLast = index === filteredPlans.length - 1; const price = findBestPrice(selectedPeriod, plan.prices); let upgradeRoute; if (!isLoggedIn) { upgradeRoute = `/register?redirectFrom=pricing`; } if (isSubscribed) { upgradeRoute = `/change-plan/${plan.id}/${price?.id}/confirm`; } if (isLoggedIn && !plan.free) { upgradeRoute = `/checkout/${plan.id}/${price?.id}`; } return (
{price ? ( ) : (
)}
); })}
); } interface ActionButtonTextProps { product: Product; } function ActionButtonText({product}: ActionButtonTextProps) { const {isLoggedIn} = useAuth(); if (product.free && isLoggedIn) { return ; } if (product.free || !isLoggedIn) { return ; } return ; } function SkeletonLoader() { return ( ); } function PlanSkeleton() { return ( ); }