@burdenoff/microfe-billing 2026.528.1 → 2026.529.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PlanEditPage.js","names":[],"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-dom';\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 { 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';\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 [quotaAllocations, setQuotaAllocations] = useState<QuotaAllocation[]>([]);\n const [currencyPriceOverrides, setCurrencyPriceOverrides] = 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 // 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 const limits = feature.quota.limits as { value?: number } | null;\n const value = limits?.value ?? 1;\n quotaMap.set(quotaId, (quotaMap.get(quotaId) ?? 0) + 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-muted 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-muted 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-foreground\">\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-primary text-primary-foreground rounded-md hover:bg-primary/90\"\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 (!price || isNaN(Number(price)) || Number(price) < 0) {\n setError('Valid price 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: Number(price),\n currency,\n duration,\n isActive,\n quotas: quotaAllocations.map((a) => ({\n quotaId: a.quotaId,\n quantity: a.quantity,\n })),\n ...(currencyPriceOverrides.length > 0 ? { currencyPriceOverrides } : {}),\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 <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 rounded-lg bg-card overflow-hidden h-fit\">\n <div className=\"p-4 border-b border-border bg-muted/30\">\n <h2 className=\"font-semibold text-foreground\">\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-foreground 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 rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary\"\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 htmlFor=\"price\" className=\"block text-sm font-medium text-foreground mb-1\">\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 className=\"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary\"\n placeholder=\"49.99\"\n required\n />\n </div>\n <div>\n <label\n htmlFor=\"currency\"\n className=\"block text-sm font-medium text-foreground 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 className=\"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-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-foreground 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 className=\"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-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 text-primary focus:ring-primary\"\n />\n <label htmlFor=\"isActive\" className=\"text-sm font-medium text-foreground\">\n {tr('billing.plans.planIsActive', 'Plan is active')}\n </label>\n </div>\n </div>\n </div>\n\n {/* Quota Allocations */}\n <div className=\"border border-border rounded-lg bg-card overflow-hidden h-fit\">\n <div className=\"p-4 border-b border-border bg-muted/30 flex items-center justify-between\">\n <h2 className=\"font-semibold text-foreground\">\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-primary hover:bg-primary/10 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-muted-foreground\">\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 limitValue = limits?.value ?? 0;\n const limitType = limits?.type ?? 'unknown';\n const totalValue = limitValue * allocation.quantity;\n\n return (\n <div\n key={index}\n className=\"p-3 border border-border rounded-lg bg-muted/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 rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary ${\n allocation.quotaId === '' ? 'text-muted-foreground' : 'text-foreground'\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 <div className=\"text-muted-foreground\">\n <span className=\"capitalize\">Type: {limitType}</span>\n <span className=\"mx-2\">•</span>\n <span>\n Value per unit:{' '}\n <span className=\"font-medium text-foreground\">\n {limitValue.toLocaleString()}\n </span>\n </span>\n </div>\n </div>\n\n {/* Quantity & Total */}\n <div className=\"flex items-center gap-4\">\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-muted-foreground\">\n {tr('billing.plans.quantity', 'Quantity')}:\n </label>\n <input\n type=\"number\"\n min=\"1\"\n value={allocation.quantity}\n onChange={(e) =>\n handleQuotaChange(index, 'quantity', e.target.value)\n }\n className=\"w-24 px-3 py-1.5 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-center\"\n />\n </div>\n <div className=\"flex items-center gap-2 text-sm\">\n <span className=\"text-muted-foreground\">=</span>\n <span className=\"font-semibold text-status-success-text\">\n {totalValue.toLocaleString()} total\n </span>\n </div>\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-primary text-primary-foreground rounded-md hover:bg-primary/90 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 text-foreground rounded-md hover:bg-muted transition-colors\"\n >\n Cancel\n </button>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,IAAa,UAAyB;CACpC,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B;EACpD,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe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WAAW,EAAC,IACpC;eACR,kBAAC,SAAD;YACE,MAAK;YACL,KAAI;YACJ,OAAO,EAAW;YAClB,WAAW,MACT,EAAkB,GAAO,YAAY,EAAE,OAAO,MAAM;YAEtD,WAAU;YACV,CAAA,CACE;cACN,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACE,kBAAC,QAAD;YAAM,WAAU;sBAAwB;YAAQ,CAAA,EAChD,kBAAC,QAAD;YAAM,WAAU;sBAAhB,CACG,EAAW,gBAAgB,EAAC,SACxB;cACH;aACF;YACL,EAAA,CAAA,CAED;WAnFC,EAmFD;SAER;OAEA,CAAA,CACF;QACF;;IAEN,kBAAC,GAAD;KACE,WAAW;KACX,UAAU;KACV,CAAA;IAGF,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,UAAD;MACE,MAAK;MACL,UAAU;MACV,WAAU;gBAET,IACG,EAAG,wBAAwB,YAAY,GACvC,EAAG,6BAA6B,eAAe;MAC5C,CAAA,EACT,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,EAAW,UAAU,IAAS;MAC7C,WAAU;gBACX;MAEQ,CAAA,CACL;;IACD;KACH"}
1
+ {"version":3,"file":"PlanEditPage.js","names":[],"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-dom';\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 { 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';\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 [quotaAllocations, setQuotaAllocations] = useState<QuotaAllocation[]>([]);\n const [currencyPriceOverrides, setCurrencyPriceOverrides] = 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 // 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-muted 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-muted 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-foreground\">\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-primary text-primary-foreground rounded-md hover:bg-primary/90\"\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 (!price || isNaN(Number(price)) || Number(price) < 0) {\n setError('Valid price 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: Number(price),\n currency,\n duration,\n isActive,\n quotas: quotaAllocations.map((a) => ({\n quotaId: a.quotaId,\n quantity: a.quantity,\n })),\n ...(currencyPriceOverrides.length > 0 ? { currencyPriceOverrides } : {}),\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 <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 rounded-lg bg-card overflow-hidden h-fit\">\n <div className=\"p-4 border-b border-border bg-muted/30\">\n <h2 className=\"font-semibold text-foreground\">\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-foreground 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 rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary\"\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 htmlFor=\"price\" className=\"block text-sm font-medium text-foreground mb-1\">\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 className=\"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary\"\n placeholder=\"49.99\"\n required\n />\n </div>\n <div>\n <label\n htmlFor=\"currency\"\n className=\"block text-sm font-medium text-foreground 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 className=\"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-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-foreground 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 className=\"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-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 text-primary focus:ring-primary\"\n />\n <label htmlFor=\"isActive\" className=\"text-sm font-medium text-foreground\">\n {tr('billing.plans.planIsActive', 'Plan is active')}\n </label>\n </div>\n </div>\n </div>\n\n {/* Quota Allocations */}\n <div className=\"border border-border rounded-lg bg-card overflow-hidden h-fit\">\n <div className=\"p-4 border-b border-border bg-muted/30 flex items-center justify-between\">\n <h2 className=\"font-semibold text-foreground\">\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-primary hover:bg-primary/10 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-muted-foreground\">\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 limitValue = limits?.value ?? 0;\n const limitType = limits?.type ?? 'unknown';\n const totalValue = limitValue * allocation.quantity;\n\n return (\n <div\n key={index}\n className=\"p-3 border border-border rounded-lg bg-muted/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 rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary ${\n allocation.quotaId === '' ? 'text-muted-foreground' : 'text-foreground'\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 <div className=\"text-muted-foreground\">\n <span className=\"capitalize\">Type: {limitType}</span>\n <span className=\"mx-2\">•</span>\n <span>\n Value per unit:{' '}\n <span className=\"font-medium text-foreground\">\n {limitValue.toLocaleString()}\n </span>\n </span>\n </div>\n </div>\n\n {/* Quantity & Total */}\n <div className=\"flex items-center gap-4\">\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-muted-foreground\">\n {tr('billing.plans.quantity', 'Quantity')}:\n </label>\n <input\n type=\"number\"\n min=\"1\"\n value={allocation.quantity}\n onChange={(e) =>\n handleQuotaChange(index, 'quantity', e.target.value)\n }\n className=\"w-24 px-3 py-1.5 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-center\"\n />\n </div>\n <div className=\"flex items-center gap-2 text-sm\">\n <span className=\"text-muted-foreground\">=</span>\n <span className=\"font-semibold text-status-success-text\">\n {totalValue.toLocaleString()} total\n </span>\n </div>\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-primary text-primary-foreground rounded-md hover:bg-primary/90 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 text-foreground rounded-md hover:bg-muted transition-colors\"\n >\n Cancel\n </button>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,IAAa,UAAyB;CACpC,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B;EACpD,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,IAAW;IAEnC,EAAE,cAAW,GAA+B,EAC5C,IAAa,GAAoB,EACjC,IAAc,GAAuB,EACrC,EAAE,SAAM,WAAW,GAAe,OAAO,GAAW,eAAY,EAAQ,EAAO,EAC/E,EAAE,WAAQ,WAAW,MAAoB,EAAU,EAAE,YAAY,IAAM,CAAC,EACxE,EAAE,eAAY,kBAAe,GAAkB,EAG/C,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAU,KAAe,EAAS,MAAM,EACzC,CAAC,GAAU,KAAe,EAAuB,EAAa,QAAQ,EACtE,CAAC,GAAU,KAAe,EAAS,GAAK,EACxC,CAAC,GAAkB,KAAuB,EAA4B,EAAE,CAAC,EACzE,CAAC,GAAwB,KAA6B,EAE1D,EAAE,CAAC,EACC,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,CAAC,GAAS,KAAc,EAAS,GAAM;AAmC7C,KAhCA,QAAgB;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,UAAU,IAAS;MAC7C,WAAU;gBACX;MAEQ,CAAA,CACL;;IACD;KACH"}
@@ -3,20 +3,21 @@ import { ServerError as t } from "../../../shared/components/ServerError.js";
3
3
  import "../../../shared/components/index.js";
