import { Button, Card, List, SegmentedControl, ThemeIcon, Title, Text, Group, } from "@mantine/core"; import { useState } from "react"; import { IconCheck } from "@tabler/icons-react"; import { useBillingPlans } from "@/ee/billing/queries/billing-query.ts"; import { getCheckoutLink } from "@/ee/billing/services/billing-service.ts"; export default function BillingPlans() { const { data: plans } = useBillingPlans(); const [interval, setInterval] = useState("yearly"); if (!plans) { return 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); } }; return ( {plans.map((plan) => { const price = interval === "monthly" ? plan.price.monthly : plan.price.yearly; const priceId = interval === "monthly" ? plan.monthlyId : plan.yearlyId; const yearlyMonthPrice = parseInt(plan.price.yearly) / 12; return ( {plan.name} {interval === "monthly" && ( <> ${price}{" "} /user/month )} {interval === "yearly" && ( <> ${yearlyMonthPrice}{" "} /user/month )}
billed {interval}
} > {plan.features.map((feature, index) => ( {feature} ))}
); })}
); }