import { Button, Card, List, ThemeIcon, Title, Text, Group, Select, Container, Stack, Badge, Flex, Switch, } from "@mantine/core"; import { useState } from "react"; import { IconCheck } from "@tabler/icons-react"; import { getCheckoutLink } from "@/ee/billing/services/billing-service.ts"; import { useBillingPlans } from "@/ee/billing/queries/billing-query.ts"; export default function BillingPlans() { const { data: plans } = useBillingPlans(); const [isAnnual, setIsAnnual] = useState(true); const [selectedTierValue, setSelectedTierValue] = useState( null, ); const handleCheckout = async (priceId: string) => { try { const checkoutLink = await getCheckoutLink({ priceId: priceId, }); window.location.href = checkoutLink.url; } catch (err) { console.error("Failed to get checkout link", err); } }; if (!plans || plans.length === 0) { return null; } const firstPlan = plans[0]; // Set initial tier value if not set if (!selectedTierValue && firstPlan.pricingTiers.length > 0) { setSelectedTierValue(firstPlan.pricingTiers[0].upTo.toString()); return null; } if (!selectedTierValue) { return null; } const selectData = firstPlan.pricingTiers .filter((tier) => !tier.custom) .map((tier, index) => { const prevMaxUsers = index > 0 ? firstPlan.pricingTiers[index - 1].upTo : 0; return { value: tier.upTo.toString(), label: `${prevMaxUsers + 1}-${tier.upTo} users`, }; }); return ( {/* Controls Section */} {/* Team Size and Billing Controls */}