⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
feat(billing): polish billing settings page UI
Andrejeda0d055960e
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/billing.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/billing.tsxindex 4e7809df1..7456e5be3 100644--- a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/billing.tsx+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/billing.tsx@@ -1,6 +1,8 @@import { createFileRoute } from "@tanstack/react-router";+import { ArrowUpRight, Check, Sparkles, TriangleAlert } from "lucide-react";import { useState } from "react";import PageTitle from "@/components/page-title";+import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { Separator } from "@/components/ui/separator";import { Spinner } from "@/components/ui/spinner";@@ -10,6 +12,7 @@ import {} from "@/hooks/mutations/billing/use-billing-actions";import { useGetBilling } from "@/hooks/queries/billing/use-get-billing";import { useWorkspacePermission } from "@/hooks/use-workspace-permission";+import { cn } from "@/lib/cn";export const Route = createFileRoute("/_layout/_authenticated/dashboard/settings/workspace/billing",@@ -18,32 +21,66 @@ export const Route = createFileRoute(});type Interval = "monthly" | "annual";+type PlanKey = "personal" | "team";-const PLANS = [+const PLANS: {+ plan: PlanKey;+ name: string;+ tagline: string;+ monthly: { price: string; suffix: string; note: string };+ annual: { price: string; suffix: string; note: string };+ features: string[];+ highlighted?: boolean;+}[] = [{- plan: "personal" as const,- name: "Cloud Personal",+ plan: "personal",+ name: "Personal",tagline: "For individuals",- monthly: "€4 / month",- annual: "€40 / year",+ monthly: { price: "€4", suffix: "/ month", note: "Billed monthly" },+ annual: {+ price: "€40",+ suffix: "/ year",+ note: "€3.33 / month, billed yearly",+ },+ features: [+ "Single user",+ "Unlimited projects and tasks",+ "Automatic backups and updates",+ "Email support",+ ],},{- plan: "team" as const,- name: "Cloud Team",- tagline: "Per user, for teams",- monthly: "€5 / user / month",- annual: "€50 / user / year",+ plan: "team",+ name: "Team",+ tagline: "For teams working together",+ monthly: { price: "€5", suffix: "/ user / month", note: "Billed monthly" },+ annual: {+ price: "€50",+ suffix: "/ user / year",+ note: "€4.17 / user / month, billed yearly",+ },+ features: [+ "Unlimited team members",+ "Unlimited projects and tasks",+ "Workspace roles and permissions",+ "Automatic backups and updates",+ "Priority email support",+ ],+ highlighted: true,},];-const STATUS_LABEL: Record<string, string> = {- active: "Active",- trialing: "Trial",- past_due: "Payment past due",- scheduled_cancel: "Cancels at period end",- canceled: "Canceled",- expired: "Expired",- paused: "Paused",+const STATUS: Record<+ string,+ { label: string; variant: "success" | "warning" | "error" | "secondary" }+> = {+ active: { label: "Active", variant: "success" },+ trialing: { label: "Trial", variant: "success" },+ past_due: { label: "Payment past due", variant: "warning" },+ scheduled_cancel: { label: "Cancels soon", variant: "warning" },+ canceled: { label: "Canceled", variant: "error" },+ expired: { label: "Expired", variant: "error" },+ paused: { label: "Paused", variant: "secondary" },};function formatDate(value: string | null | undefined) {@@ -55,6 +92,27 @@ function formatDate(value: string | null | undefined) {});}+function daysUntil(value: string | null | undefined) {+ if (!value) return null;+ const ms = new Date(value).getTime() - Date.now();+ return Math.max(0, Math.ceil(ms / (24 * 60 * 60 * 1000)));+}++function SectionHeader({+ title,+ subtitle,+}: {+ title: string;+ subtitle: string;+}) {+ return (+ <div className="space-y-1">+ <h2 className="font-medium text-md">{title}</h2>+ <p className="text-muted-foreground text-xs">{subtitle}</p>+ </div>+ );+}+function RouteComponent() {const { workspace, isAdmin } = useWorkspacePermission();const workspaceId = workspace?.id;@@ -63,7 +121,7 @@ function RouteComponent() {const { data: billing, isLoading } = useGetBilling(workspaceId);const checkout = useCreateCheckout(workspaceId);const portal = useOpenBillingPortal(workspaceId);- const [interval, setInterval] = useState<Interval>("monthly");+ const [interval, setInterval] = useState<Interval>("annual");if (isLoading) {return (@@ -80,18 +138,28 @@ function RouteComponent() {<div className="mx-auto max-w-4xl space-y-2"><h1 className="font-semibold text-2xl">Billing</h1><p className="text-muted-foreground text-sm">- Billing is not enabled on this instance. Self-hosted Kaneo includes- every feature for free.+ Billing isn't enabled on this instance. Self-hosted Kaneo includes+ every feature, free forever.</p></div></>);}- const status = billing.status ? STATUS_LABEL[billing.status] : null;- const renews = formatDate(billing.currentPeriodEnd);- const trialEnds = formatDate(billing.trialEndsAt);const hasSubscription = Boolean(billing.plan && billing.status);+ const status = billing.status ? STATUS[billing.status] : null;+ const renews = formatDate(billing.currentPeriodEnd);+ const trialDaysLeft = daysUntil(billing.trialEndsAt);+ const trialExpired =+ !billing.foundingFree && !hasSubscription && trialDaysLeft === 0;++ const pricePer = billing.billingInterval === "annual" ? "year" : "month";+ const planLabel =+ billing.plan === "team"+ ? "Team"+ : billing.plan === "personal"+ ? "Personal"+ : null;return (<>@@ -99,117 +167,235 @@ function RouteComponent() {<div className="mx-auto max-w-4xl space-y-8"><div className="space-y-2"><h1 className="font-semibold text-2xl">Billing</h1>- <p className="text-muted-foreground text-sm">+ <p className="text-muted-foreground">Manage the Kaneo Cloud subscription for this workspace.</p></div>- <div className="space-y-4">- <h2 className="font-medium text-md">Current plan</h2>- <div className="rounded-lg border border-border p-4">- {billing.foundingFree ? (- <p className="text-sm">- <span className="font-medium">Founding Free.</span> This- workspace has free access to Kaneo Cloud. Thank you for being an- early user.- </p>- ) : hasSubscription ? (- <div className="space-y-1 text-sm">- <p>- <span className="font-medium capitalize">- {billing.plan} · {billing.billingInterval}- </span>- {status ? ` · ${status}` : null}- </p>- {billing.seats > 1 ? <p>{billing.seats} seats</p> : null}- {renews ? (- <p className="text-muted-foreground">- {billing.canceledAt- ? `Access ends ${renews}`- : `Renews ${renews}`}+ {/* ── Current plan ── */}+ <div className="space-y-6">+ <SectionHeader+ title="Current plan"+ subtitle="Your workspace's active plan and billing status."+ />++ {billing.foundingFree ? (+ <div className="overflow-hidden rounded-md border border-primary/30 bg-sidebar">+ <div className="flex items-start gap-3 p-5">+ <div className="mt-0.5 flex size-9 items-center justify-center rounded-md bg-primary/10 text-primary">+ <Sparkles className="size-4.5" />+ </div>+ <div className="space-y-1">+ <div className="flex items-center gap-2">+ <h3 className="font-medium text-sm">Founding Free</h3>+ <Badge variant="success" size="sm">+ Free+ </Badge>+ </div>+ <p className="text-muted-foreground text-sm leading-relaxed">+ This workspace has free access to Kaneo Cloud as an early+ supporter. Thank you for being here from the start.</p>- ) : null}+ </div>+ </div>+ </div>+ ) : hasSubscription ? (+ <div className="rounded-md border border-border bg-sidebar">+ <div className="flex flex-wrap items-start justify-between gap-4 p-5">+ <div className="space-y-1.5">+ <div className="flex items-center gap-2">+ <h3 className="font-medium text-sm">+ Kaneo Cloud {planLabel}+ </h3>+ {status ? (+ <Badge variant={status.variant} size="sm">+ {status.label}+ </Badge>+ ) : null}+ </div>+ <p className="text-muted-foreground text-sm">+ {billing.plan === "team"+ ? `€${billing.billingInterval === "annual" ? 50 : 5} / user / ${pricePer}`+ : `€${billing.billingInterval === "annual" ? 40 : 4} / ${pricePer}`}+ {billing.seats > 1 ? ` · ${billing.seats} seats` : null}+ </p>+ </div>+ <div className="text-right">+ {renews ? (+ <p className="text-muted-foreground text-xs">+ {billing.canceledAt ? "Access ends" : "Renews"}+ </p>+ ) : null}+ {renews ? (+ <p className="font-medium text-sm">{renews}</p>+ ) : null}+ </div></div>- ) : (- <div className="space-y-1 text-sm">- <p className="font-medium">Free trial</p>- <p className="text-muted-foreground">- {trialEnds- ? `Your trial ends ${trialEnds}. Choose a plan to continue.`- : "Choose a plan to continue after your trial."}+ <Separator />+ <div className="flex items-center justify-between gap-3 px-5 py-3">+ <p className="text-muted-foreground text-xs">+ Update payment method, view invoices, or cancel anytime.</p>+ {billing.hasCustomer ? (+ <Button+ variant="outline"+ size="sm"+ disabled={!canManage || portal.isPending}+ onClick={() => portal.mutate()}+ >+ {portal.isPending ? "Opening…" : "Manage billing"}+ <ArrowUpRight className="size-4" />+ </Button>+ ) : null}</div>- )}- </div>-- {billing.hasCustomer ? (- <Button- variant="outline"- size="sm"- disabled={!canManage || portal.isPending}- onClick={() => portal.mutate()}+ </div>+ ) : (+ <div+ className={cn(+ "rounded-md border bg-sidebar p-5",+ trialExpired ? "border-warning/40" : "border-border",+ )}>- {portal.isPending ? "Opening…" : "Manage billing & invoices"}- </Button>- ) : null}+ <div className="flex items-start gap-3">+ <div+ className={cn(+ "mt-0.5 flex size-9 items-center justify-center rounded-md",+ trialExpired+ ? "bg-warning/10 text-warning-foreground"+ : "bg-primary/10 text-primary",+ )}+ >+ {trialExpired ? (+ <TriangleAlert className="size-4.5" />+ ) : (+ <Sparkles className="size-4.5" />+ )}+ </div>+ <div className="space-y-1">+ <h3 className="font-medium text-sm">+ {trialExpired ? "Your trial has ended" : "Free trial"}+ </h3>+ <p className="text-muted-foreground text-sm leading-relaxed">+ {trialExpired+ ? "Subscribe to a plan below to keep creating and editing. Your data stays safe and exportable in the meantime."+ : trialDaysLeft !== null+ ? `You have ${trialDaysLeft} ${trialDaysLeft === 1 ? "day" : "days"} left on your free trial. Choose a plan to continue without interruption.`+ : "Choose a plan below to continue after your trial."}+ </p>+ </div>+ </div>+ </div>+ )}</div>+ {/* ── Plan picker ── */}{!billing.foundingFree && !hasSubscription ? (- <>- <Separator />- <div className="space-y-4">- <div className="flex items-center justify-between">- <h2 className="font-medium text-md">Choose a plan</h2>- <div className="flex rounded-lg border border-border p-0.5 text-sm">+ <div className="space-y-6">+ <div className="flex flex-wrap items-end justify-between gap-3">+ <SectionHeader+ title="Choose a plan"+ subtitle="Switch anytime. Cancel whenever you like."+ />+ <div className="inline-flex items-center gap-2">+ <div className="inline-flex rounded-md border border-border bg-sidebar p-0.5 text-xs">{(["monthly", "annual"] as const).map((value) => (<buttonkey={value}type="button"onClick={() => setInterval(value)}- className={`rounded-md px-3 py-1 capitalize transition-colors ${+ className={cn(+ "rounded-[0.3rem] px-3 py-1 font-medium capitalize transition-colors",interval === value- ? "bg-accent text-accent-foreground"- : "text-muted-foreground"- }`}+ ? "bg-background text-foreground shadow-sm"+ : "text-muted-foreground hover:text-foreground",+ )}>{value}</button>))}</div>+ {interval === "annual" ? (+ <Badge variant="success" size="sm">+ 2 months free+ </Badge>+ ) : null}</div>+ </div>- <div className="grid gap-4 sm:grid-cols-2">- {PLANS.map((p) => (- <div- key={p.plan}- className="flex flex-col rounded-lg border border-border p-4"- >- <p className="font-medium text-sm">{p.name}</p>- <p className="text-muted-foreground text-sm">{p.tagline}</p>- <p className="mt-3 font-medium text-lg">- {interval === "monthly" ? p.monthly : p.annual}- </p>- <Button- size="sm"- className="mt-4"- disabled={!canManage || checkout.isPending}- onClick={() =>- checkout.mutate({ plan: p.plan, interval })- }+ <div className="rounded-2xl border border-border/70 bg-card/70 p-2">+ <div className="grid grid-cols-1 gap-2 sm:grid-cols-2">+ {PLANS.map((p) => {+ const price = interval === "monthly" ? p.monthly : p.annual;+ return (+ <div+ key={p.plan}+ className={cn(+ "flex flex-col rounded-xl border p-6",+ p.highlighted+ ? "border-primary/40 bg-card shadow-[0_0_40px_-12px] shadow-primary/20"+ : "border-border/70 bg-card",+ )}>- {checkout.isPending ? "Starting…" : "Subscribe"}- </Button>- </div>- ))}- </div>+ <div className="flex items-center justify-between">+ <h3 className="font-medium text-sm">{p.name}</h3>+ {p.highlighted ? (+ <span className="rounded-full border border-primary/30 bg-primary/10 px-2.5 py-0.5 font-medium text-primary text-xs">+ Most popular+ </span>+ ) : null}+ </div>+ <p className="mt-1 text-foreground/60 text-sm">+ {p.tagline}+ </p>- {!canManage ? (- <p className="text-muted-foreground text-sm">- Only workspace owners and admins can manage billing.- </p>- ) : null}+ <div className="mt-6 flex items-baseline gap-1.5">+ <span className="font-medium text-4xl tracking-tight">+ {price.price}+ </span>+ <span className="text-foreground/60 text-sm">+ {price.suffix}+ </span>+ </div>+ <p className="mt-1.5 text-foreground/60 text-sm">+ {price.note}+ </p>++ <ul className="mt-8 flex-1 space-y-3 text-sm">+ {p.features.map((feature) => (+ <li+ key={feature}+ className="flex items-start gap-2.5"+ >+ <Check className="mt-0.5 h-4 w-4 shrink-0 text-primary" />+ <span className="text-foreground/90">+ {feature}+ </span>+ </li>+ ))}+ </ul>++ <Button+ variant={p.highlighted ? "default" : "outline"}+ className="mt-8 w-full"+ disabled={!canManage || checkout.isPending}+ onClick={() =>+ checkout.mutate({ plan: p.plan, interval })+ }+ >+ {checkout.isPending ? "Starting…" : `Choose ${p.name}`}+ </Button>+ </div>+ );+ })}+ </div></div>- </>++ <p className="text-muted-foreground text-xs">+ {canManage+ ? "Payments are securely processed by Creem. Prices exclude VAT where applicable."+ : "Only workspace owners and admins can manage billing."}+ </p>+ </div>) : null}</div></>