import { BadgeCheck } from 'lucide-react'; import { BillingConfig, getProductPlanPairByVariantId } from '@kit/billing'; import { Tables } from '@kit/supabase/database'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@kit/ui/card'; import { Trans } from '@kit/ui/trans'; import { CurrentPlanBadge } from './current-plan-badge'; import { LineItemDetails } from './line-item-details'; type Order = Tables<{ schema: 'medreport' }, 'orders'>; type LineItem = Tables<{ schema: 'medreport' }, 'order_items'>; interface Props { order: Order & { items: LineItem[]; }; config: BillingConfig; } export function CurrentLifetimeOrderCard({ order, config, }: React.PropsWithChildren) { const lineItems = order.items; const firstLineItem = lineItems[0]; if (!firstLineItem) { throw new Error('No line items found in subscription'); } const { product, plan } = getProductPlanPairByVariantId( config, firstLineItem.variant_id, ); if (!product || !plan) { throw new Error( 'Product or plan not found. Did you forget to add it to the billing config?', ); } const productLineItems = plan.lineItems; return (
{product.name}
); }