4
4
  import { formatCurrency as n, formatPlanDuration as r, formatPlanDurationLabel as i } from "../../../shared/utils/format.js";
5
5
  import { isServerError as a } from "../../../shared/utils/error.js";
6
+ import { getPlanFeatureQuantity as o } from "../../../shared/utils/planFeatureQuantity.js";
6
7
  import "../../../shared/utils/index.js";
7
- import { useBillingNavigate as o } from "../../../hooks/useBillingNavigate.js";
8
- import { getDisplayPrice as s, useDefaultBillingCurrency as c } from "../../../hooks/useDefaultBillingCurrency.js";
9
- import { usePlans as l } from "../hooks/usePlans.js";
8
+ import { useBillingNavigate as s } from "../../../hooks/useBillingNavigate.js";
9
+ import { getDisplayPrice as c, useDefaultBillingCurrency as l } from "../../../hooks/useDefaultBillingCurrency.js";
10
+ import { usePlans as u } from "../hooks/usePlans.js";
10
11
  import "../hooks/index.js";
11
- import { useState as u } from "react";
12
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
13
- import { useI18n as p } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
12
+ import { useState as d } from "react";
13
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
14
+ import { useI18n as m } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
14
15
  //#region src/billing/modules/plans/pages/PlansBrowsePage.tsx
