@burdenoff/microfe-product 2026.514.4 → 2026.516.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.
- package/dist/product-management/modules/products/components/ProductPlans.d.ts.map +1 -1
- package/dist/product-management/modules/products/components/ProductPlans.js +232 -205
- package/dist/product-management/modules/products/components/ProductPlans.js.map +1 -1
- package/dist/product-management/modules/products/pages/ProductsListPage.d.ts.map +1 -1
- package/dist/product-management/modules/products/pages/ProductsListPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductPlans.d.ts","sourceRoot":"","sources":["../../../../../src/product-management/modules/products/components/ProductPlans.tsx"],"names":[],"mappings":"AA8HA,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,WAAW,EAAE,YAAY,EACzB,QAAgB,GACjB,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ProductPlans.d.ts","sourceRoot":"","sources":["../../../../../src/product-management/modules/products/components/ProductPlans.tsx"],"names":[],"mappings":"AA8HA,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,WAAW,EAAE,YAAY,EACzB,QAAgB,GACjB,EAAE,iBAAiB,2CAooBnB"}
|
|
@@ -1,81 +1,81 @@
|
|
|
1
1
|
import { useTr as e } from "../../../shared/hooks/useTr.js";
|
|
2
2
|
import { useCallback as t, useEffect as n, useState as r } from "react";
|
|
3
|
-
import { Check as i, DollarSign as a, Edit as o, List as s, Loader2 as c, Plus as l, ToggleLeft as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { graphqlFetch as
|
|
3
|
+
import { Check as i, DollarSign as a, Edit as o, List as s, Loader2 as c, Plus as l, ToggleLeft as ee, ToggleRight as te } from "lucide-react";
|
|
4
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
|
+
import { graphqlFetch as p } from "@burdenoff/fe-libs/shared/graphql/fetch";
|
|
6
6
|
//#region src/product-management/modules/products/components/ProductPlans.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let
|
|
7
|
+
var m = "\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", h = "\n query GetAllQuotas {\n getAllQuotas {\n id\n name\n limits\n }\n }\n", g = "\n mutation CreateQuota($input: createQuotaInput!) {\n createQuota(input: $input)\n }\n", _ = "\n mutation CreatePlan($input: createPlanInput!) {\n createPlan(input: $input)\n }\n", v = "\n mutation UpdatePlan($input: updatePlanInput!) {\n updatePlan(input: $input)\n }\n", y = "\n mutation TogglePlan($planID: ID!, $status: Boolean!) {\n togglePlan(planID: $planID, status: $status)\n }\n";
|
|
8
|
+
function b({ productId: b, productName: ne, readOnly: x = !1 }) {
|
|
9
|
+
let S = e(), [C, re] = r([]), [w, T] = r([]), [E, D] = r(!0), [O, k] = r(null), [A, j] = r(!1), [M, N] = r(null), [P, F] = r(!1), [I, L] = r(!1), [R, z] = r(""), [B, V] = r({
|
|
10
10
|
name: "",
|
|
11
11
|
price: "",
|
|
12
12
|
currency: "USD",
|
|
13
13
|
duration: "monthly",
|
|
14
14
|
quotas: []
|
|
15
|
-
}),
|
|
16
|
-
let n = await
|
|
15
|
+
}), H = t(async (e, t) => {
|
|
16
|
+
let n = await p({
|
|
17
17
|
gateway: "global",
|
|
18
18
|
query: e,
|
|
19
19
|
variables: t
|
|
20
20
|
});
|
|
21
21
|
if (n.errors?.length) throw Error(n.errors[0].message);
|
|
22
22
|
return n.data ?? null;
|
|
23
|
-
}, []),
|
|
23
|
+
}, []), U = t(async () => {
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
let [e, t] = await Promise.all([
|
|
27
|
-
|
|
25
|
+
D(!0);
|
|
26
|
+
let [e, t] = await Promise.all([H(m), H(h)]);
|
|
27
|
+
re((e?.getAllPlans || []).filter((e) => e.productID === b)), T(t?.getAllQuotas || []), k(null);
|
|
28
28
|
} catch (e) {
|
|
29
|
-
|
|
29
|
+
k(S("products.failedToLoadPlans", "Failed to load plans")), console.error("Failed to fetch plans:", e);
|
|
30
30
|
} finally {
|
|
31
|
-
|
|
31
|
+
D(!1);
|
|
32
32
|
}
|
|
33
|
-
}, [
|
|
33
|
+
}, [b, H]);
|
|
34
34
|
n(() => {
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
let
|
|
38
|
-
|
|
35
|
+
U();
|
|
36
|
+
}, [U]);
|
|
37
|
+
let W = () => {
|
|
38
|
+
V({
|
|
39
39
|
name: "",
|
|
40
40
|
price: "",
|
|
41
41
|
currency: "USD",
|
|
42
42
|
duration: "monthly",
|
|
43
43
|
quotas: []
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
e.preventDefault(),
|
|
44
|
+
}), N(null), j(!1);
|
|
45
|
+
}, G = async (e) => {
|
|
46
|
+
e.preventDefault(), F(!0);
|
|
47
47
|
try {
|
|
48
|
-
|
|
49
|
-
id:
|
|
50
|
-
name:
|
|
51
|
-
price: parseFloat(
|
|
52
|
-
currency:
|
|
53
|
-
duration:
|
|
54
|
-
quotas:
|
|
55
|
-
} }) : await
|
|
56
|
-
name:
|
|
57
|
-
price: parseFloat(
|
|
58
|
-
currency:
|
|
59
|
-
duration:
|
|
60
|
-
productId:
|
|
61
|
-
quotas:
|
|
62
|
-
} }),
|
|
48
|
+
M ? await H(v, { input: {
|
|
49
|
+
id: M.id,
|
|
50
|
+
name: B.name,
|
|
51
|
+
price: parseFloat(B.price),
|
|
52
|
+
currency: B.currency,
|
|
53
|
+
duration: B.duration,
|
|
54
|
+
quotas: B.quotas
|
|
55
|
+
} }) : await H(_, { input: {
|
|
56
|
+
name: B.name,
|
|
57
|
+
price: parseFloat(B.price),
|
|
58
|
+
currency: B.currency,
|
|
59
|
+
duration: B.duration,
|
|
60
|
+
productId: b,
|
|
61
|
+
quotas: B.quotas
|
|
62
|
+
} }), W(), await U();
|
|
63
63
|
} catch (e) {
|
|
64
|
-
console.error("Failed to save plan:", e),
|
|
64
|
+
console.error("Failed to save plan:", e), k(S("products.failedToSavePlan", "Failed to save plan"));
|
|
65
65
|
} finally {
|
|
66
|
-
|
|
66
|
+
F(!1);
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, K = async (e) => {
|
|
69
69
|
try {
|
|
70
|
-
await
|
|
70
|
+
await H(y, {
|
|
71
71
|
planID: e.id,
|
|
72
72
|
status: !e.isActive
|
|
73
|
-
}), await
|
|
73
|
+
}), await U();
|
|
74
74
|
} catch (e) {
|
|
75
75
|
console.error("Failed to toggle plan:", e);
|
|
76
76
|
}
|
|
77
|
-
},
|
|
78
|
-
|
|
77
|
+
}, q = (e) => {
|
|
78
|
+
N(e), V({
|
|
79
79
|
name: e.name,
|
|
80
80
|
price: e.price.toString(),
|
|
81
81
|
currency: e.currency,
|
|
@@ -84,120 +84,123 @@ function S({ productId: S, productName: ee, readOnly: C = !1 }) {
|
|
|
84
84
|
quotaId: e.quotaId,
|
|
85
85
|
quantity: 1
|
|
86
86
|
}))
|
|
87
|
-
}),
|
|
88
|
-
},
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
name:
|
|
87
|
+
}), j(!0);
|
|
88
|
+
}, J = async () => {
|
|
89
|
+
if (R.trim()) try {
|
|
90
|
+
F(!0), await H(g, { input: {
|
|
91
|
+
name: R.trim(),
|
|
92
92
|
quotaType: "PRODUCT_SPECIFIC",
|
|
93
93
|
limits: {},
|
|
94
94
|
reusable: !0
|
|
95
|
-
} }),
|
|
95
|
+
} }), z(""), L(!1), await U();
|
|
96
96
|
} catch (e) {
|
|
97
|
-
console.error("Failed to create quota:", e),
|
|
97
|
+
console.error("Failed to create quota:", e), k(S("products.failedToCreateFeature", "Failed to create feature"));
|
|
98
98
|
} finally {
|
|
99
|
-
|
|
99
|
+
F(!1);
|
|
100
100
|
}
|
|
101
|
-
},
|
|
102
|
-
|
|
101
|
+
}, Y = (e) => {
|
|
102
|
+
let t = e.toLowerCase();
|
|
103
|
+
return t.includes("team") || t.includes("business") || t.includes("enterprise");
|
|
104
|
+
}, X = C.filter((e) => !Y(e.name)), Z = C.filter((e) => Y(e.name)), ie = X.filter((e) => e.duration === "monthly"), ae = X.filter((e) => e.duration === "yearly"), [Q, $] = r("individual");
|
|
105
|
+
return /* @__PURE__ */ f("div", {
|
|
103
106
|
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",
|
|
104
107
|
children: [
|
|
105
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ f("div", {
|
|
106
109
|
className: "flex items-center justify-between mb-4",
|
|
107
|
-
children: [/* @__PURE__ */
|
|
110
|
+
children: [/* @__PURE__ */ f("h2", {
|
|
108
111
|
className: "text-lg font-semibold text-text-primary flex items-center gap-2",
|
|
109
|
-
children: [/* @__PURE__ */
|
|
110
|
-
}), !
|
|
112
|
+
children: [/* @__PURE__ */ d(a, { size: 18 }), S("products.pricingPlans", "Pricing Plans")]
|
|
113
|
+
}), !x && /* @__PURE__ */ f("button", {
|
|
111
114
|
onClick: () => {
|
|
112
|
-
|
|
115
|
+
W(), j(!A);
|
|
113
116
|
},
|
|
114
117
|
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 ",
|
|
115
|
-
children: [/* @__PURE__ */
|
|
118
|
+
children: [/* @__PURE__ */ d(l, { size: 14 }), S("products.addPlan", "Add Plan")]
|
|
116
119
|
})]
|
|
117
120
|
}),
|
|
118
|
-
|
|
119
|
-
onSubmit:
|
|
121
|
+
A && !x && /* @__PURE__ */ f("form", {
|
|
122
|
+
onSubmit: G,
|
|
120
123
|
className: "mb-6 p-4 bg-muted rounded-lg border border-default",
|
|
121
124
|
children: [
|
|
122
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ d("h3", {
|
|
123
126
|
className: "text-sm font-semibold text-text-primary mb-3",
|
|
124
|
-
children:
|
|
127
|
+
children: M ? S("products.editPlan", "Edit Plan") : S("products.createNewPlan", "Create New Plan")
|
|
125
128
|
}),
|
|
126
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */ f("div", {
|
|
127
130
|
className: "grid grid-cols-2 sm:grid-cols-4 gap-3",
|
|
128
131
|
children: [
|
|
129
|
-
/* @__PURE__ */
|
|
132
|
+
/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ f("label", {
|
|
130
133
|
className: "block text-xs font-medium text-text-secondary mb-1",
|
|
131
|
-
children: [
|
|
132
|
-
}), /* @__PURE__ */
|
|
134
|
+
children: [S("products.planName", "Name"), " *"]
|
|
135
|
+
}), /* @__PURE__ */ d("input", {
|
|
133
136
|
type: "text",
|
|
134
|
-
value:
|
|
135
|
-
onChange: (e) =>
|
|
136
|
-
...
|
|
137
|
+
value: B.name,
|
|
138
|
+
onChange: (e) => V({
|
|
139
|
+
...B,
|
|
137
140
|
name: e.target.value
|
|
138
141
|
}),
|
|
139
142
|
placeholder: "e.g. Basic",
|
|
140
143
|
required: !0,
|
|
141
144
|
className: "w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary"
|
|
142
145
|
})] }),
|
|
143
|
-
/* @__PURE__ */
|
|
146
|
+
/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ f("label", {
|
|
144
147
|
className: "block text-xs font-medium text-text-secondary mb-1",
|
|
145
|
-
children: [
|
|
146
|
-
}), /* @__PURE__ */
|
|
148
|
+
children: [S("products.planPrice", "Price"), " *"]
|
|
149
|
+
}), /* @__PURE__ */ d("input", {
|
|
147
150
|
type: "number",
|
|
148
151
|
step: "0.01",
|
|
149
152
|
min: "0",
|
|
150
|
-
value:
|
|
151
|
-
onChange: (e) =>
|
|
152
|
-
...
|
|
153
|
+
value: B.price,
|
|
154
|
+
onChange: (e) => V({
|
|
155
|
+
...B,
|
|
153
156
|
price: e.target.value
|
|
154
157
|
}),
|
|
155
158
|
placeholder: "9.99",
|
|
156
159
|
required: !0,
|
|
157
160
|
className: "w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary"
|
|
158
161
|
})] }),
|
|
159
|
-
/* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ f("label", {
|
|
160
163
|
className: "block text-xs font-medium text-text-secondary mb-1",
|
|
161
|
-
children: [
|
|
162
|
-
}), /* @__PURE__ */
|
|
163
|
-
value:
|
|
164
|
-
onChange: (e) =>
|
|
165
|
-
...
|
|
164
|
+
children: [S("products.planDuration", "Duration"), " *"]
|
|
165
|
+
}), /* @__PURE__ */ f("select", {
|
|
166
|
+
value: B.duration,
|
|
167
|
+
onChange: (e) => V({
|
|
168
|
+
...B,
|
|
166
169
|
duration: e.target.value
|
|
167
170
|
}),
|
|
168
171
|
className: "w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary",
|
|
169
|
-
children: [/* @__PURE__ */
|
|
172
|
+
children: [/* @__PURE__ */ d("option", {
|
|
170
173
|
value: "monthly",
|
|
171
|
-
children:
|
|
172
|
-
}), /* @__PURE__ */
|
|
174
|
+
children: S("products.monthly", "Monthly")
|
|
175
|
+
}), /* @__PURE__ */ d("option", {
|
|
173
176
|
value: "yearly",
|
|
174
|
-
children:
|
|
177
|
+
children: S("products.yearly", "Yearly")
|
|
175
178
|
})]
|
|
176
179
|
})] }),
|
|
177
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
|
|
178
181
|
className: "block text-xs font-medium text-text-secondary mb-1",
|
|
179
|
-
children:
|
|
180
|
-
}), /* @__PURE__ */
|
|
181
|
-
value:
|
|
182
|
-
onChange: (e) =>
|
|
183
|
-
...
|
|
182
|
+
children: S("products.currency", "Currency")
|
|
183
|
+
}), /* @__PURE__ */ f("select", {
|
|
184
|
+
value: B.currency,
|
|
185
|
+
onChange: (e) => V({
|
|
186
|
+
...B,
|
|
184
187
|
currency: e.target.value
|
|
185
188
|
}),
|
|
186
189
|
className: "w-full px-3 py-2 text-sm rounded-md border border-default bg-surface text-text-primary",
|
|
187
190
|
children: [
|
|
188
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ d("option", {
|
|
189
192
|
value: "USD",
|
|
190
193
|
children: "USD"
|
|
191
194
|
}),
|
|
192
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ d("option", {
|
|
193
196
|
value: "EUR",
|
|
194
197
|
children: "EUR"
|
|
195
198
|
}),
|
|
196
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ d("option", {
|
|
197
200
|
value: "GBP",
|
|
198
201
|
children: "GBP"
|
|
199
202
|
}),
|
|
200
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ d("option", {
|
|
201
204
|
value: "INR",
|
|
202
205
|
children: "INR"
|
|
203
206
|
})
|
|
@@ -205,241 +208,265 @@ function S({ productId: S, productName: ee, readOnly: C = !1 }) {
|
|
|
205
208
|
})] })
|
|
206
209
|
]
|
|
207
210
|
}),
|
|
208
|
-
/* @__PURE__ */
|
|
211
|
+
/* @__PURE__ */ f("div", {
|
|
209
212
|
className: "mt-3",
|
|
210
|
-
children: [/* @__PURE__ */
|
|
213
|
+
children: [/* @__PURE__ */ f("label", {
|
|
211
214
|
className: "block text-xs font-medium text-text-secondary mb-1",
|
|
212
|
-
children: [/* @__PURE__ */
|
|
215
|
+
children: [/* @__PURE__ */ d(s, {
|
|
213
216
|
size: 12,
|
|
214
217
|
className: "inline mr-1"
|
|
215
|
-
}),
|
|
216
|
-
}),
|
|
218
|
+
}), S("products.featuresQuotas", "Features / Quotas")]
|
|
219
|
+
}), w.length > 0 ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("div", {
|
|
217
220
|
className: "space-y-1.5 max-h-32 overflow-y-auto",
|
|
218
|
-
children:
|
|
221
|
+
children: w.map((e) => /* @__PURE__ */ f("label", {
|
|
219
222
|
className: "flex items-center gap-2 text-xs text-text-primary cursor-pointer hover:bg-muted/50 px-2 py-1 rounded",
|
|
220
|
-
children: [/* @__PURE__ */
|
|
223
|
+
children: [/* @__PURE__ */ d("input", {
|
|
221
224
|
type: "checkbox",
|
|
222
|
-
checked:
|
|
225
|
+
checked: B.quotas.some((t) => t.quotaId === e.id),
|
|
223
226
|
onChange: (t) => {
|
|
224
|
-
t.target.checked ?
|
|
225
|
-
...
|
|
226
|
-
quotas: [...
|
|
227
|
+
t.target.checked ? V({
|
|
228
|
+
...B,
|
|
229
|
+
quotas: [...B.quotas, {
|
|
227
230
|
quotaId: e.id,
|
|
228
231
|
quantity: 1
|
|
229
232
|
}]
|
|
230
|
-
}) :
|
|
231
|
-
...
|
|
232
|
-
quotas:
|
|
233
|
+
}) : V({
|
|
234
|
+
...B,
|
|
235
|
+
quotas: B.quotas.filter((t) => t.quotaId !== e.id)
|
|
233
236
|
});
|
|
234
237
|
},
|
|
235
238
|
className: "rounded border-default"
|
|
236
239
|
}), e.name]
|
|
237
240
|
}, e.id))
|
|
238
|
-
}), /* @__PURE__ */
|
|
241
|
+
}), /* @__PURE__ */ f("div", {
|
|
239
242
|
className: "flex items-center gap-2 mt-2",
|
|
240
243
|
children: [
|
|
241
|
-
/* @__PURE__ */
|
|
244
|
+
/* @__PURE__ */ f("p", {
|
|
242
245
|
className: "text-xs text-text-secondary",
|
|
243
246
|
children: [
|
|
244
|
-
|
|
247
|
+
B.quotas.length,
|
|
245
248
|
" ",
|
|
246
|
-
|
|
249
|
+
S("products.featuresSelected", "feature(s) selected")
|
|
247
250
|
]
|
|
248
251
|
}),
|
|
249
|
-
/* @__PURE__ */
|
|
252
|
+
/* @__PURE__ */ d("span", {
|
|
250
253
|
className: "text-xs text-text-secondary",
|
|
251
254
|
children: "|"
|
|
252
255
|
}),
|
|
253
|
-
|
|
256
|
+
I ? /* @__PURE__ */ f("div", {
|
|
254
257
|
className: "flex items-center gap-1.5",
|
|
255
258
|
children: [
|
|
256
|
-
/* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ d("input", {
|
|
257
260
|
type: "text",
|
|
258
|
-
value:
|
|
259
|
-
onChange: (e) =>
|
|
260
|
-
placeholder:
|
|
261
|
+
value: R,
|
|
262
|
+
onChange: (e) => z(e.target.value),
|
|
263
|
+
placeholder: S("products.featureNamePlaceholder", "Feature name"),
|
|
261
264
|
className: "px-2 py-1 text-xs rounded border border-default bg-surface text-text-primary w-36",
|
|
262
265
|
onKeyDown: (e) => {
|
|
263
|
-
e.key === "Enter" && (e.preventDefault(),
|
|
266
|
+
e.key === "Enter" && (e.preventDefault(), J());
|
|
264
267
|
}
|
|
265
268
|
}),
|
|
266
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ d("button", {
|
|
267
270
|
type: "button",
|
|
268
|
-
onClick:
|
|
269
|
-
disabled:
|
|
271
|
+
onClick: J,
|
|
272
|
+
disabled: P || !R.trim(),
|
|
270
273
|
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",
|
|
271
|
-
children:
|
|
274
|
+
children: S("productCommon.add", "Add")
|
|
272
275
|
}),
|
|
273
|
-
/* @__PURE__ */
|
|
276
|
+
/* @__PURE__ */ d("button", {
|
|
274
277
|
type: "button",
|
|
275
278
|
onClick: () => {
|
|
276
|
-
|
|
279
|
+
L(!1), z("");
|
|
277
280
|
},
|
|
278
281
|
className: "px-1.5 py-1 text-xs text-text-secondary hover:text-text-primary",
|
|
279
|
-
children:
|
|
282
|
+
children: S("productCommon.cancel", "Cancel")
|
|
280
283
|
})
|
|
281
284
|
]
|
|
282
|
-
}) : /* @__PURE__ */
|
|
285
|
+
}) : /* @__PURE__ */ d("button", {
|
|
283
286
|
type: "button",
|
|
284
|
-
onClick: () =>
|
|
287
|
+
onClick: () => L(!0),
|
|
285
288
|
className: "text-xs text-[var(--color-action-primary-bg)] hover:underline",
|
|
286
|
-
children:
|
|
289
|
+
children: S("products.createNewFeature", "+ Create new feature")
|
|
287
290
|
})
|
|
288
291
|
]
|
|
289
|
-
})] }) : /* @__PURE__ */
|
|
292
|
+
})] }) : /* @__PURE__ */ f("div", {
|
|
290
293
|
className: "text-xs text-text-secondary",
|
|
291
294
|
children: [
|
|
292
|
-
|
|
295
|
+
S("products.noFeaturesCreated", "No features created yet."),
|
|
293
296
|
" ",
|
|
294
|
-
|
|
297
|
+
I ? /* @__PURE__ */ f("div", {
|
|
295
298
|
className: "flex items-center gap-1.5 mt-1.5",
|
|
296
299
|
children: [
|
|
297
|
-
/* @__PURE__ */
|
|
300
|
+
/* @__PURE__ */ d("input", {
|
|
298
301
|
type: "text",
|
|
299
|
-
value:
|
|
300
|
-
onChange: (e) =>
|
|
302
|
+
value: R,
|
|
303
|
+
onChange: (e) => z(e.target.value),
|
|
301
304
|
placeholder: "Feature name",
|
|
302
305
|
className: "px-2 py-1 text-xs rounded border border-default bg-surface text-text-primary w-36",
|
|
303
306
|
onKeyDown: (e) => {
|
|
304
|
-
e.key === "Enter" && (e.preventDefault(),
|
|
307
|
+
e.key === "Enter" && (e.preventDefault(), J());
|
|
305
308
|
}
|
|
306
309
|
}),
|
|
307
|
-
/* @__PURE__ */
|
|
310
|
+
/* @__PURE__ */ d("button", {
|
|
308
311
|
type: "button",
|
|
309
|
-
onClick:
|
|
310
|
-
disabled:
|
|
312
|
+
onClick: J,
|
|
313
|
+
disabled: P || !R.trim(),
|
|
311
314
|
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",
|
|
312
315
|
children: "Add"
|
|
313
316
|
}),
|
|
314
|
-
/* @__PURE__ */
|
|
317
|
+
/* @__PURE__ */ d("button", {
|
|
315
318
|
type: "button",
|
|
316
319
|
onClick: () => {
|
|
317
|
-
|
|
320
|
+
L(!1), z("");
|
|
318
321
|
},
|
|
319
322
|
className: "px-1.5 py-1 text-xs text-text-secondary hover:text-text-primary",
|
|
320
323
|
children: "Cancel"
|
|
321
324
|
})
|
|
322
325
|
]
|
|
323
|
-
}) : /* @__PURE__ */
|
|
326
|
+
}) : /* @__PURE__ */ d("button", {
|
|
324
327
|
type: "button",
|
|
325
|
-
onClick: () =>
|
|
328
|
+
onClick: () => L(!0),
|
|
326
329
|
className: "text-[var(--color-action-primary-bg)] hover:underline",
|
|
327
|
-
children:
|
|
330
|
+
children: S("products.createYourFirstFeature", "Create your first feature")
|
|
328
331
|
})
|
|
329
332
|
]
|
|
330
333
|
})]
|
|
331
334
|
}),
|
|
332
|
-
/* @__PURE__ */
|
|
335
|
+
/* @__PURE__ */ f("div", {
|
|
333
336
|
className: "flex gap-2 mt-3",
|
|
334
|
-
children: [/* @__PURE__ */
|
|
337
|
+
children: [/* @__PURE__ */ f("button", {
|
|
335
338
|
type: "submit",
|
|
336
|
-
disabled:
|
|
339
|
+
disabled: P,
|
|
337
340
|
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 ",
|
|
338
|
-
children: [
|
|
341
|
+
children: [P && /* @__PURE__ */ d(c, {
|
|
339
342
|
size: 14,
|
|
340
343
|
className: "animate-spin"
|
|
341
|
-
}),
|
|
342
|
-
}), /* @__PURE__ */
|
|
344
|
+
}), M ? S("products.updatePlan", "Update Plan") : S("products.createPlan", "Create Plan")]
|
|
345
|
+
}), /* @__PURE__ */ d("button", {
|
|
343
346
|
type: "button",
|
|
344
|
-
onClick:
|
|
347
|
+
onClick: W,
|
|
345
348
|
className: "px-4 py-2 text-sm text-text-secondary hover:text-text-primary transition-colors",
|
|
346
|
-
children:
|
|
349
|
+
children: S("productCommon.cancel", "Cancel")
|
|
347
350
|
})]
|
|
348
351
|
})
|
|
349
352
|
]
|
|
350
353
|
}),
|
|
351
|
-
|
|
354
|
+
O && /* @__PURE__ */ d("div", {
|
|
352
355
|
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)]",
|
|
353
|
-
children:
|
|
356
|
+
children: O
|
|
354
357
|
}),
|
|
355
|
-
|
|
358
|
+
E ? /* @__PURE__ */ f("div", {
|
|
356
359
|
className: "flex items-center justify-center py-8",
|
|
357
|
-
children: [/* @__PURE__ */
|
|
360
|
+
children: [/* @__PURE__ */ d(c, {
|
|
358
361
|
size: 20,
|
|
359
362
|
className: "animate-spin text-text-secondary"
|
|
360
|
-
}), /* @__PURE__ */
|
|
363
|
+
}), /* @__PURE__ */ d("span", {
|
|
361
364
|
className: "ml-2 text-sm text-text-secondary",
|
|
362
|
-
children:
|
|
365
|
+
children: S("products.loadingPlans", "Loading plans...")
|
|
363
366
|
})]
|
|
364
|
-
}) :
|
|
367
|
+
}) : C.length === 0 ? /* @__PURE__ */ f("div", {
|
|
365
368
|
className: "text-center py-8",
|
|
366
369
|
children: [
|
|
367
|
-
/* @__PURE__ */
|
|
370
|
+
/* @__PURE__ */ d(a, {
|
|
368
371
|
size: 32,
|
|
369
372
|
className: "mx-auto mb-2 text-text-secondary opacity-50"
|
|
370
373
|
}),
|
|
371
|
-
/* @__PURE__ */
|
|
374
|
+
/* @__PURE__ */ d("p", {
|
|
372
375
|
className: "text-sm text-text-secondary",
|
|
373
|
-
children:
|
|
376
|
+
children: S("products.noPricingPlans", "No pricing plans yet")
|
|
374
377
|
}),
|
|
375
|
-
/* @__PURE__ */
|
|
378
|
+
/* @__PURE__ */ d("p", {
|
|
376
379
|
className: "text-xs text-text-secondary mt-1",
|
|
377
|
-
children:
|
|
380
|
+
children: S("products.clickAddPlan", "Click \"Add Plan\" to create your first plan")
|
|
378
381
|
})
|
|
379
382
|
]
|
|
380
|
-
}) : /* @__PURE__ */
|
|
383
|
+
}) : /* @__PURE__ */ f("div", {
|
|
381
384
|
className: "space-y-6",
|
|
382
|
-
children: [{
|
|
383
|
-
|
|
384
|
-
|
|
385
|
+
children: [Z.length > 0 && /* @__PURE__ */ f("div", {
|
|
386
|
+
className: "flex gap-2 mb-2",
|
|
387
|
+
children: [/* @__PURE__ */ f("button", {
|
|
388
|
+
type: "button",
|
|
389
|
+
onClick: () => $("individual"),
|
|
390
|
+
className: `px-4 py-1.5 rounded-lg text-sm font-medium transition-all ${Q === "individual" ? "bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)]" : "bg-[var(--color-bg-muted)] text-text-secondary hover:text-text-primary"}`,
|
|
391
|
+
children: [
|
|
392
|
+
"Individual (",
|
|
393
|
+
X.length,
|
|
394
|
+
")"
|
|
395
|
+
]
|
|
396
|
+
}), /* @__PURE__ */ f("button", {
|
|
397
|
+
type: "button",
|
|
398
|
+
onClick: () => $("enterprise"),
|
|
399
|
+
className: `px-4 py-1.5 rounded-lg text-sm font-medium transition-all ${Q === "enterprise" ? "bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)]" : "bg-[var(--color-bg-muted)] text-text-secondary hover:text-text-primary"}`,
|
|
400
|
+
children: [
|
|
401
|
+
"Enterprise (",
|
|
402
|
+
Z.length,
|
|
403
|
+
")"
|
|
404
|
+
]
|
|
405
|
+
})]
|
|
406
|
+
}), (Q === "individual" || Z.length === 0 ? [{
|
|
407
|
+
label: S("products.monthlyPlans", "Monthly Plans"),
|
|
408
|
+
plans: ie
|
|
385
409
|
}, {
|
|
386
|
-
label:
|
|
387
|
-
plans:
|
|
388
|
-
}]
|
|
410
|
+
label: S("products.yearlyPlans", "Yearly Plans"),
|
|
411
|
+
plans: ae
|
|
412
|
+
}] : [{
|
|
413
|
+
label: S("products.enterprisePlans", "Enterprise Plans"),
|
|
414
|
+
plans: Z
|
|
415
|
+
}]).filter((e) => e.plans.length > 0).map((e) => /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("h3", {
|
|
389
416
|
className: "text-xs font-semibold text-text-secondary uppercase tracking-wider mb-3",
|
|
390
417
|
children: e.label
|
|
391
|
-
}), /* @__PURE__ */
|
|
418
|
+
}), /* @__PURE__ */ d("div", {
|
|
392
419
|
className: "grid grid-cols-1 md:grid-cols-3 gap-4",
|
|
393
420
|
children: e.plans.sort((e, t) => e.price - t.price).map((e) => {
|
|
394
421
|
let t = e.currency === "USD" ? "$" : e.currency === "EUR" ? "€" : e.currency === "GBP" ? "£" : "₹", n = e.name.toLowerCase().includes("professional") || e.name.toLowerCase().includes("pro");
|
|
395
|
-
return /* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ f("div", {
|
|
396
423
|
className: `
|
|
397
424
|
relative rounded-xl border p-5 transition-all duration-200
|
|
398
425
|
${e.isActive ? "border-default bg-surface hover:shadow-md" : "border-default bg-muted/30 opacity-60"}
|
|
399
426
|
${n ? "border-[var(--color-action-primary-bg)] ring-1 ring-[var(--color-action-primary-bg)]/20" : ""}
|
|
400
427
|
`,
|
|
401
428
|
children: [
|
|
402
|
-
n && /* @__PURE__ */
|
|
429
|
+
n && /* @__PURE__ */ d("span", {
|
|
403
430
|
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",
|
|
404
|
-
children:
|
|
431
|
+
children: S("products.popular", "Popular")
|
|
405
432
|
}),
|
|
406
|
-
/* @__PURE__ */
|
|
433
|
+
/* @__PURE__ */ f("div", {
|
|
407
434
|
className: "flex items-start justify-between mb-3",
|
|
408
|
-
children: [/* @__PURE__ */
|
|
435
|
+
children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("h4", {
|
|
409
436
|
className: "text-base font-semibold text-text-primary",
|
|
410
437
|
children: e.name
|
|
411
|
-
}), /* @__PURE__ */
|
|
438
|
+
}), /* @__PURE__ */ d("span", {
|
|
412
439
|
className: `inline-flex items-center px-1.5 py-0.5 text-xs font-medium rounded-full mt-1 ${e.isActive ? "bg-[var(--color-status-success-subtle)] text-[var(--color-status-success)]" : "bg-muted text-text-secondary"}`,
|
|
413
|
-
children: e.isActive ?
|
|
414
|
-
})] }), !
|
|
440
|
+
children: e.isActive ? S("products.statusActive", "Active") : S("products.statusInactive", "Inactive")
|
|
441
|
+
})] }), !x && /* @__PURE__ */ f("div", {
|
|
415
442
|
className: "flex items-center gap-0.5",
|
|
416
|
-
children: [/* @__PURE__ */
|
|
417
|
-
onClick: () =>
|
|
418
|
-
title: e.isActive ?
|
|
443
|
+
children: [/* @__PURE__ */ d("button", {
|
|
444
|
+
onClick: () => K(e),
|
|
445
|
+
title: e.isActive ? S("products.deactivate", "Deactivate") : S("products.activate", "Activate"),
|
|
419
446
|
className: "p-1.5 rounded-lg hover:bg-muted transition-colors text-text-secondary hover:text-text-primary",
|
|
420
|
-
children: e.isActive ? /* @__PURE__ */
|
|
447
|
+
children: e.isActive ? /* @__PURE__ */ d(te, {
|
|
421
448
|
size: 16,
|
|
422
449
|
className: "text-[var(--color-status-success)]"
|
|
423
|
-
}) : /* @__PURE__ */
|
|
424
|
-
}), /* @__PURE__ */
|
|
425
|
-
onClick: () =>
|
|
426
|
-
title:
|
|
450
|
+
}) : /* @__PURE__ */ d(ee, { size: 16 })
|
|
451
|
+
}), /* @__PURE__ */ d("button", {
|
|
452
|
+
onClick: () => q(e),
|
|
453
|
+
title: S("products.edit", "Edit"),
|
|
427
454
|
className: "p-1.5 rounded-lg hover:bg-muted transition-colors text-text-secondary hover:text-text-primary",
|
|
428
|
-
children: /* @__PURE__ */
|
|
455
|
+
children: /* @__PURE__ */ d(o, { size: 14 })
|
|
429
456
|
})]
|
|
430
457
|
})]
|
|
431
458
|
}),
|
|
432
|
-
/* @__PURE__ */
|
|
459
|
+
/* @__PURE__ */ f("div", {
|
|
433
460
|
className: "mb-4",
|
|
434
|
-
children: [/* @__PURE__ */
|
|
461
|
+
children: [/* @__PURE__ */ f("span", {
|
|
435
462
|
className: "text-3xl font-bold text-text-primary",
|
|
436
463
|
children: [t, e.price]
|
|
437
|
-
}), /* @__PURE__ */
|
|
464
|
+
}), /* @__PURE__ */ f("span", {
|
|
438
465
|
className: "text-sm text-text-secondary ml-1",
|
|
439
466
|
children: ["/", e.duration === "monthly" ? "month" : "year"]
|
|
440
467
|
})]
|
|
441
468
|
}),
|
|
442
|
-
e.features && e.features.length > 0 ? /* @__PURE__ */
|
|
469
|
+
e.features && e.features.length > 0 ? /* @__PURE__ */ f("div", {
|
|
443
470
|
className: "space-y-2 border-t border-default pt-3",
|
|
444
471
|
children: [e.features.slice(0, 6).map((e) => {
|
|
445
472
|
let t = e.quota, n = e.quotaId;
|
|
@@ -447,14 +474,14 @@ function S({ productId: S, productName: ee, readOnly: C = !1 }) {
|
|
|
447
474
|
let e = t.name.split("."), r = ((e.length >= 3 ? e[e.length - 2] : e[e.length - 1]) || t.name).replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), i = t.limits && typeof t.limits == "object" ? t.limits.value : null;
|
|
448
475
|
n = typeof i == "number" ? `${i.toLocaleString()} ${r}` : r;
|
|
449
476
|
}
|
|
450
|
-
return /* @__PURE__ */
|
|
477
|
+
return /* @__PURE__ */ f("div", {
|
|
451
478
|
className: "flex items-center gap-2 text-sm text-text-primary",
|
|
452
|
-
children: [/* @__PURE__ */
|
|
479
|
+
children: [/* @__PURE__ */ d(i, {
|
|
453
480
|
size: 14,
|
|
454
481
|
className: "text-[var(--color-status-success)] flex-shrink-0"
|
|
455
|
-
}), /* @__PURE__ */
|
|
482
|
+
}), /* @__PURE__ */ d("span", { children: n })]
|
|
456
483
|
}, e.id);
|
|
457
|
-
}), e.features.length > 6 && /* @__PURE__ */
|
|
484
|
+
}), e.features.length > 6 && /* @__PURE__ */ f("p", {
|
|
458
485
|
className: "text-xs text-text-secondary pl-5",
|
|
459
486
|
children: [
|
|
460
487
|
"+",
|
|
@@ -462,22 +489,22 @@ function S({ productId: S, productName: ee, readOnly: C = !1 }) {
|
|
|
462
489
|
" more"
|
|
463
490
|
]
|
|
464
491
|
})]
|
|
465
|
-
}) : /* @__PURE__ */
|
|
492
|
+
}) : /* @__PURE__ */ d("div", {
|
|
466
493
|
className: "border-t border-default pt-3",
|
|
467
|
-
children: /* @__PURE__ */
|
|
494
|
+
children: /* @__PURE__ */ d("p", {
|
|
468
495
|
className: "text-xs text-text-secondary italic",
|
|
469
|
-
children:
|
|
496
|
+
children: S("products.noFeaturesAssigned", "No features assigned")
|
|
470
497
|
})
|
|
471
498
|
})
|
|
472
499
|
]
|
|
473
500
|
}, e.id);
|
|
474
501
|
})
|
|
475
|
-
})] }, e.label))
|
|
502
|
+
})] }, e.label))]
|
|
476
503
|
})
|
|
477
504
|
]
|
|
478
505
|
});
|
|
479
506
|
}
|
|
480
507
|
//#endregion
|
|
481
|
-
export {
|
|
508
|
+
export { b as ProductPlans };
|
|
482
509
|
|
|
483
510
|
//# sourceMappingURL=ProductPlans.js.map
|
|
@@ -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<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.slice(0, 6).map((f) => {\n const quota = f.quota;\n let label = f.quotaId;\n if (quota) {\n // Extract readable name from dotted quota name\n const parts = quota.name.split('.');\n const resource =\n parts.length >= 3\n ? parts[parts.length - 2]\n : parts[parts.length - 1];\n const readableName = (resource || quota.name)\n .replace(/[-_]/g, ' ')\n .replace(/\\b\\w/g, (c: string) => c.toUpperCase());\n const value =\n quota.limits && typeof quota.limits === 'object'\n ? (quota.limits as Record<string, unknown>).value\n : null;\n label =\n typeof value === 'number'\n ? `${value.toLocaleString()} ${readableName}`\n : readableName;\n }\n return (\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>{label}</span>\n </div>\n );\n })}\n {plan.features.length > 6 && (\n <p className=\"text-xs text-text-secondary pl-5\">\n +{plan.features.length - 6} more\n </p>\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,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AQ,UAAU,MAAc,EAAE,aAAa,CAAC,EAC7C,IACJ,EAAM,UAAU,OAAO,EAAM,UAAW,WACnC,EAAM,OAAmC,QAC1C;AACN,eACE,OAAO,KAAU,WACb,GAAG,EAAM,gBAAgB,CAAC,GAAG,MAC7B;;AAER,iBACE,kBAAC,OAAD;WAEE,WAAU;qBAFZ,CAIE,kBAAC,GAAD;YACE,MAAM;YACN,WAAU;YACV,CAAA,EACF,kBAAC,QAAD,EAAA,UAAO,GAAa,CAAA,CAChB;aARC,EAAE,GAQH;WAER,EACD,EAAK,SAAS,SAAS,KACtB,kBAAC,KAAD;UAAG,WAAU;oBAAb;WAAgD;WAC5C,EAAK,SAAS,SAAS;WAAE;WACzB;YAEF;aAEN,kBAAC,OAAD;SAAK,WAAU;mBACb,kBAAC,KAAD;UAAG,WAAU;oBACV,EAAG,+BAA+B,uBAAuB;UACxD,CAAA;SACA,CAAA;QAEJ;SA5HC,EAAK,GA4HN;OAER;KACA,CAAA,CACF,EAAA,EArJI,EAAM,MAqJV,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 // Split plans by audience\n const isEnterprisePlan = (name: string) => {\n const n = name.toLowerCase();\n return n.includes('team') || n.includes('business') || n.includes('enterprise');\n };\n const individualPlans = plans.filter((p) => !isEnterprisePlan(p.name));\n const enterprisePlansList = plans.filter((p) => isEnterprisePlan(p.name));\n\n const monthlyPlans = individualPlans.filter((p) => p.duration === 'monthly');\n const yearlyPlans = individualPlans.filter((p) => p.duration === 'yearly');\n const [audienceTab, setAudienceTab] = useState<'individual' | 'enterprise'>('individual');\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 {/* Audience Tabs */}\n {enterprisePlansList.length > 0 && (\n <div className=\"flex gap-2 mb-2\">\n <button\n type=\"button\"\n onClick={() => setAudienceTab('individual')}\n className={`px-4 py-1.5 rounded-lg text-sm font-medium transition-all ${\n audienceTab === 'individual'\n ? 'bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)]'\n : 'bg-[var(--color-bg-muted)] text-text-secondary hover:text-text-primary'\n }`}\n >\n Individual ({individualPlans.length})\n </button>\n <button\n type=\"button\"\n onClick={() => setAudienceTab('enterprise')}\n className={`px-4 py-1.5 rounded-lg text-sm font-medium transition-all ${\n audienceTab === 'enterprise'\n ? 'bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)]'\n : 'bg-[var(--color-bg-muted)] text-text-secondary hover:text-text-primary'\n }`}\n >\n Enterprise ({enterprisePlansList.length})\n </button>\n </div>\n )}\n\n {/* Plan Groups */}\n {(audienceTab === 'individual' || enterprisePlansList.length === 0 ? [\n { label: tr('products.monthlyPlans', 'Monthly Plans'), plans: monthlyPlans },\n { label: tr('products.yearlyPlans', 'Yearly Plans'), plans: yearlyPlans },\n ] : [\n { label: tr('products.enterprisePlans', 'Enterprise Plans'), plans: enterprisePlansList },\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.slice(0, 6).map((f) => {\n const quota = f.quota;\n let label = f.quotaId;\n if (quota) {\n // Extract readable name from dotted quota name\n const parts = quota.name.split('.');\n const resource =\n parts.length >= 3\n ? parts[parts.length - 2]\n : parts[parts.length - 1];\n const readableName = (resource || quota.name)\n .replace(/[-_]/g, ' ')\n .replace(/\\b\\w/g, (c: string) => c.toUpperCase());\n const value =\n quota.limits && typeof quota.limits === 'object'\n ? (quota.limits as Record<string, unknown>).value\n : null;\n label =\n typeof value === 'number'\n ? `${value.toLocaleString()} ${readableName}`\n : readableName;\n }\n return (\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>{label}</span>\n </div>\n );\n })}\n {plan.features.length > 6 && (\n <p className=\"text-xs text-text-secondary pl-5\">\n +{plan.features.length - 6} more\n </p>\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,MAAY,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,OA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,IAAQ,EAAE;AACd,cAAI,GAAO;WAET,IAAM,IAAQ,EAAM,KAAK,MAAM,IAAI,EAK7B,MAHJ,EAAM,UAAU,IACZ,EAAM,EAAM,SAAS,KACrB,EAAM,EAAM,SAAS,OACO,EAAM,MACrC,QAAQ,SAAS,IAAI,CACrB,QAAQ,UAAU,MAAc,EAAE,aAAa,CAAC,EAC7C,IACJ,EAAM,UAAU,OAAO,EAAM,UAAW,WACnC,EAAM,OAAmC,QAC1C;AACN,eACE,OAAO,KAAU,WACb,GAAG,EAAM,gBAAgB,CAAC,GAAG,MAC7B;;AAER,iBACE,kBAAC,OAAD;WAEE,WAAU;qBAFZ,CAIE,kBAAC,GAAD;YACE,MAAM;YACN,WAAU;YACV,CAAA,EACF,kBAAC,QAAD,EAAA,UAAO,GAAa,CAAA,CAChB;aARC,EAAE,GAQH;WAER,EACD,EAAK,SAAS,SAAS,KACtB,kBAAC,KAAD;UAAG,WAAU;oBAAb;WAAgD;WAC5C,EAAK,SAAS,SAAS;WAAE;WACzB;YAEF;aAEN,kBAAC,OAAD;SAAK,WAAU;mBACb,kBAAC,KAAD;UAAG,WAAU;oBACV,EAAG,+BAA+B,uBAAuB;UACxD,CAAA;SACA,CAAA;QAEJ;SA5HC,EAAK,GA4HN;OAER;KACA,CAAA,CACF,EAAA,EArJI,EAAM,MAqJV,CACN,CACA;;GAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsListPage.d.ts","sourceRoot":"","sources":["../../../../../src/product-management/modules/products/pages/ProductsListPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProductsListPage.d.ts","sourceRoot":"","sources":["../../../../../src/product-management/modules/products/pages/ProductsListPage.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,gBAAgB,4CAiX/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsListPage.js","names":[],"sources":["../../../../../src/product-management/modules/products/pages/ProductsListPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { ChevronLeft, ChevronRight, Download, Plus, RefreshCw, Eye, SquarePen, Trash2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PermissionGate } from '@burdenoff/fe-libs/shared/components';\nimport { useProductConsole } from '../../../providers/ProductConsoleProvider';\nimport { useProducts, useDeleteProduct } from '../hooks/useProducts';\nimport { ProductStatusBadge } from '../components/ProductStatusBadge';\nimport { SearchInput } from '../../../shared/components/input/SearchInput';\nimport { LoadingState } from '../../../shared/components/feedback/LoadingState';\nimport { ErrorState } from '../../../shared/components/feedback/ErrorState';\nimport { exportToCsv } from '../../../shared/utils/exportUtils';\nimport type { ProductFilterInput } from '../types';\nimport { ProductStatus } from '../types';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../../../../utils/nativeBridge';\n\nconst PAGE_SIZE = 20;\n\nexport function ProductsListPage() {\n const { navigate, basePath = '/products' } = useProductConsole();\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const [searchQuery, setSearchQuery] = useState('');\n const [filter, setFilter] = useState<ProductFilterInput>({});\n const [page, setPage] = useState(0);\n\n const { products, total, hasMore, loading, error, refetch } = useProducts(\n { ...filter, search: searchQuery || undefined },\n { limit: PAGE_SIZE, offset: page * PAGE_SIZE }\n );\n\n const { deleteProduct, loading: deleteLoading } = useDeleteProduct();\n\n // Reset to first page when search/filter changes\n const handleSearch = (value: string) => {\n setSearchQuery(value);\n setPage(0);\n };\n\n const handleFilterChange = (newFilter: ProductFilterInput) => {\n setFilter(newFilter);\n setPage(0);\n };\n\n const handleDelete = async (id: string) => {\n void nativeImpact('medium');\n const message = tr(\n 'products.confirmDeleteProduct',\n 'Are you sure you want to delete this product?'\n );\n const native = await nativeConfirm({\n title: 'Delete product',\n message,\n okButtonTitle: 'Delete',\n cancelButtonTitle: 'Cancel',\n });\n const ok = native === null ? window.confirm(message) : native;\n if (!ok) return;\n\n try {\n await deleteProduct(id);\n void nativeNotify('success');\n refetch();\n } catch (error) {\n void nativeNotify('error');\n console.error('Failed to delete product:', error);\n }\n };\n\n // Only show full-page loading on initial load (no products yet and loading)\n if (loading && products.length === 0 && !searchQuery && !filter.status) {\n return (\n <div className=\"min-h-full bg-[var(--color-bg-canvas)] p-6\">\n <LoadingState message={tr('products.loadingProducts', 'Loading products...')} />\n </div>\n );\n }\n\n if (error && products.length === 0) {\n return (\n <div className=\"min-h-full bg-[var(--color-bg-canvas)] p-6\">\n <ErrorState\n message={error.message}\n action={{\n label: tr('productCommon.retry', 'Retry'),\n onClick: () => refetch(),\n }}\n />\n </div>\n );\n }\n\n const totalPages = Math.max(1, Math.ceil(total / PAGE_SIZE));\n const showingFrom = products.length > 0 ? page * PAGE_SIZE + 1 : 0;\n const showingTo = Math.min((page + 1) * PAGE_SIZE, total);\n\n return (\n <div className=\"min-h-full bg-[var(--color-bg-canvas)] p-6 animate-in fade-in duration-300\">\n {/* Page Header */}\n <div className=\"mb-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <div>\n <h1 className=\"text-3xl font-bold text-text-primary mb-2\">\n {tr('products.title', 'Products')}\n </h1>\n <p className=\"text-text-secondary\">\n {tr('products.subtitle', 'Manage platform products and features')}\n </p>\n </div>\n\n <PermissionGate role=\"super_admin\">\n <button\n onClick={() => navigate(`${basePath}/new`)}\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-[var(--color-action-primary-bg)]\n text-[var(--color-action-primary-text)]\n rounded-lg\n hover:opacity-90 hover:scale-[1.02]\n transition-all duration-200\n font-medium\n \"\n >\n <Plus size={20} />\n {tr('products.createProduct', 'Create Product')}\n </button>\n </PermissionGate>\n </div>\n\n {/* Search and Filters */}\n <div className=\"flex gap-4\">\n {/* Search */}\n <SearchInput\n value={searchQuery}\n onChange={handleSearch}\n placeholder={tr('products.searchPlaceholder', 'Search products...')}\n className=\"flex-1\"\n />\n\n {/* Status Filter */}\n <select\n value={filter.status || ''}\n onChange={(e) =>\n handleFilterChange({\n ...filter,\n status: e.target.value\n ? (e.target.value as (typeof ProductStatus)[keyof typeof ProductStatus])\n : undefined,\n })\n }\n className=\"\n px-4 py-2\n bg-surface\n border border-default\n rounded-lg\n text-text-primary\n focus:outline-none focus:ring-2 focus:ring-[var(--color-border-focus)]\n transition-all duration-200\n \"\n >\n <option value=\"\">{tr('products.allStatuses', 'All Statuses')}</option>\n <option value={ProductStatus.ACTIVE}>{tr('products.statusActive', 'Active')}</option>\n <option value={ProductStatus.DRAFT}>{tr('products.statusDraft', 'Draft')}</option>\n <option value={ProductStatus.WAITLIST}>\n {tr('products.statusWaitlist', 'Waitlist')}\n </option>\n <option value={ProductStatus.COMING_SOON}>\n {tr('products.statusComingSoon', 'Coming Soon')}\n </option>\n </select>\n\n {/* Refresh */}\n <button\n onClick={() => refetch()}\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-surface\n text-text-primary\n border border-default\n rounded-lg\n hover:bg-muted\n transition-all duration-200\n \"\n >\n <RefreshCw size={18} className={loading ? 'animate-spin' : ''} />\n </button>\n\n {/* Export */}\n {products.length > 0 && (\n <button\n onClick={() =>\n exportToCsv(\n 'products',\n products.map((p) => ({\n id: p.id,\n name: p.name,\n slug: p.slug,\n status: p.status,\n description: p.description ?? '',\n tags: (p.tags ?? []).join(', '),\n website: p.website ?? '',\n appUrl: p.appUrl ?? '',\n createdAt: p.createdAt,\n updatedAt: p.updatedAt,\n }))\n )\n }\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-surface\n text-text-primary\n border border-default\n rounded-lg\n hover:bg-muted\n transition-all duration-200\n \"\n title={tr('products.exportCsv', 'Export as CSV')}\n >\n <Download size={18} />\n </button>\n )}\n </div>\n </div>\n\n {/* Products Table */}\n {products.length === 0 && !loading ? (\n <div className=\"bg-surface border border-default rounded-lg p-12 text-center animate-in fade-in duration-300\">\n <p className=\"text-text-secondary mb-4\">\n {searchQuery || filter.status\n ? tr('products.noMatchingProducts', 'No products match your search')\n : tr('products.noProductsFound', 'No products found')}\n </p>\n {!searchQuery && !filter.status && (\n <button\n onClick={() => navigate(`${basePath}/new`)}\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-[var(--color-action-primary-bg)]\n text-[var(--color-action-primary-text)]\n rounded-lg\n hover:opacity-90 hover:scale-[1.02]\n transition-all duration-200\n font-medium\n \"\n >\n <Plus size={20} />\n {tr('products.createProduct', 'Create Product')}\n </button>\n )}\n </div>\n ) : (\n <div className=\"bg-surface border border-default rounded-lg shadow-[var(--shadow-elevation-1)] overflow-hidden\">\n <table className=\"w-full\">\n <thead className=\"bg-muted border-b border-default\">\n <tr>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnProduct', 'Product')}\n </th>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnStatus', 'Status')}\n </th>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnCategory', 'Category')}\n </th>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnVersion', 'Version')}\n </th>\n <th className=\"text-right px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnActions', 'Actions')}\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-[var(--color-border-default)]\">\n {products.map((product) => (\n <tr key={product.id} className=\"hover:bg-muted transition-all duration-200\">\n <td className=\"px-6 py-4\">\n <div className=\"flex items-center gap-3\">\n {product.logoUrl ? (\n <img\n src={product.logoUrl}\n alt={product.name}\n className=\"w-10 h-10 rounded-lg object-cover\"\n />\n ) : (\n <div className=\"w-10 h-10 rounded-lg bg-[var(--color-status-warning-subtle)] flex items-center justify-center\">\n <span className=\"text-[var(--color-status-warning)] font-semibold\">\n {product.name[0]}\n </span>\n </div>\n )}\n <div>\n <p className=\"font-medium text-text-primary\">{product.name}</p>\n <p className=\"text-sm text-text-tertiary font-mono\">/{product.slug}</p>\n </div>\n </div>\n </td>\n <td className=\"px-6 py-4\">\n <ProductStatusBadge status={product.status} />\n </td>\n <td className=\"px-6 py-4\">\n <span className=\"text-sm text-text-primary\">—</span>\n </td>\n <td className=\"px-6 py-4\">\n <span className=\"text-sm text-text-primary font-mono\">—</span>\n </td>\n <td className=\"px-6 py-4\">\n <div className=\"flex items-center justify-end gap-2\">\n <button\n onClick={() => navigate(`${basePath}/${product.id}`)}\n className=\"p-2 rounded-lg text-text-secondary hover:bg-muted transition-all duration-200\"\n title={tr('products.viewDetails', 'View details')}\n >\n <Eye size={18} />\n </button>\n <PermissionGate role=\"super_admin\">\n <button\n onClick={() => navigate(`${basePath}/${product.id}/edit`)}\n className=\"p-2 rounded-lg text-text-secondary hover:bg-muted transition-all duration-200\"\n title={tr('products.edit', 'Edit')}\n >\n <SquarePen size={18} />\n </button>\n <button\n onClick={() => handleDelete(product.id)}\n disabled={deleteLoading}\n className=\"p-2 rounded-lg text-[var(--color-status-error)] hover:bg-[var(--color-status-error-subtle)] transition-all duration-200 disabled:opacity-50\"\n title={tr('products.delete', 'Delete')}\n >\n <Trash2 size={18} />\n </button>\n </PermissionGate>\n </div>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n\n {/* Pagination */}\n {total > 0 && (\n <div className=\"flex items-center justify-between px-6 py-3 border-t border-default bg-muted/50\">\n <p className=\"text-sm text-text-secondary\">\n {tr('products.showing', 'Showing')} {showingFrom}–{showingTo}{' '}\n {tr('products.of', 'of')} {total}{' '}\n {tr('products.products', 'products')}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n onClick={() => setPage((p) => Math.max(0, p - 1))}\n disabled={page === 0}\n className=\"\n inline-flex items-center gap-1 px-3 py-1.5 text-sm\n bg-surface border border-default rounded-lg\n text-text-primary\n hover:bg-muted transition-all duration-200\n disabled:opacity-40 disabled:cursor-not-allowed\n \"\n >\n <ChevronLeft size={16} />\n {tr('products.prev', 'Prev')}\n </button>\n <span className=\"text-sm text-text-secondary px-2\">\n {page + 1} / {totalPages}\n </span>\n <button\n onClick={() => setPage((p) => p + 1)}\n disabled={!hasMore && page + 1 >= totalPages}\n className=\"\n inline-flex items-center gap-1 px-3 py-1.5 text-sm\n bg-surface border border-default rounded-lg\n text-text-primary\n hover:bg-muted transition-all duration-200\n disabled:opacity-40 disabled:cursor-not-allowed\n \"\n >\n {tr('products.next', 'Next')}\n <ChevronRight size={16} />\n </button>\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAM,IAAY;AAElB,SAAgB,IAAmB;CACjC,IAAM,EAAE,aAAU,cAAW,gBAAgB,GAAmB,EAC1D,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAAqB;EAC5C,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,IAAW;IAEnC,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAQ,KAAa,EAA6B,EAAE,CAAC,EACtD,CAAC,GAAM,KAAW,EAAS,EAAE,EAE7B,EAAE,aAAU,UAAO,YAAS,YAAS,UAAO,eAAY,EAC5D;EAAE,GAAG;EAAQ,QAAQ,KAAe,KAAA;EAAW,EAC/C;EAAE,OAAO;EAAW,QAAQ,IAAO;EAAW,CAC/C,EAEK,EAAE,kBAAe,SAAS,MAAkB,GAAkB,EAG9D,KAAgB,MAAkB;AAEtC,EADA,EAAe,EAAM,EACrB,EAAQ,EAAE;IAGN,KAAsB,MAAkC;AAE5D,EADA,EAAU,EAAU,EACpB,EAAQ,EAAE;IAGN,IAAe,OAAO,MAAe;AACpC,IAAa,SAAS;EAC3B,IAAM,IAAU,EACd,iCACA,gDACD,EACK,IAAS,MAAM,EAAc;GACjC,OAAO;GACP;GACA,eAAe;GACf,mBAAmB;GACpB,CAAC;AACS,YAAW,OAAO,OAAO,QAAQ,EAAQ,GAAG,EAGvD,KAAI;AAGF,GAFA,MAAM,EAAc,EAAG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AC7D,EAAG,eAAe,KAAK;MAAC;MAAE;MAAO;MACjC,EAAG,qBAAqB,WAAW;MAClC;QACJ,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,UAAD;OACE,eAAe,GAAS,MAAM,KAAK,IAAI,GAAG,IAAI,EAAE,CAAC;OACjD,UAAU,MAAS;OACnB,WAAU;iBAHZ,CAWE,kBAAC,GAAD,EAAa,MAAM,IAAM,CAAA,EACxB,EAAG,iBAAiB,OAAO,CACrB;;MACT,kBAAC,QAAD;OAAM,WAAU;iBAAhB;QACG,IAAO;QAAE;QAAI;QACT;;MACP,kBAAC,UAAD;OACE,eAAe,GAAS,MAAM,IAAI,EAAE;OACpC,UAAU,CAAC,KAAW,IAAO,KAAK;OAClC,WAAU;iBAHZ,CAWG,EAAG,iBAAiB,OAAO,EAC5B,kBAAC,GAAD,EAAc,MAAM,IAAM,CAAA,CACnB;;MACL;OACF;MAEJ;KAEJ"}
|
|
1
|
+
{"version":3,"file":"ProductsListPage.js","names":[],"sources":["../../../../../src/product-management/modules/products/pages/ProductsListPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n ChevronLeft,\n ChevronRight,\n Download,\n Plus,\n RefreshCw,\n Eye,\n SquarePen,\n Trash2,\n} from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PermissionGate } from '@burdenoff/fe-libs/shared/components';\nimport { useProductConsole } from '../../../providers/ProductConsoleProvider';\nimport { useProducts, useDeleteProduct } from '../hooks/useProducts';\nimport { ProductStatusBadge } from '../components/ProductStatusBadge';\nimport { SearchInput } from '../../../shared/components/input/SearchInput';\nimport { LoadingState } from '../../../shared/components/feedback/LoadingState';\nimport { ErrorState } from '../../../shared/components/feedback/ErrorState';\nimport { exportToCsv } from '../../../shared/utils/exportUtils';\nimport type { ProductFilterInput } from '../types';\nimport { ProductStatus } from '../types';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../../../../utils/nativeBridge';\n\nconst PAGE_SIZE = 20;\n\nexport function ProductsListPage() {\n const { navigate, basePath = '/products' } = useProductConsole();\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const [searchQuery, setSearchQuery] = useState('');\n const [filter, setFilter] = useState<ProductFilterInput>({});\n const [page, setPage] = useState(0);\n\n const { products, total, hasMore, loading, error, refetch } = useProducts(\n { ...filter, search: searchQuery || undefined },\n { limit: PAGE_SIZE, offset: page * PAGE_SIZE }\n );\n\n const { deleteProduct, loading: deleteLoading } = useDeleteProduct();\n\n // Reset to first page when search/filter changes\n const handleSearch = (value: string) => {\n setSearchQuery(value);\n setPage(0);\n };\n\n const handleFilterChange = (newFilter: ProductFilterInput) => {\n setFilter(newFilter);\n setPage(0);\n };\n\n const handleDelete = async (id: string) => {\n void nativeImpact('medium');\n const message = tr(\n 'products.confirmDeleteProduct',\n 'Are you sure you want to delete this product?'\n );\n const native = await nativeConfirm({\n title: 'Delete product',\n message,\n okButtonTitle: 'Delete',\n cancelButtonTitle: 'Cancel',\n });\n const ok = native === null ? window.confirm(message) : native;\n if (!ok) return;\n\n try {\n await deleteProduct(id);\n void nativeNotify('success');\n refetch();\n } catch (error) {\n void nativeNotify('error');\n console.error('Failed to delete product:', error);\n }\n };\n\n // Only show full-page loading on initial load (no products yet and loading)\n if (loading && products.length === 0 && !searchQuery && !filter.status) {\n return (\n <div className=\"min-h-full bg-[var(--color-bg-canvas)] p-6\">\n <LoadingState message={tr('products.loadingProducts', 'Loading products...')} />\n </div>\n );\n }\n\n if (error && products.length === 0) {\n return (\n <div className=\"min-h-full bg-[var(--color-bg-canvas)] p-6\">\n <ErrorState\n message={error.message}\n action={{\n label: tr('productCommon.retry', 'Retry'),\n onClick: () => refetch(),\n }}\n />\n </div>\n );\n }\n\n const totalPages = Math.max(1, Math.ceil(total / PAGE_SIZE));\n const showingFrom = products.length > 0 ? page * PAGE_SIZE + 1 : 0;\n const showingTo = Math.min((page + 1) * PAGE_SIZE, total);\n\n return (\n <div className=\"min-h-full bg-[var(--color-bg-canvas)] p-6 animate-in fade-in duration-300\">\n {/* Page Header */}\n <div className=\"mb-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <div>\n <h1 className=\"text-3xl font-bold text-text-primary mb-2\">\n {tr('products.title', 'Products')}\n </h1>\n <p className=\"text-text-secondary\">\n {tr('products.subtitle', 'Manage platform products and features')}\n </p>\n </div>\n\n <PermissionGate role=\"super_admin\">\n <button\n onClick={() => navigate(`${basePath}/new`)}\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-[var(--color-action-primary-bg)]\n text-[var(--color-action-primary-text)]\n rounded-lg\n hover:opacity-90 hover:scale-[1.02]\n transition-all duration-200\n font-medium\n \"\n >\n <Plus size={20} />\n {tr('products.createProduct', 'Create Product')}\n </button>\n </PermissionGate>\n </div>\n\n {/* Search and Filters */}\n <div className=\"flex gap-4\">\n {/* Search */}\n <SearchInput\n value={searchQuery}\n onChange={handleSearch}\n placeholder={tr('products.searchPlaceholder', 'Search products...')}\n className=\"flex-1\"\n />\n\n {/* Status Filter */}\n <select\n value={filter.status || ''}\n onChange={(e) =>\n handleFilterChange({\n ...filter,\n status: e.target.value\n ? (e.target.value as (typeof ProductStatus)[keyof typeof ProductStatus])\n : undefined,\n })\n }\n className=\"\n px-4 py-2\n bg-surface\n border border-default\n rounded-lg\n text-text-primary\n focus:outline-none focus:ring-2 focus:ring-[var(--color-border-focus)]\n transition-all duration-200\n \"\n >\n <option value=\"\">{tr('products.allStatuses', 'All Statuses')}</option>\n <option value={ProductStatus.ACTIVE}>{tr('products.statusActive', 'Active')}</option>\n <option value={ProductStatus.DRAFT}>{tr('products.statusDraft', 'Draft')}</option>\n <option value={ProductStatus.WAITLIST}>\n {tr('products.statusWaitlist', 'Waitlist')}\n </option>\n <option value={ProductStatus.COMING_SOON}>\n {tr('products.statusComingSoon', 'Coming Soon')}\n </option>\n </select>\n\n {/* Refresh */}\n <button\n onClick={() => refetch()}\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-surface\n text-text-primary\n border border-default\n rounded-lg\n hover:bg-muted\n transition-all duration-200\n \"\n >\n <RefreshCw size={18} className={loading ? 'animate-spin' : ''} />\n </button>\n\n {/* Export */}\n {products.length > 0 && (\n <button\n onClick={() =>\n exportToCsv(\n 'products',\n products.map((p) => ({\n id: p.id,\n name: p.name,\n slug: p.slug,\n status: p.status,\n description: p.description ?? '',\n tags: (p.tags ?? []).join(', '),\n website: p.website ?? '',\n appUrl: p.appUrl ?? '',\n createdAt: p.createdAt,\n updatedAt: p.updatedAt,\n }))\n )\n }\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-surface\n text-text-primary\n border border-default\n rounded-lg\n hover:bg-muted\n transition-all duration-200\n \"\n title={tr('products.exportCsv', 'Export as CSV')}\n >\n <Download size={18} />\n </button>\n )}\n </div>\n </div>\n\n {/* Products Table */}\n {products.length === 0 && !loading ? (\n <div className=\"bg-surface border border-default rounded-lg p-12 text-center animate-in fade-in duration-300\">\n <p className=\"text-text-secondary mb-4\">\n {searchQuery || filter.status\n ? tr('products.noMatchingProducts', 'No products match your search')\n : tr('products.noProductsFound', 'No products found')}\n </p>\n {!searchQuery && !filter.status && (\n <button\n onClick={() => navigate(`${basePath}/new`)}\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-[var(--color-action-primary-bg)]\n text-[var(--color-action-primary-text)]\n rounded-lg\n hover:opacity-90 hover:scale-[1.02]\n transition-all duration-200\n font-medium\n \"\n >\n <Plus size={20} />\n {tr('products.createProduct', 'Create Product')}\n </button>\n )}\n </div>\n ) : (\n <div className=\"bg-surface border border-default rounded-lg shadow-[var(--shadow-elevation-1)] overflow-hidden\">\n <table className=\"w-full\">\n <thead className=\"bg-muted border-b border-default\">\n <tr>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnProduct', 'Product')}\n </th>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnStatus', 'Status')}\n </th>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnCategory', 'Category')}\n </th>\n <th className=\"text-left px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnVersion', 'Version')}\n </th>\n <th className=\"text-right px-6 py-3 text-xs font-semibold text-text-secondary uppercase\">\n {tr('products.columnActions', 'Actions')}\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-[var(--color-border-default)]\">\n {products.map((product) => (\n <tr key={product.id} className=\"hover:bg-muted transition-all duration-200\">\n <td className=\"px-6 py-4\">\n <div className=\"flex items-center gap-3\">\n {product.logoUrl ? (\n <img\n src={product.logoUrl}\n alt={product.name}\n className=\"w-10 h-10 rounded-lg object-cover\"\n />\n ) : (\n <div className=\"w-10 h-10 rounded-lg bg-[var(--color-status-warning-subtle)] flex items-center justify-center\">\n <span className=\"text-[var(--color-status-warning)] font-semibold\">\n {product.name[0]}\n </span>\n </div>\n )}\n <div>\n <p className=\"font-medium text-text-primary\">{product.name}</p>\n <p className=\"text-sm text-text-tertiary font-mono\">/{product.slug}</p>\n </div>\n </div>\n </td>\n <td className=\"px-6 py-4\">\n <ProductStatusBadge status={product.status} />\n </td>\n <td className=\"px-6 py-4\">\n <span className=\"text-sm text-text-primary\">—</span>\n </td>\n <td className=\"px-6 py-4\">\n <span className=\"text-sm text-text-primary font-mono\">—</span>\n </td>\n <td className=\"px-6 py-4\">\n <div className=\"flex items-center justify-end gap-2\">\n <button\n onClick={() => navigate(`${basePath}/${product.id}`)}\n className=\"p-2 rounded-lg text-text-secondary hover:bg-muted transition-all duration-200\"\n title={tr('products.viewDetails', 'View details')}\n >\n <Eye size={18} />\n </button>\n <PermissionGate role=\"super_admin\">\n <button\n onClick={() => navigate(`${basePath}/${product.id}/edit`)}\n className=\"p-2 rounded-lg text-text-secondary hover:bg-muted transition-all duration-200\"\n title={tr('products.edit', 'Edit')}\n >\n <SquarePen size={18} />\n </button>\n <button\n onClick={() => handleDelete(product.id)}\n disabled={deleteLoading}\n className=\"p-2 rounded-lg text-[var(--color-status-error)] hover:bg-[var(--color-status-error-subtle)] transition-all duration-200 disabled:opacity-50\"\n title={tr('products.delete', 'Delete')}\n >\n <Trash2 size={18} />\n </button>\n </PermissionGate>\n </div>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n\n {/* Pagination */}\n {total > 0 && (\n <div className=\"flex items-center justify-between px-6 py-3 border-t border-default bg-muted/50\">\n <p className=\"text-sm text-text-secondary\">\n {tr('products.showing', 'Showing')} {showingFrom}–{showingTo}{' '}\n {tr('products.of', 'of')} {total} {tr('products.products', 'products')}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n onClick={() => setPage((p) => Math.max(0, p - 1))}\n disabled={page === 0}\n className=\"\n inline-flex items-center gap-1 px-3 py-1.5 text-sm\n bg-surface border border-default rounded-lg\n text-text-primary\n hover:bg-muted transition-all duration-200\n disabled:opacity-40 disabled:cursor-not-allowed\n \"\n >\n <ChevronLeft size={16} />\n {tr('products.prev', 'Prev')}\n </button>\n <span className=\"text-sm text-text-secondary px-2\">\n {page + 1} / {totalPages}\n </span>\n <button\n onClick={() => setPage((p) => p + 1)}\n disabled={!hasMore && page + 1 >= totalPages}\n className=\"\n inline-flex items-center gap-1 px-3 py-1.5 text-sm\n bg-surface border border-default rounded-lg\n text-text-primary\n hover:bg-muted transition-all duration-200\n disabled:opacity-40 disabled:cursor-not-allowed\n \"\n >\n {tr('products.next', 'Next')}\n <ChevronRight size={16} />\n </button>\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAM,IAAY;AAElB,SAAgB,IAAmB;CACjC,IAAM,EAAE,aAAU,cAAW,gBAAgB,GAAmB,EAC1D,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAAqB;EAC5C,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,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