@burdenoff/microfe-billing 2026.1114.5 → 2026.1114.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing/BillingUserRoutes.js +74 -87
- package/dist/billing/BillingUserRoutes.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonBrowseDetailPage.js +1 -1
- package/dist/billing/modules/addons/pages/AddonDetailPage.js +1 -1
- package/dist/billing/modules/addons/pages/AddonEditPage.js +1 -1
- package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +3 -3
- package/dist/billing/modules/addons/pages/AddonsBrowsePage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +176 -168
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/TransactionsPage.js +117 -111
- package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +143 -138
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditTransactionsPage.js +132 -126
- package/dist/billing/modules/credits/pages/CreditTransactionsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/DeveloperRevenueAdminPage.js +13 -13
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js +24 -24
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js +1 -1
- package/dist/billing/modules/plans/pages/PlanEditPage.js +6 -6
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +35 -35
- package/dist/billing/modules/plans/pages/PlansListPage.js +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js +4 -4
- package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js +4 -4
- package/dist/billing/modules/store/index.d.ts +0 -1
- package/dist/billing/shared/components/BillingHistoryTabs.d.ts +9 -0
- package/dist/billing/shared/components/BillingHistoryTabs.js +30 -0
- package/dist/billing/shared/components/BillingHistoryTabs.js.map +1 -0
- package/dist/billing/shared/components/historyTabs.d.ts +19 -0
- package/dist/billing/shared/components/historyTabs.js +32 -0
- package/dist/billing/shared/components/historyTabs.js.map +1 -0
- package/dist/billing/shared/components/index.d.ts +1 -0
- package/dist/billing/shared/components/index.js +2 -1
- package/package.json +1 -1
- package/dist/billing/modules/store/graphql/index.js +0 -1
- package/dist/billing/modules/store/index.js +0 -2
- package/dist/billing/modules/store/pages/StoreCheckoutPage.d.ts +0 -9
- package/dist/billing/modules/store/pages/StoreCheckoutPage.js +0 -16
- package/dist/billing/modules/store/pages/StoreCheckoutPage.js.map +0 -1
|
@@ -4,9 +4,9 @@ import { ServerError as n } from "../../../shared/components/ServerError.js";
|
|
|
4
4
|
import { CurrencyPriceOverridesEditor as r } from "../../../shared/components/CurrencyPriceOverridesEditor.js";
|
|
5
5
|
import { useBillingNavigate as ee } from "../../../hooks/useBillingNavigate.js";
|
|
6
6
|
import "../hooks/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { useBillingPermissions as i } from "../../../hooks/useBillingPermissions.js";
|
|
8
|
+
import { isServerError as a } from "../../../shared/utils/error.js";
|
|
9
|
+
import { getPlanFeatureQuantity as te } from "../../../shared/utils/planFeatureQuantity.js";
|
|
10
10
|
import "../../../shared/components/index.js";
|
|
11
11
|
import "../../../shared/utils/index.js";
|
|
12
12
|
import { usePlan as o, usePlanMutations as s } from "../hooks/usePlans.js";
|
|
@@ -23,7 +23,7 @@ var y = () => {
|
|
|
23
23
|
let { t: y } = v(), b = (e, t) => {
|
|
24
24
|
let n = y(e);
|
|
25
25
|
return n === e ? t : n;
|
|
26
|
-
}, { planId: x } = m(), S = ee(), C =
|
|
26
|
+
}, { planId: x } = m(), S = ee(), C = i(), { plan: w, isLoading: T, error: E, refetch: D } = o(x), { quotas: O, isLoading: k } = c({ onlyActive: !0 }), { updatePlan: A, isUpdating: j } = s(), [M, N] = f(""), [ne, P] = f(""), [F, I] = f("USD"), [L, R] = f(l.MONTHLY), [z, B] = f(!0), [V, H] = f(!0), [U, W] = f([]), [G, K] = f([]), [q, J] = f([]), [Y, X] = f(null), [Z, Q] = f(!1);
|
|
27
27
|
if (d(() => {
|
|
28
28
|
if (w) {
|
|
29
29
|
if (N(w.name ?? ""), P(String(w.price ?? "")), I(w.currency ?? "USD"), R(w.duration ?? l.MONTHLY), B(w.isActive ?? !0), H(w.isPurchasable ?? !0), w.currencyPrices && typeof w.currencyPrices == "object") {
|
|
@@ -36,7 +36,7 @@ var y = () => {
|
|
|
36
36
|
if (w.features && w.features.length > 0) {
|
|
37
37
|
let e = [], t = /* @__PURE__ */ new Map();
|
|
38
38
|
for (let e of w.features) if (e.quota?.id) {
|
|
39
|
-
let n = e.quota.id, r =
|
|
39
|
+
let n = e.quota.id, r = te(e) || 1;
|
|
40
40
|
t.set(n, r);
|
|
41
41
|
}
|
|
42
42
|
for (let [n, r] of t) e.push({
|
|
@@ -60,7 +60,7 @@ var y = () => {
|
|
|
60
60
|
].map((e) => /* @__PURE__ */ g("div", { className: "h-16 bg-bg-sunken animate-pulse rounded" }, e))
|
|
61
61
|
})]
|
|
62
62
|
});
|
|
63
|
-
if (E &&
|
|
63
|
+
if (E && a(E)) return /* @__PURE__ */ g("div", {
|
|
64
64
|
className: "p-6",
|
|
65
65
|
children: /* @__PURE__ */ g(n, {
|
|
66
66
|
title: b("billing.plans.serverUnavailable", "Server Unavailable"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanEditPage.js","names":["_Fragment","Fragment$1","PlanEditPage","useI18n","tr","translated","t","key","fallback","useParams","navigateTo","useBillingNavigate","permissions","useBillingPermissions","isPlanLoading","planError","usePlan","planId","isQuotasLoading","useQuotas","usePlanMutations","name","setName","useState","price","setPrice","currency","setCurrency","duration","setDuration","PlanDuration","isActive","setIsActive","isPurchasable","setIsPurchasable","quotaAllocations","setQuotaAllocations","currencyPriceOverrides","setCurrencyPriceOverrides","initialCurrencyPriceOverrides","setInitialCurrencyPriceOverrides","error","setError","success","setSuccess","useEffect","plan","existing","overrides","v","amount","allocations","quotaMap","feature","quotaId","value","getPlanFeatureQuantity","quantity","AccessDenied","i","isServerError","ServerError","refetch","handleAddQuota","handleRemoveQuota","index","handleQuotaChange","updated","field","PageHeader","PagePurpose","a","input","getChangedCurrencyPriceOverrides","updatePlan","err","selectedQuota","quotas","q","allocation","limitType","quota","CurrencyPriceOverridesEditor","isUpdating"],"sources":["../../../../../src/billing/modules/plans/pages/PlanEditPage.tsx"],"sourcesContent":["/**\n * Plans Module - Plan Edit Page\n * Form to edit an existing plan\n */\n\nimport { useState, useEffect, type FC, type FormEvent } from 'react';\nimport { useParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { usePlan, usePlanMutations, useQuotas } from '../hooks';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n AccessDenied,\n CurrencyPriceOverridesEditor,\n PageHeader,\n ServerError,\n} from '../../../shared/components';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { getPlanFeatureQuantity, isServerError } from '../../../shared/utils';\nimport {\n PlanDuration,\n type CurrencyPriceOverrideInput,\n type UpdatePlanInput,\n} from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { getChangedCurrencyPriceOverrides } from '../utils/currencyPriceOverrides';\n\ninterface QuotaAllocation {\n quotaId: string;\n quantity: number;\n}\n\nexport const PlanEditPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const { planId } = useParams<{ planId: string }>();\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const { plan, isLoading: isPlanLoading, error: planError, refetch } = usePlan(planId);\n const { quotas, isLoading: isQuotasLoading } = useQuotas({ onlyActive: true });\n const { updatePlan, isUpdating } = usePlanMutations();\n\n // Form state\n const [name, setName] = useState('');\n const [price, setPrice] = useState('');\n const [currency, setCurrency] = useState('USD');\n const [duration, setDuration] = useState<PlanDuration>(PlanDuration.MONTHLY);\n const [isActive, setIsActive] = useState(true);\n const [isPurchasable, setIsPurchasable] = useState(true);\n const [quotaAllocations, setQuotaAllocations] = useState<QuotaAllocation[]>([]);\n const [currencyPriceOverrides, setCurrencyPriceOverrides] = useState<\n CurrencyPriceOverrideInput[]\n >([]);\n const [initialCurrencyPriceOverrides, setInitialCurrencyPriceOverrides] = useState<\n CurrencyPriceOverrideInput[]\n >([]);\n const [error, setError] = useState<string | null>(null);\n const [success, setSuccess] = useState(false);\n\n // Populate form when plan data loads\n useEffect(() => {\n if (plan) {\n setName(plan.name ?? '');\n setPrice(String(plan.price ?? ''));\n setCurrency(plan.currency ?? 'USD');\n setDuration(plan.duration ?? PlanDuration.MONTHLY);\n setIsActive(plan.isActive ?? true);\n setIsPurchasable(plan.isPurchasable ?? true);\n // Pre-populate currency price overrides so existing prices are preserved on save\n if (plan.currencyPrices && typeof plan.currencyPrices === 'object') {\n const existing = plan.currencyPrices as Record<string, number>;\n const overrides = Object.entries(existing)\n .filter(([, v]) => typeof v === 'number')\n .map(([currency, amount]) => ({ currency, amount }));\n setCurrencyPriceOverrides(overrides);\n setInitialCurrencyPriceOverrides(overrides);\n }\n // Extract quota allocations from features\n if (plan.features && plan.features.length > 0) {\n const allocations: QuotaAllocation[] = [];\n const quotaMap = new Map<string, number>();\n\n for (const feature of plan.features) {\n if (feature.quota?.id) {\n const quotaId = feature.quota.id;\n // SubscriptionFeature now stores per-plan override in context.quantity.\n // Fall back to quota.limits.value for legacy autoseeded plans.\n const value = getPlanFeatureQuantity(feature) || 1;\n quotaMap.set(quotaId, value);\n }\n }\n\n for (const [quotaId, quantity] of quotaMap) {\n allocations.push({ quotaId, quantity });\n }\n\n setQuotaAllocations(allocations);\n }\n }\n }, [plan]);\n\n // Permission check\n if (!permissions.canManagePlans) {\n return (\n <AccessDenied\n message={tr('billing.plans.noEditPermission', \"You don't have permission to edit plans.\")}\n />\n );\n }\n\n // Loading state\n if (isPlanLoading || isQuotasLoading) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"max-w-2xl space-y-4\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n </div>\n );\n }\n\n // Error state\n if (planError && isServerError(planError)) {\n return (\n <div className=\"p-6\">\n <ServerError\n title={tr('billing.plans.serverUnavailable', 'Server Unavailable')}\n message={tr(\n 'billing.plans.serverUnavailableLoadPlan',\n 'Unable to load plan. The server might be down or experiencing issues.'\n )}\n onRetry={() => refetch()}\n showRetry\n />\n </div>\n );\n }\n\n if (!plan) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('billing.plans.planNotFound', 'Plan not found')}\n </h2>\n <button\n type=\"button\"\n onClick={() => navigateTo('/plans')}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover\"\n >\n Back to Plans\n </button>\n </div>\n </div>\n );\n }\n\n const handleAddQuota = () => {\n // Add new quota at the top with empty quotaId (placeholder)\n setQuotaAllocations([{ quotaId: '', quantity: 1 }, ...quotaAllocations]);\n };\n\n const handleRemoveQuota = (index: number) => {\n setQuotaAllocations(quotaAllocations.filter((_, i) => i !== index));\n };\n\n const handleQuotaChange = (\n index: number,\n field: 'quotaId' | 'quantity',\n value: string | number\n ) => {\n const updated = [...quotaAllocations];\n if (field === 'quotaId') {\n updated[index].quotaId = value as string;\n } else {\n updated[index].quantity = Number(value);\n }\n setQuotaAllocations(updated);\n };\n\n const handleSubmit = async (e: FormEvent) => {\n e.preventDefault();\n setError(null);\n setSuccess(false);\n\n // Validation\n if (!name.trim()) {\n setError('Plan name is required');\n return;\n }\n if (quotaAllocations.length === 0) {\n setError('At least one quota is required');\n return;\n }\n // Check for unselected quotas\n const unselectedQuotas = quotaAllocations.filter((a) => a.quotaId === '');\n if (unselectedQuotas.length > 0) {\n setError('Please select a quota for all allocations');\n return;\n }\n\n const input: UpdatePlanInput = {\n id: planId!,\n name: name.trim(),\n // price, currency and duration are immutable on existing plans (the payment\n // provider plans are locked to them), and the Plan.price/currency the form is\n // pre-filled with are resolved in the caller's billing currency, not the stored\n // one. Never send them back from the edit form.\n isActive,\n isPurchasable,\n quotas: quotaAllocations.map((a) => ({\n quotaId: a.quotaId,\n quantity: a.quantity,\n })),\n ...(getChangedCurrencyPriceOverrides(initialCurrencyPriceOverrides, currencyPriceOverrides)\n .length > 0\n ? {\n currencyPriceOverrides: getChangedCurrencyPriceOverrides(\n initialCurrencyPriceOverrides,\n currencyPriceOverrides\n ),\n }\n : {}),\n };\n\n try {\n await updatePlan(input);\n setSuccess(true);\n // Navigate back after short delay\n setTimeout(() => navigateTo(`/plans/${planId}`), 1500);\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to update plan');\n }\n };\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={`Edit Plan: ${plan.name}`}\n description={tr(\n 'billing.plans.editPlanDesc',\n 'Update the plan details and quota allocations'\n )}\n />\n\n <PagePurpose>\n {tr(\n 'billing.plans.editPurpose',\n \"Update this plan's price, currency/seat pricing and the quotas it grants. Changes apply to new subscriptions; existing subscribers keep the terms they signed up with until they renew or change plans.\"\n )}\n </PagePurpose>\n\n <form onSubmit={handleSubmit} className=\"space-y-6\">\n {/* Error/Success Messages */}\n {error && (\n <div className=\"p-4 bg-status-error-bg-subtle border border-border-subtle rounded-lg\">\n <p className=\"text-sm text-status-error-text\">{error}</p>\n </div>\n )}\n {success && (\n <div className=\"p-4 bg-status-success-bg-subtle border border-border-subtle rounded-lg\">\n <p className=\"text-sm text-status-success-text\">\n {tr('billing.plans.updateSuccess', 'Plan updated successfully! Redirecting...')}\n </p>\n </div>\n )}\n\n {/* Two-column layout on desktop */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n {/* Basic Info */}\n <div className=\"border border-border-seam rounded-card bg-bg-surface overflow-hidden shadow-[var(--shadow-elevation-1)] h-fit\">\n <div className=\"p-4 border-b border-border-subtle bg-bg-sunken/30\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.plans.basicInfo', 'Basic Information')}\n </h2>\n </div>\n <div className=\"p-4 space-y-4\">\n {/* Name */}\n <div>\n <label htmlFor=\"name\" className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('billing.plans.planNameLabel', 'Plan Name')} *\n </label>\n <input\n id=\"name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n placeholder={tr('billing.plans.planNamePlaceholder', 'e.g., Pro Plan')}\n required\n />\n </div>\n\n {/* Price & Currency */}\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label\n htmlFor=\"price\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.plans.priceLabel', 'Price')} *\n </label>\n <input\n id=\"price\"\n type=\"number\"\n step=\"0.01\"\n min=\"0\"\n value={price}\n onChange={(e) => setPrice(e.target.value)}\n disabled\n title=\"Price cannot be changed on an existing plan. Create a new plan instead.\"\n className=\"w-full disabled:opacity-60 disabled:cursor-not-allowed px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n placeholder=\"49.99\"\n />\n </div>\n <div>\n <label\n htmlFor=\"currency\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.plans.currencyLabel', 'Currency')} *\n </label>\n <select\n id=\"currency\"\n value={currency}\n onChange={(e) => setCurrency(e.target.value)}\n disabled\n title=\"Currency cannot be changed on an existing plan. Create a new plan instead.\"\n className=\"w-full disabled:opacity-60 disabled:cursor-not-allowed px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"USD\">USD ($)</option>\n <option value=\"EUR\">EUR</option>\n <option value=\"GBP\">GBP</option>\n <option value=\"INR\">INR</option>\n <option value=\"AUD\">AUD</option>\n <option value=\"CAD\">CAD</option>\n <option value=\"JPY\">JPY</option>\n <option value=\"SGD\">SGD</option>\n </select>\n </div>\n </div>\n\n {/* Duration */}\n <div>\n <label\n htmlFor=\"duration\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.plans.billingPeriodLabel', 'Billing Period')} *\n </label>\n <select\n id=\"duration\"\n value={duration}\n onChange={(e) => setDuration(e.target.value as PlanDuration)}\n disabled\n title=\"Billing period cannot be changed on an existing plan. Create a new plan instead.\"\n className=\"w-full disabled:opacity-60 disabled:cursor-not-allowed px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value={PlanDuration.MONTHLY}>Monthly</option>\n <option value={PlanDuration.YEARLY}>Yearly</option>\n </select>\n </div>\n\n {/* Status */}\n <div className=\"flex items-center gap-3\">\n <input\n id=\"isActive\"\n type=\"checkbox\"\n checked={isActive}\n onChange={(e) => setIsActive(e.target.checked)}\n className=\"size-4 rounded border-border-subtle text-text-link focus:ring-[var(--color-focus-ring)]\"\n />\n <label htmlFor=\"isActive\" className=\"text-sm font-medium text-text-primary\">\n {tr('billing.plans.planIsActive', 'Plan is active')}\n </label>\n </div>\n\n {/* Purchasable toggle */}\n <div className=\"flex items-start justify-between gap-4 pt-1\">\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {tr('billing.plans.isPurchasableLabel', 'Publicly purchasable')}\n </p>\n <p className=\"text-xs text-text-muted mt-0.5\">\n {isPurchasable\n ? tr(\n 'billing.plans.isPurchasableOn',\n 'Visible on pricing page — users can subscribe directly.'\n )\n : tr(\n 'billing.plans.isPurchasableOff',\n 'Internal / custom plan — hidden from pricing page, assign via API only.'\n )}\n </p>\n </div>\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={isPurchasable}\n onClick={() => setIsPurchasable((v) => !v)}\n className={`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:ring-offset-2 ${\n isPurchasable ? 'bg-action-primary-bg' : 'bg-text-muted/30'\n }`}\n >\n <span\n className={`inline-block h-5 w-5 transform rounded-full bg-bg-surface shadow transition-transform ${\n isPurchasable ? 'translate-x-5' : 'translate-x-0'\n }`}\n />\n </button>\n </div>\n </div>\n </div>\n\n {/* Quota Allocations */}\n <div className=\"border border-border-seam rounded-card bg-bg-surface overflow-hidden shadow-[var(--shadow-elevation-1)] h-fit\">\n <div className=\"p-4 border-b border-border-subtle bg-bg-sunken/30 flex items-center justify-between\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.plans.quotaAllocations', 'Quota Allocations')}\n </h2>\n <button\n type=\"button\"\n onClick={handleAddQuota}\n className=\"px-3 py-1 text-sm font-medium text-text-link hover:bg-[var(--color-accent-soft)] rounded-md transition-colors\"\n >\n + Add Quota\n </button>\n </div>\n <div className=\"p-4 space-y-3\">\n {quotaAllocations.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n {tr(\n 'billing.plans.noQuotasAllocated',\n 'No quotas allocated. Click \"Add Quota\" to add one.'\n )}\n </p>\n ) : (\n quotaAllocations.map((allocation, index) => {\n const selectedQuota = quotas.find((q) => q.id === allocation.quotaId);\n const limits = selectedQuota?.limits as { type?: string; value?: number } | null;\n const limitType = limits?.type ?? 'unknown';\n\n return (\n <div\n key={index}\n className=\"p-3 border border-border-subtle rounded-lg bg-bg-sunken/20 space-y-3\"\n >\n <div className=\"flex items-center gap-3\">\n <select\n value={allocation.quotaId}\n onChange={(e) => handleQuotaChange(index, 'quotaId', e.target.value)}\n className={`flex-1 px-3 py-2 border border-border-subtle rounded-input bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] ${\n allocation.quotaId === '' ? 'text-text-muted' : 'text-text-primary'\n }`}\n >\n <option value=\"\" disabled>\n {tr('billing.plans.selectQuota', 'Select a quota...')}\n </option>\n {quotas.map((quota) => (\n <option key={quota.id} value={quota.id}>\n {quota.name}\n </option>\n ))}\n </select>\n <button\n type=\"button\"\n onClick={() => handleRemoveQuota(index)}\n className=\"p-2 text-status-error-text hover:bg-status-error-bg-subtle rounded-md transition-colors\"\n title=\"Remove quota\"\n >\n <svg\n className=\"size-5\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16\"\n />\n </svg>\n </button>\n </div>\n\n {/* Quota Info - only show when quota is selected */}\n {selectedQuota && (\n <>\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"capitalize text-text-muted\">Type: {limitType}</span>\n </div>\n\n {/* Limit value — allocation.quantity is the absolute limit */}\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-text-muted\">\n {tr('billing.plans.limit', 'Limit')}:\n </label>\n <input\n type=\"number\"\n min=\"1\"\n value={allocation.quantity}\n onChange={(e) => handleQuotaChange(index, 'quantity', e.target.value)}\n className=\"w-36 px-3 py-1.5 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-center\"\n />\n </div>\n </>\n )}\n </div>\n );\n })\n )}\n </div>\n </div>\n </div>\n\n <CurrencyPriceOverridesEditor\n overrides={currencyPriceOverrides}\n onChange={setCurrencyPriceOverrides}\n />\n\n {/* Actions */}\n <div className=\"flex items-center gap-3 pt-4\">\n <button\n type=\"submit\"\n disabled={isUpdating}\n className=\"px-6 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors disabled:opacity-50\"\n >\n {isUpdating\n ? tr('billing.plans.saving', 'Saving...')\n : tr('billing.plans.saveChanges', 'Save Changes')}\n </button>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/plans/${planId}`)}\n className=\"px-6 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n Cancel\n </button>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,IAAaE,UAAyB;CACpC,IAAM,EAAE,SAAMC,EAAQ,GAChBC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAAMC,IAAWH;CACzC,GACM,EAAE,cAAWI,EAA8B,GAC3CC,IAAaC,GAAmB,GAChCC,IAAcC,GAAsB,GACpC,EAAE,SAAM,WAAWC,GAAe,OAAOC,GAAW,eAAYC,EAAQC,CAAM,GAC9E,EAAE,WAAQ,WAAWC,MAAoBC,EAAU,EAAE,YAAY,GAAK,CAAC,GACvE,EAAE,eAAY,kBAAeC,EAAiB,GAG9C,CAACC,GAAMC,KAAWC,EAAS,EAAE,GAC7B,C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AAA,CAAA,CAED;SAhEE,GAAAA,CAgEF;QAET,CAAC;OAEA,CAAA,CACF;MACF,CAAA,CAAA;;KAEL,kBAACiB,GAAD;MACE,WAAW7C;MACX,UAAUC;KACX,CAAA;KAGD,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,UAAD;OACE,MAAK;OACL,UAAU6C;OACV,WAAU;OAET,UAAAA,IACG/E,EAAG,wBAAwB,WAAW,IACtCA,EAAG,6BAA6B,cAAc;MAC5C,CAAA,GACR,kBAAC,UAAD;OACE,MAAK;OACL,eAAeM,EAAW,UAAUO,GAAQ;OAC5C,WAAU;OACX,UAAA;MAEO,CAAA,CACL;;IACD;;EACH;;AAET"}
|
|
1
|
+
{"version":3,"file":"PlanEditPage.js","names":["_Fragment","Fragment$1","PlanEditPage","useI18n","tr","translated","t","key","fallback","useParams","navigateTo","useBillingNavigate","permissions","useBillingPermissions","isPlanLoading","planError","usePlan","planId","isQuotasLoading","useQuotas","usePlanMutations","name","setName","useState","price","setPrice","currency","setCurrency","duration","setDuration","PlanDuration","isActive","setIsActive","isPurchasable","setIsPurchasable","quotaAllocations","setQuotaAllocations","currencyPriceOverrides","setCurrencyPriceOverrides","initialCurrencyPriceOverrides","setInitialCurrencyPriceOverrides","error","setError","success","setSuccess","useEffect","plan","existing","overrides","v","amount","allocations","quotaMap","feature","quotaId","value","getPlanFeatureQuantity","quantity","AccessDenied","i","isServerError","ServerError","refetch","handleAddQuota","handleRemoveQuota","index","handleQuotaChange","updated","field","PageHeader","PagePurpose","a","input","getChangedCurrencyPriceOverrides","updatePlan","err","selectedQuota","quotas","q","allocation","limitType","quota","CurrencyPriceOverridesEditor","isUpdating"],"sources":["../../../../../src/billing/modules/plans/pages/PlanEditPage.tsx"],"sourcesContent":["/**\n * Plans Module - Plan Edit Page\n * Form to edit an existing plan\n */\n\nimport { useState, useEffect, type FC, type FormEvent } from 'react';\nimport { useParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { usePlan, usePlanMutations, useQuotas } from '../hooks';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n AccessDenied,\n CurrencyPriceOverridesEditor,\n PageHeader,\n ServerError,\n} from '../../../shared/components';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { getPlanFeatureQuantity, isServerError } from '../../../shared/utils';\nimport {\n PlanDuration,\n type CurrencyPriceOverrideInput,\n type UpdatePlanInput,\n} from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { getChangedCurrencyPriceOverrides } from '../utils/currencyPriceOverrides';\n\ninterface QuotaAllocation {\n quotaId: string;\n quantity: number;\n}\n\nexport const PlanEditPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const { planId } = useParams<{ planId: string }>();\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const { plan, isLoading: isPlanLoading, error: planError, refetch } = usePlan(planId);\n const { quotas, isLoading: isQuotasLoading } = useQuotas({ onlyActive: true });\n const { updatePlan, isUpdating } = usePlanMutations();\n\n // Form state\n const [name, setName] = useState('');\n const [price, setPrice] = useState('');\n const [currency, setCurrency] = useState('USD');\n const [duration, setDuration] = useState<PlanDuration>(PlanDuration.MONTHLY);\n const [isActive, setIsActive] = useState(true);\n const [isPurchasable, setIsPurchasable] = useState(true);\n const [quotaAllocations, setQuotaAllocations] = useState<QuotaAllocation[]>([]);\n const [currencyPriceOverrides, setCurrencyPriceOverrides] = useState<\n CurrencyPriceOverrideInput[]\n >([]);\n const [initialCurrencyPriceOverrides, setInitialCurrencyPriceOverrides] = useState<\n CurrencyPriceOverrideInput[]\n >([]);\n const [error, setError] = useState<string | null>(null);\n const [success, setSuccess] = useState(false);\n\n // Populate form when plan data loads\n useEffect(() => {\n if (plan) {\n setName(plan.name ?? '');\n setPrice(String(plan.price ?? ''));\n setCurrency(plan.currency ?? 'USD');\n setDuration(plan.duration ?? PlanDuration.MONTHLY);\n setIsActive(plan.isActive ?? true);\n setIsPurchasable(plan.isPurchasable ?? true);\n // Pre-populate currency price overrides so existing prices are preserved on save\n if (plan.currencyPrices && typeof plan.currencyPrices === 'object') {\n const existing = plan.currencyPrices as Record<string, number>;\n const overrides = Object.entries(existing)\n .filter(([, v]) => typeof v === 'number')\n .map(([currency, amount]) => ({ currency, amount }));\n setCurrencyPriceOverrides(overrides);\n setInitialCurrencyPriceOverrides(overrides);\n }\n // Extract quota allocations from features\n if (plan.features && plan.features.length > 0) {\n const allocations: QuotaAllocation[] = [];\n const quotaMap = new Map<string, number>();\n\n for (const feature of plan.features) {\n if (feature.quota?.id) {\n const quotaId = feature.quota.id;\n // SubscriptionFeature now stores per-plan override in context.quantity.\n // Fall back to quota.limits.value for legacy autoseeded plans.\n const value = getPlanFeatureQuantity(feature) || 1;\n quotaMap.set(quotaId, value);\n }\n }\n\n for (const [quotaId, quantity] of quotaMap) {\n allocations.push({ quotaId, quantity });\n }\n\n setQuotaAllocations(allocations);\n }\n }\n }, [plan]);\n\n // Permission check\n if (!permissions.canManagePlans) {\n return (\n <AccessDenied\n message={tr('billing.plans.noEditPermission', \"You don't have permission to edit plans.\")}\n />\n );\n }\n\n // Loading state\n if (isPlanLoading || isQuotasLoading) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"max-w-2xl space-y-4\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"h-16 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n </div>\n );\n }\n\n // Error state\n if (planError && isServerError(planError)) {\n return (\n <div className=\"p-6\">\n <ServerError\n title={tr('billing.plans.serverUnavailable', 'Server Unavailable')}\n message={tr(\n 'billing.plans.serverUnavailableLoadPlan',\n 'Unable to load plan. The server might be down or experiencing issues.'\n )}\n onRetry={() => refetch()}\n showRetry\n />\n </div>\n );\n }\n\n if (!plan) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('billing.plans.planNotFound', 'Plan not found')}\n </h2>\n <button\n type=\"button\"\n onClick={() => navigateTo('/plans')}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover\"\n >\n Back to Plans\n </button>\n </div>\n </div>\n );\n }\n\n const handleAddQuota = () => {\n // Add new quota at the top with empty quotaId (placeholder)\n setQuotaAllocations([{ quotaId: '', quantity: 1 }, ...quotaAllocations]);\n };\n\n const handleRemoveQuota = (index: number) => {\n setQuotaAllocations(quotaAllocations.filter((_, i) => i !== index));\n };\n\n const handleQuotaChange = (\n index: number,\n field: 'quotaId' | 'quantity',\n value: string | number\n ) => {\n const updated = [...quotaAllocations];\n if (field === 'quotaId') {\n updated[index].quotaId = value as string;\n } else {\n updated[index].quantity = Number(value);\n }\n setQuotaAllocations(updated);\n };\n\n const handleSubmit = async (e: FormEvent) => {\n e.preventDefault();\n setError(null);\n setSuccess(false);\n\n // Validation\n if (!name.trim()) {\n setError('Plan name is required');\n return;\n }\n if (quotaAllocations.length === 0) {\n setError('At least one quota is required');\n return;\n }\n // Check for unselected quotas\n const unselectedQuotas = quotaAllocations.filter((a) => a.quotaId === '');\n if (unselectedQuotas.length > 0) {\n setError('Please select a quota for all allocations');\n return;\n }\n\n const input: UpdatePlanInput = {\n id: planId!,\n name: name.trim(),\n // price, currency and duration are immutable on existing plans (the payment\n // provider plans are locked to them), and the Plan.price/currency the form is\n // pre-filled with are resolved in the caller's billing currency, not the stored\n // one. Never send them back from the edit form.\n isActive,\n isPurchasable,\n quotas: quotaAllocations.map((a) => ({\n quotaId: a.quotaId,\n quantity: a.quantity,\n })),\n ...(getChangedCurrencyPriceOverrides(initialCurrencyPriceOverrides, currencyPriceOverrides)\n .length > 0\n ? {\n currencyPriceOverrides: getChangedCurrencyPriceOverrides(\n initialCurrencyPriceOverrides,\n currencyPriceOverrides\n ),\n }\n : {}),\n };\n\n try {\n await updatePlan(input);\n setSuccess(true);\n // Navigate back after short delay\n setTimeout(() => navigateTo(`/plans/${planId}`), 1500);\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to update plan');\n }\n };\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={`Edit Plan: ${plan.name}`}\n description={tr(\n 'billing.plans.editPlanDesc',\n 'Update the plan details and quota allocations'\n )}\n />\n\n <PagePurpose>\n {tr(\n 'billing.plans.editPurpose',\n \"Update this plan's price, currency/seat pricing and the quotas it grants. Changes apply to new subscriptions; existing subscribers keep the terms they signed up with until they renew or change plans.\"\n )}\n </PagePurpose>\n\n <form onSubmit={handleSubmit} className=\"space-y-6\">\n {/* Error/Success Messages */}\n {error && (\n <div className=\"p-4 bg-status-error-bg-subtle border border-border-subtle rounded-lg\">\n <p className=\"text-sm text-status-error-text\">{error}</p>\n </div>\n )}\n {success && (\n <div className=\"p-4 bg-status-success-bg-subtle border border-border-subtle rounded-lg\">\n <p className=\"text-sm text-status-success-text\">\n {tr('billing.plans.updateSuccess', 'Plan updated successfully! Redirecting...')}\n </p>\n </div>\n )}\n\n {/* Two-column layout on desktop */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n {/* Basic Info */}\n <div className=\"border border-border-seam rounded-card bg-bg-surface overflow-hidden shadow-[var(--shadow-elevation-1)] h-fit\">\n <div className=\"p-4 border-b border-border-subtle bg-bg-sunken/30\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.plans.basicInfo', 'Basic Information')}\n </h2>\n </div>\n <div className=\"p-4 space-y-4\">\n {/* Name */}\n <div>\n <label htmlFor=\"name\" className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('billing.plans.planNameLabel', 'Plan Name')} *\n </label>\n <input\n id=\"name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n placeholder={tr('billing.plans.planNamePlaceholder', 'e.g., Pro Plan')}\n required\n />\n </div>\n\n {/* Price & Currency */}\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label\n htmlFor=\"price\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.plans.priceLabel', 'Price')} *\n </label>\n <input\n id=\"price\"\n type=\"number\"\n step=\"0.01\"\n min=\"0\"\n value={price}\n onChange={(e) => setPrice(e.target.value)}\n disabled\n title=\"Price cannot be changed on an existing plan. Create a new plan instead.\"\n className=\"w-full disabled:opacity-60 disabled:cursor-not-allowed px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n placeholder=\"49.99\"\n />\n </div>\n <div>\n <label\n htmlFor=\"currency\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.plans.currencyLabel', 'Currency')} *\n </label>\n <select\n id=\"currency\"\n value={currency}\n onChange={(e) => setCurrency(e.target.value)}\n disabled\n title=\"Currency cannot be changed on an existing plan. Create a new plan instead.\"\n className=\"w-full disabled:opacity-60 disabled:cursor-not-allowed px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"USD\">USD ($)</option>\n <option value=\"EUR\">EUR</option>\n <option value=\"GBP\">GBP</option>\n <option value=\"INR\">INR</option>\n <option value=\"AUD\">AUD</option>\n <option value=\"CAD\">CAD</option>\n <option value=\"JPY\">JPY</option>\n <option value=\"SGD\">SGD</option>\n </select>\n </div>\n </div>\n\n {/* Duration */}\n <div>\n <label\n htmlFor=\"duration\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.plans.billingPeriodLabel', 'Billing Period')} *\n </label>\n <select\n id=\"duration\"\n value={duration}\n onChange={(e) => setDuration(e.target.value as PlanDuration)}\n disabled\n title=\"Billing period cannot be changed on an existing plan. Create a new plan instead.\"\n className=\"w-full disabled:opacity-60 disabled:cursor-not-allowed px-3 py-2 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value={PlanDuration.MONTHLY}>Monthly</option>\n <option value={PlanDuration.YEARLY}>Yearly</option>\n </select>\n </div>\n\n {/* Status */}\n <div className=\"flex items-center gap-3\">\n <input\n id=\"isActive\"\n type=\"checkbox\"\n checked={isActive}\n onChange={(e) => setIsActive(e.target.checked)}\n className=\"size-4 rounded border-border-subtle text-text-link focus:ring-[var(--color-focus-ring)]\"\n />\n <label htmlFor=\"isActive\" className=\"text-sm font-medium text-text-primary\">\n {tr('billing.plans.planIsActive', 'Plan is active')}\n </label>\n </div>\n\n {/* Purchasable toggle */}\n <div className=\"flex items-start justify-between gap-4 pt-1\">\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {tr('billing.plans.isPurchasableLabel', 'Publicly purchasable')}\n </p>\n <p className=\"text-xs text-text-muted mt-0.5\">\n {isPurchasable\n ? tr(\n 'billing.plans.isPurchasableOn',\n 'Visible on pricing page — users can subscribe directly.'\n )\n : tr(\n 'billing.plans.isPurchasableOff',\n 'Internal / custom plan — hidden from pricing page, assign via API only.'\n )}\n </p>\n </div>\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={isPurchasable}\n onClick={() => setIsPurchasable((v) => !v)}\n className={`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:ring-offset-2 ${\n isPurchasable ? 'bg-action-primary-bg' : 'bg-text-muted/30'\n }`}\n >\n <span\n className={`inline-block h-5 w-5 transform rounded-full bg-bg-surface shadow transition-transform ${\n isPurchasable ? 'translate-x-5' : 'translate-x-0'\n }`}\n />\n </button>\n </div>\n </div>\n </div>\n\n {/* Quota Allocations */}\n <div className=\"border border-border-seam rounded-card bg-bg-surface overflow-hidden shadow-[var(--shadow-elevation-1)] h-fit\">\n <div className=\"p-4 border-b border-border-subtle bg-bg-sunken/30 flex items-center justify-between\">\n <h2 className=\"font-semibold text-text-primary\">\n {tr('billing.plans.quotaAllocations', 'Quota Allocations')}\n </h2>\n <button\n type=\"button\"\n onClick={handleAddQuota}\n className=\"px-3 py-1 text-sm font-medium text-text-link hover:bg-[var(--color-accent-soft)] rounded-md transition-colors\"\n >\n + Add Quota\n </button>\n </div>\n <div className=\"p-4 space-y-3\">\n {quotaAllocations.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n {tr(\n 'billing.plans.noQuotasAllocated',\n 'No quotas allocated. Click \"Add Quota\" to add one.'\n )}\n </p>\n ) : (\n quotaAllocations.map((allocation, index) => {\n const selectedQuota = quotas.find((q) => q.id === allocation.quotaId);\n const limits = selectedQuota?.limits as { type?: string; value?: number } | null;\n const limitType = limits?.type ?? 'unknown';\n\n return (\n <div\n key={index}\n className=\"p-3 border border-border-subtle rounded-lg bg-bg-sunken/20 space-y-3\"\n >\n <div className=\"flex items-center gap-3\">\n <select\n value={allocation.quotaId}\n onChange={(e) => handleQuotaChange(index, 'quotaId', e.target.value)}\n className={`flex-1 px-3 py-2 border border-border-subtle rounded-input bg-bg-surface scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] ${\n allocation.quotaId === '' ? 'text-text-muted' : 'text-text-primary'\n }`}\n >\n <option value=\"\" disabled>\n {tr('billing.plans.selectQuota', 'Select a quota...')}\n </option>\n {quotas.map((quota) => (\n <option key={quota.id} value={quota.id}>\n {quota.name}\n </option>\n ))}\n </select>\n <button\n type=\"button\"\n onClick={() => handleRemoveQuota(index)}\n className=\"p-2 text-status-error-text hover:bg-status-error-bg-subtle rounded-md transition-colors\"\n title=\"Remove quota\"\n >\n <svg\n className=\"size-5\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16\"\n />\n </svg>\n </button>\n </div>\n\n {/* Quota Info - only show when quota is selected */}\n {selectedQuota && (\n <>\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"capitalize text-text-muted\">Type: {limitType}</span>\n </div>\n\n {/* Limit value — allocation.quantity is the absolute limit */}\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-text-muted\">\n {tr('billing.plans.limit', 'Limit')}:\n </label>\n <input\n type=\"number\"\n min=\"1\"\n value={allocation.quantity}\n onChange={(e) => handleQuotaChange(index, 'quantity', e.target.value)}\n className=\"w-36 px-3 py-1.5 border border-border-subtle rounded-input bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] text-center\"\n />\n </div>\n </>\n )}\n </div>\n );\n })\n )}\n </div>\n </div>\n </div>\n\n <CurrencyPriceOverridesEditor\n overrides={currencyPriceOverrides}\n onChange={setCurrencyPriceOverrides}\n />\n\n {/* Actions */}\n <div className=\"flex items-center gap-3 pt-4\">\n <button\n type=\"submit\"\n disabled={isUpdating}\n className=\"px-6 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors disabled:opacity-50\"\n >\n {isUpdating\n ? tr('billing.plans.saving', 'Saving...')\n : tr('billing.plans.saveChanges', 'Save Changes')}\n </button>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/plans/${planId}`)}\n className=\"px-6 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n Cancel\n </button>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,IAAaE,UAAyB;CACpC,IAAM,EAAE,SAAMC,EAAQ,GAChBC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAAMC,IAAWH;CACzC,GACM,EAAE,cAAWI,EAA8B,GAC3CC,IAAaC,GAAmB,GAChCC,IAAcC,EAAsB,GACpC,EAAE,SAAM,WAAWC,GAAe,OAAOC,GAAW,eAAYC,EAAQC,CAAM,GAC9E,EAAE,WAAQ,WAAWC,MAAoBC,EAAU,EAAE,YAAY,GAAK,CAAC,GACvE,EAAE,eAAY,kBAAeC,EAAiB,GAG9C,CAACC,GAAMC,KAAWC,EAAS,EAAE,GAC7B,CAACC,IAAOC,KAAYF,EAAS,EAAE,GAC/B,CAACG,GAAUC,KAAeJ,EAAS,KAAK,GACxC,CAACK,GAAUC,KAAeN,EAAuBO,EAAa,OAAO,GACrE,CAACC,GAAUC,KAAeT,EAAS,EAAI,GACvC,CAACU,GAAeC,KAAoBX,EAAS,EAAI,GACjD,CAACY,GAAkBC,KAAuBb,EAA4B,CAAC,CAAC,GACxE,CAACc,GAAwBC,KAA6Bf,EAE1D,CAAC,CAAC,GACE,CAACgB,GAA+BC,KAAoCjB,EAExE,CAAC,CAAC,GACE,CAACkB,GAAOC,KAAYnB,EAAwB,IAAI,GAChD,CAACoB,GAASC,KAAcrB,EAAS,EAAK;CA6C5C,IA1CAsB,QAAgB;EACd,IAAIC,GAAM;GAQR,IAPAxB,EAAQwB,EAAK,QAAQ,EAAE,GACvBrB,EAAS,OAAOqB,EAAK,SAAS,EAAE,CAAC,GACjCnB,EAAYmB,EAAK,YAAY,KAAK,GAClCjB,EAAYiB,EAAK,YAAYhB,EAAa,OAAO,GACjDE,EAAYc,EAAK,YAAY,E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AA,kBAAC,QAAD;cACE,eAAc;cACd,gBAAe;cACf,aAAa;cACb,GAAE;aACH,CAAA;YACE,CAAA;WACC,CAAA,CACL;UAGJ,CAAA,GAAAW,KACC,kBAAA5E,GAAA,EAAA,UAAA,CACE,kBAAC,OAAD;WAAK,WAAU;WACb,UAAA,kBAAC,QAAD;YAAM,WAAU;YAAhB,UAAA,CAA6C,UAAOgF,CAAgB;;UACjE,CAAA,GAGL,kBAAC,OAAD;WAAK,WAAU;WAAf,UAAA,CACE,kBAAC,SAAD;YAAO,WAAU;YAAjB,UAAA,CACG5E,EAAG,uBAAuB,OAAO,GAAE,GAC/B;WACP,CAAA,GAAA,kBAAC,SAAD;YACE,MAAK;YACL,KAAI;YACJ,OAAO2E,EAAW;YAClB,WAAW,MAAMb,EAAkBD,GAAO,YAAY,EAAE,OAAO,KAAK;YACpE,WAAU;WACX,CAAA,CACE;UACL,CAAA,CAAA,EAAA,CAAA,CAED;SAhEE,GAAAA,CAgEF;QAET,CAAC;OAEA,CAAA,CACF;MACF,CAAA,CAAA;;KAEL,kBAACiB,GAAD;MACE,WAAW7C;MACX,UAAUC;KACX,CAAA;KAGD,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,UAAD;OACE,MAAK;OACL,UAAU6C;OACV,WAAU;OAET,UAAAA,IACG/E,EAAG,wBAAwB,WAAW,IACtCA,EAAG,6BAA6B,cAAc;MAC5C,CAAA,GACR,kBAAC,UAAD;OACE,MAAK;OACL,eAAeM,EAAW,UAAUO,GAAQ;OAC5C,WAAU;OACX,UAAA;MAEO,CAAA,CACL;;IACD;;EACH;;AAET"}
|
|
@@ -3,10 +3,10 @@ import { ServerError as t } from "../../../shared/components/ServerError.js";
|
|
|
3
3
|
import { useBilling as n } from "../../../providers/BillingProvider.js";
|
|
4
4
|
import "../hooks/index.js";
|
|
5
5
|
import { useDefaultBillingAccount as r } from "../../subscriptions/hooks/useSubscriptions.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { useIsFluidgridsVariant as i } from "../../../hooks/useBillingVariant.js";
|
|
7
|
+
import { formatCurrency as a, formatPlanDuration as o, formatPlanDurationLabel as s } from "../../../shared/utils/format.js";
|
|
8
|
+
import { isServerError as c } from "../../../shared/utils/error.js";
|
|
9
|
+
import { getPlanFeatureQuantity as l } from "../../../shared/utils/planFeatureQuantity.js";
|
|
10
10
|
import { activeProductSubscriptions as u, resolvePlanAction as d } from "../utils/planAction.js";
|
|
11
11
|
import "../../../shared/components/index.js";
|
|
12
12
|
import { usePlans as f } from "../hooks/usePlans.js";
|
|
@@ -25,7 +25,7 @@ function A(e) {
|
|
|
25
25
|
let t = /* @__PURE__ */ new Map();
|
|
26
26
|
for (let n of e) {
|
|
27
27
|
if (!n.quota) continue;
|
|
28
|
-
let e = n.quota.id, r =
|
|
28
|
+
let e = n.quota.id, r = l(n), i = t.get(e);
|
|
29
29
|
i ? i.totalValue += r : t.set(e, {
|
|
30
30
|
quotaId: e,
|
|
31
31
|
name: n.quota.name ?? "Unknown Quota",
|
|
@@ -42,15 +42,15 @@ function j(e) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
var M = () => {
|
|
45
|
-
let { t:
|
|
46
|
-
let n =
|
|
45
|
+
let { t: a } = k(), o = (e, t) => {
|
|
46
|
+
let n = a(e);
|
|
47
47
|
return n === e ? t : n;
|
|
48
|
-
},
|
|
48
|
+
}, s = e(), { productId: l, plansDocsUrl: m } = n(), h = b(l), { plans: g, isLoading: _, error: v, refetch: y } = f({
|
|
49
49
|
includeFree: !1,
|
|
50
|
-
productId:
|
|
51
|
-
}), w =
|
|
50
|
+
productId: l ?? void 0
|
|
51
|
+
}), w = i(), { subscriptions: T } = r(), E = u(T, new Set(g.map((e) => e.id))), A = (e) => w ? d(e, E) : null, j = (e) => {
|
|
52
52
|
let t = A(e);
|
|
53
|
-
t?.kind === "change" ?
|
|
53
|
+
t?.kind === "change" ? s(`/subscriptions/${t.subscriptionId}/upgrade`) : s(`/checkout/${e}`);
|
|
54
54
|
}, [M, F] = x("grid"), [R, z] = x(p.MONTHLY), B = g.filter((e) => e.isActive && e.isPurchasable !== !1 && e.duration === R), V = B.length >= 2 ? 1 : -1;
|
|
55
55
|
return _ && g.length === 0 ? /* @__PURE__ */ O("div", {
|
|
56
56
|
className: "space-y-6 px-6 lg:px-8 py-6",
|
|
@@ -76,11 +76,11 @@ var M = () => {
|
|
|
76
76
|
]
|
|
77
77
|
}, e))
|
|
78
78
|
})]
|
|
79
|
-
}) : v &&
|
|
79
|
+
}) : v && c(v) ? /* @__PURE__ */ D("div", {
|
|
80
80
|
className: "p-6",
|
|
81
81
|
children: /* @__PURE__ */ D(t, {
|
|
82
|
-
title:
|
|
83
|
-
message:
|
|
82
|
+
title: o("billing.plans.serverUnavailable", "Server Unavailable"),
|
|
83
|
+
message: o("billing.plans.unableToLoadPlans", "Unable to load plans."),
|
|
84
84
|
onRetry: () => y(),
|
|
85
85
|
showRetry: !0
|
|
86
86
|
})
|
|
@@ -90,17 +90,17 @@ var M = () => {
|
|
|
90
90
|
/* @__PURE__ */ O("div", { children: [
|
|
91
91
|
/* @__PURE__ */ D("h1", {
|
|
92
92
|
className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
|
|
93
|
-
children:
|
|
93
|
+
children: o("billing.plans.browsePlansTitle", "Plans")
|
|
94
94
|
}),
|
|
95
95
|
/* @__PURE__ */ D("p", {
|
|
96
96
|
className: "text-sm text-text-secondary mt-1",
|
|
97
|
-
children:
|
|
97
|
+
children: o("billing.plans.browsePlansSubtitle", "Choose a plan that fits your needs")
|
|
98
98
|
}),
|
|
99
99
|
/* @__PURE__ */ D(C, {
|
|
100
100
|
className: "mt-3",
|
|
101
101
|
learnMoreHref: m,
|
|
102
|
-
learnMoreLabel:
|
|
103
|
-
children:
|
|
102
|
+
learnMoreLabel: o("billing.plans.learnMore", "Learn more"),
|
|
103
|
+
children: o("billing.plans.browsePurpose", "Compare what each plan includes — quotas, features and price — and subscribe to the one that fits your team. Switch between monthly and yearly billing to see the difference, or contact us for a custom Enterprise contract.")
|
|
104
104
|
})
|
|
105
105
|
] }),
|
|
106
106
|
/* @__PURE__ */ O("div", {
|
|
@@ -154,14 +154,14 @@ var M = () => {
|
|
|
154
154
|
}),
|
|
155
155
|
B.length === 0 ? /* @__PURE__ */ D(S, {
|
|
156
156
|
illustration: "empty-data",
|
|
157
|
-
title:
|
|
158
|
-
description:
|
|
157
|
+
title: o("billing.plans.noPlansAvailable", "No plans available"),
|
|
158
|
+
description: o("billing.plans.checkBackLater", "Check back later for new plans.")
|
|
159
159
|
}) : M === "grid" ? /* @__PURE__ */ O("div", {
|
|
160
160
|
className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 items-stretch",
|
|
161
161
|
children: [B.map((e, t) => /* @__PURE__ */ D(I, {
|
|
162
162
|
plan: e,
|
|
163
163
|
highlighted: t === V,
|
|
164
|
-
onView: () =>
|
|
164
|
+
onView: () => s(`/plans/${e.id}`),
|
|
165
165
|
onSubscribe: () => j(e.id),
|
|
166
166
|
action: A(e.id)
|
|
167
167
|
}, e.id)), /* @__PURE__ */ D(N, { offer: h })]
|
|
@@ -169,7 +169,7 @@ var M = () => {
|
|
|
169
169
|
className: "space-y-3",
|
|
170
170
|
children: [B.map((e) => /* @__PURE__ */ D(L, {
|
|
171
171
|
plan: e,
|
|
172
|
-
onView: () =>
|
|
172
|
+
onView: () => s(`/plans/${e.id}`),
|
|
173
173
|
onSubscribe: () => j(e.id),
|
|
174
174
|
action: A(e.id)
|
|
175
175
|
}, e.id)), /* @__PURE__ */ D(P, { offer: h })]
|
|
@@ -286,12 +286,12 @@ var M = () => {
|
|
|
286
286
|
function F(e) {
|
|
287
287
|
return e?.kind === "current" ? "Current plan" : e?.kind === "change" ? "Change to this plan" : "Subscribe";
|
|
288
288
|
}
|
|
289
|
-
var I = ({ plan: e, highlighted: t = !1, onView: n, onSubscribe: r, action:
|
|
289
|
+
var I = ({ plan: e, highlighted: t = !1, onView: n, onSubscribe: r, action: i }) => {
|
|
290
290
|
let c = j(e.features || []), l = A(e.features || []).length - c.length, u = h(), { price: d, currency: f } = m(e.price, e.currency, e.currencyPrices, u);
|
|
291
291
|
return /* @__PURE__ */ O("div", {
|
|
292
292
|
className: `relative flex flex-col h-full rounded-card bg-bg-surface p-6 transition-[border-color,box-shadow] duration-200 ${t ? "border-2 border-action-primary-bg shadow-[var(--shadow-glow)]" : "border border-border-subtle shadow-elevation-1 hover:border-border-strong hover:shadow-elevation-2"}`,
|
|
293
293
|
children: [
|
|
294
|
-
|
|
294
|
+
i?.kind === "current" && /* @__PURE__ */ D("span", {
|
|
295
295
|
className: "absolute -top-3 right-4 inline-flex items-center rounded-full bg-bg-sunken px-3 py-1 text-xs font-semibold text-text-primary border border-border-subtle",
|
|
296
296
|
children: "Current plan"
|
|
297
297
|
}),
|
|
@@ -309,17 +309,17 @@ var I = ({ plan: e, highlighted: t = !1, onView: n, onSubscribe: r, action: s })
|
|
|
309
309
|
children: e.name
|
|
310
310
|
}), /* @__PURE__ */ D("span", {
|
|
311
311
|
className: "text-sm text-text-secondary",
|
|
312
|
-
children:
|
|
312
|
+
children: s(e.duration)
|
|
313
313
|
})]
|
|
314
314
|
}),
|
|
315
315
|
/* @__PURE__ */ O("div", {
|
|
316
316
|
className: "flex items-baseline gap-1.5 mb-5",
|
|
317
317
|
children: [/* @__PURE__ */ D("span", {
|
|
318
318
|
className: "text-4xl font-bold tabular-nums tracking-tight text-text-primary",
|
|
319
|
-
children:
|
|
319
|
+
children: a(d, f)
|
|
320
320
|
}), /* @__PURE__ */ O("span", {
|
|
321
321
|
className: "text-text-secondary text-sm",
|
|
322
|
-
children: ["/ ",
|
|
322
|
+
children: ["/ ", o(e.duration)]
|
|
323
323
|
})]
|
|
324
324
|
}),
|
|
325
325
|
c.length > 0 && /* @__PURE__ */ O("ul", {
|
|
@@ -356,10 +356,10 @@ var I = ({ plan: e, highlighted: t = !1, onView: n, onSubscribe: r, action: s })
|
|
|
356
356
|
children: [/* @__PURE__ */ O("button", {
|
|
357
357
|
type: "button",
|
|
358
358
|
onClick: r,
|
|
359
|
-
disabled:
|
|
360
|
-
"aria-disabled":
|
|
359
|
+
disabled: i?.kind === "current",
|
|
360
|
+
"aria-disabled": i?.kind === "current",
|
|
361
361
|
className: "group disabled:cursor-not-allowed disabled:opacity-60 inline-flex w-full items-center justify-center gap-2 rounded-button bg-action-primary-bg px-4 py-2.5 text-sm font-semibold text-action-primary-text shadow-elevation-1 transition-colors duration-200 hover:bg-action-primary-bgHover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
|
|
362
|
-
children: [F(
|
|
362
|
+
children: [F(i), /* @__PURE__ */ D(w, {
|
|
363
363
|
className: "size-4 transition-transform duration-200",
|
|
364
364
|
"aria-hidden": "true"
|
|
365
365
|
})]
|
|
@@ -373,7 +373,7 @@ var I = ({ plan: e, highlighted: t = !1, onView: n, onSubscribe: r, action: s })
|
|
|
373
373
|
]
|
|
374
374
|
});
|
|
375
375
|
}, L = ({ plan: e, onView: t, onSubscribe: n, action: r }) => {
|
|
376
|
-
let
|
|
376
|
+
let i = j(e.features || []), s = h();
|
|
377
377
|
return /* @__PURE__ */ O("div", {
|
|
378
378
|
className: "flex items-center gap-4 p-5 border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 transition-all duration-200 hover:border-border-strong hover:shadow-elevation-2",
|
|
379
379
|
children: [
|
|
@@ -400,9 +400,9 @@ var I = ({ plan: e, highlighted: t = !1, onView: n, onSubscribe: r, action: s })
|
|
|
400
400
|
}), /* @__PURE__ */ O("p", {
|
|
401
401
|
className: "text-sm text-text-secondary",
|
|
402
402
|
children: [
|
|
403
|
-
|
|
403
|
+
i.length,
|
|
404
404
|
" key feature",
|
|
405
|
-
|
|
405
|
+
i.length === 1 ? "" : "s",
|
|
406
406
|
" included"
|
|
407
407
|
]
|
|
408
408
|
})]
|
|
@@ -413,11 +413,11 @@ var I = ({ plan: e, highlighted: t = !1, onView: n, onSubscribe: r, action: s })
|
|
|
413
413
|
className: "font-semibold text-text-primary",
|
|
414
414
|
children: (() => {
|
|
415
415
|
let { price: t, currency: n } = m(e.price, e.currency, e.currencyPrices, s);
|
|
416
|
-
return
|
|
416
|
+
return a(t, n);
|
|
417
417
|
})()
|
|
418
418
|
}), /* @__PURE__ */ O("div", {
|
|
419
419
|
className: "text-sm text-text-secondary",
|
|
420
|
-
children: ["per ",
|
|
420
|
+
children: ["per ", o(e.duration)]
|
|
421
421
|
})]
|
|
422
422
|
}),
|
|
423
423
|
/* @__PURE__ */ O("div", {
|
|
@@ -3,10 +3,10 @@ import { AccessDenied as t } from "../../../shared/components/AccessDenied.js";
|
|
|
3
3
|
import { ServerError as n } from "../../../shared/components/ServerError.js";
|
|
4
4
|
import "../hooks/index.js";
|
|
5
5
|
import { useBillingPermissions as r } from "../../../hooks/useBillingPermissions.js";
|
|
6
|
+
import "../../../shared/components/index.js";
|
|
6
7
|
import { formatCurrency as i, formatPlanDuration as a, formatPlanDurationLabel as o } from "../../../shared/utils/format.js";
|
|
7
8
|
import { isServerError as s } from "../../../shared/utils/error.js";
|
|
8
9
|
import { getPlanFeatureQuantity as c } from "../../../shared/utils/planFeatureQuantity.js";
|
|
9
|
-
import "../../../shared/components/index.js";
|
|
10
10
|
import "../../../shared/utils/index.js";
|
|
11
11
|
import { PricingModel as l } from "../../../shared/types/graphql.js";
|
|
12
12
|
import { useTr as u } from "../../../shared/hooks/useTr.js";
|
|
@@ -3,8 +3,8 @@ import { PageHeader as t } from "../../../shared/components/PageHeader.js";
|
|
|
3
3
|
import { ServerError as n } from "../../../shared/components/ServerError.js";
|
|
4
4
|
import { useBillingNavigate as r } from "../../../hooks/useBillingNavigate.js";
|
|
5
5
|
import "../hooks/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { useBillingPermissions as i } from "../../../hooks/useBillingPermissions.js";
|
|
7
|
+
import { isServerError as a } from "../../../shared/utils/error.js";
|
|
8
8
|
import "../../../shared/components/index.js";
|
|
9
9
|
import { formatDate as o } from "../../../shared/utils/format.js";
|
|
10
10
|
import { useQuotaTemplate as s, useQuotaTemplateMutations as c } from "../hooks/useQuotaTemplates.js";
|
|
@@ -18,7 +18,7 @@ var h = () => {
|
|
|
18
18
|
let { t: h } = m(), g = (e, t) => {
|
|
19
19
|
let n = h(e);
|
|
20
20
|
return n === e ? t : n;
|
|
21
|
-
}, { quotaId: _ } = d(), v = r(), y =
|
|
21
|
+
}, { quotaId: _ } = d(), v = r(), y = i(), { quota: b, isLoading: x, error: S, refetch: C } = s(_), { toggleQuota: w, isToggling: T } = c();
|
|
22
22
|
if (!y.canViewQuotas) return /* @__PURE__ */ f(e, { message: "You don't have permission to view quota details." });
|
|
23
23
|
if (x) return /* @__PURE__ */ p("div", {
|
|
24
24
|
className: "space-y-6 p-6",
|
|
@@ -34,7 +34,7 @@ var h = () => {
|
|
|
34
34
|
}), /* @__PURE__ */ f("div", { className: "h-64 bg-bg-sunken animate-pulse rounded" })]
|
|
35
35
|
})]
|
|
36
36
|
});
|
|
37
|
-
if (S &&
|
|
37
|
+
if (S && a(S)) return /* @__PURE__ */ f("div", {
|
|
38
38
|
className: "p-6",
|
|
39
39
|
children: /* @__PURE__ */ f(n, {
|
|
40
40
|
title: "Server Unavailable",
|
|
@@ -3,8 +3,8 @@ import { PageHeader as t } from "../../../shared/components/PageHeader.js";
|
|
|
3
3
|
import { ServerError as n } from "../../../shared/components/ServerError.js";
|
|
4
4
|
import { useBillingNavigate as r } from "../../../hooks/useBillingNavigate.js";
|
|
5
5
|
import "../hooks/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { useBillingPermissions as i } from "../../../hooks/useBillingPermissions.js";
|
|
7
|
+
import { isServerError as a } from "../../../shared/utils/error.js";
|
|
8
8
|
import "../../../shared/components/index.js";
|
|
9
9
|
import "../../../shared/utils/index.js";
|
|
10
10
|
import { useQuotaTemplate as o, useQuotaTemplateMutations as s } from "../hooks/useQuotaTemplates.js";
|
|
@@ -19,7 +19,7 @@ var g = () => {
|
|
|
19
19
|
let { t: g } = h(), _ = (e, t) => {
|
|
20
20
|
let n = g(e);
|
|
21
21
|
return n === e ? t : n;
|
|
22
|
-
}, { quotaId: v } = f(), y = r(), b =
|
|
22
|
+
}, { quotaId: v } = f(), y = r(), b = i(), { quota: x, isLoading: S, error: C, refetch: w } = o(v), { updateQuota: T, isUpdating: E } = s(), [D, O] = u(""), [k, A] = u(""), [j, M] = u(""), [N, P] = u("numeric"), [F, I] = u(""), [L, R] = u(""), [z, B] = u(!1), [V, H] = u(c.NEVER), [U, W] = u(!0), [G, K] = u(null), [q, J] = u(!1);
|
|
23
23
|
return l(() => {
|
|
24
24
|
if (x) {
|
|
25
25
|
O(x.name ?? ""), B(x.reusable ?? !1), H(x.resetPeriod ?? c.NEVER), W(x.isActive ?? !0);
|
|
@@ -39,7 +39,7 @@ var g = () => {
|
|
|
39
39
|
4
|
|
40
40
|
].map((e) => /* @__PURE__ */ p("div", { className: "h-16 bg-bg-sunken animate-pulse rounded" }, e))
|
|
41
41
|
})]
|
|
42
|
-
}) : C &&
|
|
42
|
+
}) : C && a(C) ? /* @__PURE__ */ p("div", {
|
|
43
43
|
className: "p-6",
|
|
44
44
|
children: /* @__PURE__ */ p(n, {
|
|
45
45
|
title: "Server Unavailable",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BillingHistoryTabId } from './historyTabs';
|
|
3
|
+
interface BillingHistoryTabsProps {
|
|
4
|
+
active: BillingHistoryTabId;
|
|
5
|
+
billingAccountId?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** Tab strip shared by Invoices, Payments, Credit history and Refunds (FluidGrids only). */
|
|
8
|
+
export declare const BillingHistoryTabs: FC<BillingHistoryTabsProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useBillingNavigate as e } from "../../hooks/useBillingNavigate.js";
|
|
2
|
+
import { getBillingHistoryTabs as t } from "./historyTabs.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
5
|
+
// src/billing/shared/components/BillingHistoryTabs.tsx
|
|
6
|
+
var i = ({ active: i, billingAccountId: a }) => {
|
|
7
|
+
let { t: o } = r(), s = e(), c = (e, t) => {
|
|
8
|
+
let n = o(e);
|
|
9
|
+
return n === e ? t : n;
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ n("nav", {
|
|
12
|
+
"aria-label": c("billing.history.label", "Billing history"),
|
|
13
|
+
className: "flex max-w-full flex-wrap items-center gap-1 rounded-card border border-border-subtle bg-bg-surface p-1",
|
|
14
|
+
children: t(a).map((e) => {
|
|
15
|
+
let t = e.id === i;
|
|
16
|
+
return /* @__PURE__ */ n("button", {
|
|
17
|
+
type: "button",
|
|
18
|
+
"aria-current": t ? "page" : void 0,
|
|
19
|
+
onClick: () => {
|
|
20
|
+
t || s(e.path);
|
|
21
|
+
},
|
|
22
|
+
className: `whitespace-nowrap rounded-button px-3 py-1.5 text-sm transition-colors ${t ? "bg-bg-sunken font-medium text-text-primary" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
|
|
23
|
+
children: c(e.labelKey, e.fallbackLabel)
|
|
24
|
+
}, e.id);
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export { i as BillingHistoryTabs };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=BillingHistoryTabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BillingHistoryTabs.js","names":["BillingHistoryTabs","useI18n","navigateTo","useBillingNavigate","tr","translated","t","key","fallback","getBillingHistoryTabs","billingAccountId","isActive","tab","active"],"sources":["../../../../src/billing/shared/components/BillingHistoryTabs.tsx"],"sourcesContent":["import { type FC } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\nimport { useBillingNavigate } from '../../hooks/useBillingNavigate';\nimport { getBillingHistoryTabs, type BillingHistoryTabId } from './historyTabs';\n\ninterface BillingHistoryTabsProps {\n active: BillingHistoryTabId;\n billingAccountId?: string | null;\n}\n\n/** Tab strip shared by Invoices, Payments, Credit history and Refunds (FluidGrids only). */\nexport const BillingHistoryTabs: FC<BillingHistoryTabsProps> = ({ active, billingAccountId }) => {\n const { t } = useI18n();\n const navigateTo = useBillingNavigate();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n\n return (\n <nav\n aria-label={tr('billing.history.label', 'Billing history')}\n className=\"flex max-w-full flex-wrap items-center gap-1 rounded-card border border-border-subtle bg-bg-surface p-1\"\n >\n {getBillingHistoryTabs(billingAccountId).map((tab) => {\n const isActive = tab.id === active;\n return (\n <button\n key={tab.id}\n type=\"button\"\n aria-current={isActive ? 'page' : undefined}\n onClick={() => {\n if (!isActive) navigateTo(tab.path);\n }}\n className={`whitespace-nowrap rounded-button px-3 py-1.5 text-sm transition-colors ${\n isActive\n ? 'bg-bg-sunken font-medium text-text-primary'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n >\n {tr(tab.labelKey, tab.fallbackLabel)}\n </button>\n );\n })}\n </nav>\n );\n};\n"],"mappings":";;;;;AAYA,IAAaA,KAAmD,EAAE,WAAQ,0BAAuB;CAC/F,IAAM,EAAE,SAAMC,EAAQ,GAChBC,IAAaC,EAAmB,GAChCC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAAMC,IAAWH;CACzC;CAEA,OACE,kBAAC,OAAD;EACE,cAAYD,EAAG,yBAAyB,iBAAiB;EACzD,WAAU;EAET,UAAAK,EAAsBC,CAAgB,CAAC,CAAC,KAAK,MAAQ;GACpD,IAAMC,IAAWC,EAAI,OAAOC;GAC5B,OACE,kBAAC,UAAD;IAEE,MAAK;IACL,gBAAcF,IAAW,SAAS,KAAA;IAClC,eAAe;KACb,AAAKA,KAAUT,EAAWU,EAAI,IAAI;IACpC;IACA,WAAW,0EACTD,IACI,+CACA;IAGL,UAAAP,EAAGQ,EAAI,UAAUA,EAAI,aAAa;GAC7B,GAbDA,EAAI,EAaH;EAEZ,CAAC;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Billing history (BOFF-11860, FluidGrids variant): invoices, payments, credit
|
|
3
|
+
* history and refunds answer one question, "what did I pay?", so the four pages
|
|
4
|
+
* share one tab strip. Each page keeps its own route and behaviour.
|
|
5
|
+
*/
|
|
6
|
+
export type BillingHistoryTabId = 'invoices' | 'payments' | 'credits' | 'refunds';
|
|
7
|
+
export interface BillingHistoryTabDef {
|
|
8
|
+
id: BillingHistoryTabId;
|
|
9
|
+
/** i18n key */
|
|
10
|
+
labelKey: string;
|
|
11
|
+
fallbackLabel: string;
|
|
12
|
+
/** Path relative to the billing base path. */
|
|
13
|
+
path: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The tabs to show. Payments and Credits history are per billing account, so
|
|
17
|
+
* they appear only once an account is known; Invoices and Refunds always do.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getBillingHistoryTabs(billingAccountId: string | null | undefined): BillingHistoryTabDef[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/billing/shared/components/historyTabs.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = [{
|
|
4
|
+
id: "invoices",
|
|
5
|
+
labelKey: "billing.history.invoices",
|
|
6
|
+
fallbackLabel: "Invoices",
|
|
7
|
+
path: "/invoices"
|
|
8
|
+
}];
|
|
9
|
+
if (e) {
|
|
10
|
+
let n = encodeURIComponent(e);
|
|
11
|
+
t.push({
|
|
12
|
+
id: "payments",
|
|
13
|
+
labelKey: "billing.history.payments",
|
|
14
|
+
fallbackLabel: "Payments",
|
|
15
|
+
path: `/transactions/${n}`
|
|
16
|
+
}, {
|
|
17
|
+
id: "credits",
|
|
18
|
+
labelKey: "billing.history.credits",
|
|
19
|
+
fallbackLabel: "Credit history",
|
|
20
|
+
path: `/creditTransactions/${n}`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return t.push({
|
|
24
|
+
id: "refunds",
|
|
25
|
+
labelKey: "billing.history.refunds",
|
|
26
|
+
fallbackLabel: "Refunds",
|
|
27
|
+
path: "/refunds"
|
|
28
|
+
}), t;
|
|
29
|
+
}
|
|
30
|
+
export { e as getBillingHistoryTabs };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=historyTabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historyTabs.js","names":["getBillingHistoryTabs","tabs","billingAccountId","id"],"sources":["../../../../src/billing/shared/components/historyTabs.ts"],"sourcesContent":["/**\n * Billing history (BOFF-11860, FluidGrids variant): invoices, payments, credit\n * history and refunds answer one question, \"what did I pay?\", so the four pages\n * share one tab strip. Each page keeps its own route and behaviour.\n */\n\nexport type BillingHistoryTabId = 'invoices' | 'payments' | 'credits' | 'refunds';\n\nexport interface BillingHistoryTabDef {\n id: BillingHistoryTabId;\n /** i18n key */\n labelKey: string;\n fallbackLabel: string;\n /** Path relative to the billing base path. */\n path: string;\n}\n\n/**\n * The tabs to show. Payments and Credits history are per billing account, so\n * they appear only once an account is known; Invoices and Refunds always do.\n */\nexport function getBillingHistoryTabs(\n billingAccountId: string | null | undefined\n): BillingHistoryTabDef[] {\n const tabs: BillingHistoryTabDef[] = [\n {\n id: 'invoices',\n labelKey: 'billing.history.invoices',\n fallbackLabel: 'Invoices',\n path: '/invoices',\n },\n ];\n if (billingAccountId) {\n const id = encodeURIComponent(billingAccountId);\n tabs.push(\n {\n id: 'payments',\n labelKey: 'billing.history.payments',\n fallbackLabel: 'Payments',\n path: `/transactions/${id}`,\n },\n {\n id: 'credits',\n labelKey: 'billing.history.credits',\n fallbackLabel: 'Credit history',\n path: `/creditTransactions/${id}`,\n }\n );\n }\n tabs.push({\n id: 'refunds',\n labelKey: 'billing.history.refunds',\n fallbackLabel: 'Refunds',\n path: '/refunds',\n });\n return tabs;\n}\n"],"mappings":";AAqBA,SAAgBA,EACd,GACwB;CACxB,IAAMC,IAA+B,CACnC;EACE,IAAI;EACJ,UAAU;EACV,eAAe;EACf,MAAM;CACR,CACF;CACA,IAAIC,GAAkB;EACpB,IAAMC,IAAK,mBAAmBD,CAAgB;EAC9C,EAAK,KACH;GACE,IAAI;GACJ,UAAU;GACV,eAAe;GACf,MAAM,iBAAiBC;EACzB,GACA;GACE,IAAI;GACJ,UAAU;GACV,eAAe;GACf,MAAM,uBAAuBA;EAC/B,CACF;CACF;CAOA,OANAF,EAAK,KAAK;EACR,IAAI;EACJ,UAAU;EACV,eAAe;EACf,MAAM;CACR,CAAC,GACMA;AACT"}
|
|
@@ -12,3 +12,4 @@ export { ActorIdentity } from './ActorIdentity';
|
|
|
12
12
|
export { PushPermissionNudge } from './PushPermissionNudge';
|
|
13
13
|
export { MoneyActionDialog, type MoneyActionDetail } from './MoneyActionDialog';
|
|
14
14
|
export { HeaderActions } from './HeaderActions';
|
|
15
|
+
export { BillingHistoryTabs } from './BillingHistoryTabs';
|
|
@@ -9,4 +9,5 @@ import { ActorIdentity as o } from "./ActorIdentity.js";
|
|
|
9
9
|
import "./PushPermissionNudge.js";
|
|
10
10
|
import { MoneyActionDialog as s } from "./MoneyActionDialog.js";
|
|
11
11
|
import { HeaderActions as c } from "./HeaderActions.js";
|
|
12
|
-
|
|
12
|
+
import { BillingHistoryTabs as l } from "./BillingHistoryTabs.js";
|
|
13
|
+
export { e as AccessDenied, o as ActorIdentity, l as BillingHistoryTabs, a as CurrencyPriceOverridesEditor, r as EmptyState, c as HeaderActions, s as MoneyActionDialog, t as PageHeader, i as ServerError, n as StatCard };
|