@burdenoff/microfe-billing 2026.530.2 → 2026.530.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing/BillingAdminRoutes.js +110 -71
- package/dist/billing/BillingAdminRoutes.js.map +1 -1
- package/dist/billing/BillingRoot.js +81 -73
- package/dist/billing/BillingRoot.js.map +1 -1
- package/dist/billing/BillingUserRoutes.js +103 -90
- package/dist/billing/BillingUserRoutes.js.map +1 -1
- package/dist/billing/modules/billing/index.js +2 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +135 -126
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +417 -0
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -0
- package/dist/billing/modules/billing/pages/index.js +1 -0
- package/dist/billing/modules/checkout/hooks/useCheckout.js +163 -161
- package/dist/billing/modules/checkout/hooks/useCheckout.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js +344 -167
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js.map +1 -1
- package/dist/billing/modules/plans/constants/featuredQuotas.js +37 -0
- package/dist/billing/modules/plans/constants/featuredQuotas.js.map +1 -0
- package/dist/billing/modules/plans/index.js +2 -1
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js +205 -0
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js.map +1 -0
- package/dist/billing/modules/plans/pages/PlanCreatePage.js +51 -33
- package/dist/billing/modules/plans/pages/PlanCreatePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanEditPage.js +78 -60
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +246 -126
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/index.js +1 -0
- package/dist/billing/modules/promotions/index.js +4 -0
- package/dist/billing/modules/promotions/pages/CreatePromotionPage.js +289 -0
- package/dist/billing/modules/promotions/pages/CreatePromotionPage.js.map +1 -0
- package/dist/billing/modules/promotions/pages/PromotionsListPage.js +168 -0
- package/dist/billing/modules/promotions/pages/PromotionsListPage.js.map +1 -0
- package/dist/billing/modules/promotions/pages/index.js +2 -0
- package/dist/billing/shared/types/graphql.js.map +1 -1
- package/dist/generated/global-operations.js +422 -290
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js +3 -1
- package/dist/generated/global-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,187 +4,195 @@ import { BillingAdminRoutes as n } from "./BillingAdminRoutes.js";
|
|
|
4
4
|
import { useCallback as r, useEffect as i } from "react";
|
|
5
5
|
import { ErrorBoundary as a } from "@burdenoff/fe-libs/shared/components";
|
|
6
6
|
import { FeatureFlagProvider as o } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
7
|
-
import { Activity as s, Blocks as c, Coins as l, Gauge as u,
|
|
8
|
-
import { jsx as
|
|
9
|
-
import { useI18n as
|
|
7
|
+
import { Activity as s, Blocks as c, Coins as l, Gauge as u, Gift as d, Landmark as f, LayoutDashboard as p, Package as m, RefreshCw as h, RotateCcw as g, Settings as _, Ticket as v, TicketCheck as y, TrendingUp as b } from "lucide-react";
|
|
8
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
9
|
+
import { useI18n as S } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
10
10
|
//#region src/billing/BillingRoot.tsx
|
|
11
|
-
var
|
|
12
|
-
let { t:
|
|
13
|
-
let n =
|
|
11
|
+
var C = (C) => {
|
|
12
|
+
let { t: w } = S(), T = r((e, t) => {
|
|
13
|
+
let n = w(e);
|
|
14
14
|
return n === e ? t : n;
|
|
15
|
-
}, [
|
|
15
|
+
}, [w]), { registerNavItems: E, registerFooterItems: D, basePath: O = "/", mode: k = "user" } = C, A = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
|
|
16
16
|
return i(() => {
|
|
17
|
-
if (!
|
|
17
|
+
if (!E) return;
|
|
18
18
|
let e = [
|
|
19
19
|
{
|
|
20
20
|
id: "billing-overview",
|
|
21
|
-
label:
|
|
22
|
-
path:
|
|
23
|
-
icon: /* @__PURE__ */
|
|
21
|
+
label: T("billing.nav.billing", "Billing"),
|
|
22
|
+
path: O === "/" ? "/" : A(O, "overview"),
|
|
23
|
+
icon: /* @__PURE__ */ x(p, { size: 20 }),
|
|
24
24
|
order: 100,
|
|
25
25
|
group: "billing"
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
id: "billing-subscriptions",
|
|
29
|
-
label:
|
|
30
|
-
path:
|
|
31
|
-
icon: /* @__PURE__ */
|
|
29
|
+
label: T("billing.nav.subscriptions", "Subscriptions"),
|
|
30
|
+
path: A(O, "subscriptions"),
|
|
31
|
+
icon: /* @__PURE__ */ x(h, { size: 20 }),
|
|
32
32
|
order: 110,
|
|
33
33
|
group: "billing"
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
id: "billing-plans",
|
|
37
|
-
label:
|
|
38
|
-
path:
|
|
39
|
-
icon: /* @__PURE__ */
|
|
37
|
+
label: T("billing.nav.plans", "Plans"),
|
|
38
|
+
path: A(O, "plans"),
|
|
39
|
+
icon: /* @__PURE__ */ x(m, { size: 20 }),
|
|
40
40
|
order: 120,
|
|
41
41
|
group: "billing"
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
id: "billing-addons",
|
|
45
|
-
label:
|
|
46
|
-
path:
|
|
47
|
-
icon: /* @__PURE__ */
|
|
45
|
+
label: T("billing.nav.addons", "Addons"),
|
|
46
|
+
path: A(O, "addons"),
|
|
47
|
+
icon: /* @__PURE__ */ x(c, { size: 20 }),
|
|
48
48
|
order: 130,
|
|
49
49
|
group: "billing"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
id: "billing-usage",
|
|
53
|
-
label:
|
|
54
|
-
path:
|
|
55
|
-
icon: /* @__PURE__ */
|
|
53
|
+
label: T("billing.nav.usage", "Usage"),
|
|
54
|
+
path: A(O, "usage"),
|
|
55
|
+
icon: /* @__PURE__ */ x(s, { size: 20 }),
|
|
56
56
|
order: 180,
|
|
57
57
|
group: "billing"
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
id: "billing-affiliate",
|
|
61
|
-
label:
|
|
62
|
-
path:
|
|
63
|
-
icon: /* @__PURE__ */
|
|
61
|
+
label: T("billing.nav.affiliate", "Affiliate"),
|
|
62
|
+
path: A(O, "affiliate"),
|
|
63
|
+
icon: /* @__PURE__ */ x(y, { size: 20 }),
|
|
64
64
|
order: 190,
|
|
65
65
|
group: "billing"
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
id: "billing-earnings",
|
|
69
|
-
label:
|
|
70
|
-
path:
|
|
71
|
-
icon: /* @__PURE__ */
|
|
69
|
+
label: T("billing.nav.earnings", "Earnings"),
|
|
70
|
+
path: A(O, "earnings"),
|
|
71
|
+
icon: /* @__PURE__ */ x(l, { size: 20 }),
|
|
72
72
|
order: 200,
|
|
73
73
|
group: "billing"
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
id: "billing-payouts",
|
|
77
|
-
label:
|
|
78
|
-
path:
|
|
79
|
-
icon: /* @__PURE__ */
|
|
77
|
+
label: T("billing.nav.payouts", "Payouts"),
|
|
78
|
+
path: A(O, "payouts"),
|
|
79
|
+
icon: /* @__PURE__ */ x(f, { size: 20 }),
|
|
80
80
|
order: 205,
|
|
81
81
|
group: "billing"
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
id: "billing-settings",
|
|
85
|
-
label:
|
|
86
|
-
path:
|
|
87
|
-
icon: /* @__PURE__ */
|
|
85
|
+
label: T("billing.nav.settings", "Settings"),
|
|
86
|
+
path: A(O, "settings"),
|
|
87
|
+
icon: /* @__PURE__ */ x(_, { size: 20 }),
|
|
88
88
|
order: 210,
|
|
89
89
|
group: "billing"
|
|
90
90
|
}
|
|
91
91
|
], t = [
|
|
92
92
|
{
|
|
93
93
|
id: "billing-plans",
|
|
94
|
-
label:
|
|
95
|
-
path:
|
|
96
|
-
icon: /* @__PURE__ */
|
|
94
|
+
label: T("billing.nav.plans", "Plans"),
|
|
95
|
+
path: A(O, "plans"),
|
|
96
|
+
icon: /* @__PURE__ */ x(m, { size: 20 }),
|
|
97
97
|
order: 100,
|
|
98
98
|
group: "billing"
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
id: "billing-addons",
|
|
102
|
-
label:
|
|
103
|
-
path:
|
|
104
|
-
icon: /* @__PURE__ */
|
|
102
|
+
label: T("billing.nav.addons", "Addons"),
|
|
103
|
+
path: A(O, "addons"),
|
|
104
|
+
icon: /* @__PURE__ */ x(c, { size: 20 }),
|
|
105
105
|
order: 110,
|
|
106
106
|
group: "billing"
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
id: "billing-quotas",
|
|
110
|
-
label:
|
|
111
|
-
path:
|
|
112
|
-
icon: /* @__PURE__ */
|
|
110
|
+
label: T("billing.nav.quotas", "Quotas"),
|
|
111
|
+
path: A(O, "quotas"),
|
|
112
|
+
icon: /* @__PURE__ */ x(u, { size: 20 }),
|
|
113
113
|
order: 120,
|
|
114
114
|
group: "billing"
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
id: "billing-coupons",
|
|
118
|
-
label:
|
|
119
|
-
path:
|
|
120
|
-
icon: /* @__PURE__ */
|
|
118
|
+
label: T("billing.nav.coupons", "Coupons"),
|
|
119
|
+
path: A(O, "coupons"),
|
|
120
|
+
icon: /* @__PURE__ */ x(v, { size: 20 }),
|
|
121
121
|
order: 130,
|
|
122
122
|
group: "billing"
|
|
123
123
|
},
|
|
124
|
+
{
|
|
125
|
+
id: "billing-promotions",
|
|
126
|
+
label: T("billing.nav.promotions", "Promotions"),
|
|
127
|
+
path: A(O, "promotions"),
|
|
128
|
+
icon: /* @__PURE__ */ x(d, { size: 20 }),
|
|
129
|
+
order: 135,
|
|
130
|
+
group: "billing"
|
|
131
|
+
},
|
|
124
132
|
{
|
|
125
133
|
id: "billing-credits-admin",
|
|
126
|
-
label:
|
|
127
|
-
path:
|
|
128
|
-
icon: /* @__PURE__ */
|
|
134
|
+
label: T("billing.nav.creditGrants", "Credit Grants"),
|
|
135
|
+
path: A(O, "credits"),
|
|
136
|
+
icon: /* @__PURE__ */ x(l, { size: 20 }),
|
|
129
137
|
order: 150,
|
|
130
138
|
group: "billing"
|
|
131
139
|
},
|
|
132
140
|
{
|
|
133
141
|
id: "billing-refunds",
|
|
134
|
-
label:
|
|
135
|
-
path:
|
|
136
|
-
icon: /* @__PURE__ */
|
|
142
|
+
label: T("billing.nav.refunds", "Refunds"),
|
|
143
|
+
path: A(O, "refunds"),
|
|
144
|
+
icon: /* @__PURE__ */ x(g, { size: 20 }),
|
|
137
145
|
order: 160,
|
|
138
146
|
group: "billing"
|
|
139
147
|
},
|
|
140
148
|
{
|
|
141
149
|
id: "billing-admin-payouts",
|
|
142
|
-
label:
|
|
143
|
-
path:
|
|
144
|
-
icon: /* @__PURE__ */
|
|
150
|
+
label: T("billing.nav.payouts", "Payouts"),
|
|
151
|
+
path: A(O, "payouts"),
|
|
152
|
+
icon: /* @__PURE__ */ x(f, { size: 20 }),
|
|
145
153
|
order: 165,
|
|
146
154
|
group: "billing"
|
|
147
155
|
},
|
|
148
156
|
{
|
|
149
157
|
id: "billing-analytics",
|
|
150
|
-
label:
|
|
151
|
-
path:
|
|
152
|
-
icon: /* @__PURE__ */ b
|
|
158
|
+
label: T("billing.nav.analytics", "Analytics"),
|
|
159
|
+
path: A(O, "analytics"),
|
|
160
|
+
icon: /* @__PURE__ */ x(b, { size: 20 }),
|
|
153
161
|
order: 170,
|
|
154
162
|
group: "billing"
|
|
155
163
|
}
|
|
156
164
|
];
|
|
157
|
-
return
|
|
165
|
+
return E(k === "admin" ? t : e);
|
|
158
166
|
}, [
|
|
159
|
-
|
|
160
|
-
D,
|
|
167
|
+
E,
|
|
161
168
|
O,
|
|
162
|
-
|
|
169
|
+
k,
|
|
170
|
+
T
|
|
163
171
|
]), i(() => {
|
|
164
|
-
if (
|
|
172
|
+
if (D) return D([{
|
|
165
173
|
id: "billing-status",
|
|
166
|
-
label:
|
|
174
|
+
label: T("billing.nav.billingReady", "Billing Ready"),
|
|
167
175
|
type: "status",
|
|
168
176
|
order: 10,
|
|
169
177
|
section: "left"
|
|
170
178
|
}]);
|
|
171
|
-
}, [
|
|
172
|
-
fallback: /* @__PURE__ */
|
|
179
|
+
}, [D, T]), /* @__PURE__ */ x(a, {
|
|
180
|
+
fallback: /* @__PURE__ */ x("div", {
|
|
173
181
|
className: "p-6 text-center text-text-secondary",
|
|
174
|
-
children:
|
|
182
|
+
children: T("billing.errorBoundary.message", "Something went wrong loading this module. Please refresh the page.")
|
|
175
183
|
}),
|
|
176
|
-
children: /* @__PURE__ */
|
|
184
|
+
children: /* @__PURE__ */ x(o, {
|
|
177
185
|
workspaceId: null,
|
|
178
186
|
gateway: "global",
|
|
179
187
|
defaultEnabled: !0,
|
|
180
|
-
children: /* @__PURE__ */
|
|
181
|
-
...
|
|
182
|
-
children:
|
|
188
|
+
children: /* @__PURE__ */ x(e, {
|
|
189
|
+
...C,
|
|
190
|
+
children: x(k === "admin" ? n : t, {})
|
|
183
191
|
})
|
|
184
192
|
})
|
|
185
193
|
});
|
|
186
194
|
};
|
|
187
195
|
//#endregion
|
|
188
|
-
export {
|
|
196
|
+
export { C as BillingRoot };
|
|
189
197
|
|
|
190
198
|
//# sourceMappingURL=BillingRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BillingRoot.js","names":[],"sources":["../../src/billing/BillingRoot.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useCallback, useEffect } from 'react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport {\n LayoutDashboard,\n RefreshCw,\n Package,\n Blocks,\n Gauge,\n RotateCcw,\n Activity,\n TrendingUp,\n Settings,\n Ticket,\n Coins,\n TicketCheck,\n Landmark,\n} from 'lucide-react';\nimport { BillingProvider } from './providers/BillingProvider';\nimport type { NavItem, BillingRootProps } from './types';\nimport { BillingUserRoutes } from './BillingUserRoutes';\nimport { BillingAdminRoutes } from './BillingAdminRoutes';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\n/**\n * Root component for the Billing microfrontend.\n *\n * This is the main entry point that host applications import and render.\n * It sets up the necessary providers and renders the internal routing.\n * Automatically registers navigation items with the shell if registration functions are provided.\n *\n * @example\n * ```tsx\n * import { BillingRoot, type BillingRootProps } from '@burdenoff/microfe-billing';\n *\n * function App() {\n * const props: BillingRootProps = {\n * basePath: '/billing',\n * navigate: (path) => router.push(path),\n * currentUser: { id: '1', email: 'user@example.com', firstName: 'John', lastName: 'Doe' },\n * workspaceId: 'ws-123',\n * orgId: 'org-123',\n * apiGatewayUrl: 'https://api.example.com/tenant/graphql',\n * authToken: 'token',\n * stripePublishableKey: 'pk_test_...',\n * razorpayKey: 'rzp_test_...',\n * onSubscriptionCreate: (subscription) => console.log('Subscription created:', subscription),\n * onSubscriptionUpdate: (subscription) => console.log('Subscription updated:', subscription),\n * onPaymentProcess: (payment) => console.log('Payment processed:', payment),\n * registerNavItems: (items) => { return () => {}; },\n * };\n *\n * return <BillingRoot {...props} />;\n * }\n * ```\n */\nexport const BillingRoot: FC<BillingRootProps> = (props) => {\n const { t } = useI18n();\n const tr = useCallback(\n (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n },\n [t]\n );\n const { registerNavItems, registerFooterItems, basePath = '/', mode = 'user' } = props;\n\n // Helper to join paths correctly, avoiding double slashes\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 // Register navigation items with the shell based on mode\n useEffect(() => {\n if (!registerNavItems) return;\n\n const userNavItems: NavItem[] = [\n {\n id: 'billing-overview',\n label: tr('billing.nav.billing', 'Billing'),\n path: basePath === '/' ? '/' : joinPath(basePath, 'overview'),\n icon: <LayoutDashboard size={20} />,\n order: 100,\n group: 'billing',\n },\n {\n id: 'billing-subscriptions',\n label: tr('billing.nav.subscriptions', 'Subscriptions'),\n path: joinPath(basePath, 'subscriptions'),\n icon: <RefreshCw size={20} />,\n order: 110,\n group: 'billing',\n },\n {\n id: 'billing-plans',\n label: tr('billing.nav.plans', 'Plans'),\n path: joinPath(basePath, 'plans'),\n icon: <Package size={20} />,\n order: 120,\n group: 'billing',\n },\n {\n id: 'billing-addons',\n label: tr('billing.nav.addons', 'Addons'),\n path: joinPath(basePath, 'addons'),\n icon: <Blocks size={20} />,\n order: 130,\n group: 'billing',\n },\n {\n id: 'billing-usage',\n label: tr('billing.nav.usage', 'Usage'),\n path: joinPath(basePath, 'usage'),\n icon: <Activity size={20} />,\n order: 180,\n group: 'billing',\n },\n {\n id: 'billing-affiliate',\n label: tr('billing.nav.affiliate', 'Affiliate'),\n path: joinPath(basePath, 'affiliate'),\n icon: <TicketCheck size={20} />,\n order: 190,\n group: 'billing',\n },\n {\n id: 'billing-earnings',\n label: tr('billing.nav.earnings', 'Earnings'),\n path: joinPath(basePath, 'earnings'),\n icon: <Coins size={20} />,\n order: 200,\n group: 'billing',\n },\n {\n id: 'billing-payouts',\n label: tr('billing.nav.payouts', 'Payouts'),\n path: joinPath(basePath, 'payouts'),\n icon: <Landmark size={20} />,\n order: 205,\n group: 'billing',\n },\n {\n id: 'billing-settings',\n label: tr('billing.nav.settings', 'Settings'),\n path: joinPath(basePath, 'settings'),\n icon: <Settings size={20} />,\n order: 210,\n group: 'billing',\n },\n ];\n\n const adminNavItems: NavItem[] = [\n {\n id: 'billing-plans',\n label: tr('billing.nav.plans', 'Plans'),\n path: joinPath(basePath, 'plans'),\n icon: <Package size={20} />,\n order: 100,\n group: 'billing',\n },\n {\n id: 'billing-addons',\n label: tr('billing.nav.addons', 'Addons'),\n path: joinPath(basePath, 'addons'),\n icon: <Blocks size={20} />,\n order: 110,\n group: 'billing',\n },\n {\n id: 'billing-quotas',\n label: tr('billing.nav.quotas', 'Quotas'),\n path: joinPath(basePath, 'quotas'),\n icon: <Gauge size={20} />,\n order: 120,\n group: 'billing',\n },\n {\n id: 'billing-coupons',\n label: tr('billing.nav.coupons', 'Coupons'),\n path: joinPath(basePath, 'coupons'),\n icon: <Ticket size={20} />,\n order: 130,\n group: 'billing',\n },\n\n {\n id: 'billing-credits-admin',\n label: tr('billing.nav.creditGrants', 'Credit Grants'),\n path: joinPath(basePath, 'credits'),\n icon: <Coins size={20} />,\n order: 150,\n group: 'billing',\n },\n {\n id: 'billing-refunds',\n label: tr('billing.nav.refunds', 'Refunds'),\n path: joinPath(basePath, 'refunds'),\n icon: <RotateCcw size={20} />,\n order: 160,\n group: 'billing',\n },\n {\n id: 'billing-admin-payouts',\n label: tr('billing.nav.payouts', 'Payouts'),\n path: joinPath(basePath, 'payouts'),\n icon: <Landmark size={20} />,\n order: 165,\n group: 'billing',\n },\n {\n id: 'billing-analytics',\n label: tr('billing.nav.analytics', 'Analytics'),\n path: joinPath(basePath, 'analytics'),\n icon: <TrendingUp size={20} />,\n order: 170,\n group: 'billing',\n },\n ];\n\n const navItems = mode === 'admin' ? adminNavItems : userNavItems;\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath, mode, tr]);\n\n // Register footer items (example: billing status indicator in left section)\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'billing-status',\n label: tr('billing.nav.billingReady', 'Billing Ready'),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems, tr]);\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'billing.errorBoundary.message',\n 'Something went wrong loading this module. Please refresh the page.'\n )}\n </div>\n }\n >\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <BillingProvider {...props}>\n {mode === 'admin' ? <BillingAdminRoutes /> : <BillingUserRoutes />}\n </BillingProvider>\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;AAyDA,IAAa,KAAqC,MAAU;CAC1D,IAAM,EAAE,SAAM,GAAS,EACjB,IAAK,GACR,GAAa,MAA6B;EACzC,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,IAAW;IAEzC,CAAC,EAAE,CACJ,EACK,EAAE,qBAAkB,wBAAqB,cAAW,KAAK,UAAO,WAAW,GAG3E,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;AA8KtD,QAzKA,QAAgB;AACd,MAAI,CAAC,EAAkB;EAEvB,IAAM,IAA0B;GAC9B;IACE,IAAI;IACJ,OAAO,EAAG,uBAAuB,UAAU;IAC3C,MAAM,MAAa,MAAM,MAAM,EAAS,GAAU,WAAW;IAC7D,MAAM,kBAAC,GAAD,EAAiB,MAAM,IAAM,CAAA;IACnC,OAAO;IACP,OAAO;IACR;GACD;IACE,IAAI;IACJ,OAAO,EAAG,6BAA6B,gBAAgB;IACvD,MAAM,EAAS,GAAU,gBAAgB;IACzC,MAAM,kBAAC,GAAD,EAAW,MAAM,IAAM,CAAA;IAC7B,OAAO;IACP,OAAO;IACR;GACD;IACE,IAAI;IACJ,OAAO,EAAG,qBAAqB,QAAQ;IACvC,MAAM,EAAS,GAAU,QAAQ;IACjC,MAAM,kBAAC,GAAD,EAAS,MAAM,IAAM,CAAA;IAC3B,OAAO;IACP,OAAO;IACR;GACD;IACE,IAAI;IACJ,OAAO,EAAG,sBAAsB,SAAS;IACzC,MAAM,EAA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AD;GAAK,WAAU;aACZ,EACC,iCACA,qEACD;GACG,CAAA;YAGR,kBAAC,GAAD;GAAqB,aAAa;GAAM,SAAQ;GAAS,gBAAgB;aACvE,kBAAC,GAAD;IAAiB,GAAI;cACC,EAAnB,MAAS,UAAW,IAAyB,GAA1B,EAAsB,CAAwB;IAClD,CAAA;GACE,CAAA;EACR,CAAA"}
|
|
1
|
+
{"version":3,"file":"BillingRoot.js","names":[],"sources":["../../src/billing/BillingRoot.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useCallback, useEffect } from 'react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport {\n LayoutDashboard,\n RefreshCw,\n Package,\n Blocks,\n Gauge,\n RotateCcw,\n Activity,\n TrendingUp,\n Settings,\n Ticket,\n Coins,\n TicketCheck,\n Landmark,\n Gift,\n} from 'lucide-react';\nimport { BillingProvider } from './providers/BillingProvider';\nimport type { NavItem, BillingRootProps } from './types';\nimport { BillingUserRoutes } from './BillingUserRoutes';\nimport { BillingAdminRoutes } from './BillingAdminRoutes';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\n/**\n * Root component for the Billing microfrontend.\n *\n * This is the main entry point that host applications import and render.\n * It sets up the necessary providers and renders the internal routing.\n * Automatically registers navigation items with the shell if registration functions are provided.\n *\n * @example\n * ```tsx\n * import { BillingRoot, type BillingRootProps } from '@burdenoff/microfe-billing';\n *\n * function App() {\n * const props: BillingRootProps = {\n * basePath: '/billing',\n * navigate: (path) => router.push(path),\n * currentUser: { id: '1', email: 'user@example.com', firstName: 'John', lastName: 'Doe' },\n * workspaceId: 'ws-123',\n * orgId: 'org-123',\n * apiGatewayUrl: 'https://api.example.com/tenant/graphql',\n * authToken: 'token',\n * stripePublishableKey: 'pk_test_...',\n * razorpayKey: 'rzp_test_...',\n * onSubscriptionCreate: (subscription) => console.log('Subscription created:', subscription),\n * onSubscriptionUpdate: (subscription) => console.log('Subscription updated:', subscription),\n * onPaymentProcess: (payment) => console.log('Payment processed:', payment),\n * registerNavItems: (items) => { return () => {}; },\n * };\n *\n * return <BillingRoot {...props} />;\n * }\n * ```\n */\nexport const BillingRoot: FC<BillingRootProps> = (props) => {\n const { t } = useI18n();\n const tr = useCallback(\n (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n },\n [t]\n );\n const { registerNavItems, registerFooterItems, basePath = '/', mode = 'user' } = props;\n\n // Helper to join paths correctly, avoiding double slashes\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 // Register navigation items with the shell based on mode\n useEffect(() => {\n if (!registerNavItems) return;\n\n const userNavItems: NavItem[] = [\n {\n id: 'billing-overview',\n label: tr('billing.nav.billing', 'Billing'),\n path: basePath === '/' ? '/' : joinPath(basePath, 'overview'),\n icon: <LayoutDashboard size={20} />,\n order: 100,\n group: 'billing',\n },\n {\n id: 'billing-subscriptions',\n label: tr('billing.nav.subscriptions', 'Subscriptions'),\n path: joinPath(basePath, 'subscriptions'),\n icon: <RefreshCw size={20} />,\n order: 110,\n group: 'billing',\n },\n {\n id: 'billing-plans',\n label: tr('billing.nav.plans', 'Plans'),\n path: joinPath(basePath, 'plans'),\n icon: <Package size={20} />,\n order: 120,\n group: 'billing',\n },\n {\n id: 'billing-addons',\n label: tr('billing.nav.addons', 'Addons'),\n path: joinPath(basePath, 'addons'),\n icon: <Blocks size={20} />,\n order: 130,\n group: 'billing',\n },\n {\n id: 'billing-usage',\n label: tr('billing.nav.usage', 'Usage'),\n path: joinPath(basePath, 'usage'),\n icon: <Activity size={20} />,\n order: 180,\n group: 'billing',\n },\n {\n id: 'billing-affiliate',\n label: tr('billing.nav.affiliate', 'Affiliate'),\n path: joinPath(basePath, 'affiliate'),\n icon: <TicketCheck size={20} />,\n order: 190,\n group: 'billing',\n },\n {\n id: 'billing-earnings',\n label: tr('billing.nav.earnings', 'Earnings'),\n path: joinPath(basePath, 'earnings'),\n icon: <Coins size={20} />,\n order: 200,\n group: 'billing',\n },\n {\n id: 'billing-payouts',\n label: tr('billing.nav.payouts', 'Payouts'),\n path: joinPath(basePath, 'payouts'),\n icon: <Landmark size={20} />,\n order: 205,\n group: 'billing',\n },\n {\n id: 'billing-settings',\n label: tr('billing.nav.settings', 'Settings'),\n path: joinPath(basePath, 'settings'),\n icon: <Settings size={20} />,\n order: 210,\n group: 'billing',\n },\n ];\n\n const adminNavItems: NavItem[] = [\n {\n id: 'billing-plans',\n label: tr('billing.nav.plans', 'Plans'),\n path: joinPath(basePath, 'plans'),\n icon: <Package size={20} />,\n order: 100,\n group: 'billing',\n },\n {\n id: 'billing-addons',\n label: tr('billing.nav.addons', 'Addons'),\n path: joinPath(basePath, 'addons'),\n icon: <Blocks size={20} />,\n order: 110,\n group: 'billing',\n },\n {\n id: 'billing-quotas',\n label: tr('billing.nav.quotas', 'Quotas'),\n path: joinPath(basePath, 'quotas'),\n icon: <Gauge size={20} />,\n order: 120,\n group: 'billing',\n },\n {\n id: 'billing-coupons',\n label: tr('billing.nav.coupons', 'Coupons'),\n path: joinPath(basePath, 'coupons'),\n icon: <Ticket size={20} />,\n order: 130,\n group: 'billing',\n },\n {\n id: 'billing-promotions',\n label: tr('billing.nav.promotions', 'Promotions'),\n path: joinPath(basePath, 'promotions'),\n icon: <Gift size={20} />,\n order: 135,\n group: 'billing',\n },\n\n {\n id: 'billing-credits-admin',\n label: tr('billing.nav.creditGrants', 'Credit Grants'),\n path: joinPath(basePath, 'credits'),\n icon: <Coins size={20} />,\n order: 150,\n group: 'billing',\n },\n {\n id: 'billing-refunds',\n label: tr('billing.nav.refunds', 'Refunds'),\n path: joinPath(basePath, 'refunds'),\n icon: <RotateCcw size={20} />,\n order: 160,\n group: 'billing',\n },\n {\n id: 'billing-admin-payouts',\n label: tr('billing.nav.payouts', 'Payouts'),\n path: joinPath(basePath, 'payouts'),\n icon: <Landmark size={20} />,\n order: 165,\n group: 'billing',\n },\n {\n id: 'billing-analytics',\n label: tr('billing.nav.analytics', 'Analytics'),\n path: joinPath(basePath, 'analytics'),\n icon: <TrendingUp size={20} />,\n order: 170,\n group: 'billing',\n },\n ];\n\n const navItems = mode === 'admin' ? adminNavItems : userNavItems;\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath, mode, tr]);\n\n // Register footer items (example: billing status indicator in left section)\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'billing-status',\n label: tr('billing.nav.billingReady', 'Billing Ready'),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems, tr]);\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'billing.errorBoundary.message',\n 'Something went wrong loading this module. Please refresh the page.'\n )}\n </div>\n }\n >\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <BillingProvider {...props}>\n {mode === 'admin' ? <BillingAdminRoutes /> : <BillingUserRoutes />}\n </BillingProvider>\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;AA0DA,IAAa,KAAqC,MAAU;CAC1D,IAAM,EAAE,SAAM,GAAS,EACjB,IAAK,GACR,GAAa,MAA6B;EACzC,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,IAAW;IAEzC,CAAC,EAAE,CACJ,EACK,EAAE,qBAAkB,wBAAqB,cAAW,KAAK,UAAO,WAAW,GAG3E,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;AAsLtD,QAjLA,QAAgB;AACd,MAAI,CAAC,EAAkB;EA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