@burdenoff/microfe-product 2026.512.2 → 2026.513.2
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/node_modules/zod/v4/classic/errors.js +1 -1
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -1
- package/dist/node_modules/zod/v4/classic/schemas.js +176 -439
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -1
- package/dist/node_modules/zod/v4/core/api.js +6 -6
- package/dist/node_modules/zod/v4/core/api.js.map +1 -1
- package/dist/node_modules/zod/v4/core/core.js +8 -11
- package/dist/node_modules/zod/v4/core/core.js.map +1 -1
- package/dist/node_modules/zod/v4/core/errors.js +9 -12
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -1
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +5 -7
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -1
- package/dist/node_modules/zod/v4/core/parse.js +7 -28
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -1
- package/dist/node_modules/zod/v4/core/regexes.js +11 -11
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -1
- package/dist/node_modules/zod/v4/core/schemas.js +142 -206
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -1
- package/dist/node_modules/zod/v4/core/to-json-schema.js +5 -7
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -1
- package/dist/node_modules/zod/v4/core/util.js +71 -70
- package/dist/node_modules/zod/v4/core/util.js.map +1 -1
- package/dist/node_modules/zod/v4/core/versions.js +2 -2
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -1
- package/dist/product-management/ProductManagementRoot.d.ts.map +1 -1
- package/dist/product-management/ProductManagementRoot.js +22 -17
- package/dist/product-management/ProductManagementRoot.js.map +1 -1
- package/dist/product-management/modules/products/components/ProductPlans.js +1 -1
- package/dist/product-management/modules/products/components/ProductPlans.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,55 +5,60 @@ import { useEffect as r } from "react";
|
|
|
5
5
|
import { FileText as i, Flag as a, Package as o } from "lucide-react";
|
|
6
6
|
import { jsx as s } from "react/jsx-runtime";
|
|
7
7
|
import { FeatureFlagProvider as c } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
8
|
+
import { PermissionProvider as l } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
8
9
|
//#region src/product-management/ProductManagementRoot.tsx
|
|
9
|
-
var
|
|
10
|
-
let { registerNavItems:
|
|
10
|
+
var u = (u) => {
|
|
11
|
+
let { registerNavItems: d, registerFooterItems: f, basePath: p = "/globalconsole", tenantId: m } = u, h = e(), g = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
|
|
11
12
|
return r(() => {
|
|
12
|
-
if (
|
|
13
|
+
if (d) return d([
|
|
13
14
|
{
|
|
14
15
|
id: "globalconsole-products",
|
|
15
|
-
label:
|
|
16
|
-
path:
|
|
16
|
+
label: h("products.navProducts", "Products"),
|
|
17
|
+
path: g(p, "/products"),
|
|
17
18
|
icon: /* @__PURE__ */ s(o, { size: 20 }),
|
|
18
19
|
order: 50,
|
|
19
20
|
group: "globalconsole"
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
23
|
id: "globalconsole-content-pages",
|
|
23
|
-
label:
|
|
24
|
-
path:
|
|
24
|
+
label: h("contentPages.navContentPages", "Content Pages"),
|
|
25
|
+
path: g(p, "/products/content-pages"),
|
|
25
26
|
icon: /* @__PURE__ */ s(i, { size: 20 }),
|
|
26
27
|
order: 55,
|
|
27
28
|
group: "globalconsole"
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
31
|
id: "globalconsole-feature-flags",
|
|
31
|
-
label:
|
|
32
|
-
path:
|
|
32
|
+
label: h("featureFlags.navFeatureFlags", "Feature Flags"),
|
|
33
|
+
path: g(p, "/products/feature-flags"),
|
|
33
34
|
icon: /* @__PURE__ */ s(a, { size: 20 }),
|
|
34
35
|
order: 60,
|
|
35
36
|
group: "globalconsole"
|
|
36
37
|
}
|
|
37
38
|
]);
|
|
38
|
-
}, [
|
|
39
|
-
if (
|
|
39
|
+
}, [d, p]), r(() => {
|
|
40
|
+
if (f) return f([{
|
|
40
41
|
id: "product-management-version",
|
|
41
|
-
label:
|
|
42
|
+
label: h("products.footerVersion", "Product Management v0.1.0"),
|
|
42
43
|
type: "status",
|
|
43
44
|
order: 50,
|
|
44
45
|
section: "left"
|
|
45
46
|
}]);
|
|
46
|
-
}, [
|
|
47
|
+
}, [f]), /* @__PURE__ */ s(c, {
|
|
47
48
|
workspaceId: null,
|
|
48
49
|
gateway: "global",
|
|
49
50
|
defaultEnabled: !0,
|
|
50
|
-
children: /* @__PURE__ */ s(
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
children: /* @__PURE__ */ s(l, {
|
|
52
|
+
scopeId: m ?? null,
|
|
53
|
+
gateway: "global",
|
|
54
|
+
children: /* @__PURE__ */ s(t, {
|
|
55
|
+
...u,
|
|
56
|
+
children: /* @__PURE__ */ s(n, {})
|
|
57
|
+
})
|
|
53
58
|
})
|
|
54
59
|
});
|
|
55
60
|
};
|
|
56
61
|
//#endregion
|
|
57
|
-
export {
|
|
62
|
+
export { u as ProductManagementRoot };
|
|
58
63
|
|
|
59
64
|
//# sourceMappingURL=ProductManagementRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductManagementRoot.js","names":[],"sources":["../../src/product-management/ProductManagementRoot.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect } from 'react';\nimport { Flag, Package, FileText } from 'lucide-react';\nimport { useTr } from './shared/hooks/useTr';\nimport { ProductConsoleProvider } from './providers/ProductConsoleProvider';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport type { NavItem, ProductManagementRootProps } from './types';\nimport { ProductManagementRoutes } from './ProductManagementRoutes';\n\nexport const ProductManagementRoot: FC<ProductManagementRootProps> = (props) => {\n const {
|
|
1
|
+
{"version":3,"file":"ProductManagementRoot.js","names":[],"sources":["../../src/product-management/ProductManagementRoot.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect } from 'react';\nimport { Flag, Package, FileText } from 'lucide-react';\nimport { useTr } from './shared/hooks/useTr';\nimport { ProductConsoleProvider } from './providers/ProductConsoleProvider';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { PermissionProvider } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { NavItem, ProductManagementRootProps } from './types';\nimport { ProductManagementRoutes } from './ProductManagementRoutes';\n\nexport const ProductManagementRoot: FC<ProductManagementRootProps> = (props) => {\n const {\n registerNavItems,\n registerFooterItems,\n basePath = '/globalconsole',\n tenantId,\n } = props;\n const tr = useTr();\n\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n {\n id: 'globalconsole-products',\n label: tr('products.navProducts', 'Products'),\n path: joinPath(basePath, '/products'),\n icon: <Package size={20} />,\n order: 50,\n group: 'globalconsole',\n },\n {\n id: 'globalconsole-content-pages',\n label: tr('contentPages.navContentPages', 'Content Pages'),\n path: joinPath(basePath, '/products/content-pages'),\n icon: <FileText size={20} />,\n order: 55,\n group: 'globalconsole',\n },\n {\n id: 'globalconsole-feature-flags',\n label: tr('featureFlags.navFeatureFlags', 'Feature Flags'),\n path: joinPath(basePath, '/products/feature-flags'),\n icon: <Flag size={20} />,\n order: 60,\n group: 'globalconsole',\n },\n ];\n\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath]);\n\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'product-management-version',\n label: tr('products.footerVersion', 'Product Management v0.1.0'),\n type: 'status' as const,\n order: 50,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems]);\n\n return (\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <PermissionProvider scopeId={tenantId ?? null} gateway=\"global\">\n <ProductConsoleProvider {...props}>\n <ProductManagementRoutes />\n </ProductConsoleProvider>\n </PermissionProvider>\n </FeatureFlagProvider>\n );\n};\n"],"mappings":";;;;;;;;;AAUA,IAAa,KAAyD,MAAU;CAC9E,IAAM,EACJ,qBACA,wBACA,cAAW,kBACX,gBACE,GACE,IAAK,GAAO,EAEZ,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;AAuDtD,QAnDA,QAAgB;AACT,QA8BL,QADgB,EAAiB;GA1B/B;IACE,IAAI;IACJ,OAAO,EAAG,wBAAwB,WAAW;IAC7C,MAAM,EAAS,GAAU,YAAY;IACrC,MAAM,kBAAC,GAAD,EAAS,MAAM,IAAM,CAAA;IAC3B,OAAO;IACP,OAAO;IACR;GACD;IACE,IAAI;IACJ,OAAO,EAAG,gCAAgC,gBAAgB;IAC1D,MAAM,EAAS,GAAU,0BAA0B;IACnD,MAAM,kBAAC,GAAD,EAAU,MAAM,IAAM,CAAA;IAC5B,OAAO;IACP,OAAO;IACR;GACD;IACE,IAAI;IACJ,OAAO,EAAG,gCAAgC,gBAAgB;IAC1D,MAAM,EAAS,GAAU,0BAA0B;IACnD,MAAM,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA;IACxB,OAAO;IACP,OAAO;IACR;GAG8B,CAC1B;IACN,CAAC,GAAkB,EAAS,CAAC,EAEhC,QAAgB;AACT,QAaL,QADgB,EAAoB,CATlC;GACE,IAAI;GACJ,OAAO,EAAG,0BAA0B,4BAA4B;GAChE,MAAM;GACN,OAAO;GACP,SAAS;GACV,CAGiC,CAC7B;IACN,CAAC,EAAoB,CAAC,EAGvB,kBAAC,GAAD;EAAqB,aAAa;EAAM,SAAQ;EAAS,gBAAgB;YACvE,kBAAC,GAAD;GAAoB,SAAS,KAAY;GAAM,SAAQ;aACrD,kBAAC,GAAD;IAAwB,GAAI;cAC1B,kBAAC,GAAD,EAA2B,CAAA;IACJ,CAAA;GACN,CAAA;EACD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductPlans.js","names":[],"sources":["../../../../../src/product-management/modules/products/components/ProductPlans.tsx"],"sourcesContent":["/**\n * Product Plans Management Component\n *\n * Displays and manages pricing plans for a product.\n * Fetches plans from the billing service via the global gateway.\n */\nimport { useState, useEffect, useCallback } from 'react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql/fetch';\nimport {\n Plus,\n Edit,\n ToggleLeft,\n ToggleRight,\n DollarSign,\n Loader2,\n List,\n Check,\n} from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ninterface PlanQuota {\n id: string;\n quotaId: string;\n quota: {\n id: string;\n name: string;\n limits: Record<string, unknown> | null;\n } | null;\n}\n\ninterface Plan {\n id: string;\n name: string;\n price: number;\n currency: string;\n duration: 'monthly' | 'yearly';\n isActive: boolean;\n productID: string | null;\n features: PlanQuota[];\n createdAt: string;\n}\n\ninterface PlanFormData {\n name: string;\n price: string;\n currency: string;\n duration: 'monthly' | 'yearly';\n quotas: Array<{ quotaId: string; quantity: number }>;\n}\n\ninterface Quota {\n id: string;\n name: string;\n limits: Record<string, unknown> | null;\n}\n\n// ============================================================================\n// GraphQL Operations\n// ============================================================================\n\nconst GET_ALL_PLANS = `\n query GetAllPlans {\n getAllPlans {\n id\n name\n price\n currency\n duration\n isActive\n productID\n features {\n id\n quotaId\n quota {\n id\n name\n limits\n }\n }\n createdAt\n }\n }\n`;\n\nconst GET_ALL_QUOTAS = `\n query GetAllQuotas {\n getAllQuotas {\n id\n name\n limits\n }\n }\n`;\n\nconst CREATE_QUOTA = `\n mutation CreateQuota($input: createQuotaInput!) {\n createQuota(input: $input)\n }\n`;\n\nconst CREATE_PLAN = `\n mutation CreatePlan($input: createPlanInput!) {\n createPlan(input: $input)\n }\n`;\n\nconst UPDATE_PLAN = `\n mutation UpdatePlan($input: updatePlanInput!) {\n updatePlan(input: $input)\n }\n`;\n\nconst TOGGLE_PLAN = `\n mutation TogglePlan($planID: ID!, $status: Boolean!) {\n togglePlan(planID: $planID, status: $status)\n }\n`;\n\n// ============================================================================\n// Component\n// ============================================================================\n\ninterface ProductPlansProps {\n productId: string;\n productName: string;\n readOnly?: boolean;\n}\n\nexport function ProductPlans({\n productId,\n productName: _productName,\n readOnly = false,\n}: ProductPlansProps) {\n const tr = useTr();\n\n const [plans, setPlans] = useState<Plan[]>([]);\n const [availableQuotas, setAvailableQuotas] = useState<Quota[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [showForm, setShowForm] = useState(false);\n const [editingPlan, setEditingPlan] = useState<Plan | null>(null);\n const [submitting, setSubmitting] = useState(false);\n const [showQuotaForm, setShowQuotaForm] = useState(false);\n const [newQuotaName, setNewQuotaName] = useState('');\n const [formData, setFormData] = useState<PlanFormData>({\n name: '',\n price: '',\n currency: 'USD',\n duration: 'monthly',\n quotas: [],\n });\n\n const fetchGraphQL = useCallback(\n async <T,>(query: string, variables?: Record<string, unknown>): Promise<T | null> => {\n const result = await graphqlFetch<{ data?: T; errors?: Array<{ message: string }> }>({\n gateway: 'global',\n query,\n variables,\n });\n if (result.errors?.length) throw new Error(result.errors[0].message);\n return result.data?.data ?? null;\n },\n []\n );\n\n const fetchPlans = useCallback(async () => {\n try {\n setLoading(true);\n const [plansResult, quotasResult] = await Promise.all([\n fetchGraphQL<{ getAllPlans: Plan[] }>(GET_ALL_PLANS),\n fetchGraphQL<{ getAllQuotas: Quota[] }>(GET_ALL_QUOTAS),\n ]);\n const allPlans = plansResult?.getAllPlans || [];\n setPlans(allPlans.filter((p: Plan) => p.productID === productId));\n setAvailableQuotas(quotasResult?.getAllQuotas || []);\n setError(null);\n } catch (err) {\n setError(tr('products.failedToLoadPlans', 'Failed to load plans'));\n console.error('Failed to fetch plans:', err);\n } finally {\n setLoading(false);\n }\n }, [productId, fetchGraphQL]);\n\n useEffect(() => {\n fetchPlans();\n }, [fetchPlans]);\n\n const resetForm = () => {\n setFormData({ name: '', price: '', currency: 'USD', duration: 'monthly', quotas: [] });\n setEditingPlan(null);\n setShowForm(false);\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setSubmitting(true);\n\n try {\n if (editingPlan) {\n await fetchGraphQL(UPDATE_PLAN, {\n input: {\n id: editingPlan.id,\n name: formData.name,\n price: parseFloat(formData.price),\n currency: formData.currency,\n duration: formData.duration,\n quotas: formData.quotas,\n },\n });\n } else {\n await fetchGraphQL(CREATE_PLAN, {\n input: {\n name: formData.name,\n price: parseFloat(formData.price),\n currency: formData.currency,\n duration: formData.duration,\n productId: productId,\n quotas: formData.quotas,\n },\n });\n }\n\n resetForm();\n await fetchPlans();\n } catch (err) {\n console.error('Failed to save plan:', err);\n setError(tr('products.failedToSavePlan', 'Failed to save plan'));\n } finally {\n setSubmitting(false);\n }\n };\n\n const handleToggle = async (plan: Plan) => {\n try {\n await fetchGraphQL(TOGGLE_PLAN, { planID: plan.id, status: !plan.isActive });\n await fetchPlans();\n } catch (err) {\n console.error('Failed to toggle plan:', err);\n }\n };\n\n const handleEdit = (plan: Plan) => {\n setEditingPlan(plan);\n setFormData({\n name: plan.name,\n price: plan.price.toString(),\n currency: plan.currency,\n duration: plan.duration,\n quotas: (plan.features || []).map((f) => ({\n quotaId: f.quotaId,\n quantity: 1,\n })),\n });\n setShowForm(true);\n };\n\n const handleCreateQuota = async () => {\n if (!newQuotaName.trim()) return;\n try {\n setSubmitting(true);\n await fetchGraphQL(CREATE_QUOTA, {\n input: {\n name: newQuotaName.trim(),\n quotaType: 'PRODUCT_SPECIFIC',\n limits: {},\n reusable: true,\n },\n });\n setNewQuotaName('');\n setShowQuotaForm(false);\n await fetchPlans(); // refreshes quotas too\n } catch (err) {\n console.error('Failed to create quota:', err);\n setError(tr('products.failedToCreateFeature', 'Failed to create feature'));\n } finally {\n setSubmitting(false);\n }\n };\n\n const monthlyPlans = plans.filter((p) => p.duration === 'monthly');\n const yearlyPlans = plans.filter((p) => p.duration === 'yearly');\n\n return (\n <div className=\"bg-surface border border-default rounded-lg p-6 shadow-[var(--shadow-elevation-1)] transition-all duration-200 hover:shadow-[var(--shadow-elevation-2)] lg:col-span-2\">\n <div className=\"flex items-center justify-between mb-4\">\n <h2 className=\"text-lg font-semibold text-text-primary flex items-center gap-2\">\n <DollarSign size={18} />\n {tr('products.pricingPlans', 'Pricing Plans')}\n </h2>\n {!readOnly && (\n <button\n onClick={() => {\n resetForm();\n setShowForm(!showForm);\n }}\n className=\"\n inline-flex items-center gap-1.5 px-3 py-1.5\n bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)]\n rounded-lg text-sm font-medium\n hover:opacity-90 transition-all duration-200\n \"\n >\n <Plus size={14} />\n {tr('products.addPlan', 'Add Plan')}\n </button>\n )}\n </div>\n\n {/* Create/Edit Form */}\n {showForm && !readOnly && (\n <form\n onSubmit={handleSubmit}\n className=\"mb-6 p-4 bg-muted rounded-lg border border-default\"\n >\n <h3 className=\"text-sm font-semibold text-text-primary mb-3\">\n {editingPlan\n ? tr('products.editPlan', 'Edit Plan')\n : tr('products.createNewPlan', 'Create New Plan')}\n </h3>\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-3\">\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.planName', 'Name')} *\n </label>\n <input\n type=\"text\"\n value={formData.name}\n onChange={(e) => setFormData({ ...formData, name: e.target.value })}\n placeholder=\"e.g. Basic\"\n required\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary\"\n />\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.planPrice', 'Price')} *\n </label>\n <input\n type=\"number\"\n step=\"0.01\"\n min=\"0\"\n value={formData.price}\n onChange={(e) => setFormData({ ...formData, price: e.target.value })}\n placeholder=\"9.99\"\n required\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary\"\n />\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.planDuration', 'Duration')} *\n </label>\n <select\n value={formData.duration}\n onChange={(e) =>\n setFormData({ ...formData, duration: e.target.value as 'monthly' | 'yearly' })\n }\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary\"\n >\n <option value=\"monthly\">{tr('products.monthly', 'Monthly')}</option>\n <option value=\"yearly\">{tr('products.yearly', 'Yearly')}</option>\n </select>\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.currency', 'Currency')}\n </label>\n <select\n value={formData.currency}\n onChange={(e) => setFormData({ ...formData, currency: e.target.value })}\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface 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 </select>\n </div>\n </div>\n {/* Quotas/Features */}\n <div className=\"mt-3\">\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n <List size={12} className=\"inline mr-1\" />\n {tr('products.featuresQuotas', 'Features / Quotas')}\n </label>\n {availableQuotas.length > 0 ? (\n <>\n <div className=\"space-y-1.5 max-h-32 overflow-y-auto\">\n {availableQuotas.map((quota) => {\n const isSelected = formData.quotas.some((q) => q.quotaId === quota.id);\n return (\n <label\n key={quota.id}\n className=\"flex items-center gap-2 text-xs text-text-primary cursor-pointer hover:bg-muted/50 px-2 py-1 rounded\"\n >\n <input\n type=\"checkbox\"\n checked={isSelected}\n onChange={(e) => {\n if (e.target.checked) {\n setFormData({\n ...formData,\n quotas: [...formData.quotas, { quotaId: quota.id, quantity: 1 }],\n });\n } else {\n setFormData({\n ...formData,\n quotas: formData.quotas.filter((q) => q.quotaId !== quota.id),\n });\n }\n }}\n className=\"rounded border-default\"\n />\n {quota.name}\n </label>\n );\n })}\n </div>\n <div className=\"flex items-center gap-2 mt-2\">\n <p className=\"text-xs text-text-secondary\">\n {formData.quotas.length}{' '}\n {tr('products.featuresSelected', 'feature(s) selected')}\n </p>\n <span className=\"text-xs text-text-secondary\">|</span>\n {!showQuotaForm ? (\n <button\n type=\"button\"\n onClick={() => setShowQuotaForm(true)}\n className=\"text-xs text-[var(--color-action-primary-bg)] hover:underline\"\n >\n {tr('products.createNewFeature', '+ Create new feature')}\n </button>\n ) : (\n <div className=\"flex items-center gap-1.5\">\n <input\n type=\"text\"\n value={newQuotaName}\n onChange={(e) => setNewQuotaName(e.target.value)}\n placeholder={tr('products.featureNamePlaceholder', 'Feature name')}\n className=\"px-2 py-1 text-xs rounded border border-default bg-surface text-text-primary w-36\"\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n handleCreateQuota();\n }\n }}\n />\n <button\n type=\"button\"\n onClick={handleCreateQuota}\n disabled={submitting || !newQuotaName.trim()}\n className=\"px-2 py-1 text-xs bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)] rounded hover:opacity-90 disabled:opacity-50\"\n >\n {tr('productCommon.add', 'Add')}\n </button>\n <button\n type=\"button\"\n onClick={() => {\n setShowQuotaForm(false);\n setNewQuotaName('');\n }}\n className=\"px-1.5 py-1 text-xs text-text-secondary hover:text-text-primary\"\n >\n {tr('productCommon.cancel', 'Cancel')}\n </button>\n </div>\n )}\n </div>\n </>\n ) : (\n <div className=\"text-xs text-text-secondary\">\n {tr('products.noFeaturesCreated', 'No features created yet.')}{' '}\n {!showQuotaForm ? (\n <button\n type=\"button\"\n onClick={() => setShowQuotaForm(true)}\n className=\"text-[var(--color-action-primary-bg)] hover:underline\"\n >\n {tr('products.createYourFirstFeature', 'Create your first feature')}\n </button>\n ) : (\n <div className=\"flex items-center gap-1.5 mt-1.5\">\n <input\n type=\"text\"\n value={newQuotaName}\n onChange={(e) => setNewQuotaName(e.target.value)}\n placeholder=\"Feature name\"\n className=\"px-2 py-1 text-xs rounded border border-default bg-surface text-text-primary w-36\"\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n handleCreateQuota();\n }\n }}\n />\n <button\n type=\"button\"\n onClick={handleCreateQuota}\n disabled={submitting || !newQuotaName.trim()}\n className=\"px-2 py-1 text-xs bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)] rounded hover:opacity-90 disabled:opacity-50\"\n >\n Add\n </button>\n <button\n type=\"button\"\n onClick={() => {\n setShowQuotaForm(false);\n setNewQuotaName('');\n }}\n className=\"px-1.5 py-1 text-xs text-text-secondary hover:text-text-primary\"\n >\n Cancel\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n\n <div className=\"flex gap-2 mt-3\">\n <button\n type=\"submit\"\n disabled={submitting}\n className=\"\n inline-flex items-center gap-1.5 px-4 py-2\n bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)]\n rounded-md text-sm font-medium\n hover:opacity-90 transition-all duration-200\n disabled:opacity-50\n \"\n >\n {submitting && <Loader2 size={14} className=\"animate-spin\" />}\n {editingPlan\n ? tr('products.updatePlan', 'Update Plan')\n : tr('products.createPlan', 'Create Plan')}\n </button>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"px-4 py-2 text-sm text-text-secondary hover:text-text-primary transition-colors\"\n >\n {tr('productCommon.cancel', 'Cancel')}\n </button>\n </div>\n </form>\n )}\n\n {/* Error */}\n {error && (\n <div className=\"mb-4 p-3 bg-[var(--color-status-error-subtle)] border border-[var(--color-status-error-border)] rounded-lg text-sm text-[var(--color-status-error)]\">\n {error}\n </div>\n )}\n\n {/* Loading */}\n {loading ? (\n <div className=\"flex items-center justify-center py-8\">\n <Loader2 size={20} className=\"animate-spin text-text-secondary\" />\n <span className=\"ml-2 text-sm text-text-secondary\">\n {tr('products.loadingPlans', 'Loading plans...')}\n </span>\n </div>\n ) : plans.length === 0 ? (\n <div className=\"text-center py-8\">\n <DollarSign size={32} className=\"mx-auto mb-2 text-text-secondary opacity-50\" />\n <p className=\"text-sm text-text-secondary\">\n {tr('products.noPricingPlans', 'No pricing plans yet')}\n </p>\n <p className=\"text-xs text-text-secondary mt-1\">\n {tr('products.clickAddPlan', 'Click \"Add Plan\" to create your first plan')}\n </p>\n </div>\n ) : (\n <div className=\"space-y-6\">\n {[\n { label: tr('products.monthlyPlans', 'Monthly Plans'), plans: monthlyPlans },\n { label: tr('products.yearlyPlans', 'Yearly Plans'), plans: yearlyPlans },\n ]\n .filter((g) => g.plans.length > 0)\n .map((group) => (\n <div key={group.label}>\n <h3 className=\"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-3\">\n {group.label}\n </h3>\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-4\">\n {group.plans\n .sort((a, b) => a.price - b.price)\n .map((plan) => {\n const currencySymbol =\n plan.currency === 'USD'\n ? '$'\n : plan.currency === 'EUR'\n ? '\\u20AC'\n : plan.currency === 'GBP'\n ? '\\u00A3'\n : '\\u20B9';\n const isPopular =\n plan.name.toLowerCase().includes('professional') ||\n plan.name.toLowerCase().includes('pro');\n return (\n <div\n key={plan.id}\n className={`\n relative rounded-xl border p-5 transition-all duration-200\n ${plan.isActive ? 'border-default bg-surface hover:shadow-md' : 'border-default bg-muted/30 opacity-60'}\n ${isPopular ? 'border-[var(--color-action-primary-bg)] ring-1 ring-[var(--color-action-primary-bg)]/20' : ''}\n `}\n >\n {isPopular && (\n <span className=\"absolute -top-2.5 left-1/2 -translate-x-1/2 px-3 py-0.5 text-xs font-semibold bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)] rounded-full\">\n {tr('products.popular', 'Popular')}\n </span>\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between mb-3\">\n <div>\n <h4 className=\"text-base font-semibold text-text-primary\">\n {plan.name}\n </h4>\n <span\n className={`inline-flex items-center px-1.5 py-0.5 text-xs font-medium rounded-full mt-1 ${\n plan.isActive\n ? 'bg-[var(--color-status-success-subtle)] text-[var(--color-status-success)]'\n : 'bg-muted text-text-secondary'\n }`}\n >\n {plan.isActive\n ? tr('products.statusActive', 'Active')\n : tr('products.statusInactive', 'Inactive')}\n </span>\n </div>\n {!readOnly && (\n <div className=\"flex items-center gap-0.5\">\n <button\n onClick={() => handleToggle(plan)}\n title={\n plan.isActive\n ? tr('products.deactivate', 'Deactivate')\n : tr('products.activate', 'Activate')\n }\n className=\"p-1.5 rounded-lg hover:bg-muted transition-colors text-text-secondary hover:text-text-primary\"\n >\n {plan.isActive ? (\n <ToggleRight\n size={16}\n className=\"text-[var(--color-status-success)]\"\n />\n ) : (\n <ToggleLeft size={16} />\n )}\n </button>\n <button\n onClick={() => handleEdit(plan)}\n title={tr('products.edit', 'Edit')}\n className=\"p-1.5 rounded-lg hover:bg-muted transition-colors text-text-secondary hover:text-text-primary\"\n >\n <Edit size={14} />\n </button>\n </div>\n )}\n </div>\n\n {/* Price */}\n <div className=\"mb-4\">\n <span className=\"text-3xl font-bold text-text-primary\">\n {currencySymbol}\n {plan.price}\n </span>\n <span className=\"text-sm text-text-secondary ml-1\">\n /{plan.duration === 'monthly' ? 'month' : 'year'}\n </span>\n </div>\n\n {/* Features */}\n {plan.features && plan.features.length > 0 ? (\n <div className=\"space-y-2 border-t border-default pt-3\">\n {plan.features.map((f) => (\n <div\n key={f.id}\n className=\"flex items-center gap-2 text-sm text-text-primary\"\n >\n <Check\n size={14}\n className=\"text-[var(--color-status-success)] flex-shrink-0\"\n />\n <span>{f.quota?.name || f.quotaId}</span>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"border-t border-default pt-3\">\n <p className=\"text-xs text-text-secondary italic\">\n {tr('products.noFeaturesAssigned', 'No features assigned')}\n </p>\n </div>\n )}\n </div>\n );\n })}\n </div>\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":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AD;UAEE,WAAU;oBAFZ,CAIE,kBAAC,GAAD;WACE,MAAM;WACN,WAAU;WACV,CAAA,EACF,kBAAC,QAAD,EAAA,UAAO,EAAE,OAAO,QAAQ,EAAE,SAAe,CAAA,CACrC;YARC,EAAE,GAQH,CACN;SACE,CAAA,GAEN,kBAAC,OAAD;SAAK,WAAU;mBACb,kBAAC,KAAD;UAAG,WAAU;oBACV,EAAG,+BAA+B,uBAAuB;UACxD,CAAA;SACA,CAAA;QAEJ;SAhGC,EAAK,GAgGN;OAER;KACA,CAAA,CACF,EAAA,EAzHI,EAAM,MAyHV,CACN;IACA,CAAA;GAEJ"}
|
|
1
|
+
{"version":3,"file":"ProductPlans.js","names":[],"sources":["../../../../../src/product-management/modules/products/components/ProductPlans.tsx"],"sourcesContent":["/**\n * Product Plans Management Component\n *\n * Displays and manages pricing plans for a product.\n * Fetches plans from the billing service via the global gateway.\n */\nimport { useState, useEffect, useCallback } from 'react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql/fetch';\nimport {\n Plus,\n Edit,\n ToggleLeft,\n ToggleRight,\n DollarSign,\n Loader2,\n List,\n Check,\n} from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ninterface PlanQuota {\n id: string;\n quotaId: string;\n quota: {\n id: string;\n name: string;\n limits: Record<string, unknown> | null;\n } | null;\n}\n\ninterface Plan {\n id: string;\n name: string;\n price: number;\n currency: string;\n duration: 'monthly' | 'yearly';\n isActive: boolean;\n productID: string | null;\n features: PlanQuota[];\n createdAt: string;\n}\n\ninterface PlanFormData {\n name: string;\n price: string;\n currency: string;\n duration: 'monthly' | 'yearly';\n quotas: Array<{ quotaId: string; quantity: number }>;\n}\n\ninterface Quota {\n id: string;\n name: string;\n limits: Record<string, unknown> | null;\n}\n\n// ============================================================================\n// GraphQL Operations\n// ============================================================================\n\nconst GET_ALL_PLANS = `\n query GetAllPlans {\n getAllPlans {\n id\n name\n price\n currency\n duration\n isActive\n productID\n features {\n id\n quotaId\n quota {\n id\n name\n limits\n }\n }\n createdAt\n }\n }\n`;\n\nconst GET_ALL_QUOTAS = `\n query GetAllQuotas {\n getAllQuotas {\n id\n name\n limits\n }\n }\n`;\n\nconst CREATE_QUOTA = `\n mutation CreateQuota($input: createQuotaInput!) {\n createQuota(input: $input)\n }\n`;\n\nconst CREATE_PLAN = `\n mutation CreatePlan($input: createPlanInput!) {\n createPlan(input: $input)\n }\n`;\n\nconst UPDATE_PLAN = `\n mutation UpdatePlan($input: updatePlanInput!) {\n updatePlan(input: $input)\n }\n`;\n\nconst TOGGLE_PLAN = `\n mutation TogglePlan($planID: ID!, $status: Boolean!) {\n togglePlan(planID: $planID, status: $status)\n }\n`;\n\n// ============================================================================\n// Component\n// ============================================================================\n\ninterface ProductPlansProps {\n productId: string;\n productName: string;\n readOnly?: boolean;\n}\n\nexport function ProductPlans({\n productId,\n productName: _productName,\n readOnly = false,\n}: ProductPlansProps) {\n const tr = useTr();\n\n const [plans, setPlans] = useState<Plan[]>([]);\n const [availableQuotas, setAvailableQuotas] = useState<Quota[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [showForm, setShowForm] = useState(false);\n const [editingPlan, setEditingPlan] = useState<Plan | null>(null);\n const [submitting, setSubmitting] = useState(false);\n const [showQuotaForm, setShowQuotaForm] = useState(false);\n const [newQuotaName, setNewQuotaName] = useState('');\n const [formData, setFormData] = useState<PlanFormData>({\n name: '',\n price: '',\n currency: 'USD',\n duration: 'monthly',\n quotas: [],\n });\n\n const fetchGraphQL = useCallback(\n async <T,>(query: string, variables?: Record<string, unknown>): Promise<T | null> => {\n const result = await graphqlFetch<T>({\n gateway: 'global',\n query,\n variables,\n });\n if (result.errors?.length) throw new Error(result.errors[0].message);\n return result.data ?? null;\n },\n []\n );\n\n const fetchPlans = useCallback(async () => {\n try {\n setLoading(true);\n const [plansResult, quotasResult] = await Promise.all([\n fetchGraphQL<{ getAllPlans: Plan[] }>(GET_ALL_PLANS),\n fetchGraphQL<{ getAllQuotas: Quota[] }>(GET_ALL_QUOTAS),\n ]);\n const allPlans = plansResult?.getAllPlans || [];\n setPlans(allPlans.filter((p: Plan) => p.productID === productId));\n setAvailableQuotas(quotasResult?.getAllQuotas || []);\n setError(null);\n } catch (err) {\n setError(tr('products.failedToLoadPlans', 'Failed to load plans'));\n console.error('Failed to fetch plans:', err);\n } finally {\n setLoading(false);\n }\n }, [productId, fetchGraphQL]);\n\n useEffect(() => {\n fetchPlans();\n }, [fetchPlans]);\n\n const resetForm = () => {\n setFormData({ name: '', price: '', currency: 'USD', duration: 'monthly', quotas: [] });\n setEditingPlan(null);\n setShowForm(false);\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setSubmitting(true);\n\n try {\n if (editingPlan) {\n await fetchGraphQL(UPDATE_PLAN, {\n input: {\n id: editingPlan.id,\n name: formData.name,\n price: parseFloat(formData.price),\n currency: formData.currency,\n duration: formData.duration,\n quotas: formData.quotas,\n },\n });\n } else {\n await fetchGraphQL(CREATE_PLAN, {\n input: {\n name: formData.name,\n price: parseFloat(formData.price),\n currency: formData.currency,\n duration: formData.duration,\n productId: productId,\n quotas: formData.quotas,\n },\n });\n }\n\n resetForm();\n await fetchPlans();\n } catch (err) {\n console.error('Failed to save plan:', err);\n setError(tr('products.failedToSavePlan', 'Failed to save plan'));\n } finally {\n setSubmitting(false);\n }\n };\n\n const handleToggle = async (plan: Plan) => {\n try {\n await fetchGraphQL(TOGGLE_PLAN, { planID: plan.id, status: !plan.isActive });\n await fetchPlans();\n } catch (err) {\n console.error('Failed to toggle plan:', err);\n }\n };\n\n const handleEdit = (plan: Plan) => {\n setEditingPlan(plan);\n setFormData({\n name: plan.name,\n price: plan.price.toString(),\n currency: plan.currency,\n duration: plan.duration,\n quotas: (plan.features || []).map((f) => ({\n quotaId: f.quotaId,\n quantity: 1,\n })),\n });\n setShowForm(true);\n };\n\n const handleCreateQuota = async () => {\n if (!newQuotaName.trim()) return;\n try {\n setSubmitting(true);\n await fetchGraphQL(CREATE_QUOTA, {\n input: {\n name: newQuotaName.trim(),\n quotaType: 'PRODUCT_SPECIFIC',\n limits: {},\n reusable: true,\n },\n });\n setNewQuotaName('');\n setShowQuotaForm(false);\n await fetchPlans(); // refreshes quotas too\n } catch (err) {\n console.error('Failed to create quota:', err);\n setError(tr('products.failedToCreateFeature', 'Failed to create feature'));\n } finally {\n setSubmitting(false);\n }\n };\n\n const monthlyPlans = plans.filter((p) => p.duration === 'monthly');\n const yearlyPlans = plans.filter((p) => p.duration === 'yearly');\n\n return (\n <div className=\"bg-surface border border-default rounded-lg p-6 shadow-[var(--shadow-elevation-1)] transition-all duration-200 hover:shadow-[var(--shadow-elevation-2)] lg:col-span-2\">\n <div className=\"flex items-center justify-between mb-4\">\n <h2 className=\"text-lg font-semibold text-text-primary flex items-center gap-2\">\n <DollarSign size={18} />\n {tr('products.pricingPlans', 'Pricing Plans')}\n </h2>\n {!readOnly && (\n <button\n onClick={() => {\n resetForm();\n setShowForm(!showForm);\n }}\n className=\"\n inline-flex items-center gap-1.5 px-3 py-1.5\n bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)]\n rounded-lg text-sm font-medium\n hover:opacity-90 transition-all duration-200\n \"\n >\n <Plus size={14} />\n {tr('products.addPlan', 'Add Plan')}\n </button>\n )}\n </div>\n\n {/* Create/Edit Form */}\n {showForm && !readOnly && (\n <form\n onSubmit={handleSubmit}\n className=\"mb-6 p-4 bg-muted rounded-lg border border-default\"\n >\n <h3 className=\"text-sm font-semibold text-text-primary mb-3\">\n {editingPlan\n ? tr('products.editPlan', 'Edit Plan')\n : tr('products.createNewPlan', 'Create New Plan')}\n </h3>\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-3\">\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.planName', 'Name')} *\n </label>\n <input\n type=\"text\"\n value={formData.name}\n onChange={(e) => setFormData({ ...formData, name: e.target.value })}\n placeholder=\"e.g. Basic\"\n required\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary\"\n />\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.planPrice', 'Price')} *\n </label>\n <input\n type=\"number\"\n step=\"0.01\"\n min=\"0\"\n value={formData.price}\n onChange={(e) => setFormData({ ...formData, price: e.target.value })}\n placeholder=\"9.99\"\n required\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary\"\n />\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.planDuration', 'Duration')} *\n </label>\n <select\n value={formData.duration}\n onChange={(e) =>\n setFormData({ ...formData, duration: e.target.value as 'monthly' | 'yearly' })\n }\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary\"\n >\n <option value=\"monthly\">{tr('products.monthly', 'Monthly')}</option>\n <option value=\"yearly\">{tr('products.yearly', 'Yearly')}</option>\n </select>\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n {tr('products.currency', 'Currency')}\n </label>\n <select\n value={formData.currency}\n onChange={(e) => setFormData({ ...formData, currency: e.target.value })}\n className=\"w-full px-3 py-2 text-sm rounded-md border border-default bg-surface 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 </select>\n </div>\n </div>\n {/* Quotas/Features */}\n <div className=\"mt-3\">\n <label className=\"block text-xs font-medium text-text-secondary mb-1\">\n <List size={12} className=\"inline mr-1\" />\n {tr('products.featuresQuotas', 'Features / Quotas')}\n </label>\n {availableQuotas.length > 0 ? (\n <>\n <div className=\"space-y-1.5 max-h-32 overflow-y-auto\">\n {availableQuotas.map((quota) => {\n const isSelected = formData.quotas.some((q) => q.quotaId === quota.id);\n return (\n <label\n key={quota.id}\n className=\"flex items-center gap-2 text-xs text-text-primary cursor-pointer hover:bg-muted/50 px-2 py-1 rounded\"\n >\n <input\n type=\"checkbox\"\n checked={isSelected}\n onChange={(e) => {\n if (e.target.checked) {\n setFormData({\n ...formData,\n quotas: [...formData.quotas, { quotaId: quota.id, quantity: 1 }],\n });\n } else {\n setFormData({\n ...formData,\n quotas: formData.quotas.filter((q) => q.quotaId !== quota.id),\n });\n }\n }}\n className=\"rounded border-default\"\n />\n {quota.name}\n </label>\n );\n })}\n </div>\n <div className=\"flex items-center gap-2 mt-2\">\n <p className=\"text-xs text-text-secondary\">\n {formData.quotas.length}{' '}\n {tr('products.featuresSelected', 'feature(s) selected')}\n </p>\n <span className=\"text-xs text-text-secondary\">|</span>\n {!showQuotaForm ? (\n <button\n type=\"button\"\n onClick={() => setShowQuotaForm(true)}\n className=\"text-xs text-[var(--color-action-primary-bg)] hover:underline\"\n >\n {tr('products.createNewFeature', '+ Create new feature')}\n </button>\n ) : (\n <div className=\"flex items-center gap-1.5\">\n <input\n type=\"text\"\n value={newQuotaName}\n onChange={(e) => setNewQuotaName(e.target.value)}\n placeholder={tr('products.featureNamePlaceholder', 'Feature name')}\n className=\"px-2 py-1 text-xs rounded border border-default bg-surface text-text-primary w-36\"\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n handleCreateQuota();\n }\n }}\n />\n <button\n type=\"button\"\n onClick={handleCreateQuota}\n disabled={submitting || !newQuotaName.trim()}\n className=\"px-2 py-1 text-xs bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)] rounded hover:opacity-90 disabled:opacity-50\"\n >\n {tr('productCommon.add', 'Add')}\n </button>\n <button\n type=\"button\"\n onClick={() => {\n setShowQuotaForm(false);\n setNewQuotaName('');\n }}\n className=\"px-1.5 py-1 text-xs text-text-secondary hover:text-text-primary\"\n >\n {tr('productCommon.cancel', 'Cancel')}\n </button>\n </div>\n )}\n </div>\n </>\n ) : (\n <div className=\"text-xs text-text-secondary\">\n {tr('products.noFeaturesCreated', 'No features created yet.')}{' '}\n {!showQuotaForm ? (\n <button\n type=\"button\"\n onClick={() => setShowQuotaForm(true)}\n className=\"text-[var(--color-action-primary-bg)] hover:underline\"\n >\n {tr('products.createYourFirstFeature', 'Create your first feature')}\n </button>\n ) : (\n <div className=\"flex items-center gap-1.5 mt-1.5\">\n <input\n type=\"text\"\n value={newQuotaName}\n onChange={(e) => setNewQuotaName(e.target.value)}\n placeholder=\"Feature name\"\n className=\"px-2 py-1 text-xs rounded border border-default bg-surface text-text-primary w-36\"\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n handleCreateQuota();\n }\n }}\n />\n <button\n type=\"button\"\n onClick={handleCreateQuota}\n disabled={submitting || !newQuotaName.trim()}\n className=\"px-2 py-1 text-xs bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)] rounded hover:opacity-90 disabled:opacity-50\"\n >\n Add\n </button>\n <button\n type=\"button\"\n onClick={() => {\n setShowQuotaForm(false);\n setNewQuotaName('');\n }}\n className=\"px-1.5 py-1 text-xs text-text-secondary hover:text-text-primary\"\n >\n Cancel\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n\n <div className=\"flex gap-2 mt-3\">\n <button\n type=\"submit\"\n disabled={submitting}\n className=\"\n inline-flex items-center gap-1.5 px-4 py-2\n bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)]\n rounded-md text-sm font-medium\n hover:opacity-90 transition-all duration-200\n disabled:opacity-50\n \"\n >\n {submitting && <Loader2 size={14} className=\"animate-spin\" />}\n {editingPlan\n ? tr('products.updatePlan', 'Update Plan')\n : tr('products.createPlan', 'Create Plan')}\n </button>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"px-4 py-2 text-sm text-text-secondary hover:text-text-primary transition-colors\"\n >\n {tr('productCommon.cancel', 'Cancel')}\n </button>\n </div>\n </form>\n )}\n\n {/* Error */}\n {error && (\n <div className=\"mb-4 p-3 bg-[var(--color-status-error-subtle)] border border-[var(--color-status-error-border)] rounded-lg text-sm text-[var(--color-status-error)]\">\n {error}\n </div>\n )}\n\n {/* Loading */}\n {loading ? (\n <div className=\"flex items-center justify-center py-8\">\n <Loader2 size={20} className=\"animate-spin text-text-secondary\" />\n <span className=\"ml-2 text-sm text-text-secondary\">\n {tr('products.loadingPlans', 'Loading plans...')}\n </span>\n </div>\n ) : plans.length === 0 ? (\n <div className=\"text-center py-8\">\n <DollarSign size={32} className=\"mx-auto mb-2 text-text-secondary opacity-50\" />\n <p className=\"text-sm text-text-secondary\">\n {tr('products.noPricingPlans', 'No pricing plans yet')}\n </p>\n <p className=\"text-xs text-text-secondary mt-1\">\n {tr('products.clickAddPlan', 'Click \"Add Plan\" to create your first plan')}\n </p>\n </div>\n ) : (\n <div className=\"space-y-6\">\n {[\n { label: tr('products.monthlyPlans', 'Monthly Plans'), plans: monthlyPlans },\n { label: tr('products.yearlyPlans', 'Yearly Plans'), plans: yearlyPlans },\n ]\n .filter((g) => g.plans.length > 0)\n .map((group) => (\n <div key={group.label}>\n <h3 className=\"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-3\">\n {group.label}\n </h3>\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-4\">\n {group.plans\n .sort((a, b) => a.price - b.price)\n .map((plan) => {\n const currencySymbol =\n plan.currency === 'USD'\n ? '$'\n : plan.currency === 'EUR'\n ? '\\u20AC'\n : plan.currency === 'GBP'\n ? '\\u00A3'\n : '\\u20B9';\n const isPopular =\n plan.name.toLowerCase().includes('professional') ||\n plan.name.toLowerCase().includes('pro');\n return (\n <div\n key={plan.id}\n className={`\n relative rounded-xl border p-5 transition-all duration-200\n ${plan.isActive ? 'border-default bg-surface hover:shadow-md' : 'border-default bg-muted/30 opacity-60'}\n ${isPopular ? 'border-[var(--color-action-primary-bg)] ring-1 ring-[var(--color-action-primary-bg)]/20' : ''}\n `}\n >\n {isPopular && (\n <span className=\"absolute -top-2.5 left-1/2 -translate-x-1/2 px-3 py-0.5 text-xs font-semibold bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)] rounded-full\">\n {tr('products.popular', 'Popular')}\n </span>\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between mb-3\">\n <div>\n <h4 className=\"text-base font-semibold text-text-primary\">\n {plan.name}\n </h4>\n <span\n className={`inline-flex items-center px-1.5 py-0.5 text-xs font-medium rounded-full mt-1 ${\n plan.isActive\n ? 'bg-[var(--color-status-success-subtle)] text-[var(--color-status-success)]'\n : 'bg-muted text-text-secondary'\n }`}\n >\n {plan.isActive\n ? tr('products.statusActive', 'Active')\n : tr('products.statusInactive', 'Inactive')}\n </span>\n </div>\n {!readOnly && (\n <div className=\"flex items-center gap-0.5\">\n <button\n onClick={() => handleToggle(plan)}\n title={\n plan.isActive\n ? tr('products.deactivate', 'Deactivate')\n : tr('products.activate', 'Activate')\n }\n className=\"p-1.5 rounded-lg hover:bg-muted transition-colors text-text-secondary hover:text-text-primary\"\n >\n {plan.isActive ? (\n <ToggleRight\n size={16}\n className=\"text-[var(--color-status-success)]\"\n />\n ) : (\n <ToggleLeft size={16} />\n )}\n </button>\n <button\n onClick={() => handleEdit(plan)}\n title={tr('products.edit', 'Edit')}\n className=\"p-1.5 rounded-lg hover:bg-muted transition-colors text-text-secondary hover:text-text-primary\"\n >\n <Edit size={14} />\n </button>\n </div>\n )}\n </div>\n\n {/* Price */}\n <div className=\"mb-4\">\n <span className=\"text-3xl font-bold text-text-primary\">\n {currencySymbol}\n {plan.price}\n </span>\n <span className=\"text-sm text-text-secondary ml-1\">\n /{plan.duration === 'monthly' ? 'month' : 'year'}\n </span>\n </div>\n\n {/* Features */}\n {plan.features && plan.features.length > 0 ? (\n <div className=\"space-y-2 border-t border-default pt-3\">\n {plan.features.map((f) => (\n <div\n key={f.id}\n className=\"flex items-center gap-2 text-sm text-text-primary\"\n >\n <Check\n size={14}\n className=\"text-[var(--color-status-success)] flex-shrink-0\"\n />\n <span>{f.quota?.name || f.quotaId}</span>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"border-t border-default pt-3\">\n <p className=\"text-xs text-text-secondary italic\">\n {tr('products.noFeaturesAssigned', 'No features assigned')}\n </p>\n </div>\n )}\n </div>\n );\n })}\n </div>\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAgEA,IAAM,IAAgB,qTAwBhB,IAAiB,kGAUjB,IAAe,gGAMf,IAAc,6FAMd,IAAc,6FAMd,IAAc;AAgBpB,SAAgB,EAAa,EAC3B,cACA,aAAa,IACb,cAAW,MACS;CACpB,IAAM,IAAK,GAAO,EAEZ,CAAC,GAAO,KAAY,EAAiB,EAAE,CAAC,EACxC,CAAC,GAAiB,KAAsB,EAAkB,EAAE,CAAC,EAC7D,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,CAAC,GAAU,KAAe,EAAS,GAAM,EACzC,CAAC,GAAa,KAAkB,EAAsB,KAAK,EAC3D,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAe,KAAoB,EAAS,GAAM,EACnD,CAAC,GAAc,KAAmB,EAAS,GAAG,EAC9C,CAAC,GAAU,KAAe,EAAuB;EACrD,MAAM;EACN,OAAO;EACP,UAAU;EACV,UAAU;EACV,QAAQ,EAAE;EACX,CAAC,EAEI,IAAe,EACnB,OAAW,GAAe,MAA2D;EACnF,IAAM,IAAS,MAAM,EAAgB;GACnC,SAAS;GACT;GACA;GACD,CAAC;AACF,MAAI,EAAO,QAAQ,OAAQ,OAAU,MAAM,EAAO,OAAO,GAAG,QAAQ;AACpE,SAAO,EAAO,QAAQ;IAExB,EAAE,CACH,EAEK,IAAa,EAAY,YAAY;AACzC,MAAI;AACF,KAAW,GAAK;GAChB,IAAM,CAAC,GAAa,KAAgB,MAAM,QAAQ,IAAI,CACpD,EAAsC,EAAc,EACpD,EAAwC,EAAe,CACxD,CAAC;AAIF,GAFA,GADiB,GAAa,eAAe,EAAE,EAC7B,QAAQ,MAAY,EAAE,cAAc,EAAU,CAAC,EAC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