Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: unified billing

Chadpihab59d6b811720
diff --git a/src/components/InviteTeammateDialog.tsx b/src/components/InviteTeammateDialog.tsx
index 446414a9b..0ef814161 100644
--- a/src/components/InviteTeammateDialog.tsx
+++ b/src/components/InviteTeammateDialog.tsx
@@ -107,7 +107,10 @@ export default function InviteTeammateDialog({
onInvited?.();
onOpenChange(false);
} catch (error) {
- if (error instanceof CloudApiError && error.code === "seat_limit_reached") {
+ if (
+ error instanceof CloudApiError &&
+ (error.code === "seat_limit_reached" || error.code === "workspace_subscription_required")
+ ) {
const details = error.details as { seats?: number } | undefined;
setSeatLimitSeats(details?.seats ?? seats ?? 0);
} else {
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index 6d685d56d..95e5856d9 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -101,8 +101,10 @@ import { startMigration, useMigration } from "../stores/noteStore.js";
import { syncService } from "../services/SyncService.js";
import { formatBytes } from "../utils/formatBytes";
import { useSettingsStore } from "../stores/settingsStore";
+import { useWorkspaceStore } from "../stores/workspaceStore";
import { canManageSystemAudioInApp } from "../utils/systemAudioAccess";
import WorkspaceSection from "./settings/WorkspaceSection";
+import WorkspaceBillingOverview from "./settings/WorkspaceBillingOverview";
const formatAmount = (cents: number, currency: string) =>
(cents / 100).toLocaleString(undefined, { style: "currency", currency });
@@ -922,6 +924,10 @@ export default function SettingsPage({
const { theme, setTheme } = useTheme();
const usage = useUsage();
+ const billingWorkspaces = useWorkspaceStore((s) => s.workspaces);
+ const coveringWorkspaceNames = (usage?.entitledWorkspaceIds ?? [])
+ .map((id) => billingWorkspaces.find((workspace) => workspace.id === id)?.name)
+ .filter((name): name is string => Boolean(name));
const hasShownApproachingToast = useRef(false);
useEffect(() => {
if (usage?.isApproachingLimit && !hasShownApproachingToast.current) {
@@ -1728,7 +1734,7 @@ export default function SettingsPage({
case "plansBilling":
return (
- <div className="space-y-5">
+ <div className="flex flex-col gap-5">
{!AUTH_URL ? (
<>
<SectionHeader
@@ -1748,408 +1754,396 @@ export default function SettingsPage({
</>
) : isLoaded ? (
<>
- <SectionHeader title={t("settingsPage.account.pricing.title")} />
- <div className={`grid gap-1.5 ${isCompact ? "grid-cols-2" : "grid-cols-4"}`}>
- {/* Free */}
- <div
- className={cn(
- "rounded-md p-2.5 flex flex-col",
- !usage?.isSubscribed && !usage?.isTrial
- ? "border-2 border-primary/30 bg-primary/3 dark:border-primary/20 dark:bg-primary/5"
- : "border border-border/50 dark:border-border-subtle/60 bg-card/30 dark:bg-surface-2/30"
- )}
- >
- <p className="text-xs font-semibold text-foreground">
- {t("settingsPage.account.pricing.free.name")}
- </p>
- <div className="flex items-baseline gap-0.5 mt-0.5">
- <span className="text-lg font-bold text-foreground">
- {t("settingsPage.account.pricing.free.price")}
- </span>
- <span className="text-[9px] text-muted-foreground">
- / {t("settingsPage.account.pricing.free.period")}
- </span>
- </div>
- <ul className="space-y-0.5 mt-2 flex-1">
- {(
- t("settingsPage.account.pricing.free.features", {
- returnObjects: true,
- }) as string[]
- ).map((feature, i) =>
- feature.startsWith("## ") ? (
- <li
- key={i}
- className={`text-[8px] font-semibold uppercase tracking-wide text-muted-foreground/60 ${i > 0 ? "pt-1.5" : ""}`}
- >
- {feature.slice(3)}
- </li>
- ) : (
- <li
- key={i}
- className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
- >
- <Check size={9} className="mt-[2px] text-primary/70 shrink-0" />
- {feature}
- </li>
- )
+ {isSignedIn && (
+ <div className="order-1">
+ <WorkspaceBillingOverview onRefreshEntitlement={usage?.refetch} />
+ </div>
+ )}
+ <div className="order-3 space-y-5">
+ <SectionHeader title={t("settingsPage.account.pricing.title")} />
+ <div className={`grid gap-1.5 ${isCompact ? "grid-cols-2" : "grid-cols-4"}`}>
+ {/* Free */}
+ <div
+ className={cn(
+ "rounded-md p-2.5 flex flex-col",
+ !usage?.isPersonallySubscribed && !usage?.isTrial
+ ? "border-2 border-primary/30 bg-primary/3 dark:border-primary/20 dark:bg-primary/5"
+ : "border border-border/50 dark:border-border-subtle/60 bg-card/30 dark:bg-surface-2/30"
)}
- </ul>
- {!isSignedIn ? (
- <Button
- onClick={startOnboarding}
- variant="outline"
- size="sm"
- className="mt-2 w-full h-6 text-[10px]"
- >
- {t("settingsPage.account.signedOutPlans.button")}
- </Button>
- ) : usage?.isSubscribed && !usage?.isTrial ? (
- <Button
- onClick={handleBillingPortal}
- variant="outline"
- size="sm"
- className="mt-2 w-full h-6 text-[10px]"
- >
- {t("settingsPage.account.pricing.downgrade")}
- </Button>
- ) : (
- <div className="mt-2 text-center">
- <span className="text-[9px] font-medium text-primary/70">
- {t("settingsPage.account.pricing.currentPlan")}
+ >
+ <p className="text-xs font-semibold text-foreground">
+ {t("settingsPage.account.pricing.free.name")}
+ </p>
+ <div className="flex items-baseline gap-0.5 mt-0.5">
+ <span className="text-lg font-bold text-foreground">
+ {t("settingsPage.account.pricing.free.price")}
+ </span>
+ <span className="text-[9px] text-muted-foreground">
+ / {t("settingsPage.account.pricing.free.period")}
</span>
</div>
- )}
- </div>
+ <ul className="space-y-0.5 mt-2 flex-1">
+ {(
+ t("settingsPage.account.pricing.free.features", {
+ returnObjects: true,
+ }) as string[]
+ ).map((feature, i) =>
+ feature.startsWith("## ") ? (
+ <li
+ key={i}
+ className={`text-[8px] font-semibold uppercase tracking-wide text-muted-foreground/60 ${i > 0 ? "pt-1.5" : ""}`}
+ >
+ {feature.slice(3)}
+ </li>
+ ) : (
+ <li
+ key={i}
+ className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
+ >
+ <Check size={9} className="mt-[2px] text-primary/70 shrink-0" />
+ {feature}
+ </li>
+ )
+ )}
+ </ul>
+ {!isSignedIn ? (
+ <Button
+ onClick={startOnboarding}
+ variant="outline"
+ size="sm"
+ className="mt-2 w-full h-6 text-[10px]"
+ >
+ {t("settingsPage.account.signedOutPlans.button")}
+ </Button>
+ ) : usage?.isPersonallySubscribed && !usage?.isTrial ? (
+ <Button
+ onClick={handleBillingPortal}
+ variant="outline"
+ size="sm"
+ className="mt-2 w-full h-6 text-[10px]"
+ >
+ {t("settingsPage.account.pricing.downgrade")}
+ </Button>
+ ) : (
+ <div className="mt-2 text-center">
+ <span className="text-[9px] font-medium text-primary/70">
+ {t("settingsPage.account.pricing.currentPlan")}
+ </span>
+ </div>
+ )}
+ </div>
- {/* Pro */}
- <div
- className={cn(
- "rounded-md border-2 p-2.5 flex flex-col",
- usage?.isSubscribed && usage?.plan === "pro"
- ? "border-primary/40 bg-primary/5 dark:border-primary/30 dark:bg-primary/8"
- : "border-primary/20 bg-primary/2 dark:border-primary/15 dark:bg-primary/3"
- )}
- >
- <p className="text-xs font-semibold text-foreground">
- {t("settingsPage.account.pricing.pro.name")}
- </p>
- <button
- onClick={() => setBillingState((prev) => ({ ...prev, pro: !prev.pro }))}
- role="switch"
- aria-checked={billingState.pro}
- className="flex items-center gap-1.5 mt-1"
+ {/* Pro */}
+ <div
+ className={cn(
+ "rounded-md border-2 p-2.5 flex flex-col",
+ usage?.isPersonallySubscribed && usage?.plan === "pro"
+ ? "border-primary/40 bg-primary/5 dark:border-primary/30 dark:bg-primary/8"
+ : "border-primary/20 bg-primary/2 dark:border-primary/15 dark:bg-primary/3"
+ )}
>
- <div
- className={`relative w-7 h-4 rounded-full transition-colors ${billingState.pro ? "bg-primary" : "bg-muted"}`}
+ <p className="text-xs font-semibold text-foreground">
+ {t("settingsPage.account.pricing.pro.name")}
+ </p>
+ <button
+ onClick={() => setBillingState((prev) => ({ ...prev, pro: !prev.pro }))}
+ role="switch"
+ aria-checked={billingState.pro}
+ className="flex items-center gap-1.5 mt-1"
>
<div
- className={`absolute top-0.5 left-0.5 w-3 h-3 rounded-full bg-white transition-transform ${billingState.pro ? "translate-x-3" : ""}`}
- />
- </div>
- <span className="text-[9px] text-muted-foreground">
- {t("settingsPage.account.pricing.billedYearly")}
- </span>
- </button>
- <div className="flex items-baseline gap-0.5 mt-1">
- <span className="text-lg font-bold text-foreground">
- {billingState.pro
- ? t("settingsPage.account.pricing.pro.annualEquivalent")
- : t("settingsPage.account.pricing.pro.monthlyPrice")}
- </span>
- <span className="text-[9px] text-muted-foreground">
- {t("settingsPage.account.pricing.pro.monthlyPeriod")}
- </span>
- </div>
- <p className="text-[9px] text-muted-foreground/70 mt-1.5">
- {t("settingsPage.account.pricing.pro.includesPrefix")}
- </p>
- <ul className="space-y-0.5 mt-1 flex-1">
- {(
- t("settingsPage.account.pricing.pro.features", {
- returnObjects: true,
- }) as string[]
- ).map((feature, i) => (
- <li
- key={i}
- className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
+ className={`relative w-7 h-4 rounded-full transition-colors ${billingState.pro ? "bg-primary" : "bg-muted"}`}
>
- <Check size={9} className="mt-[2px] text-primary shrink-0" />
- {feature}
- </li>
- ))}
- </ul>
- {(usage?.isSubscribed && usage?.plan === "pro" && !usage?.isTrial) ||
- usage?.isTrial ? (
- <div className="mt-2 text-center">
- <span className="text-[9px] font-medium text-primary">
- {t("settingsPage.account.pricing.currentPlan")}
+ <div
+ className={`absolute top-0.5 left-0.5 w-3 h-3 rounded-full bg-white transition-transform ${billingState.pro ? "translate-x-3" : ""}`}
+ />
+ </div>
+ <span className="text-[9px] text-muted-foreground">
+ {t("settingsPage.account.pricing.billedYearly")}
+ </span>
+ </button>
+ <div className="flex items-baseline gap-0.5 mt-1">
+ <span className="text-lg font-bold text-foreground">
+ {billingState.pro
+ ? t("settingsPage.account.pricing.pro.annualEquivalent")
+ : t("settingsPage.account.pricing.pro.monthlyPrice")}
+ </span>
+ <span className="text-[9px] text-muted-foreground">
+ {t("settingsPage.account.pricing.pro.monthlyPeriod")}
</span>
</div>
- ) : usage?.isSubscribed && usage?.plan === "business" ? (
- <Button
- onClick={() =>
- handleSwitchPlan(billingState.pro ? "annual" : "monthly", "pro")
- }
- disabled={previewLoading || usage.checkoutLoading}
- variant="outline"
- size="sm"
- className="mt-2 w-full h-6 text-[10px]"
- >
- {previewLoading ? (
- <Loader2 size={10} className="animate-spin" />
- ) : (
- t("settingsPage.account.pricing.downgrade")
- )}
- </Button>
- ) : (
- <Button
+ <p className="text-[9px] text-muted-foreground/70 mt-1.5">
+ {t("settingsPage.account.pricing.pro.includesPrefix")}
+ </p>
+ <ul className="space-y-0.5 mt-1 flex-1">
+ {(
+ t("settingsPage.account.pricing.pro.features", {
+ returnObjects: true,
+ }) as string[]
+ ).map((feature, i) => (
+ <li
+ key={i}
+ className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
+ >
+ <Check size={9} className="mt-[2px] text-primary shrink-0" />
+ {feature}
+ </li>
+ ))}
+ </ul>
+ {(usage?.isPersonallySubscribed &&
+ usage?.plan === "pro" &&
+ !usage?.isTrial) ||
+ usage?.isTrial ? (
+ <div className="mt-2 text-center">
+ <span className="text-[9px] font-medium text-primary">
+ {t("settingsPage.account.pricing.currentPlan")}
+ </span>
+ </div>
+ ) : usage?.isPersonallySubscribed && usage?.plan === "business" ? (
+ <Button
+ onClick={() =>
+ handleSwitchPlan(billingState.pro ? "annual" : "monthly", "pro")
+ }
+ disabled={previewLoading || usage.checkoutLoading}
+ variant="outline"
+ size="sm"
+ className="mt-2 w-full h-6 text-[10px]"
+ >
+ {previewLoading ? (
+ <Loader2 size={10} className="animate-spin" />
+ ) : (
+ t("settingsPage.account.pricing.downgrade")
+ )}
+ </Button>
+ ) : (
+ <Button
+ onClick={() =>
+ handleCheckout(billingState.pro ? "annual" : "monthly", "pro")
+ }
+ disabled={checkoutTier === "pro"}
+ size="sm"
+ className="mt-2 w-full h-6 text-[10px]"
+ >
+ {checkoutTier === "pro" ? (
+ <Loader2 size={10} className="animate-spin" />
+ ) : (
+ t("settingsPage.account.pricing.pro.cta")
+ )}
+ </Button>
+ )}
+ </div>
+
+ {/* Business */}
+ <div className="rounded-md border-2 border-primary/50 bg-primary/8 dark:border-primary/40 dark:bg-primary/10 p-2.5 flex flex-col relative">
+ <span className="absolute -top-2.5 left-1/2 -translate-x-1/2 bg-primary text-primary-foreground text-[8px] font-semibold px-2.5 py-0.5 rounded-full whitespace-nowrap shadow-sm">
+ {t("settingsPage.account.pricing.business.badge")}
+ </span>
+ <p className="text-xs font-semibold text-foreground">
+ {t("settingsPage.account.pricing.business.name")}
+ </p>
+ <button
onClick={() =>
- handleCheckout(billingState.pro ? "annual" : "monthly", "pro")
+ setBillingState((prev) => ({ ...prev, business: !prev.business }))
}
- disabled={checkoutTier === "pro"}
- size="sm"
- className="mt-2 w-full h-6 text-[10px]"
- >
- {checkoutTier === "pro" ? (
- <Loader2 size={10} className="animate-spin" />
- ) : (
- t("settingsPage.account.pricing.pro.cta")
- )}
- </Button>
- )}
- </div>
-
- {/* Business */}
- <div className="rounded-md border-2 border-primary/50 bg-primary/8 dark:border-primary/40 dark:bg-primary/10 p-2.5 flex flex-col relative">
- <span className="absolute -top-2.5 left-1/2 -translate-x-1/2 bg-primary text-primary-foreground text-[8px] font-semibold px-2.5 py-0.5 rounded-full whitespace-nowrap shadow-sm">
- {t("settingsPage.account.pricing.business.badge")}
- </span>
- <p className="text-xs font-semibold text-foreground">
- {t("settingsPage.account.pricing.business.name")}
- </p>
- <button
- onClick={() =>
- setBillingState((prev) => ({ ...prev, business: !prev.business }))
- }
- role="switch"
- aria-checked={billingState.business}
- className="flex items-center gap-1.5 mt-1"
- >
- <div
- className={`relative w-7 h-4 rounded-full transition-colors ${billingState.business ? "bg-primary" : "bg-muted"}`}
+ role="switch"
+ aria-checked={billingState.business}
+ className="flex items-center gap-1.5 mt-1"
>
<div
- className={`absolute top-0.5 left-0.5 w-3 h-3 rounded-full bg-white transition-transform ${billingState.business ? "translate-x-3" : ""}`}
- />
+ className={`relative w-7 h-4 rounded-full transition-colors ${billingState.business ? "bg-primary" : "bg-muted"}`}
+ >
+ <div
+ className={`absolute top-0.5 left-0.5 w-3 h-3 rounded-full bg-white transition-transform ${billingState.business ? "translate-x-3" : ""}`}
+ />
+ </div>
+ <span className="text-[9px] text-muted-foreground">
+ {t("settingsPage.account.pricing.billedYearly")}
+ </span>
+ </button>
+ <div className="flex items-baseline gap-0.5 mt-1">
+ <span className="text-lg font-bold text-foreground">
+ {billingState.business
+ ? t("settingsPage.account.pricing.business.annualEquivalent")
+ : t("settingsPage.account.pricing.business.monthlyPrice")}
+ </span>
+ <span className="text-[9px] text-muted-foreground">
+ {t("settingsPage.account.pricing.business.monthlyPeriod")}
+ </span>
</div>
- <span className="text-[9px] text-muted-foreground">
- {t("settingsPage.account.pricing.billedYearly")}
- </span>
- </button>
- <div className="flex items-baseline gap-0.5 mt-1">
- <span className="text-lg font-bold text-foreground">
- {billingState.business
- ? t("settingsPage.account.pricing.business.annualEquivalent")
- : t("settingsPage.account.pricing.business.monthlyPrice")}
- </span>
- <span className="text-[9px] text-muted-foreground">
- {t("settingsPage.account.pricing.business.monthlyPeriod")}
- </span>
- </div>
- <p className="text-[9px] text-muted-foreground/70 mt-1.5">
- {t("settingsPage.account.pricing.business.includesPrefix")}
- </p>
- <ul className="space-y-0.5 mt-1 flex-1">
- {(
- t("settingsPage.account.pricing.business.features", {
- returnObjects: true,
- }) as string[]
- ).map((feature, i) => (
- <li
- key={i}
- className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
+ <p className="text-[9px] text-muted-foreground/70 mt-1.5">
+ {t("settingsPage.account.pricing.business.includesPrefix")}
+ </p>
+ <ul className="space-y-0.5 mt-1 flex-1">
+ {(
+ t("settingsPage.account.pricing.business.features", {
+ returnObjects: true,
+ }) as string[]
+ ).map((feature, i) => (
+ <li
+ key={i}
+ className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
+ >
+ <Check size={9} className="mt-[2px] text-primary shrink-0" />
+ {feature}
+ </li>
+ ))}
+ </ul>
+ {!isSignedIn ? (
+ <Button
+ onClick={startOnboarding}
+ size="sm"
+ className="mt-2 w-full h-6 text-[10px]"
>
- <Check size={9} className="mt-[2px] text-primary shrink-0" />
- {feature}
- </li>
- ))}
- </ul>
- {usage?.isSubscribed && usage?.plan === "business" && !usage?.isTrial ? (
- <div className="mt-2 text-center">
- <span className="text-[9px] font-medium text-primary">
- {t("settingsPage.account.pricing.currentPlan")}
+ {t("settingsPage.account.pricing.business.cta")}
+ </Button>
+ ) : (
+ <div className="mt-2 text-center">
+ <span className="text-[9px] font-medium text-primary">
+ {t("settingsPage.unifiedBilling.businessWorkspaceOnly")}
+ </span>
+ </div>
+ )}
+ </div>
+
+ {/* Enterprise */}
+ <div className="rounded-md border border-border/50 dark:border-border-subtle/60 bg-card/30 dark:bg-surface-2/30 p-2.5 flex flex-col">
+ <p className="text-xs font-semibold text-foreground">
+ {t("settingsPage.account.pricing.enterprise.name")}
+ </p>
+ <p className="text-[9px] text-muted-foreground mt-1">
+ {t("settingsPage.account.pricing.enterprise.subtitle")}
+ </p>
+ <div className="flex items-baseline gap-0.5 mt-1">
+ <span className="text-lg font-bold text-foreground">
+ {t("settingsPage.account.pricing.enterprise.price")}
</span>
</div>
- ) : usage?.isSubscribed && usage?.plan === "pro" && !usage?.isTrial ? (
+ <p className="text-[9px] text-muted-foreground/70 mt-1.5">
+ {t("settingsPage.account.pricing.enterprise.includesPrefix")}
+ </p>
+ <ul className="space-y-0.5 mt-1 flex-1">
+ {(
+ t("settingsPage.account.pricing.enterprise.features", {
+ returnObjects: true,
+ }) as string[]
+ ).map((feature, i) => (
+ <li
+ key={i}
+ className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
+ >
+ <Check
+ size={9}
+ className="mt-[2px] text-purple-500 dark:text-purple-400 shrink-0"
+ />
+ {feature}
+ </li>
+ ))}
+ </ul>
<Button
- onClick={() =>
- handleSwitchPlan(billingState.business ? "annual" : "monthly", "business")
- }
- disabled={previewLoading || usage.checkoutLoading}
+ variant="outline"
size="sm"
className="mt-2 w-full h-6 text-[10px]"
- >
- {previewLoading ? (
- <Loader2 size={10} className="animate-spin" />
- ) : (
- t("settingsPage.account.pricing.upgrade")
- )}
- </Button>
- ) : (
- <Button
onClick={() =>
- handleCheckout(billingState.business ? "annual" : "monthly", "business")
+ window.electronAPI?.openExternal?.("https://openwhispr.com/contact-sales")
}
- disabled={checkoutTier === "business"}
- size="sm"
- className="mt-2 w-full h-6 text-[10px]"
>
- {checkoutTier === "business" ? (
- <Loader2 size={10} className="animate-spin" />
- ) : (
- t("settingsPage.account.pricing.business.cta")
- )}
+ <Mail size={10} />
+ {t("settingsPage.account.pricing.enterprise.cta")}
</Button>
- )}
- </div>
-
- {/* Enterprise */}
- <div className="rounded-md border border-border/50 dark:border-border-subtle/60 bg-card/30 dark:bg-surface-2/30 p-2.5 flex flex-col">
- <p className="text-xs font-semibold text-foreground">
- {t("settingsPage.account.pricing.enterprise.name")}
- </p>
- <p className="text-[9px] text-muted-foreground mt-1">
- {t("settingsPage.account.pricing.enterprise.subtitle")}
- </p>
- <div className="flex items-baseline gap-0.5 mt-1">
- <span className="text-lg font-bold text-foreground">
- {t("settingsPage.account.pricing.enterprise.price")}
- </span>
</div>
- <p className="text-[9px] text-muted-foreground/70 mt-1.5">
- {t("settingsPage.account.pricing.enterprise.includesPrefix")}
- </p>
- <ul className="space-y-0.5 mt-1 flex-1">
- {(
- t("settingsPage.account.pricing.enterprise.features", {
- returnObjects: true,
- }) as string[]
- ).map((feature, i) => (
- <li
- key={i}
- className="flex items-start gap-1 text-[10px] text-muted-foreground leading-tight"
- >
- <Check
- size={9}
- className="mt-[2px] text-purple-500 dark:text-purple-400 shrink-0"
- />
- {feature}
- </li>
- ))}
- </ul>
- <Button
- variant="outline"
- size="sm"
- className="mt-2 w-full h-6 text-[10px]"
- onClick={() =>
- window.electronAPI?.openExternal?.("https://openwhispr.com/contact-sales")
- }
- >
- <Mail size={10} />
- {t("settingsPage.account.pricing.enterprise.cta")}
- </Button>
</div>
- </div>
- <Dialog
- open={!!switchPreview}
- onOpenChange={(open) => !open && setSwitchPreview(null)}
- >
- <DialogContent className="sm:max-w-90">
- <DialogHeader>
- <DialogTitle>
- {t("settingsPage.account.pricing.confirmSwitch.title")}
- </DialogTitle>
- <DialogDescription>
- {switchPreview &&
- t("settingsPage.account.pricing.confirmSwitch.description", {
- plan: switchPreview.tier === "pro" ? "Pro" : "Business",
- interval:
- switchPreview.plan === "annual"
- ? t("settingsPage.account.pricing.confirmSwitch.yearly")
- : t("settingsPage.account.pricing.confirmSwitch.monthly"),
- })}
- </DialogDescription>
- </DialogHeader>
- {switchPreview && (
- <div className="rounded-lg border border-border/50 dark:border-border-subtle/60 overflow-hidden">
- <div className="flex justify-between items-center px-3 py-2.5 bg-muted/40 dark:bg-surface-2/50">
- <span className="text-xs text-muted-foreground">
- {switchPreview.immediateAmount < 0
- ? t("settingsPage.account.pricing.confirmSwitch.accountCredit")
- : t("settingsPage.account.pricing.confirmSwitch.chargeToday")}
- </span>
- <span
- className={cn(
- "text-sm font-semibold",
- switchPreview.immediateAmount < 0
- ? "text-emerald-600 dark:text-emerald-400"
- : "text-foreground"
- )}
- >
- {formatAmount(
- Math.abs(switchPreview.immediateAmount),
- switchPreview.currency
- )}
- </span>
- </div>
- <div className="divide-y divide-border/40">
- <div className="flex justify-between items-center px-3 py-2">
+ <Dialog
+ open={!!switchPreview}
+ onOpenChange={(open) => !open && setSwitchPreview(null)}
+ >
+ <DialogContent className="sm:max-w-90">
+ <DialogHeader>
+ <DialogTitle>
+ {t("settingsPage.account.pricing.confirmSwitch.title")}
+ </DialogTitle>
+ <DialogDescription>
+ {switchPreview &&
+ t("settingsPage.account.pricing.confirmSwitch.description", {
+ plan: switchPreview.tier === "pro" ? "Pro" : "Business",
+ interval:
+ switchPreview.plan === "annual"
+ ? t("settingsPage.account.pricing.confirmSwitch.yearly")
+ : t("settingsPage.account.pricing.confirmSwitch.monthly"),
+ })}
+ </DialogDescription>
+ </DialogHeader>
+ {switchPreview && (
+ <div className="rounded-lg border border-border/50 dark:border-border-subtle/60 overflow-hidden">
+ <div className="flex justify-between items-center px-3 py-2.5 bg-muted/40 dark:bg-surface-2/50">
<span className="text-xs text-muted-foreground">
- {t("settingsPage.account.pricing.confirmSwitch.newPrice")}
+ {switchPreview.immediateAmount < 0
+ ? t("settingsPage.account.pricing.confirmSwitch.accountCredit")
+ : t("settingsPage.account.pricing.confirmSwitch.chargeToday")}
</span>
- <span className="text-xs font-medium text-foreground">
- {formatAmount(switchPreview.newPriceAmount, switchPreview.currency)}/
- {switchPreview.newInterval === "year"
- ? t("settingsPage.account.pricing.confirmSwitch.yr")
- : t("settingsPage.account.pricing.confirmSwitch.mo")}
+ <span
+ className={cn(
+ "text-sm font-semibold",
+ switchPreview.immediateAmount < 0
+ ? "text-emerald-600 dark:text-emerald-400"
+ : "text-foreground"
+ )}
+ >
+ {formatAmount(
+ Math.abs(switchPreview.immediateAmount),
+ switchPreview.currency
+ )}
</span>
</div>
- {switchPreview.nextBillingDate && (
+ <div className="divide-y divide-border/40">
<div className="flex justify-between items-center px-3 py-2">
<span className="text-xs text-muted-foreground">
- {t("settingsPage.account.pricing.confirmSwitch.nextBilling")}
+ {t("settingsPage.account.pricing.confirmSwitch.newPrice")}
</span>
<span className="text-xs font-medium text-foreground">
- {new Date(switchPreview.nextBillingDate).toLocaleDateString()}
+ {formatAmount(switchPreview.newPriceAmount, switchPreview.currency)}
+ /
+ {switchPreview.newInterval === "year"
+ ? t("settingsPage.account.pricing.confirmSwitch.yr")
+ : t("settingsPage.account.pricing.confirmSwitch.mo")}
</span>
</div>
- )}
+ {switchPreview.nextBillingDate && (
+ <div className="flex justify-between items-center px-3 py-2">
+ <span className="text-xs text-muted-foreground">
+ {t("settingsPage.account.pricing.confirmSwitch.nextBilling")}
+ </span>
+ <span className="text-xs font-medium text-foreground">
+ {new Date(switchPreview.nextBillingDate).toLocaleDateString()}
+ </span>
+ </div>
+ )}
+ </div>
</div>
- </div>
- )}
- <DialogFooter>
- <Button variant="outline" size="sm" onClick={() => setSwitchPreview(null)}>
- {t("settingsPage.account.pricing.confirmSwitch.cancel")}
- </Button>
- <Button
- size="sm"
- onClick={confirmSwitchPlan}
- disabled={usage?.checkoutLoading}
- >
- {usage?.checkoutLoading ? (
- <Loader2 size={14} className="animate-spin" />
- ) : (
- t("settingsPage.account.pricing.confirmSwitch.confirm")
- )}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
+ )}
+ <DialogFooter>
+ <Button variant="outline" size="sm" onClick={() => setSwitchPreview(null)}>
+ {t("settingsPage.account.pricing.confirmSwitch.cancel")}
+ </Button>
+ <Button
+ size="sm"
+ onClick={confirmSwitchPlan}
+ disabled={usage?.checkoutLoading}
+ >
+ {usage?.checkoutLoading ? (
+ <Loader2 size={14} className="animate-spin" />
+ ) : (
+ t("settingsPage.account.pricing.confirmSwitch.confirm")
+ )}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </div>
{isSignedIn ? (
- <>
- <SectionHeader title={t("settingsPage.account.planTitle")} />
+ <div className="order-2 space-y-5">
+ <SectionHeader title={t("settingsPage.unifiedBilling.personalPlanTitle")} />
{!usage || !usage.hasLoaded ? (
<SettingsPanel>
<SettingsPanelRow>
@@ -2189,7 +2183,7 @@ export default function SettingsPage({
? t("settingsPage.account.planLabels.trial")
: usage.isPastDue
? t("settingsPage.account.planLabels.free")
- : usage.isSubscribed
+ : usage.isPersonallySubscribed
? usage.plan === "business"
? t("settingsPage.account.planLabels.business")
: t("settingsPage.account.planLabels.pro")
@@ -2205,7 +2199,7 @@ export default function SettingsPage({
used: usage.wordsUsed.toLocaleString(i18n.language),
limit: usage.limit.toLocaleString(i18n.language),
})
- : usage.isSubscribed
+ : usage.isPersonallySubscribed
? usage.currentPeriodEnd
? t("settingsPage.account.planDescriptions.nextBilling", {
date: new Date(usage.currentPeriodEnd).toLocaleDateString(
@@ -2214,10 +2208,14 @@ export default function SettingsPage({
),
})
: t("settingsPage.account.planDescriptions.unlimited")
- : t("settingsPage.account.planDescriptions.freeUsage", {
- used: usage.wordsUsed.toLocaleString(i18n.language),
- limit: usage.limit.toLocaleString(i18n.language),
- })
+ : coveringWorkspaceNames.length > 0
+ ? t("settingsPage.unifiedBilling.providedBy", {
+ workspaces: coveringWorkspaceNames.join(", "),
+ })
+ : t("settingsPage.account.planDescriptions.freeUsage", {
+ used: usage.wordsUsed.toLocaleString(i18n.language),
+ limit: usage.limit.toLocaleString(i18n.language),
+ })
}
>
{usage.isTrial ? (
@@ -2226,7 +2224,7 @@ export default function SettingsPage({
<Badge variant="destructive">
{t("settingsPage.account.badges.pastDue")}
</Badge>
- ) : usage.isSubscribed ? (
+ ) : usage.isPersonallySubscribed ? (
<Badge variant="success">
{usage.plan === "business"
? t("settingsPage.account.badges.business")
@@ -2315,7 +2313,7 @@ export default function SettingsPage({
t("settingsPage.account.billing.updatePaymentMethod")
)}
</Button>
- ) : usage.isSubscribed && !usage.isTrial ? (
+ ) : usage.isPersonallySubscribed && !usage.isTrial ? (
<Button
onClick={async () => {
const result = await usage.openBillingPortal();
@@ -2369,7 +2367,7 @@ export default function SettingsPage({
</SettingsPanelRow>
</SettingsPanel>
)}
- </>
+ </div>
) : null}
</>
) : (
@@ -2389,7 +2387,12 @@ export default function SettingsPage({
);
case "workspace":
- return <WorkspaceSection initialSubTab={initialSubTab} />;
+ return (
+ <WorkspaceSection
+ initialSubTab={initialSubTab}
+ onNavigateToBilling={() => onNavigateToSection?.("plansBilling")}
+ />
+ );
case "general":
return (
diff --git a/src/components/settings/WorkspaceBillingCard.tsx b/src/components/settings/WorkspaceBillingCard.tsx
new file mode 100644
index 000000000..d0ae6ec52
--- /dev/null
+++ b/src/components/settings/WorkspaceBillingCard.tsx
@@ -0,0 +1,314 @@
+import React, { useEffect, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { ExternalLink, Loader2, Plus } from "lucide-react";
+import { Button } from "../ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "../ui/dialog";
+import { useToast } from "../ui/useToast";
+import { WorkspacesService } from "../../services/WorkspacesService";
+import { useWorkspaceStore } from "../../stores/workspaceStore";
+import type { Workspace } from "../../types/electron";
+
+interface SeatPreview {
+ next_quantity: number;
+ current_quantity: number;
+ seats_used: number;
+ amount_due: number;
+ currency: string;
+}
+
+interface Props {
+ workspace: Workspace;
+ requestedAdditionalSeats?: number;
+ onSeatIntentConsumed?: () => void;
+ onRefreshEntitlement?: () => Promise<void>;
+}
+
+const formatAmount = (cents: number, currency: string) =>
+ (cents / 100).toLocaleString(undefined, { style: "currency", currency });
+
+export default function WorkspaceBillingCard({
+ workspace,
+ requestedAdditionalSeats = 0,
+ onSeatIntentConsumed,
+ onRefreshEntitlement,
+}: Props) {
+ const { t } = useTranslation();
+ const { toast } = useToast();
+ const refresh = useWorkspaceStore((s) => s.refresh);
+ const [busy, setBusy] = useState<"checkout" | "portal" | "preview" | "seats" | null>(null);
+ const [seatPreview, setSeatPreview] = useState<SeatPreview | null>(null);
+ const focusCleanupRef = useRef<(() => void) | null>(null);
+ const isOwner = workspace.role === "owner";
+ const hasSubscription = Boolean(workspace.stripe_subscription_id);
+ const canAddSeats =
+ hasSubscription &&
+ ["pro", "business", "enterprise"].includes(workspace.plan) &&
+ ["active", "trialing"].includes(workspace.status);
+ const seatsUsed = workspace.seats_used ?? workspace.seats;
+ const seatsTotal = Math.max(workspace.seats, seatsUsed);
+ const pct = seatsTotal > 0 ? Math.min(100, (seatsUsed / seatsTotal) * 100) : 0;
+
+ useEffect(() => () => focusCleanupRef.current?.(), []);
+
+ function refreshOnReturn() {
+ focusCleanupRef.current?.();
+ const timers: ReturnType<typeof setTimeout>[] = [];
+ const poll = () => {
+ void refresh();
+ void onRefreshEntitlement?.();
+ };
+ const onFocus = () => {
+ poll();
+ for (const delayMs of [4000, 8000, 16000]) timers.push(setTimeout(poll, delayMs));
+ };
+ window.addEventListener("focus", onFocus, { once: true });
+ focusCleanupRef.current = () => {
+ window.removeEventListener("focus", onFocus);
+ timers.forEach(clearTimeout);
+ };
+ }
+
+ async function openBilling(kind: "checkout" | "portal", getUrl: () => Promise<string>) {
+ setBusy(kind);
+ try {
+ const url = await getUrl();
+ if (window.electronAPI?.openExternal) await window.electronAPI.openExternal(url);
+ else window.open(url, "_blank");
+ onSeatIntentConsumed?.();
+ refreshOnReturn();
+ } catch (error) {
+ toast({
+ title: t("common.error"),
+ description: error instanceof Error ? error.message : t("common.unknownError"),
+ variant: "destructive",
+ });
+ } finally {
+ setBusy(null);
+ }
+ }
+
+ async function previewSeatIncrease() {
+ setBusy("preview");
+ try {
+ setSeatPreview(await WorkspacesService.previewSeats(workspace.id, 1));
+ } catch (error) {
+ toast({
+ title: t("settingsPage.unifiedBilling.seatUpdateFailed"),
+ description: error instanceof Error ? error.message : t("common.unknownError"),
+ variant: "destructive",
+ });
+ } finally {
+ setBusy(null);
+ }
+ }
+
+ async function confirmSeatIncrease() {
+ if (!seatPreview) return;
+ setBusy("seats");
+ try {
+ await WorkspacesService.updateSeats(workspace.id, seatPreview.next_quantity);
+ setSeatPreview(null);
+ onSeatIntentConsumed?.();
+ await refresh();
+ toast({
+ title: t("settingsPage.unifiedBilling.seatUpdated", {
+ count: seatPreview.next_quantity,
+ }),
+ });
+ } catch (error) {
+ toast({
+ title: t("settingsPage.unifiedBilling.seatUpdateFailed"),
+ description: error instanceof Error ? error.message : t("common.unknownError"),
+ variant: "destructive",
+ });
+ } finally {
+ setBusy(null);
+ }
+ }
+
+ return (
+ <div className="rounded-lg border border-border/50 dark:border-border-subtle/70 bg-card/50 dark:bg-surface-2/50 p-4 space-y-3">
+ <div className="flex items-start justify-between gap-3">
+ <div className="min-w-0">
+ <p className="text-xs font-semibold text-foreground truncate">{workspace.name}</p>
+ <p className="text-[10px] text-muted-foreground mt-0.5">
+ {t(`settingsPage.workspace.role.${workspace.role}`)} · {workspace.slug}
+ </p>
+ </div>
+ <span
+ className={
+ "text-[10px] font-medium px-2 py-0.5 rounded-md uppercase tracking-wide " +
+ (workspace.status === "active" || workspace.status === "trialing"
+ ? "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400"
+ : workspace.status === "past_due"
+ ? "bg-amber-500/12 text-amber-600 dark:text-amber-400"
+ : "bg-foreground/8 text-foreground/65")
+ }
+ >
+ {t(`settingsPage.workspace.billing.status.${workspace.status}`, {
+ defaultValue: workspace.status,
+ })}
+ </span>
+ </div>
+
+ <div className="flex items-end justify-between gap-3">
+ <div>
+ <p className="text-[10px] uppercase tracking-wide text-muted-foreground font-medium">
+ {t("settingsPage.workspace.billing.plan")}
+ </p>
+ <p className="text-base font-semibold text-foreground">
+ {t(`settingsPage.workspace.billing.planLabel.${workspace.plan}`, {
+ defaultValue: workspace.plan,
+ })}
+ </p>
+ </div>
+ <p className="text-[10px] text-muted-foreground">
+ {workspace.is_billable !== false
+ ? t("settingsPage.unifiedBilling.billableSeat")
+ : t("settingsPage.unifiedBilling.nonBillableSeat")}
+ </p>
+ </div>
+
+ <div>
+ <div className="flex items-center justify-between text-xs mb-1.5">
+ <span className="text-muted-foreground">{t("settingsPage.workspace.billing.seats")}</span>
+ <span className="text-foreground font-medium">
+ {seatsUsed} / {seatsTotal}
+ </span>
+ </div>
+ <div className="h-1.5 rounded-full bg-foreground/5 dark:bg-white/5 overflow-hidden">
+ <div className="h-full bg-primary/70 dark:bg-primary/80" style={{ width: `${pct}%` }} />
+ </div>
+ </div>
+
+ {workspace.current_period_end && (
+ <div className="flex items-center justify-between text-xs text-muted-foreground">
+ <span>{t("settingsPage.workspace.billing.nextInvoice")}</span>
+ <span className="text-foreground">
+ {new Date(workspace.current_period_end).toLocaleDateString()}
+ </span>
+ </div>
+ )}
+
+ {!isOwner ? (
+ <p className="text-xs text-muted-foreground">
+ {workspace.billing_manager
+ ? t("settingsPage.unifiedBilling.managedBy", {
+ owner: workspace.billing_manager,
+ })
+ : t("settingsPage.workspace.billing.ownerOnly")}
+ </p>
+ ) : (
+ <div className="flex flex-wrap gap-2 pt-1">
+ {hasSubscription ? (
+ <>
+ {canAddSeats && (
+ <Button
+ onClick={() => void previewSeatIncrease()}
+ disabled={busy !== null}
+ size="sm"
+ >
+ {busy === "preview" ? (
+ <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <Plus className="mr-1.5 h-3.5 w-3.5" />
+ )}
+ {t("settingsPage.unifiedBilling.addSeat")}
+ </Button>
+ )}
+ <Button
+ onClick={() =>
+ void openBilling("portal", () => WorkspacesService.billingPortal(workspace.id))
+ }
+ disabled={busy !== null}
+ size="sm"
+ variant="outline"
+ >
+ {busy === "portal" ? (
+ <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <ExternalLink className="mr-1.5 h-3.5 w-3.5" />
+ )}
+ {t("settingsPage.workspace.billing.manageStripe")}
+ </Button>
+ </>
+ ) : (
+ <Button
+ onClick={() =>
+ void openBilling("checkout", () =>
+ WorkspacesService.billingCheckout(
+ workspace.id,
+ "monthly",
+ requestedAdditionalSeats
+ )
+ )
+ }
+ disabled={busy !== null}
+ size="sm"
+ >
+ {busy === "checkout" && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
+ {requestedAdditionalSeats > 0
+ ? t("settingsPage.unifiedBilling.startWithSeats", {
+ count: seatsUsed + requestedAdditionalSeats,
+ })
+ : t("settingsPage.workspace.billing.startSubscription")}
+ </Button>
+ )}
+ </div>
+ )}
+
+ <Dialog open={seatPreview !== null} onOpenChange={(open) => !open && setSeatPreview(null)}>
+ <DialogContent className="sm:max-w-90">
+ <DialogHeader>
+ <DialogTitle>{t("settingsPage.unifiedBilling.confirmSeats.title")}</DialogTitle>
+ <DialogDescription>
+ {seatPreview &&
+ t("settingsPage.unifiedBilling.confirmSeats.description", {
+ workspace: workspace.name,
+ count: seatPreview.next_quantity,
+ })}
+ </DialogDescription>
+ </DialogHeader>
+ {seatPreview && (
+ <div className="rounded-lg border border-border/50 divide-y divide-border/40">
+ <div className="flex justify-between px-3 py-2 text-xs">
+ <span className="text-muted-foreground">
+ {t("settingsPage.unifiedBilling.confirmSeats.newCapacity")}
+ </span>
+ <span className="font-medium">{seatPreview.next_quantity}</span>
+ </div>
+ <div className="flex justify-between px-3 py-2 text-xs">
+ <span className="text-muted-foreground">
+ {t("settingsPage.unifiedBilling.confirmSeats.chargeToday")}
+ </span>
+ <span className="font-medium">
+ {formatAmount(seatPreview.amount_due, seatPreview.currency)}
+ </span>
+ </div>
+ </div>
+ )}
+ <DialogFooter>
+ <Button variant="outline" size="sm" onClick={() => setSeatPreview(null)}>
+ {t("common.cancel")}
+ </Button>
+ <Button
+ size="sm"
+ onClick={() => void confirmSeatIncrease()}
+ disabled={busy === "seats"}
+ >
+ {busy === "seats" && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
+ {t("settingsPage.unifiedBilling.confirmSeats.confirm")}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/src/components/settings/WorkspaceBillingOverview.tsx b/src/components/settings/WorkspaceBillingOverview.tsx
new file mode 100644
index 000000000..61e5fa8bb
--- /dev/null
+++ b/src/components/settings/WorkspaceBillingOverview.tsx
@@ -0,0 +1,95 @@
+import React, { useEffect, useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { useShallow } from "zustand/react/shallow";
+import { useWorkspaceStore } from "../../stores/workspaceStore";
+import WorkspaceBillingCard from "./WorkspaceBillingCard";
+
+const SEAT_INTENT_KEY = "settings.billingSeatIntent";
+
+interface SeatIntent {
+ workspaceId: string;
+ additionalSeats: number;
+}
+
+function readSeatIntent(): SeatIntent | null {
+ try {
+ const value = localStorage.getItem(SEAT_INTENT_KEY);
+ return value ? (JSON.parse(value) as SeatIntent) : null;
+ } catch {
+ return null;
+ }
+}
+
+export default function WorkspaceBillingOverview({
+ onRefreshEntitlement,
+}: {
+ onRefreshEntitlement?: () => Promise<void>;
+}) {
+ const { t } = useTranslation();
+ const { workspaces, activeWorkspaceId, loaded, error, refresh } = useWorkspaceStore(
+ useShallow((s) => ({
+ workspaces: s.workspaces,
+ activeWorkspaceId: s.activeWorkspaceId,
+ loaded: s.loaded,
+ error: s.error,
+ refresh: s.refresh,
+ }))
+ );
+ const [seatIntent, setSeatIntent] = useState<SeatIntent | null>(() => readSeatIntent());
+
+ useEffect(() => {
+ if (!loaded) void refresh();
+ }, [loaded, refresh]);
+
+ const orderedWorkspaces = useMemo(() => {
+ if (!activeWorkspaceId) return workspaces;
+ return [...workspaces].sort((a, b) => {
+ if (a.id === activeWorkspaceId) return -1;
+ if (b.id === activeWorkspaceId) return 1;
+ return 0;
+ });
+ }, [activeWorkspaceId, workspaces]);
+
+ function clearSeatIntent() {
+ localStorage.removeItem(SEAT_INTENT_KEY);
+ setSeatIntent(null);
+ }
+
+ if (!loaded && workspaces.length === 0) {
+ return (
+ <div className="space-y-2">
+ <div className="h-4 w-36 rounded bg-foreground/5 animate-pulse" />
+ <div className="h-36 rounded-lg bg-foreground/5 animate-pulse" />
+ </div>
+ );
+ }
+ if (error || orderedWorkspaces.length === 0) return null;
+
+ return (
+ <section className="space-y-3">
+ <div>
+ <h3 className="text-xs font-semibold text-foreground">
+ {t("settingsPage.unifiedBilling.workspaceTitle")}
+ </h3>
+ <p className="text-xs text-muted-foreground/80 mt-0.5">
+ {t("settingsPage.unifiedBilling.workspaceDescription")}
+ </p>
+ </div>
+ <div className="space-y-2">
+ {orderedWorkspaces.map((workspace) => (
+ <WorkspaceBillingCard
+ key={workspace.id}
+ workspace={workspace}
+ requestedAdditionalSeats={
+ seatIntent?.workspaceId === workspace.id ? seatIntent.additionalSeats : 0
+ }
+ onSeatIntentConsumed={
+ seatIntent?.workspaceId === workspace.id ? clearSeatIntent : undefined
+ }
+ onRefreshEntitlement={onRefreshEntitlement}
+ />
+ ))}
+ </div>
+ </section>
+ );
+}
diff --git a/src/components/settings/WorkspaceBillingTab.tsx b/src/components/settings/WorkspaceBillingTab.tsx
deleted file mode 100644
index 4ce1ef715..000000000
--- a/src/components/settings/WorkspaceBillingTab.tsx
+++ /dev/null
@@ -1,194 +0,0 @@
-import React, { useCallback, useEffect, useRef, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { ExternalLink, Loader2 } from "lucide-react";
-import { Button } from "../ui/button";
-import { useToast } from "../ui/useToast";
-import { WorkspacesService } from "../../services/WorkspacesService";
-import { useWorkspaceStore } from "../../stores/workspaceStore";
-import type { Workspace } from "../../types/electron";
-
-interface Props {
- workspace: Workspace;
-}
-
-export default function WorkspaceBillingTab({ workspace }: Props) {
- const { t } = useTranslation();
- const { toast } = useToast();
- const refresh = useWorkspaceStore((s) => s.refresh);
- const isOwner = workspace.role === "owner";
- const [busy, setBusy] = useState(false);
- const [seatsUsed, setSeatsUsed] = useState<number | null>(null);
- const focusCleanupRef = useRef<(() => void) | null>(null);
-
- const loadSeats = useCallback(async () => {
- try {
- // Server truth: billable members + pending invites.
- const preview = await WorkspacesService.previewSeats(workspace.id, 1);
- setSeatsUsed(preview.next_quantity - 1);
- } catch {
- // No subscription yet or insufficient role — fall back to the member count.
- try {
- const members = await WorkspacesService.listMembers(workspace.id);
- setSeatsUsed(members.length);
- } catch {
- setSeatsUsed(null);
- }
- }
- }, [workspace.id]);
-
- useEffect(() => {
- setSeatsUsed(null);
- void loadSeats();
- }, [loadSeats]);
-
- useEffect(() => () => focusCleanupRef.current?.(), []);
-
- // The user finishes checkout / the portal in the browser; refresh when they
- // return, then re-poll a few times to outlast Stripe webhook lag.
- function refreshOnReturn() {
- focusCleanupRef.current?.();
- const timers: ReturnType<typeof setTimeout>[] = [];
- const poll = () => {
- void refresh();
- void loadSeats();
- };
- const onFocus = () => {
- poll();
- for (const delayMs of [4000, 8000, 16000]) {
- timers.push(setTimeout(poll, delayMs));
- }
- };
- window.addEventListener("focus", onFocus, { once: true });
- focusCleanupRef.current = () => {
- window.removeEventListener("focus", onFocus);
- timers.forEach(clearTimeout);
- };
- }
-
- async function openBilling(getUrl: () => Promise<string>) {
- setBusy(true);
- try {
- const url = await getUrl();
- window.electronAPI?.openExternal?.(url) ?? window.open(url, "_blank");
- refreshOnReturn();
- } catch (error) {
- toast({
- title: t("common.error"),
- description: error instanceof Error ? error.message : t("common.unknownError"),
- variant: "destructive",
- });
- } finally {
- setBusy(false);
- }
- }
-
- const seatsTotal = Math.max(workspace.seats, seatsUsed ?? 0);
- const pct =
- seatsUsed === null || seatsTotal === 0 ? 0 : Math.min(100, (seatsUsed / seatsTotal) * 100);
-
- return (
- <div className="space-y-4">
- <div>
- <h3 className="text-xs font-semibold text-foreground">
- {t("settingsPage.workspace.billing.title")}
- </h3>
- <p className="text-xs text-muted-foreground/80 mt-0.5">
- {t("settingsPage.workspace.billing.description")}
- </p>
- </div>
-
- <div className="rounded-lg border border-border/50 dark:border-border-subtle/70 bg-card/50 dark:bg-surface-2/50 p-4 space-y-3">
- <div className="flex items-baseline justify-between">
- <div>
- <p className="text-[10px] uppercase tracking-wide text-muted-foreground font-medium">
- {t("settingsPage.workspace.billing.plan")}
- </p>
- <p className="text-base font-semibold text-foreground">
- {t(`settingsPage.workspace.billing.planLabel.${workspace.plan}`, {
- defaultValue: workspace.plan,
- })}
- </p>
- </div>
- <span
- className={
- "text-[10px] font-medium px-2 py-0.5 rounded-md uppercase tracking-wide " +
- (workspace.status === "active" || workspace.status === "trialing"
- ? "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400"
- : workspace.status === "past_due"
- ? "bg-amber-500/12 text-amber-600 dark:text-amber-400"
- : "bg-foreground/8 text-foreground/65")
- }
- >
- {t(`settingsPage.workspace.billing.status.${workspace.status}`, {
- defaultValue: workspace.status,
- })}
- </span>
- </div>
-
- <div className="pt-1">
- <div className="flex items-center justify-between text-xs mb-1.5">
- <span className="text-muted-foreground">
- {t("settingsPage.workspace.billing.seats")}
- </span>
- <span className="text-foreground font-medium">
- {seatsUsed ?? "–"} / {seatsTotal}
- </span>
- </div>
- <div className="h-1.5 rounded-full bg-foreground/5 dark:bg-white/5 overflow-hidden">
- <div className="h-full bg-primary/70 dark:bg-primary/80" style={{ width: `${pct}%` }} />
- </div>
- </div>
-
- {workspace.current_period_end && (
- <div className="flex items-center justify-between text-xs text-muted-foreground">
- <span>{t("settingsPage.workspace.billing.nextInvoice")}</span>
- <span className="text-foreground">
- {new Date(workspace.current_period_end).toLocaleDateString()}
- </span>
- </div>
- )}
- </div>
-
- {!isOwner && (
- <p className="text-xs text-muted-foreground">
- {t("settingsPage.workspace.billing.ownerOnly")}
- </p>
- )}
-
- {isOwner && (
- <div className="flex gap-2">
- {workspace.stripe_subscription_id ? (
- <Button
- onClick={() => openBilling(() => WorkspacesService.billingPortal(workspace.id))}
- disabled={busy}
- size="sm"
- variant="outline"
- >
- {busy ? (
- <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
- ) : (
- <ExternalLink className="mr-1.5 h-3.5 w-3.5" />
- )}
- {busy
- ? t("settingsPage.workspace.billing.opening")
- : t("settingsPage.workspace.billing.manageStripe")}
- </Button>
- ) : (
- <Button
- onClick={() =>
- openBilling(() => WorkspacesService.billingCheckout(workspace.id, "monthly"))
- }
- disabled={busy}
- size="sm"
- >
- {busy && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
- {busy
- ? t("settingsPage.workspace.billing.opening")
- : t("settingsPage.workspace.billing.startSubscription")}
- </Button>
- )}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/components/settings/WorkspaceSection.tsx b/src/components/settings/WorkspaceSection.tsx
index 2d78bffe1..171204fc3 100644
--- a/src/components/settings/WorkspaceSection.tsx
+++ b/src/components/settings/WorkspaceSection.tsx
@@ -25,18 +25,18 @@ import {
import { cn } from "../lib/utils";
import WorkspaceMembersTab from "./WorkspaceMembersTab";
import WorkspaceTeamsTab from "./WorkspaceTeamsTab";
-import WorkspaceBillingTab from "./WorkspaceBillingTab";
import WorkspaceDeveloperTab from "./WorkspaceDeveloperTab";
import type { Workspace } from "../../types/electron";
-const SUB_TABS = ["general", "members", "teams", "billing", "developer"] as const;
+const SUB_TABS = ["general", "members", "teams", "developer"] as const;
type WorkspaceTab = (typeof SUB_TABS)[number];
interface Props {
initialSubTab?: string;
+ onNavigateToBilling?: () => void;
}
-export default function WorkspaceSection({ initialSubTab }: Props) {
+export default function WorkspaceSection({ initialSubTab, onNavigateToBilling }: Props) {
const { t } = useTranslation();
const { isSignedIn } = useAuth();
const { workspaces, activeWorkspaceId, setActiveWorkspaceId, loaded, loading, error, refresh } =
@@ -58,6 +58,15 @@ export default function WorkspaceSection({ initialSubTab }: Props) {
const [createOpen, setCreateOpen] = useState(false);
const [inviteWorkspaceId, setInviteWorkspaceId] = useState<string | null>(null);
+ function navigateToBilling(workspaceId: string) {
+ setActiveWorkspaceId(workspaceId);
+ localStorage.setItem(
+ "settings.billingSeatIntent",
+ JSON.stringify({ workspaceId, additionalSeats: 1 })
+ );
+ onNavigateToBilling?.();
+ }
+
useEffect(() => {
if (isSignedIn && !loaded) void refresh();
}, [isSignedIn, loaded, refresh]);
@@ -91,7 +100,7 @@ export default function WorkspaceSection({ initialSubTab }: Props) {
workspaceId={inviteWorkspace.id}
workspaceName={inviteWorkspace.name}
cancelLabel={t("common.skip")}
- onNavigateToBilling={() => setStoredTab("billing")}
+ onNavigateToBilling={() => navigateToBilling(inviteWorkspace.id)}
/>
)}
</>
@@ -225,11 +234,10 @@ export default function WorkspaceSection({ initialSubTab }: Props) {
{tab === "members" && (
<WorkspaceMembersTab
workspace={workspace}
- onNavigateToBilling={() => setStoredTab("billing")}
+ onNavigateToBilling={() => navigateToBilling(workspace.id)}
/>
)}
{tab === "teams" && <WorkspaceTeamsTab workspace={workspace} />}
- {tab === "billing" && <WorkspaceBillingTab workspace={workspace} />}
{tab === "developer" && canManage && <WorkspaceDeveloperTab workspace={workspace} />}
</div>
diff --git a/src/hooks/useUsage.ts b/src/hooks/useUsage.ts
index d15273750..6503e25bd 100644
--- a/src/hooks/useUsage.ts
+++ b/src/hooks/useUsage.ts
@@ -16,6 +16,10 @@ interface UsageData {
currentPeriodEnd: string | null;
billingInterval: "monthly" | "annual" | null;
resetAt: string;
+ entitlementSources: {
+ personal: boolean;
+ workspaceIds: string[];
+ };
}
interface UseUsageResult {
@@ -26,6 +30,8 @@ interface UseUsageResult {
wordsRemaining: number;
limit: number;
isSubscribed: boolean;
+ isPersonallySubscribed: boolean;
+ entitledWorkspaceIds: string[];
isTrial: boolean;
trialDaysLeft: number | null;
currentPeriodEnd: string | null;
@@ -95,6 +101,13 @@ export function useUsage(): UseUsageResult | null {
currentPeriodEnd: result.currentPeriodEnd ?? null,
billingInterval: result.billingInterval ?? null,
resetAt: result.resetAt ?? "rolling",
+ entitlementSources: result.entitlementSources ?? {
+ personal:
+ result.isTrial === true ||
+ (["pro", "business", "enterprise"].includes(result.plan ?? "free") &&
+ ["active", "trialing"].includes(result.status ?? "active")),
+ workspaceIds: [],
+ },
});
lastFetchRef.current = Date.now();
const isSubscribed = result.isSubscribed ?? false;
@@ -254,8 +267,10 @@ export function useUsage(): UseUsageResult | null {
const wordsUsed = data?.wordsUsed ?? 0;
const limit = data?.limit ?? 2000;
const isSubscribed = data?.isSubscribed ?? false;
+ const isPersonallySubscribed = data?.entitlementSources.personal ?? false;
const status = data?.status ?? "active";
- const isPastDue = (data?.plan === "pro" || data?.plan === "business") && status === "past_due";
+ const isPastDue =
+ ["pro", "business", "enterprise"].includes(data?.plan ?? "free") && status === "past_due";
const isOverLimit = !isSubscribed && limit > 0 && wordsUsed >= limit;
const isApproachingLimit = !isSubscribed && limit > 0 && wordsUsed >= limit * 0.8 && !isOverLimit;
@@ -267,6 +282,8 @@ export function useUsage(): UseUsageResult | null {
wordsRemaining: data?.wordsRemaining ?? (limit > 0 ? limit - wordsUsed : -1),
limit,
isSubscribed,
+ isPersonallySubscribed,
+ entitledWorkspaceIds: data?.entitlementSources.workspaceIds ?? [],
isTrial: data?.isTrial ?? false,
trialDaysLeft: data?.trialDaysLeft ?? null,
currentPeriodEnd: data?.currentPeriodEnd ?? null,
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 1f07f35ac..d6588720b 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -1158,7 +1158,7 @@
"label": "Tarife & Abrechnung"
},
"workspace": {
- "description": "Mitglieder, Abrechnung und API-Schlüssel",
+ "description": "Mitglieder, Team-Bereiche und API-Schlüssel",
"label": "Workspace"
},
"general": {
@@ -1191,7 +1191,7 @@
"settingsPage": {
"workspace": {
"title": "Workspace",
- "description": "Arbeiten Sie zusammen, teilen Sie Notizen und verwalten Sie die Abrechnung an einem Ort.",
+ "description": "Arbeiten Sie zusammen, teilen Sie Notizen und verwalten Sie den Workspace-Zugriff an einem Ort.",
"empty": {
"title": "Ersten Workspace erstellen",
"description": "Workspaces ermöglichen die Zusammenarbeit und das Teilen von Notizen.",
@@ -1374,6 +1374,27 @@
}
}
},
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "Kostenlos",
@@ -2493,7 +2514,7 @@
},
"workspace": {
"title": "Workspace",
- "description": "Hier werden Mitglieder, Rollen und Abrechnung Ihrer Organisation verwaltet."
+ "description": "Hier werden Mitglieder, Rollen und Team-Bereiche Ihres Workspace verwaltet."
},
"teamSpace": {
"title": "Team-Bereich",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index b4a463252..f65b904ae 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -1158,7 +1158,7 @@
"label": "Plans & Billing"
},
"workspace": {
- "description": "Members, billing & API keys",
+ "description": "Members, team spaces & API keys",
"label": "Workspace"
},
"general": {
@@ -1191,7 +1191,7 @@
"settingsPage": {
"workspace": {
"title": "Workspace",
- "description": "Collaborate with teammates, share notes, and manage billing in one place.",
+ "description": "Collaborate with teammates, share notes, and manage workspace access in one place.",
"empty": {
"title": "Create your first workspace",
"description": "Workspaces let you collaborate with teammates and share notes.",
@@ -1374,6 +1374,27 @@
}
}
},
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "Free",
@@ -2493,7 +2514,7 @@
},
"workspace": {
"title": "Workspace",
- "description": "The home for your organization's members, roles, and billing."
+ "description": "The home for your workspace's members, roles, and team spaces."
},
"teamSpace": {
"title": "Team space",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 0da903dac..db35fadb7 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -1143,12 +1143,33 @@
},
"workspace": {
"label": "Espacio de trabajo",
- "description": "Miembros, facturación y claves API"
+ "description": "Miembros, espacios de equipo y claves API"
}
},
"title": "Ajustes"
},
"settingsPage": {
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "Gratis",
@@ -1853,7 +1874,7 @@
},
"workspace": {
"title": "Espacio de trabajo",
- "description": "Colabora con compañeros, comparte notas y administra la facturación en un solo lugar.",
+ "description": "Colabora con compañeros, comparte notas y administra el acceso al espacio de trabajo en un solo lugar.",
"empty": {
"title": "Crea tu primer espacio de trabajo",
"description": "Los espacios de trabajo te permiten colaborar con compañeros y compartir notas.",
@@ -2333,7 +2354,7 @@
},
"workspace": {
"title": "Espacio de trabajo",
- "description": "El lugar de los miembros, roles y facturación de tu organización."
+ "description": "El lugar de los miembros, roles y espacios de equipo de tu espacio de trabajo."
},
"teamSpace": {
"title": "Espacio de equipo",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 624d1c87f..eedc9f702 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -1158,7 +1158,7 @@
"label": "Forfaits & facturation"
},
"workspace": {
- "description": "Membres, facturation & clés API",
+ "description": "Membres, espaces d'équipe et clés API",
"label": "Espace de travail"
},
"general": {
@@ -1191,7 +1191,7 @@
"settingsPage": {
"workspace": {
"title": "Espace de travail",
- "description": "Collaborez, partagez des notes et gérez la facturation au même endroit.",
+ "description": "Collaborez, partagez des notes et gérez l'accès à l'espace de travail au même endroit.",
"empty": {
"title": "Créez votre premier espace de travail",
"description": "Les espaces de travail vous permettent de collaborer et partager des notes.",
@@ -1374,6 +1374,27 @@
}
}
},
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "Gratuit",
@@ -2493,7 +2514,7 @@
},
"workspace": {
"title": "Espace de travail",
- "description": "L'espace des membres, des rôles et de la facturation de votre organisation."
+ "description": "L'espace des membres, des rôles et des espaces d'équipe de votre espace de travail."
},
"teamSpace": {
"title": "Espace d'équipe",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 941bb7d08..231b341fa 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -1094,13 +1094,34 @@
"label": "Sistema"
},
"workspace": {
- "description": "Membri, fatturazione e chiavi API",
+ "description": "Membri, spazi del team e chiavi API",
"label": "Area di lavoro"
}
},
"title": "Impostazioni"
},
"settingsPage": {
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "Gratuito",
@@ -1805,7 +1826,7 @@
},
"workspace": {
"title": "Area di lavoro",
- "description": "Collabora con il tuo team, condividi note e gestisci la fatturazione in un unico posto.",
+ "description": "Collabora con il tuo team, condividi note e gestisci l'accesso all'area di lavoro in un unico posto.",
"empty": {
"title": "Crea la tua prima area di lavoro",
"description": "Le aree di lavoro ti permettono di collaborare con il team e condividere note.",
@@ -2285,7 +2306,7 @@
},
"workspace": {
"title": "Area di lavoro",
- "description": "La sede di membri, ruoli e fatturazione della tua organizzazione."
+ "description": "La sede di membri, ruoli e spazi del team della tua area di lavoro."
},
"teamSpace": {
"title": "Spazio del team",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 8d7ac10b1..ed1241d67 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -1094,13 +1094,34 @@
"label": "システム"
},
"workspace": {
- "description": "メンバー、請求、API キー",
+ "description": "メンバー、チームスペース、API キー",
"label": "ワークスペース"
}
},
"title": "設定"
},
"settingsPage": {
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "無料",
@@ -1805,7 +1826,7 @@
},
"workspace": {
"title": "ワークスペース",
- "description": "チームメイトとのコラボレーション、ノートの共有、請求の管理を一括で行えます。",
+ "description": "チームメイトとのコラボレーション、ノートの共有、ワークスペースへのアクセス管理を一括で行えます。",
"empty": {
"title": "最初のワークスペースを作成",
"description": "ワークスペースでは、チームメイトとのコラボレーションやノートの共有ができます。",
@@ -2213,7 +2234,7 @@
},
"workspace": {
"title": "ワークスペース",
- "description": "組織のメンバー、役割、請求をまとめる場所です。"
+ "description": "ワークスペースのメンバー、役割、チームスペースをまとめて管理します。"
},
"teamSpace": {
"title": "チームスペース",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 0db604a10..618abdc2a 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -1073,13 +1073,34 @@
"label": "Sistema"
},
"workspace": {
- "description": "Membros, cobrança e chaves de API",
+ "description": "Membros, espaços de equipe e chaves de API",
"label": "Espaço de trabalho"
}
},
"title": "Configurações"
},
"settingsPage": {
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "Gratuito",
@@ -1784,7 +1805,7 @@
},
"workspace": {
"title": "Espaço de trabalho",
- "description": "Colabore com colegas, compartilhe notas e gerencie a cobrança em um só lugar.",
+ "description": "Colabore com colegas, compartilhe notas e gerencie o acesso ao workspace em um só lugar.",
"empty": {
"title": "Crie seu primeiro espaço de trabalho",
"description": "Espaços de trabalho permitem colaborar com colegas e compartilhar notas.",
@@ -2285,7 +2306,7 @@
},
"workspace": {
"title": "Espaço de trabalho",
- "description": "O lugar dos membros, funções e cobrança da sua organização."
+ "description": "O lugar dos membros, funções e espaços de equipe do seu workspace."
},
"teamSpace": {
"title": "Espaço de equipe",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index ce1f239dd..889b0742b 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -1094,13 +1094,34 @@
"label": "Система"
},
"workspace": {
- "description": "Участники, оплата и API-ключи",
+ "description": "Участники, командные пространства и API-ключи",
"label": "Рабочее пространство"
}
},
"title": "Настройки"
},
"settingsPage": {
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "Бесплатный",
@@ -1805,7 +1826,7 @@
},
"workspace": {
"title": "Рабочее пространство",
- "description": "Работайте с командой, делитесь заметками и управляйте оплатой в одном месте.",
+ "description": "Работайте с командой, делитесь заметками и управляйте доступом к рабочему пространству в одном месте.",
"empty": {
"title": "Создайте первое рабочее пространство",
"description": "Рабочие пространства позволяют работать с командой и делиться заметками.",
@@ -2299,7 +2320,7 @@
},
"workspace": {
"title": "Рабочее пространство",
- "description": "Здесь находятся участники, роли и настройки оплаты вашей организации."
+ "description": "Здесь находятся участники, роли и командные пространства вашего рабочего пространства."
},
"teamSpace": {
"title": "Командное пространство",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 297ab585a..eaa0e8784 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1094,13 +1094,34 @@
"label": "系统"
},
"workspace": {
- "description": "成员、账单和 API 密钥",
+ "description": "成员、团队空间和 API 密钥",
"label": "工作区"
}
},
"title": "设置"
},
"settingsPage": {
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "免费版",
@@ -1805,7 +1826,7 @@
},
"workspace": {
"title": "工作区",
- "description": "在一处与同事协作、共享笔记并管理账单。",
+ "description": "在一处与同事协作、共享笔记并管理工作区访问权限。",
"empty": {
"title": "创建你的第一个工作区",
"description": "工作区让你与同事协作并共享笔记。",
@@ -2285,7 +2306,7 @@
},
"workspace": {
"title": "工作区",
- "description": "集中管理组织的成员、角色和账单。"
+ "description": "集中管理工作区的成员、角色和团队空间。"
},
"teamSpace": {
"title": "团队空间",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 52f0624bc..518b86aad 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1094,13 +1094,34 @@
"label": "系統"
},
"workspace": {
- "description": "成員、帳單與 API 金鑰",
+ "description": "成員、團隊空間與 API 金鑰",
"label": "工作區"
}
},
"title": "設定"
},
"settingsPage": {
+ "unifiedBilling": {
+ "workspaceTitle": "Workspace billing",
+ "workspaceDescription": "Each workspace has its own plan, seats, and billing owner.",
+ "billableSeat": "Your seat is billable",
+ "nonBillableSeat": "Admin-only access · no paid seat",
+ "managedBy": "Billing is managed by {{owner}}.",
+ "addSeat": "Add seat",
+ "startWithSeats": "Start Business with {{count}} seats",
+ "seatUpdated": "Workspace capacity updated to {{count}} seats",
+ "seatUpdateFailed": "Couldn't update workspace seats",
+ "businessWorkspaceOnly": "Available for workspaces",
+ "personalPlanTitle": "Personal plan",
+ "providedBy": "Personal plan: Free · Paid access provided by {{workspaces}}",
+ "confirmSeats": {
+ "title": "Add a workspace seat?",
+ "description": "Increase {{workspace}} to {{count}} seats. Stripe will prorate the change.",
+ "newCapacity": "New capacity",
+ "chargeToday": "Charge today",
+ "confirm": "Add seat"
+ }
+ },
"account": {
"badges": {
"free": "免費",
@@ -1805,7 +1826,7 @@
},
"workspace": {
"title": "工作區",
- "description": "與團隊成員協作、分享筆記,並在同一處管理帳單。",
+ "description": "與團隊成員協作、分享筆記,並在同一處管理工作區存取權限。",
"empty": {
"title": "建立你的第一個工作區",
"description": "工作區讓你與團隊成員協作並分享筆記。",
@@ -2285,7 +2306,7 @@
},
"workspace": {
"title": "工作區",
- "description": "集中管理組織的成員、角色和帳單。"
+ "description": "集中管理工作區的成員、角色和團隊空間。"
},
"teamSpace": {
"title": "團隊空間",
diff --git a/src/services/WorkspacesService.ts b/src/services/WorkspacesService.ts
index 22bbe6076..9ee913b5e 100644
--- a/src/services/WorkspacesService.ts
+++ b/src/services/WorkspacesService.ts
@@ -42,11 +42,12 @@ async function removeMember(workspaceId: string, userId: string): Promise<void>
async function billingCheckout(
workspaceId: string,
- interval: "monthly" | "annual" = "monthly"
+ interval: "monthly" | "annual" = "monthly",
+ additionalSeats = 0
): Promise<string> {
const res = await cloudPost<DataWrap<{ url: string }>>(
`/api/workspaces/${workspaceId}/billing/checkout`,
- { interval }
+ { interval, additional_seats: additionalSeats }
);
return res.data.url;
}
@@ -61,15 +62,38 @@ async function billingPortal(workspaceId: string): Promise<string> {
async function previewSeats(
workspaceId: string,
additionalSeats: number
-): Promise<{ next_quantity: number; amount_due: number; currency: string }> {
+): Promise<{
+ next_quantity: number;
+ current_quantity: number;
+ seats_used: number;
+ amount_due: number;
+ currency: string;
+}> {
const res = await cloudPost<
- DataWrap<{ next_quantity: number; amount_due: number; currency: string }>
+ DataWrap<{
+ next_quantity: number;
+ current_quantity: number;
+ seats_used: number;
+ amount_due: number;
+ currency: string;
+ }>
>(`/api/workspaces/${workspaceId}/billing/preview-seats`, {
additional_seats: additionalSeats,
});
return res.data;
}
+async function updateSeats(
+ workspaceId: string,
+ quantity: number
+): Promise<{ quantity: number; seats_used: number }> {
+ const res = await cloudPost<DataWrap<{ quantity: number; seats_used: number }>>(
+ `/api/workspaces/${workspaceId}/billing/seats`,
+ { quantity }
+ );
+ return res.data;
+}
+
export const WorkspacesService = {
list,
create,
@@ -81,4 +105,5 @@ export const WorkspacesService = {
billingCheckout,
billingPortal,
previewSeats,
+ updateSeats,
};
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 64590bd59..93150030c 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -210,14 +210,18 @@ export interface Workspace {
current_period_end: string | null;
cancel_at_period_end: boolean;
seats: number;
+ seats_used: number;
created_at: string;
updated_at: string;
role: WorkspaceRole;
+ is_billable: boolean;
+ billing_manager: string | null;
}
export interface WorkspaceMember {
user_id: string;
role: WorkspaceRole;
+ is_billable: boolean;
joined_at: string;
email: string;
name: string | null;
@@ -1434,6 +1438,10 @@ declare global {
trialDaysLeft?: number | null;
currentPeriodEnd?: string | null;
billingInterval?: "monthly" | "annual" | null;
+ entitlementSources?: {
+ personal: boolean;
+ workspaceIds: string[];
+ };
resetAt?: string;
error?: string;
code?: string;