diff --git a/apps/client/src/ee/billing/components/billing-details.tsx b/apps/client/src/ee/billing/components/billing-details.tsx index 9ecd1558..e8534457 100644 --- a/apps/client/src/ee/billing/components/billing-details.tsx +++ b/apps/client/src/ee/billing/components/billing-details.tsx @@ -112,18 +112,58 @@ export default function BillingDetails() { fz="xs" className={classes.label} > - Total - - - {(billing.amount / 100) * billing.quantity}{" "} - {billing.currency.toUpperCase()} - - - ${billing.amount / 100} /user/{billing.interval} + Cost + {billing.billingScheme === "tiered" && ( + <> + + ${billing.amount / 100} {billing.currency.toUpperCase()} + + + per {billing.interval} + + + )} + + {billing.billingScheme !== "tiered" && ( + <> + + {(billing.amount / 100) * billing.quantity}{" "} + {billing.currency.toUpperCase()} + + + ${billing.amount / 100} /user/{billing.interval} + + + )} + + {billing.billingScheme === "tiered" && billing.tieredUpTo && ( + + +
+ + Current Tier + + + For up to {billing.tieredUpTo} users + + {/*billing.tieredFlatAmount && ( + + + )*/} +
+
+
+ )} ); diff --git a/apps/client/src/ee/billing/components/billing-plans.tsx b/apps/client/src/ee/billing/components/billing-plans.tsx index 3ff655d6..5a287bba 100644 --- a/apps/client/src/ee/billing/components/billing-plans.tsx +++ b/apps/client/src/ee/billing/components/billing-plans.tsx @@ -2,24 +2,28 @@ import { Button, Card, List, - SegmentedControl, ThemeIcon, Title, Text, Group, + Select, + Container, + Stack, + Badge, + Flex, + Switch, } 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"; +import { useBillingPlans } from "@/ee/billing/queries/billing-query.ts"; export default function BillingPlans() { const { data: plans } = useBillingPlans(); - const [interval, setInterval] = useState("yearly"); - - if (!plans) { - return null; - } + const [isAnnual, setIsAnnual] = useState(true); + const [selectedTierValue, setSelectedTierValue] = useState( + null, + ); const handleCheckout = async (priceId: string) => { try { @@ -32,84 +36,153 @@ export default function BillingPlans() { } }; + 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 ( - - {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; + + {/* Controls Section */} + + {/* Team Size and Billing Controls */} + +