15
- function m(e) {
16
+ function h(e) {
16
17
  let t = /* @__PURE__ */ new Map();
17
18
  for (let n of e) {
18
19
  if (!n.quota) continue;
19
- let e = n.quota.id, r = n.quota.limits?.value ?? 0, i = t.get(e);
20
+ let e = n.quota.id, r = o(n), i = t.get(e);
20
21
  i ? i.totalValue += r : t.set(e, {
21
22
  quotaId: e,
22
23
  name: n.quota.name ?? "Unknown Quota",
@@ -25,100 +26,100 @@ function m(e) {
25
26
  }
26
27
  return Array.from(t.values());
27
28
  }
28
- var h = () => {
29
- let { t: n } = p(), r = (e, t) => {
29
+ var g = () => {
30
+ let { t: n } = m(), r = (e, t) => {
30
31
  let r = n(e);
31
32
  return r === e ? t : r;
32
- }, i = o(), { productId: s } = e(), { plans: c, isLoading: m, error: h, refetch: v } = l({
33
+ }, i = s(), { productId: o } = e(), { plans: c, isLoading: l, error: h, refetch: g } = u({
33
34
  includeFree: !1,
34
- productId: s ?? void 0
35
- }), [y, b] = u("grid"), [x, S] = u("all"), C = c.filter((e) => !(!e.isActive || x !== "all" && e.duration !== x));
36
- return m && c.length === 0 ? /* @__PURE__ */ f("div", {
35
+ productId: o ?? void 0
36
+ }), [y, b] = d("grid"), [x, S] = d("all"), C = c.filter((e) => !(!e.isActive || x !== "all" && e.duration !== x));
37
+ return l && c.length === 0 ? /* @__PURE__ */ p("div", {
37
38
  className: "space-y-6 p-6",
38
- children: [/* @__PURE__ */ d("div", { className: "h-8 w-48 bg-muted animate-pulse rounded" }), /* @__PURE__ */ d("div", {
39
+ children: [/* @__PURE__ */ f("div", { className: "h-8 w-48 bg-muted animate-pulse rounded" }), /* @__PURE__ */ f("div", {
39
40
  className: "grid grid-cols-1 md:grid-cols-3 gap-6",
40
41
  children: [
41
42
  1,
42
43
  2,
43
44
  3
44
- ].map((e) => /* @__PURE__ */ f("div", {
45
+ ].map((e) => /* @__PURE__ */ p("div", {
45
46
  className: "border border-border rounded-lg p-6 space-y-4",
46
47
  children: [
47
- /* @__PURE__ */ d("div", { className: "h-6 w-24 bg-muted animate-pulse rounded" }),
48
- /* @__PURE__ */ d("div", { className: "h-8 w-32 bg-muted animate-pulse rounded" }),
49
- /* @__PURE__ */ d("div", {
48
+ /* @__PURE__ */ f("div", { className: "h-6 w-24 bg-muted animate-pulse rounded" }),
49
+ /* @__PURE__ */ f("div", { className: "h-8 w-32 bg-muted animate-pulse rounded" }),
50
+ /* @__PURE__ */ f("div", {
50
51
  className: "space-y-2",
51
52
  children: [
52
53
  1,
53
54
  2,
54
55
  3
55
- ].map((e) => /* @__PURE__ */ d("div", { className: "h-4 w-full bg-muted animate-pulse rounded" }, e))
56
+ ].map((e) => /* @__PURE__ */ f("div", { className: "h-4 w-full bg-muted animate-pulse rounded" }, e))
56
57
  })
57
58
  ]
58
59
  }, e))
59
60
  })]
60
- }) : h && a(h) ? /* @__PURE__ */ d("div", {
61
+ }) : h && a(h) ? /* @__PURE__ */ f("div", {
61
62
  className: "p-6",
62
- children: /* @__PURE__ */ d(t, {
63
+ children: /* @__PURE__ */ f(t, {
63
64
  title: r("billing.plans.serverUnavailable", "Server Unavailable"),
64
65
  message: r("billing.plans.unableToLoadPlans", "Unable to load plans."),
65
- onRetry: () => v(),
66
+ onRetry: () => g(),
66
67
  showRetry: !0
67
68
  })
68
- }) : /* @__PURE__ */ f("div", {
69
+ }) : /* @__PURE__ */ p("div", {
69
70
  className: "space-y-6 p-6",
70
71
  children: [
71
- /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("h1", {
72
+ /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", {
72
73
  className: "text-2xl font-bold text-foreground",
73
74
  children: r("billing.plans.browsePlansTitle", "Plans")
74
- }), /* @__PURE__ */ d("p", {
75
+ }), /* @__PURE__ */ f("p", {
75
76
  className: "text-sm text-muted-foreground mt-1",
76
77
  children: r("billing.plans.browsePlansSubtitle", "Choose a plan that fits your needs")
77
78
  })] }),
78
- /* @__PURE__ */ f("div", {
79
+ /* @__PURE__ */ p("div", {
79
80
  className: "flex flex-wrap items-center gap-4 pb-4 border-b border-border",
80
- children: [/* @__PURE__ */ d("div", {
81
+ children: [/* @__PURE__ */ f("div", {
81
82
  className: "inline-flex rounded-lg border border-border p-1 bg-muted/50",
82
83
  children: [
83
84
  "all",
84
85
  "monthly",
85
86
  "yearly"
86
- ].map((e) => /* @__PURE__ */ d("button", {
87
+ ].map((e) => /* @__PURE__ */ f("button", {
87
88
  type: "button",
88
89
  onClick: () => S(e),
89
90
  className: `px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${x === e ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
90
91
  children: e === "all" ? "All" : e === "monthly" ? "Monthly" : "Yearly"
91
92
  }, e))
92
- }), /* @__PURE__ */ f("div", {
93
+ }), /* @__PURE__ */ p("div", {
93
94
  className: "ml-auto inline-flex rounded-lg border border-border p-1 bg-muted/50",
94
- children: [/* @__PURE__ */ d("button", {
95
+ children: [/* @__PURE__ */ f("button", {
95
96
  type: "button",
96
97
  onClick: () => b("grid"),
97
98
  className: `p-1.5 rounded-md transition-colors ${y === "grid" ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
98
99
  title: "Grid view",
99
- children: /* @__PURE__ */ d("svg", {
100
+ children: /* @__PURE__ */ f("svg", {
100
101
  className: "size-4",
101
102
  fill: "none",
102
103
  viewBox: "0 0 24 24",
103
104
  stroke: "currentColor",
104
- children: /* @__PURE__ */ d("path", {
105
+ children: /* @__PURE__ */ f("path", {
105
106
  strokeLinecap: "round",
106
107
  strokeLinejoin: "round",
107
108
  strokeWidth: 2,
108
109
  d: "M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"
109
110
  })
110
111
  })
111
- }), /* @__PURE__ */ d("button", {
112
+ }), /* @__PURE__ */ f("button", {
112
113
  type: "button",
113
114
  onClick: () => b("list"),
114
115
  className: `p-1.5 rounded-md transition-colors ${y === "list" ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
115
116
  title: "List view",
116
- children: /* @__PURE__ */ d("svg", {
117
+ children: /* @__PURE__ */ f("svg", {
117
118
  className: "size-4",
118
119
  fill: "none",
119
120
  viewBox: "0 0 24 24",
120
121
  stroke: "currentColor",
121
- children: /* @__PURE__ */ d("path", {
122
+ children: /* @__PURE__ */ f("path", {
122
123
  strokeLinecap: "round",
123
124
  strokeLinejoin: "round",
124
125
  strokeWidth: 2,
@@ -128,17 +129,17 @@ var h = () => {
128
129
  })]
129
130
  })]
130
131
  }),
131
- C.length === 0 ? /* @__PURE__ */ f("div", {
132
+ C.length === 0 ? /* @__PURE__ */ p("div", {
132
133
  className: "flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg",
133
134
  children: [
134
- /* @__PURE__ */ d("div", {
135
+ /* @__PURE__ */ f("div", {
135
136
  className: "size-12 rounded-full bg-muted flex items-center justify-center mb-4",
136
- children: /* @__PURE__ */ d("svg", {
137
+ children: /* @__PURE__ */ f("svg", {
137
138
  className: "size-6 text-muted-foreground",
138
139
  fill: "none",
139
140
  viewBox: "0 0 24 24",
140
141
  stroke: "currentColor",
141
- children: /* @__PURE__ */ d("path", {
142
+ children: /* @__PURE__ */ f("path", {
142
143
  strokeLinecap: "round",
143
144
  strokeLinejoin: "round",
144
145
  strokeWidth: 2,
@@ -146,25 +147,25 @@ var h = () => {
146
147
  })
147
148
  })
148
149
  }),
149
- /* @__PURE__ */ d("h3", {
150
+ /* @__PURE__ */ f("h3", {
150
151
  className: "text-lg font-medium text-foreground",
151
152
  children: r("billing.plans.noPlansAvailable", "No plans available")
152
153
  }),
153
- /* @__PURE__ */ d("p", {
154
+ /* @__PURE__ */ f("p", {
154
155
  className: "text-sm text-muted-foreground mt-1",
155
156
  children: r("billing.plans.checkBackLater", "Check back later for new plans.")
156
157
  })
157
158
  ]
158
- }) : y === "grid" ? /* @__PURE__ */ d("div", {
159
+ }) : y === "grid" ? /* @__PURE__ */ f("div", {
159
160
  className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",
160
- children: C.map((e) => /* @__PURE__ */ d(g, {
161
+ children: C.map((e) => /* @__PURE__ */ f(_, {
161
162
  plan: e,
162
163
  onView: () => i(`/plans/${e.id}`),
163
164
  onSubscribe: () => i(`/checkout/${e.id}`)
164
165
  }, e.id))
165
- }) : /* @__PURE__ */ d("div", {
166
+ }) : /* @__PURE__ */ f("div", {
166
167
  className: "space-y-3",
167
- children: C.map((e) => /* @__PURE__ */ d(_, {
168
+ children: C.map((e) => /* @__PURE__ */ f(v, {
168
169
  plan: e,
169
170
  onView: () => i(`/plans/${e.id}`),
170
171
  onSubscribe: () => i(`/checkout/${e.id}`)
@@ -172,60 +173,60 @@ var h = () => {
172
173
  })
173
174
  ]
174
175
  });
175
- }, g = ({ plan: e, onView: t, onSubscribe: a }) => {
176
- let o = m(e.features || []), l = c();
177
- return /* @__PURE__ */ f("div", {
176
+ }, _ = ({ plan: e, onView: t, onSubscribe: a }) => {
177
+ let o = h(e.features || []), s = l();
178
+ return /* @__PURE__ */ p("div", {
178
179
  className: "border border-border rounded-lg bg-card p-6 transition-all hover:shadow-md flex flex-col h-full",
179
180
  children: [
180
- /* @__PURE__ */ f("div", {
181
+ /* @__PURE__ */ p("div", {
181
182
  className: "mb-4",
182
- children: [/* @__PURE__ */ d("h3", {
183
+ children: [/* @__PURE__ */ f("h3", {
183
184
  className: "text-lg font-bold text-foreground",
184
185
  children: e.name
185
- }), /* @__PURE__ */ d("span", {
186
+ }), /* @__PURE__ */ f("span", {
186
187
  className: "text-sm text-muted-foreground",
187
188
  children: i(e.duration)
188
189
  })]
189
190
  }),
190
- /* @__PURE__ */ f("div", {
191
+ /* @__PURE__ */ p("div", {
191
192
  className: "flex items-baseline gap-1 mb-4",
192
- children: [/* @__PURE__ */ d("span", {
193
+ children: [/* @__PURE__ */ f("span", {
193
194
  className: "text-3xl font-bold text-foreground",
194
195
  children: (() => {
195
- let { price: t, currency: r } = s(e.price, e.currency, e.currencyPrices, l);
196
+ let { price: t, currency: r } = c(e.price, e.currency, e.currencyPrices, s);
196
197
  return n(t, r);
197
198
  })()
198
- }), /* @__PURE__ */ f("span", {
199
+ }), /* @__PURE__ */ p("span", {
199
200
  className: "text-muted-foreground text-sm",
200
201
  children: ["/ ", r(e.duration)]
201
202
  })]
202
203
  }),
203
- o.length > 0 && /* @__PURE__ */ f("ul", {
204
+ o.length > 0 && /* @__PURE__ */ p("ul", {
204
205
  className: "space-y-2 mb-4",
205
- children: [o.slice(0, 5).map((e) => /* @__PURE__ */ f("li", {
206
+ children: [o.slice(0, 5).map((e) => /* @__PURE__ */ p("li", {
206
207
  className: "flex items-center justify-between text-sm",
207
- children: [/* @__PURE__ */ f("div", {
208
+ children: [/* @__PURE__ */ p("div", {
208
209
  className: "flex items-center gap-2",
209
- children: [/* @__PURE__ */ d("svg", {
210
+ children: [/* @__PURE__ */ f("svg", {
210
211
  className: "size-4 text-status-success-text shrink-0",
211
212
  fill: "none",
212
213
  viewBox: "0 0 24 24",
213
214
  stroke: "currentColor",
214
- children: /* @__PURE__ */ d("path", {
215
+ children: /* @__PURE__ */ f("path", {
215
216
  strokeLinecap: "round",
216
217
  strokeLinejoin: "round",
217
218
  strokeWidth: 2,
218
219
  d: "M5 13l4 4L19 7"
219
220
  })
220
- }), /* @__PURE__ */ d("span", {
221
+ }), /* @__PURE__ */ f("span", {
221
222
  className: "text-foreground",
222
223
  children: e.name
223
224
  })]
224
- }), /* @__PURE__ */ d("span", {
225
+ }), /* @__PURE__ */ f("span", {
225
226
  className: "font-medium text-foreground",
226
227
  children: e.totalValue.toLocaleString()
227
228
  })]
228
- }, e.quotaId)), o.length > 5 && /* @__PURE__ */ f("li", {
229
+ }, e.quotaId)), o.length > 5 && /* @__PURE__ */ p("li", {
229
230
  className: "text-sm text-muted-foreground pl-6",
230
231
  children: [
231
232
  "+",
@@ -234,14 +235,14 @@ var h = () => {
234
235
  ]
235
236
  })]
236
237
  }),
237
- /* @__PURE__ */ f("div", {
238
+ /* @__PURE__ */ p("div", {
238
239
  className: "space-y-2 pt-4 border-t border-border mt-auto",
239
- children: [/* @__PURE__ */ d("button", {
240
+ children: [/* @__PURE__ */ f("button", {
240
241
  type: "button",
241
242
  onClick: a,
242
243
  className: "w-full px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
243
244
  children: "Subscribe"
244
- }), /* @__PURE__ */ d("button", {
245
+ }), /* @__PURE__ */ f("button", {
245
246
  type: "button",
246
247
  onClick: t,
247
248
  className: "w-full px-4 py-2 text-sm font-medium border border-border text-foreground rounded-md hover:bg-muted transition-colors",
@@ -250,19 +251,19 @@ var h = () => {
250
251
  })
251
252
  ]
252
253
  });
253
- }, _ = ({ plan: e, onView: t, onSubscribe: i }) => {
254
- let a = m(e.features || []), o = c();
255
- return /* @__PURE__ */ f("div", {
254
+ }, v = ({ plan: e, onView: t, onSubscribe: i }) => {
255
+ let a = h(e.features || []), o = l();
256
+ return /* @__PURE__ */ p("div", {
256
257
  className: "flex items-center gap-4 p-4 border border-border rounded-lg bg-card transition-all hover:shadow-sm",
257
258
  children: [
258
- /* @__PURE__ */ d("div", {
259
+ /* @__PURE__ */ f("div", {
259
260
  className: "size-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",
260
- children: /* @__PURE__ */ d("svg", {
261
+ children: /* @__PURE__ */ f("svg", {
261
262
  className: "size-5 text-primary",
262
263
  fill: "none",
263
264
  viewBox: "0 0 24 24",
264
265
  stroke: "currentColor",
265
- children: /* @__PURE__ */ d("path", {
266
+ children: /* @__PURE__ */ f("path", {
266
267
  strokeLinecap: "round",
267
268
  strokeLinejoin: "round",
268
269
  strokeWidth: 2,
@@ -270,12 +271,12 @@ var h = () => {
270
271
  })
271
272
  })
272
273
  }),
273
- /* @__PURE__ */ f("div", {
274
+ /* @__PURE__ */ p("div", {
274
275
  className: "flex-1 min-w-0",
275
- children: [/* @__PURE__ */ d("h3", {
276
+ children: [/* @__PURE__ */ f("h3", {
276
277
  className: "font-semibold text-foreground truncate",
277
278
  children: e.name
278
- }), /* @__PURE__ */ f("p", {
279
+ }), /* @__PURE__ */ p("p", {
279
280
  className: "text-sm text-muted-foreground",
280
281
  children: [
281
282
  a.length,
@@ -285,27 +286,27 @@ var h = () => {
285
286
  ]
286
287
  })]
287
288
  }),
288
- /* @__PURE__ */ f("div", {
289
+ /* @__PURE__ */ p("div", {
289
290
  className: "text-right",
290
- children: [/* @__PURE__ */ d("div", {
291
+ children: [/* @__PURE__ */ f("div", {
291
292
  className: "font-semibold text-foreground",
292
293
  children: (() => {
293
- let { price: t, currency: r } = s(e.price, e.currency, e.currencyPrices, o);
294
+ let { price: t, currency: r } = c(e.price, e.currency, e.currencyPrices, o);
294
295
  return n(t, r);
295
296
  })()
296
- }), /* @__PURE__ */ f("div", {
297
+ }), /* @__PURE__ */ p("div", {
297
298
  className: "text-sm text-muted-foreground",
298
299
  children: ["per ", r(e.duration)]
299
300
  })]
300
301
  }),
301
- /* @__PURE__ */ f("div", {
302
+ /* @__PURE__ */ p("div", {
302
303
  className: "flex items-center gap-2",
303
- children: [/* @__PURE__ */ d("button", {
304
+ children: [/* @__PURE__ */ f("button", {
304
305
  type: "button",
305
306
  onClick: i,
306
307
  className: "px-3 py-1.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
307
308
  children: "Subscribe"
308
- }), /* @__PURE__ */ d("button", {
309
+ }), /* @__PURE__ */ f("button", {
309
310
  type: "button",
310
311
  onClick: t,
311
312
  className: "px-3 py-1.5 text-sm font-medium border border-border text-foreground rounded-md hover:bg-muted transition-colors",
@@ -316,6 +317,6 @@ var h = () => {
316
317
  });
317
318
  };
318
319
  //#endregion
319
- export { h as PlansBrowsePage };
320
+ export { g as PlansBrowsePage };
320
321
 
321
322
  //# sourceMappingURL=PlansBrowsePage.js.map