@openrails/billing-ui 0.243.0 → 0.245.0
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/admin/pages/catalog/metering-model.d.ts +1 -1
- package/dist/{admin-catalog-CC7I4n0_.js → admin-catalog-CK6CM9I2.js} +35 -25
- package/dist/admin-catalog-CK6CM9I2.js.map +1 -0
- package/dist/{admin-metering-BGAXbT23.js → admin-metering-COFcSPQy.js} +30 -11
- package/dist/admin-metering-COFcSPQy.js.map +1 -0
- package/dist/admin.js +5 -5
- package/dist/client/client.d.ts +13 -6
- package/dist/client/generated/routes.d.ts +9 -9
- package/dist/client/generated/wire.d.ts +16 -3
- package/dist/client/index.d.ts +1 -1
- package/dist/client/types.d.ts +14 -2
- package/dist/{client-PjivPHmE.js → client-D5Af726I.js} +8 -7
- package/dist/client-D5Af726I.js.map +1 -0
- package/dist/client.js +1 -1
- package/dist/{hooks-Ckd8F2JF.js → hooks-CYjlHS28.js} +2 -2
- package/dist/{hooks-Ckd8F2JF.js.map → hooks-CYjlHS28.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/dist/admin-catalog-CC7I4n0_.js.map +0 -1
- package/dist/admin-metering-BGAXbT23.js.map +0 -1
- package/dist/client-PjivPHmE.js.map +0 -1
|
@@ -25,7 +25,7 @@ export interface MeterFormValues {
|
|
|
25
25
|
export type AllowanceMode = "none" | "included";
|
|
26
26
|
export interface RateCardFormValues {
|
|
27
27
|
productId: string;
|
|
28
|
-
model: "per_unit" | "tiered" | "package";
|
|
28
|
+
model: "per_unit" | "tiered" | "package" | "dynamic";
|
|
29
29
|
currency: string;
|
|
30
30
|
unitAmount: string;
|
|
31
31
|
divideBy: string;
|
|
@@ -268,13 +268,17 @@ function Se({ enabled: r, draftingEnabled: s }) {
|
|
|
268
268
|
})]
|
|
269
269
|
}, t))
|
|
270
270
|
}),
|
|
271
|
-
f.drafts?.map((e, t) => /* @__PURE__ */ K(Ce, {
|
|
271
|
+
f.drafts?.map((e, t) => /* @__PURE__ */ K(Ce, {
|
|
272
|
+
draft: e,
|
|
273
|
+
draftingEnabled: s
|
|
274
|
+
}, t))
|
|
272
275
|
]
|
|
273
276
|
}) : null
|
|
274
277
|
]
|
|
275
278
|
}) }) : null;
|
|
276
279
|
}
|
|
277
|
-
function Ce({ draft: e }) {
|
|
280
|
+
function Ce({ draft: e, draftingEnabled: t }) {
|
|
281
|
+
let n = d() && t;
|
|
278
282
|
return e.kind === "refused" && e.refusal ? /* @__PURE__ */ q("div", {
|
|
279
283
|
className: "rounded-lg border border-dashed p-3 text-xs",
|
|
280
284
|
children: [
|
|
@@ -294,10 +298,16 @@ function Ce({ draft: e }) {
|
|
|
294
298
|
children: e.refusal.workaround
|
|
295
299
|
})
|
|
296
300
|
]
|
|
297
|
-
}) : e.kind === "price_change" && e.price_change ? /* @__PURE__ */ K(we, {
|
|
301
|
+
}) : e.kind === "price_change" && e.price_change ? /* @__PURE__ */ K(we, {
|
|
302
|
+
draft: e.price_change,
|
|
303
|
+
canApply: n
|
|
304
|
+
}) : e.kind === "new_price" && e.new_price ? /* @__PURE__ */ K(Te, {
|
|
305
|
+
draft: e.new_price,
|
|
306
|
+
canApply: n
|
|
307
|
+
}) : null;
|
|
298
308
|
}
|
|
299
|
-
function we({ draft: e }) {
|
|
300
|
-
let { toastApiError:
|
|
309
|
+
function we({ draft: e, canApply: t }) {
|
|
310
|
+
let { toastApiError: r, adminMutations: o } = n(), s = U(o.loadCatalogPriceDraft());
|
|
301
311
|
return /* @__PURE__ */ q("div", {
|
|
302
312
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
303
313
|
children: [
|
|
@@ -332,33 +342,33 @@ function we({ draft: e }) {
|
|
|
332
342
|
/* @__PURE__ */ K(i, { id: " affected · requires human confirm" })
|
|
333
343
|
]
|
|
334
344
|
}),
|
|
335
|
-
|
|
336
|
-
price:
|
|
337
|
-
productName:
|
|
338
|
-
productKey:
|
|
345
|
+
t && (s.data ? /* @__PURE__ */ K(de, {
|
|
346
|
+
price: s.data.price,
|
|
347
|
+
productName: s.data.productName,
|
|
348
|
+
productKey: s.data.productKey,
|
|
339
349
|
draft: e,
|
|
340
|
-
onDone: () =>
|
|
350
|
+
onDone: () => s.reset()
|
|
341
351
|
}) : /* @__PURE__ */ K(a, {
|
|
342
352
|
size: "sm",
|
|
343
353
|
className: "mt-2",
|
|
344
|
-
disabled:
|
|
354
|
+
disabled: s.isPending,
|
|
345
355
|
onClick: async () => {
|
|
346
|
-
try {
|
|
347
|
-
await
|
|
356
|
+
if (t) try {
|
|
357
|
+
await s.mutateAsync({
|
|
348
358
|
productKey: e.product_key,
|
|
349
359
|
priceKey: e.price_key
|
|
350
360
|
});
|
|
351
361
|
} catch (e) {
|
|
352
|
-
|
|
362
|
+
r(e, "Load draft for review");
|
|
353
363
|
}
|
|
354
364
|
},
|
|
355
|
-
children:
|
|
356
|
-
})
|
|
365
|
+
children: s.isPending ? "Loading…" : "Review in wizard"
|
|
366
|
+
}))
|
|
357
367
|
]
|
|
358
368
|
});
|
|
359
369
|
}
|
|
360
|
-
function Te({ draft: e }) {
|
|
361
|
-
let { toastApiError:
|
|
370
|
+
function Te({ draft: e, canApply: t }) {
|
|
371
|
+
let { toastApiError: r, adminMutations: o } = n(), s = G(), c = U(o.createCatalogDraftPrice(s));
|
|
362
372
|
return /* @__PURE__ */ q("div", {
|
|
363
373
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
364
374
|
children: [
|
|
@@ -383,18 +393,18 @@ function Te({ draft: e }) {
|
|
|
383
393
|
g(e.create_price.unit_amount, e.create_price.currency)
|
|
384
394
|
]
|
|
385
395
|
}),
|
|
386
|
-
/* @__PURE__ */ K(a, {
|
|
396
|
+
t && /* @__PURE__ */ K(a, {
|
|
387
397
|
size: "sm",
|
|
388
398
|
className: "mt-2",
|
|
389
|
-
disabled:
|
|
399
|
+
disabled: c.isPending || c.isSuccess,
|
|
390
400
|
onClick: async () => {
|
|
391
|
-
try {
|
|
392
|
-
await
|
|
401
|
+
if (t) try {
|
|
402
|
+
await c.mutateAsync(e.create_price);
|
|
393
403
|
} catch (e) {
|
|
394
|
-
|
|
404
|
+
r(e, "Create drafted price");
|
|
395
405
|
}
|
|
396
406
|
},
|
|
397
|
-
children:
|
|
407
|
+
children: c.isSuccess ? "Created" : c.isPending ? "Creating…" : "Create this price"
|
|
398
408
|
})
|
|
399
409
|
]
|
|
400
410
|
});
|
|
@@ -1186,4 +1196,4 @@ function $({ label: t, id: n, hint: r, children: i }) {
|
|
|
1186
1196
|
//#endregion
|
|
1187
1197
|
export { ke as CatalogDriftPage, Oe as CatalogPricesPage, De as CatalogProductsPage };
|
|
1188
1198
|
|
|
1189
|
-
//# sourceMappingURL=admin-catalog-
|
|
1199
|
+
//# sourceMappingURL=admin-catalog-CK6CM9I2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-catalog-CK6CM9I2.js","names":[],"sources":["../src/admin/pages/catalog/application-dialog.tsx","../src/admin/pages/catalog/copilot-panel.tsx","../src/admin/pages/catalog/index.tsx"],"sourcesContent":["import { AdminMessage, useAdminUI } from \"#orck/admin/ui-context\"\nimport { useAdminServices } from \"#orck/admin/context\"\nimport * as React from \"react\"\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\"\n\nimport { Button } from \"#orck/admin/components/ui/button\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"#orck/admin/components/ui/dialog\"\nimport { Label } from \"#orck/admin/components/ui/label\"\nimport { Textarea } from \"#orck/admin/components/ui/textarea\"\nimport { ApiError } from \"#orck/admin/lib/api/client\"\nimport { type CatalogApplicationReceipt } from \"#orck/admin/lib/api/endpoints\"\nimport type {\n CatalogConflict,\n CatalogFieldConflict,\n} from \"#orck/client/generated/wire\"\nimport { DIALOG_WIDE } from \"#orck/admin/lib/dialog-width\"\nimport { formatHours } from \"#orck/admin/lib/duration\"\nimport { formatDate, formatNativeAmount } from \"#orck/admin/lib/format\"\n\nexport function CatalogApplicationDialog() {\n const { toast, toastApiError, selectedMerchant, adminMutations } =\n useAdminServices()\n\n const { id: adminId, text: adminText } = useAdminUI()\n\n const [open, setOpen] = React.useState(false)\n const [document, setDocument] = React.useState(\"\")\n const [reviewed, setReviewed] = React.useState(false)\n const [submitted, setSubmitted] = React.useState<string>()\n const [receipt, setReceipt] = React.useState<CatalogApplicationReceipt>()\n const [message, setMessage] = React.useState(\"\")\n const [canEdit, setCanEdit] = React.useState(false)\n const [draftMerchant, setDraftMerchant] = React.useState<string>()\n const apply = useMutation(adminMutations.applyCatalog(useQueryClient()))\n\n const start = () => {\n setDraftMerchant(selectedMerchant())\n setDocument(\n JSON.stringify(\n {\n schema_version: 1,\n prune: false,\n products: {},\n },\n null,\n 2\n )\n )\n setSubmitted(undefined)\n setReceipt(undefined)\n setReviewed(false)\n setCanEdit(false)\n setMessage(\"\")\n }\n\n const run = async (force = false) => {\n if (selectedMerchant() !== draftMerchant) {\n setMessage(\n \"This draft belongs to another selected merchant. Return to that merchant before applying it.\"\n )\n return\n }\n const exactDocument = submitted ?? document\n setSubmitted(exactDocument)\n setCanEdit(false)\n setMessage(\"\")\n try {\n const result = await apply.mutateAsync({ document: exactDocument, force })\n setReceipt(result)\n const skipped = result.conflicts?.length ?? 0\n setMessage(\n result.replayed\n ? \"This batch was already applied. No changes were repeated, and later catalog edits were preserved.\"\n : skipped > 0\n ? `Applied everything no edit changed. ${skipped} ${skipped === 1 ? \"object was\" : \"objects were\"} skipped because an edit set ${skipped === 1 ? \"its\" : \"their\"} fields differently: change the batch to agree, remove those fields, or overwrite the edits.`\n : \"Batch applied. Review the current catalog before preparing another batch.\"\n )\n if (skipped > 0) {\n toast.warning(`Catalog batch applied; ${skipped} skipped`)\n } else {\n toast.success(\n result.replayed\n ? \"Original batch receipt returned\"\n : \"Catalog batch applied\"\n )\n }\n } catch (err) {\n const refused =\n err instanceof ApiError &&\n err.status >= 400 &&\n err.status < 500 &&\n err.status !== 408\n setCanEdit(refused)\n setMessage(\n refused\n ? \"Batch refused. Review the error and edit the document before trying again.\"\n : \"The outcome could not be confirmed. Retry this exact document to retrieve its receipt without repeating changes.\"\n )\n toastApiError(err, \"Apply catalog\")\n }\n }\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (apply.isPending) return\n setOpen(next)\n if (next && !document) start()\n }}\n >\n <DialogTrigger\n render={\n <Button variant=\"outline\" size=\"sm\">\n <AdminMessage id={\"Apply catalog\"} />\n </Button>\n }\n />\n <DialogContent className={DIALOG_WIDE}>\n <DialogHeader>\n <DialogTitle>\n <AdminMessage id={\"Apply catalog changes\"} />\n </DialogTitle>\n <DialogDescription>\n <AdminMessage\n id={\n \"Paste a JSON or YAML catalog batch; products, prices and meters are maps keyed by their key. Each product, price and meter applies whole, unless a field it names was set differently by an edit: it is skipped and listed, and the rest applies. A batch that applied whole is remembered; retries preserve later catalog edits. Omitted records stay unchanged unless prune is true, which archives the omitted ones only batches set.\"\n }\n />\n </DialogDescription>\n </DialogHeader>\n <div className=\"grid gap-3\">\n <Label htmlFor={adminId(\"catalog-application\")}>\n <AdminMessage id={\"Catalog document\"} />\n </Label>\n <Textarea\n id={adminId(\"catalog-application\")}\n className=\"max-h-80 min-h-48 font-mono text-xs\"\n spellCheck={false}\n value={document}\n disabled={submitted !== undefined}\n onChange={(event) => {\n setDocument(event.target.value)\n setReviewed(false)\n }}\n />\n {reviewed && !submitted && (\n <p className=\"text-sm\">\n <AdminMessage\n id={\n \"Review complete. Applying sends this exact document; this is not a database diff.\"\n }\n />\n </p>\n )}\n {message && (\n <p role=\"status\" className=\"text-sm\">\n {message}\n </p>\n )}\n {receipt && receipt.conflicts.length > 0 && (\n <CatalogConflicts conflicts={receipt.conflicts} />\n )}\n {receipt && (\n <pre\n aria-label={adminText(\"Batch receipt\")}\n className=\"max-h-48 overflow-auto rounded-md border p-3 text-xs\"\n >\n {JSON.stringify(receipt, null, 2)}\n </pre>\n )}\n </div>\n <DialogFooter>\n {canEdit && (\n <Button\n variant=\"outline\"\n onClick={() => {\n setSubmitted(undefined)\n setReviewed(false)\n setCanEdit(false)\n setMessage(\"\")\n }}\n >\n <AdminMessage id={\"Edit batch\"} />\n </Button>\n )}\n {receipt && receipt.conflicts.length > 0 && (\n <Button\n variant=\"destructive\"\n disabled={apply.isPending}\n onClick={() => void run(true)}\n >\n <AdminMessage id={\"Overwrite edits\"} />\n </Button>\n )}\n {receipt ? (\n <Button onClick={() => start()}>\n <AdminMessage id={\"New batch\"} />\n </Button>\n ) : submitted !== undefined ? (\n <Button\n disabled={apply.isPending || canEdit}\n onClick={() => void run()}\n >\n {apply.isPending ? \"Applying…\" : \"Retry exact batch\"}\n </Button>\n ) : reviewed ? (\n <Button disabled={!document.trim()} onClick={() => void run()}>\n <AdminMessage id={\"Apply reviewed batch\"} />\n </Button>\n ) : (\n <Button\n disabled={!document.trim()}\n onClick={() => setReviewed(true)}\n >\n <AdminMessage id={\"Review batch\"} />\n </Button>\n )}\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n\n// CatalogConflicts lists each object a batch skipped and the fields an edit\n// set differently, money and durations in readable units.\nfunction CatalogConflicts({ conflicts }: { conflicts: CatalogConflict[] }) {\n const { text: adminText } = useAdminUI()\n\n return (\n <ul\n aria-label={adminText(\"Skipped objects\")}\n className=\"grid gap-2 text-sm\"\n >\n {conflicts.map((conflict) => (\n <li\n key={`${conflict.object}:${conflict.product_key ?? \"\"}:${conflict.key}`}\n className=\"rounded-md border p-2\"\n >\n <p className=\"font-medium\">\n {conflict.product_key\n ? `Price ${conflict.key} of product ${conflict.product_key}`\n : `${conflict.object === \"meter\" ? \"Meter\" : \"Product\"} ${conflict.key}`}{\" \"}\n <AdminMessage id={\"skipped\"} />\n </p>\n <ul className=\"mt-1 grid gap-1 text-xs text-muted-foreground\">\n {conflict.fields.map((field) => (\n <li key={field.field}>\n {field.field}\n <AdminMessage id={\": the batch says\"} />{\" \"}\n {readableValue(field, field.file_value, conflict.currency)}\n <AdminMessage id={\", an edit set\"} />{\" \"}\n {readableValue(field, field.live_value, conflict.currency)} (\n {field.set_by}, {formatDate(field.set_at)})\n </li>\n ))}\n </ul>\n </li>\n ))}\n </ul>\n )\n}\n\nfunction readableValue(\n field: CatalogFieldConflict,\n value: unknown,\n currency: string | null\n): string {\n if (value === null || value === undefined) return \"none\"\n if (\n (field.field === \"unit_amount\" || field.field === \"trial_unit_amount\") &&\n typeof value === \"string\" &&\n currency\n ) {\n return formatNativeAmount(value, currency)\n }\n if (field.field.endsWith(\"_hours\") && typeof value === \"number\") {\n return formatHours(value)\n }\n return JSON.stringify(value)\n}\n","import { AdminMessage, useAdminUI } from \"#orck/admin/ui-context\"\nimport { useAdminServices } from \"#orck/admin/context\"\n// Catalog copilot: one-shot Q&A over catalog, pricing and migration data, like\n// catalog tools, plus drafts when drafting is enabled. The model\n// never mutates anything: a draft opens, pre-filled, in the price-change\n// wizard or as a create-price call for a person to confirm.\nimport { HugeiconsIcon } from \"@hugeicons/react\"\nimport {\n BubbleChatQuestionIcon,\n Cancel01Icon,\n Loading02Icon,\n SparklesIcon,\n} from \"@hugeicons/core-free-icons\"\nimport { useForm } from \"@tanstack/react-form\"\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\"\n\nimport { Badge } from \"#orck/admin/components/ui/badge\"\nimport { Button } from \"#orck/admin/components/ui/button\"\nimport { Card, CardContent } from \"#orck/admin/components/ui/card\"\nimport { Input } from \"#orck/admin/components/ui/input\"\nimport type {\n CatalogDraft,\n NewPriceDraft,\n PriceChangeDraft,\n} from \"#orck/admin/lib/api/copilot\"\nimport { ApiError } from \"#orck/admin/lib/api/client\"\nimport { useCatalogWrites } from \"#orck/admin/lib/capabilities\"\nimport { formatNativeAmount } from \"#orck/admin/lib/format\"\n\nimport { PriceChangeWizard } from \"#orck/admin/pages/catalog/price-wizard\"\n\nexport function CatalogCopilotPanel({\n enabled,\n draftingEnabled,\n}: {\n enabled: boolean\n draftingEnabled: boolean\n}) {\n const { text: adminText } = useAdminUI()\n\n const { adminMutations } = useAdminServices()\n\n const askCatalog = useMutation(adminMutations.askCatalogCopilot())\n const form = useForm({\n defaultValues: { question: \"\" },\n onSubmit: async ({ value }) => {\n const question = value.question.trim()\n if (!question) return\n\n askCatalog.reset()\n try {\n await askCatalog.mutateAsync(question)\n } catch {\n // The request error renders inline below the form.\n }\n },\n })\n const result = askCatalog.data\n const error = askCatalog.error\n ? askCatalog.error instanceof ApiError\n ? askCatalog.error.message\n : \"ask failed\"\n : null\n\n // Enabling the copilot is an operator setup step (see docs/billing-admin.md);\n // an unconfigured feature is not page furniture, so render nothing.\n if (!enabled) {\n return null\n }\n\n return (\n <Card>\n <CardContent className=\"flex flex-col gap-3\">\n <form\n className=\"flex items-center gap-2\"\n onSubmit={(event) => {\n event.preventDefault()\n event.stopPropagation()\n void form.handleSubmit()\n }}\n >\n <HugeiconsIcon\n icon={BubbleChatQuestionIcon}\n className=\"size-4 shrink-0 text-muted-foreground\"\n />\n <form.Field name=\"question\">\n {(field) => (\n <Input\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) => field.handleChange(event.target.value)}\n placeholder={\n draftingEnabled\n ? 'Ask about your catalog, or ask for a change — e.g. \"who is still on the old premium price?\" or \"raise premium to $12\"'\n : 'Ask about your catalog — e.g. \"what do we sell?\" or \"who is still on the old premium price?\"'\n }\n className=\"flex-1\"\n />\n )}\n </form.Field>\n <form.Subscribe\n selector={(state) =>\n [state.values.question, state.isSubmitting] as const\n }\n >\n {([question, isSubmitting]) => (\n <Button\n type=\"submit\"\n size=\"sm\"\n disabled={isSubmitting || !question.trim()}\n >\n {isSubmitting ? (\n <HugeiconsIcon\n icon={Loading02Icon}\n className=\"size-3.5 animate-spin\"\n />\n ) : null}\n <AdminMessage id={\"Ask\"} />\n </Button>\n )}\n </form.Subscribe>\n </form>\n\n {askCatalog.isPending ? (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage id={\"Checking your catalog…\"} />\n </p>\n ) : null}\n {error ? (\n <p\n className=\"text-xs whitespace-pre-wrap text-destructive\"\n role=\"alert\"\n >\n {error}\n </p>\n ) : null}\n\n {result ? (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex items-start justify-between gap-2\">\n <p className=\"text-sm whitespace-pre-wrap\">{result.answer}</p>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"size-6 shrink-0\"\n aria-label={adminText(\"Dismiss answer\")}\n onClick={() => {\n askCatalog.reset()\n }}\n >\n <HugeiconsIcon icon={Cancel01Icon} className=\"size-3.5\" />\n </Button>\n </div>\n\n {result.evidence.length > 0 && (\n <div className=\"flex flex-col gap-2\">\n {result.evidence.map((ev, i) => (\n <div key={i} className=\"rounded-lg border bg-muted/30 p-2\">\n <span className=\"mb-1 block text-xs font-medium text-muted-foreground uppercase\">\n {ev.tool}\n </span>\n <pre className=\"max-h-48 overflow-auto text-xs whitespace-pre-wrap\">\n {ev.summary}\n </pre>\n </div>\n ))}\n </div>\n )}\n\n {result.drafts?.map((draft, i) => (\n <DraftCard\n key={i}\n draft={draft}\n draftingEnabled={draftingEnabled}\n />\n ))}\n </div>\n ) : null}\n </CardContent>\n </Card>\n )\n}\n\nfunction DraftCard({\n draft,\n draftingEnabled,\n}: {\n draft: CatalogDraft\n draftingEnabled: boolean\n}) {\n const canApply = useCatalogWrites() && draftingEnabled\n if (draft.kind === \"refused\" && draft.refusal) {\n return (\n <div className=\"rounded-lg border border-dashed p-3 text-xs\">\n <p className=\"mb-1 flex items-center gap-2 font-medium\">\n <Badge variant=\"secondary\">\n <AdminMessage id={\"refused: \"} />\n {draft.refusal.code}\n </Badge>\n </p>\n <p className=\"text-muted-foreground\">{draft.refusal.reason}</p>\n <p className=\"mt-1\">{draft.refusal.workaround}</p>\n </div>\n )\n }\n if (draft.kind === \"price_change\" && draft.price_change) {\n return (\n <PriceChangeDraftCard draft={draft.price_change} canApply={canApply} />\n )\n }\n if (draft.kind === \"new_price\" && draft.new_price) {\n return <NewPriceDraftCard draft={draft.new_price} canApply={canApply} />\n }\n return null\n}\n\n// PriceChangeDraftCard loads the live price, then opens the price-change\n// wizard pre-filled at step 3; a person confirms as for a typed change.\nfunction PriceChangeDraftCard({\n draft,\n canApply,\n}: {\n draft: PriceChangeDraft\n canApply: boolean\n}) {\n const { toastApiError, adminMutations } = useAdminServices()\n\n const loadDraft = useMutation(adminMutations.loadCatalogPriceDraft())\n\n const openWizard = async () => {\n if (!canApply) return\n try {\n await loadDraft.mutateAsync({\n productKey: draft.product_key,\n priceKey: draft.price_key,\n })\n } catch (err) {\n toastApiError(err, \"Load draft for review\")\n }\n }\n\n return (\n <div className=\"rounded-lg border bg-muted/30 p-3 text-sm\">\n <div className=\"mb-1 flex items-center gap-2\">\n <HugeiconsIcon\n icon={SparklesIcon}\n className=\"size-3.5 text-muted-foreground\"\n />\n <span className=\"text-xs font-medium text-muted-foreground uppercase\">\n <AdminMessage id={\"Draft: price change\"} />\n </span>\n <Badge variant=\"secondary\">\n {BigInt(draft.new_amount) > BigInt(draft.current_amount)\n ? \"increase\"\n : \"decrease\"}\n </Badge>\n </div>\n <p>{draft.review_text}</p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n {formatNativeAmount(draft.current_amount, draft.currency)} →{\" \"}\n {formatNativeAmount(draft.new_amount, draft.currency)} ·{\" \"}\n {draft.affected_count.toLocaleString()}\n <AdminMessage id={\" affected · requires human confirm\"} />\n </p>\n {canApply &&\n (loadDraft.data ? (\n <PriceChangeWizard\n price={loadDraft.data.price}\n productName={loadDraft.data.productName}\n productKey={loadDraft.data.productKey}\n draft={draft}\n onDone={() => loadDraft.reset()}\n />\n ) : (\n <Button\n size=\"sm\"\n className=\"mt-2\"\n disabled={loadDraft.isPending}\n onClick={openWizard}\n >\n {loadDraft.isPending ? \"Loading…\" : \"Review in wizard\"}\n </Button>\n ))}\n </div>\n )\n}\n\n// NewPriceDraftCard creates the price only on a person's click, with the same\n// createPrice the New Price form uses.\nfunction NewPriceDraftCard({\n draft,\n canApply,\n}: {\n draft: NewPriceDraft\n canApply: boolean\n}) {\n const { toastApiError, adminMutations } = useAdminServices()\n\n const queryClient = useQueryClient()\n const createDraftPrice = useMutation(\n adminMutations.createCatalogDraftPrice(queryClient)\n )\n\n const confirm = async () => {\n if (!canApply) return\n try {\n await createDraftPrice.mutateAsync(draft.create_price)\n } catch (err) {\n toastApiError(err, \"Create drafted price\")\n }\n }\n\n return (\n <div className=\"rounded-lg border bg-muted/30 p-3 text-sm\">\n <div className=\"mb-1 flex items-center gap-2\">\n <HugeiconsIcon\n icon={SparklesIcon}\n className=\"size-3.5 text-muted-foreground\"\n />\n <span className=\"text-xs font-medium text-muted-foreground uppercase\">\n <AdminMessage id={\"Draft: new price\"} />\n </span>\n </div>\n <p>{draft.review_text}</p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n <AdminMessage id={\"key: \"} />\n {draft.create_price.key} ·{\" \"}\n {formatNativeAmount(\n draft.create_price.unit_amount,\n draft.create_price.currency\n )}\n </p>\n {canApply && (\n <Button\n size=\"sm\"\n className=\"mt-2\"\n disabled={createDraftPrice.isPending || createDraftPrice.isSuccess}\n onClick={confirm}\n >\n {createDraftPrice.isSuccess\n ? \"Created\"\n : createDraftPrice.isPending\n ? \"Creating…\"\n : \"Create this price\"}\n </Button>\n )}\n </div>\n )\n}\n","import { AdminMessage, useAdminUI } from \"#orck/admin/ui-context\"\nimport { useAdminServices } from \"#orck/admin/context\"\nimport { HugeiconsIcon } from \"@hugeicons/react\"\nimport { Add01Icon, Refresh01Icon } from \"@hugeicons/core-free-icons\"\nimport * as React from \"react\"\nimport { Link } from \"#orck/admin/router\"\n\nimport { useForm } from \"@tanstack/react-form\"\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nimport { FormFieldErrors } from \"#orck/admin/components/form-field-errors\"\nimport { CursorPager } from \"#orck/admin/components/cursor-pager\"\nimport { useCursorPages } from \"#orck/admin/lib/cursor-pages\"\nimport { LinkedTableRow } from \"#orck/admin/components/linked-table-row\"\nimport { StatusBadge } from \"#orck/admin/components/status-badge\"\nimport { Badge } from \"#orck/admin/components/ui/badge\"\nimport { Button } from \"#orck/admin/components/ui/button\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"#orck/admin/components/ui/dialog\"\nimport { Input } from \"#orck/admin/components/ui/input\"\nimport { Label } from \"#orck/admin/components/ui/label\"\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"#orck/admin/components/ui/select\"\nimport { Skeleton } from \"#orck/admin/components/ui/skeleton\"\nimport { Switch } from \"#orck/admin/components/ui/switch\"\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"#orck/admin/components/ui/table\"\nimport { DIALOG_FORM } from \"#orck/admin/lib/dialog-width\"\nimport type { Price, Product } from \"#orck/client/generated/wire\"\nimport {\n currencyScale,\n formatDate,\n nativeAmountFromInput,\n shortId,\n supportedCurrencies,\n} from \"#orck/admin/lib/format\"\nimport { parseHours } from \"#orck/admin/lib/duration\"\n\nimport { CatalogApplicationDialog } from \"#orck/admin/pages/catalog/application-dialog\"\nimport { CatalogCopilotPanel } from \"#orck/admin/pages/catalog/copilot-panel\"\nimport {\n priceAmountLabel,\n priceIntervalLabel,\n} from \"#orck/admin/pages/catalog/price-format\"\nimport { PriceChangeWizard } from \"#orck/admin/pages/catalog/price-wizard\"\nimport {\n useAccess,\n useCatalogWrites,\n useMerchantConfig,\n useMerchantConfigUpdates,\n} from \"#orck/admin/lib/capabilities\"\n\n// Each part of the catalog is its own page, reached from the sub-items the\n// sidebar reveals under Catalog. The shell around them is identical, so it\n// lives here rather than being repeated three times.\nconst CatalogWritesContext = React.createContext(false)\n\nfunction CatalogSection({\n title,\n children,\n}: {\n title: string\n children: React.ReactNode\n}) {\n const assistants = useAccess()?.assistants\n const writesAllowed = useCatalogWrites()\n return (\n <CatalogWritesContext.Provider value={writesAllowed}>\n <div className=\"flex flex-col gap-4\">\n <h1 className=\"text-2xl font-semibold tracking-tight\">{title}</h1>\n <CatalogCopilotPanel\n enabled={assistants?.catalog_copilot ?? false}\n draftingEnabled={\n writesAllowed && (assistants?.catalog_drafting ?? false)\n }\n />\n {!writesAllowed && (\n <p className=\"text-sm text-muted-foreground\">\n <AdminMessage\n id={\n \"Catalog updates are unavailable. You can still browse products and prices.\"\n }\n />\n </p>\n )}\n {children}\n </div>\n </CatalogWritesContext.Provider>\n )\n}\n\nexport function CatalogProductsPage() {\n const { text: adminText } = useAdminUI()\n\n return (\n <CatalogSection title={adminText(\"Products\")}>\n <ProductsTab />\n </CatalogSection>\n )\n}\n\nexport function CatalogPricesPage() {\n const { text: adminText } = useAdminUI()\n\n return (\n <CatalogSection title={adminText(\"Prices\")}>\n <PricesTab />\n </CatalogSection>\n )\n}\n\nexport function CatalogDriftPage() {\n const { text: adminText } = useAdminUI()\n const merchantConfig = useMerchantConfig()\n if (!merchantConfig) return null\n return (\n <div className=\"flex flex-col gap-4\">\n <h1 className=\"text-2xl font-semibold tracking-tight\">\n {adminText(\"Drift\")}\n </h1>\n <DriftTab />\n </div>\n )\n}\n\nconst CATALOG_PAGE_SIZE = 100\n\nfunction ProductsTab() {\n const { adminQueries } = useAdminServices()\n\n const writesAllowed = React.useContext(CatalogWritesContext)\n const pages = useCursorPages(\"\", CATALOG_PAGE_SIZE)\n const {\n data,\n isPending: loading,\n isFetching,\n } = useQuery(\n adminQueries.products({\n limit: pages.size,\n cursor: pages.cursor,\n errorAction: \"Load products\",\n })\n )\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex justify-end gap-2\">\n {writesAllowed && (\n <>\n <CatalogApplicationDialog />\n <ProductDialog />\n </>\n )}\n </div>\n {loading ? (\n <div className=\"flex flex-col gap-3 py-2\">\n {Array.from({ length: 4 }).map((_, i) => (\n <Skeleton key={i} className=\"h-6 w-full\" />\n ))}\n </div>\n ) : (\n <div className=\"overflow-x-auto\">\n <Table>\n <TableHeader>\n <TableRow className=\"hover:bg-transparent\">\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Product\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Key\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Tier\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Entitlements\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"State\"} />\n </TableHead>\n <TableHead />\n </TableRow>\n </TableHeader>\n <TableBody>\n {(data?.data ?? []).map((p) => (\n <ProductRow key={p.id} product={p} />\n ))}\n {!data?.data?.length && (\n <TableRow>\n <TableCell\n colSpan={6}\n className=\"h-24 text-center text-muted-foreground\"\n >\n <AdminMessage id={\"No products yet.\"} />\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n )}\n <CursorPager\n pages={pages}\n rows={data?.data?.length ?? 0}\n nextCursor={data?.next_cursor}\n busy={isFetching}\n sizes={[50, 100, 200]}\n />\n </div>\n )\n}\n\nfunction ProductRow({ product }: { product: Product }) {\n const { toast, toastApiError, adminMutations } = useAdminServices()\n\n const writesAllowed = React.useContext(CatalogWritesContext)\n const queryClient = useQueryClient()\n const setProductActive = useMutation(\n adminMutations.setProductActive(queryClient)\n )\n const toggle = async () => {\n try {\n await setProductActive.mutateAsync({\n id: product.id,\n active: product.archived,\n revision: product.revision,\n })\n toast.success(\n product.archived ? \"Product activated\" : \"Product deactivated\"\n )\n } catch (err) {\n toastApiError(err, \"Toggle product\")\n }\n }\n return (\n <TableRow className={product.archived ? \"opacity-60\" : undefined}>\n <TableCell className=\"font-medium\">{product.display_name}</TableCell>\n <TableCell className=\"text-xs text-muted-foreground\">\n {product.key}\n </TableCell>\n <TableCell>\n {product.tier_group\n ? `${product.tier_group} #${product.tier_rank}`\n : \"—\"}\n </TableCell>\n <TableCell>\n <span className=\"flex flex-wrap gap-1\">\n {product.entitlements.map((e) => (\n <Badge key={e} variant=\"secondary\" className=\"text-[10px]\">\n {e}\n </Badge>\n ))}\n </span>\n </TableCell>\n <TableCell>\n {product.archived ? (\n <Badge variant=\"secondary\">\n <AdminMessage id={\"archived\"} />\n </Badge>\n ) : (\n <StatusBadge status=\"active\" />\n )}\n </TableCell>\n <TableCell className=\"text-right\">\n {writesAllowed && (\n <div className=\"flex justify-end gap-2\">\n {writesAllowed && <ProductDialog product={product} />}\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={!writesAllowed || setProductActive.isPending}\n onClick={toggle}\n >\n {product.archived ? \"Activate\" : \"Deactivate\"}\n </Button>\n </div>\n )}\n </TableCell>\n </TableRow>\n )\n}\n\nfunction productFormValues(product?: Product) {\n return {\n key: product?.key ?? \"\",\n name: product?.display_name ?? \"\",\n description: product?.description ?? \"\",\n tierGroup: product?.tier_group ?? \"\",\n tierRank: String(product?.tier_rank ?? 0),\n entitlements: (product?.entitlements ?? []).join(\",\"),\n }\n}\n\nfunction ProductDialog({ product }: { product?: Product }) {\n const { toast, toastApiError, adminMutations } = useAdminServices()\n\n const { text: adminText, id: adminId } = useAdminUI()\n\n const [open, setOpen] = React.useState(false)\n const queryClient = useQueryClient()\n const createProduct = useMutation(adminMutations.createProduct(queryClient))\n const updateProduct = useMutation(adminMutations.updateProduct(queryClient))\n const form = useForm({\n defaultValues: productFormValues(product),\n onSubmit: async ({ value }) => {\n const entitlements = value.entitlements\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean)\n\n try {\n if (product) {\n await updateProduct.mutateAsync({\n id: product.id,\n product: {\n display_name: value.name,\n description: value.description,\n tier_group: value.tierGroup || null,\n tier_rank: Number(value.tierRank) || 0,\n entitlements,\n expected_revision: product.revision,\n },\n })\n toast.success(\"Product updated\")\n } else {\n await createProduct.mutateAsync({\n key: value.key,\n display_name: value.name,\n description: value.description,\n tier_group: value.tierGroup || undefined,\n tier_rank: Number(value.tierRank) || 0,\n entitlements,\n })\n toast.success(\"Product created\")\n }\n form.reset(value)\n setOpen(false)\n } catch (err) {\n toastApiError(err, product ? \"Update product\" : \"Create product\")\n }\n },\n })\n\n const handleOpenChange = (next: boolean) => {\n if (next) form.reset(productFormValues(product))\n setOpen(next)\n }\n\n return (\n <Dialog open={open} onOpenChange={handleOpenChange}>\n <DialogTrigger\n render={\n product ? (\n <Button variant=\"outline\" size=\"sm\">\n <AdminMessage id={\"Edit\"} />\n </Button>\n ) : (\n <Button size=\"sm\">\n <HugeiconsIcon icon={Add01Icon} className=\"size-4\" />\n <AdminMessage id={\" Product\"} />\n </Button>\n )\n }\n />\n <DialogContent className={DIALOG_FORM}>\n <DialogHeader>\n <DialogTitle>{product ? \"Edit product\" : \"New product\"}</DialogTitle>\n <DialogDescription>\n <AdminMessage\n id={\n \"A product is the thing a customer gets. You set what it costs afterwards, by adding a price to it.\"\n }\n />\n </DialogDescription>\n </DialogHeader>\n <form\n onSubmit={(event) => {\n event.preventDefault()\n event.stopPropagation()\n void form.handleSubmit()\n }}\n className=\"grid gap-4\"\n >\n <div className=\"grid gap-3\">\n {!product && (\n <form.Field\n name=\"key\"\n validators={{\n onBlur: ({ value }) =>\n value.trim() ? undefined : \"Enter a product key\",\n }}\n >\n {(field) => (\n <Field\n label={adminText(\"Key\")}\n id={\"p-key\"}\n hint=\"A short name you use in your own code. It cannot be changed later.\"\n >\n <Input\n id={adminId(\"p-key\")}\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n placeholder={adminText(\"premium-monthly\")}\n aria-invalid={field.state.meta.errors.length > 0}\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </Field>\n )}\n </form.Field>\n )}\n <form.Field\n name=\"name\"\n validators={{\n onBlur: ({ value }) =>\n value.trim() ? undefined : \"Enter a display name\",\n }}\n >\n {(field) => (\n <Field\n label={adminText(\"Display name\")}\n id={\"p-name\"}\n hint=\"What customers see on checkout and invoices.\"\n >\n <Input\n id={adminId(\"p-name\")}\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) => field.handleChange(event.target.value)}\n aria-invalid={field.state.meta.errors.length > 0}\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </Field>\n )}\n </form.Field>\n <form.Field name=\"description\">\n {(field) => (\n <Field label={adminText(\"Description\")} id={\"p-desc\"}>\n <Input\n id={adminId(\"p-desc\")}\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) => field.handleChange(event.target.value)}\n />\n </Field>\n )}\n </form.Field>\n <div className=\"grid grid-cols-2 gap-3\">\n <form.Field name=\"tierGroup\">\n {(field) => (\n <Field\n label={adminText(\"Tier group\")}\n id={\"p-tg\"}\n hint=\"Products in one group are upgrades of each other. Leave empty if this stands alone.\"\n >\n <Input\n id={adminId(\"p-tg\")}\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n />\n </Field>\n )}\n </form.Field>\n <form.Field name=\"tierRank\">\n {(field) => (\n <Field\n label={adminText(\"Tier rank\")}\n id={\"p-tr\"}\n hint=\"Higher rank means a higher tier in the group.\"\n >\n <Input\n id={adminId(\"p-tr\")}\n type=\"number\"\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n />\n </Field>\n )}\n </form.Field>\n </div>\n <form.Field name=\"entitlements\">\n {(field) => (\n <Field\n label={adminText(\"Entitlements\")}\n id={\"p-ents\"}\n hint=\"The access names your product checks. Separate several with commas.\"\n >\n <Input\n id={adminId(\"p-ents\")}\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) => field.handleChange(event.target.value)}\n placeholder={adminText(\"premium, downloads\")}\n />\n </Field>\n )}\n </form.Field>\n </div>\n <DialogFooter>\n <form.Subscribe\n selector={(state) =>\n [\n state.values.key,\n state.values.name,\n state.isSubmitting,\n ] as const\n }\n >\n {([key, name, isSubmitting]) => (\n <>\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={isSubmitting}\n onClick={() => setOpen(false)}\n >\n <AdminMessage id={\"Cancel\"} />\n </Button>\n <Button\n type=\"submit\"\n disabled={\n isSubmitting || !name.trim() || (!product && !key.trim())\n }\n >\n {isSubmitting ? \"Saving…\" : \"Save product\"}\n </Button>\n </>\n )}\n </form.Subscribe>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction PricesTab() {\n const { adminQueries } = useAdminServices()\n\n const writesAllowed = React.useContext(CatalogWritesContext)\n const pages = useCursorPages(\"\", CATALOG_PAGE_SIZE)\n const { data: products } = useQuery(\n adminQueries.allProducts({ errorAction: \"Load products\" })\n )\n const {\n data,\n isPending: loading,\n isFetching,\n } = useQuery(\n adminQueries.prices({\n limit: pages.size,\n cursor: pages.cursor,\n errorAction: \"Load prices\",\n })\n )\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex justify-end\">\n {writesAllowed && <PriceDialog products={products?.data ?? []} />}\n </div>\n {loading ? (\n <div className=\"flex flex-col gap-3 py-2\">\n {Array.from({ length: 4 }).map((_, i) => (\n <Skeleton key={i} className=\"h-6 w-full\" />\n ))}\n </div>\n ) : (\n <div className=\"overflow-x-auto\">\n <Table>\n <TableHeader>\n <TableRow className=\"hover:bg-transparent\">\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Price\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Product\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Amount\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Renews\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Providers\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"State\"} />\n </TableHead>\n <TableHead />\n </TableRow>\n </TableHeader>\n <TableBody>\n {(data?.data ?? []).map((price) => (\n <PriceRow\n key={price.id}\n price={price}\n product={products?.data.find(\n (p) => p.id === price.product_id\n )}\n />\n ))}\n {!data?.data?.length && (\n <TableRow>\n <TableCell\n colSpan={7}\n className=\"h-24 text-center text-muted-foreground\"\n >\n <AdminMessage id={\"No prices yet.\"} />\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n )}\n <CursorPager\n pages={pages}\n rows={data?.data?.length ?? 0}\n nextCursor={data?.next_cursor}\n busy={isFetching}\n sizes={[50, 100, 200]}\n />\n </div>\n )\n}\n\nfunction PriceRow({ price, product }: { price: Price; product?: Product }) {\n const { toast, toastApiError, adminMutations } = useAdminServices()\n\n const productName = product?.display_name ?? shortId(price.product_id, 13)\n const writesAllowed = React.useContext(CatalogWritesContext)\n const queryClient = useQueryClient()\n const setPriceActive = useMutation(adminMutations.setPriceActive(queryClient))\n const toggle = async () => {\n try {\n await setPriceActive.mutateAsync({\n id: price.id,\n active: price.archived,\n revision: price.revision,\n })\n toast.success(price.archived ? \"Price activated\" : \"Price deactivated\")\n } catch (err) {\n toastApiError(err, \"Toggle price\")\n }\n }\n return (\n <LinkedTableRow\n to={`/catalog/prices/${encodeURIComponent(price.id)}`}\n className={price.archived ? \"opacity-60\" : undefined}\n >\n <TableCell className=\"text-xs text-muted-foreground\">\n <Link\n className=\"underline-offset-2 hover:underline\"\n to={`/catalog/prices/${encodeURIComponent(price.id)}`}\n >\n {price.id}\n </Link>\n </TableCell>\n <TableCell className=\"font-medium\">{productName}</TableCell>\n <TableCell className=\"tabular-nums\">{priceAmountLabel(price)}</TableCell>\n <TableCell>{priceIntervalLabel(price)}</TableCell>\n <TableCell>\n <span className=\"flex flex-wrap gap-1\">\n {/* psp_links is keyed by PSP key (\"mobius\"), not by rail — the rail\n is recorded inside the entry (or#812). */}\n {Object.entries(price.psps ?? {}).map(([psp, state]) => (\n <Badge\n key={psp}\n variant=\"secondary\"\n className={\n state.status === \"linked\" ? \"\" : \"bg-held-surface text-held\"\n }\n title={state.message || undefined}\n >\n {psp}: {state.status}\n </Badge>\n ))}\n </span>\n </TableCell>\n <TableCell>\n {price.archived ? (\n <Badge variant=\"secondary\">\n <AdminMessage id={\"archived\"} />\n </Badge>\n ) : (\n <StatusBadge status=\"active\" />\n )}\n </TableCell>\n <TableCell className=\"text-right\">\n {writesAllowed && (\n <div className=\"flex justify-end gap-2\">\n {writesAllowed && (\n <PriceChangeWizard\n price={price}\n productName={productName}\n productKey={product?.key}\n />\n )}\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={!writesAllowed || setPriceActive.isPending}\n onClick={toggle}\n >\n {price.archived ? \"Activate\" : \"Deactivate\"}\n </Button>\n </div>\n )}\n </TableCell>\n </LinkedTableRow>\n )\n}\n\nconst durationError = ({ value }: { value: string }) =>\n !value || parseHours(value)\n ? undefined\n : \"Use hours, days or weeks, such as 30 days\"\n\nfunction PriceDialog({ products }: { products: Product[] }) {\n const { toast, toastApiError, adminMutations } = useAdminServices()\n\n const { text: adminText, id: adminId } = useAdminUI()\n\n const [open, setOpen] = React.useState(false)\n const queryClient = useQueryClient()\n const createPrice = useMutation(adminMutations.createPrice(queryClient))\n const form = useForm({\n defaultValues: {\n productId: \"\",\n amount: \"\",\n currency: \"USD\",\n accessDuration: \"\",\n billingInterval: \"\",\n },\n onSubmit: async ({ value }) => {\n const unitAmount = nativeAmountFromInput(value.amount, value.currency)\n if (unitAmount === null || BigInt(unitAmount) <= 0n) return\n const accessHours = parseHours(value.accessDuration)\n const billingHours = parseHours(value.billingInterval)\n if (\n (value.accessDuration && !accessHours) ||\n (value.billingInterval && !billingHours)\n )\n return\n try {\n await createPrice.mutateAsync({\n product_id: value.productId,\n unit_amount: unitAmount,\n currency: value.currency,\n ...(accessHours ? { access_duration_hours: accessHours } : {}),\n ...(billingHours ? { billing_interval_hours: billingHours } : {}),\n })\n form.reset()\n toast.success(\"Price created\")\n setOpen(false)\n } catch (err) {\n toastApiError(err, \"Create price\")\n }\n },\n })\n\n const handleOpenChange = (next: boolean) => {\n if (next) form.reset()\n setOpen(next)\n }\n\n return (\n <Dialog open={open} onOpenChange={handleOpenChange}>\n <DialogTrigger\n render={\n <Button size=\"sm\">\n <HugeiconsIcon icon={Add01Icon} className=\"size-4\" />\n <AdminMessage id={\" Price\"} />\n </Button>\n }\n />\n <DialogContent className={DIALOG_FORM}>\n <DialogHeader>\n <DialogTitle>\n <AdminMessage id={\"New price\"} />\n </DialogTitle>\n <DialogDescription>\n <AdminMessage\n id={\n \"These terms cannot be changed later. To charge a different amount, create another price and deactivate this one.\"\n }\n />\n </DialogDescription>\n </DialogHeader>\n <form\n onSubmit={(event) => {\n event.preventDefault()\n event.stopPropagation()\n void form.handleSubmit()\n }}\n className=\"grid gap-4\"\n >\n <div className=\"grid gap-3\">\n <form.Field name=\"productId\">\n {(field) => (\n <Field label={adminText(\"Product\")} id={\"pr-prod\"}>\n <Select\n items={products.map((product) => ({\n value: product.id,\n label: `${product.display_name} (${product.key})`,\n }))}\n value={field.state.value || null}\n onValueChange={(value) => field.handleChange(value ?? \"\")}\n >\n <SelectTrigger id={adminId(\"pr-prod\")} className=\"w-full\">\n <SelectValue placeholder={adminText(\"Pick a product…\")} />\n </SelectTrigger>\n <SelectContent>\n {products.map((product) => (\n <SelectItem key={product.id} value={product.id}>\n {product.display_name} ({product.key})\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </Field>\n )}\n </form.Field>\n {/* Amount and currency are one money value, so they sit on one row\n under one label — two labelled columns pull apart whenever the\n hint wraps. */}\n <Field\n label={adminText(\"Amount\")}\n id={\"pr-amount\"}\n hint=\"Enter it the way you would write it, such as 19.90.\"\n >\n <div className=\"flex gap-2\">\n <form.Field\n name=\"amount\"\n validators={{\n onBlurListenTo: [\"currency\"],\n onBlur: ({ value, fieldApi }) =>\n BigInt(\n nativeAmountFromInput(\n value,\n fieldApi.form.getFieldValue(\"currency\")\n ) ?? \"0\"\n ) > 0n\n ? undefined\n : \"Enter an amount greater than zero\",\n }}\n >\n {(field) => (\n <div className=\"flex-1\">\n <Input\n id={adminId(\"pr-amount\")}\n type=\"number\"\n step=\"any\"\n min=\"0\"\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n aria-invalid={field.state.meta.errors.length > 0}\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </div>\n )}\n </form.Field>\n <form.Field\n name=\"currency\"\n validators={{\n onChange: ({ value }) =>\n currencyScale(value) === undefined\n ? `Use ${supportedCurrencies.join(\", \")}`\n : undefined,\n }}\n >\n {(field) => (\n <Input\n id={adminId(\"pr-cur\")}\n aria-label={adminText(\"Currency\")}\n className=\"w-24\"\n // Registered currency codes are normalized to uppercase.\n value={field.state.value}\n maxLength={Math.max(\n ...supportedCurrencies.map((code) => code.length)\n )}\n autoCapitalize=\"characters\"\n spellCheck={false}\n placeholder={adminText(\"USD\")}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value.toUpperCase())\n }\n />\n )}\n </form.Field>\n </div>\n </Field>\n <form.Field\n name=\"accessDuration\"\n validators={{ onBlur: durationError }}\n >\n {(field) => (\n <Field\n label={adminText(\"Access duration\")}\n id={\"pr-dur\"}\n hint=\"Such as 30 days, 1 week or 12 hours. Leave it empty for access that never expires.\"\n >\n <Input\n id={adminId(\"pr-dur\")}\n placeholder={adminText(\"Never expires\")}\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) => field.handleChange(event.target.value)}\n aria-invalid={field.state.meta.errors.length > 0}\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </Field>\n )}\n </form.Field>\n <form.Field\n name=\"billingInterval\"\n validators={{ onBlur: durationError }}\n >\n {(field) => (\n <div className=\"grid gap-3 rounded-md border p-3\">\n <div className=\"flex items-center justify-between gap-4\">\n <Label htmlFor={adminId(\"pr-renew\")}>\n <AdminMessage id={\"Recurring billing\"} />\n </Label>\n <Switch\n id={adminId(\"pr-renew\")}\n checked={!!field.state.value}\n onCheckedChange={(checked) =>\n field.handleChange(checked ? \"30 days\" : \"\")\n }\n />\n </div>\n {field.state.value ? (\n <Field\n label={adminText(\"Billing interval\")}\n id={\"pr-billing\"}\n hint=\"Time between payments, such as 30 days, until the customer cancels.\"\n >\n <Input\n id={adminId(\"pr-billing\")}\n required\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n aria-invalid={field.state.meta.errors.length > 0}\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </Field>\n ) : (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage id={\"One-time payment.\"} />\n </p>\n )}\n </div>\n )}\n </form.Field>\n </div>\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => handleOpenChange(false)}\n >\n <AdminMessage id={\"Cancel\"} />\n </Button>\n <form.Subscribe\n selector={(state) =>\n [\n state.values.productId,\n state.values.amount,\n state.values.currency,\n state.values.accessDuration,\n state.values.billingInterval,\n state.isSubmitting,\n ] as const\n }\n >\n {([\n productId,\n amount,\n currency,\n accessDuration,\n billingInterval,\n isSubmitting,\n ]) => (\n <Button\n type=\"submit\"\n disabled={\n isSubmitting ||\n !productId ||\n BigInt(nativeAmountFromInput(amount, currency) ?? \"0\") <=\n 0n ||\n durationError({ value: accessDuration }) !== undefined ||\n durationError({ value: billingInterval }) !== undefined\n }\n >\n {isSubmitting ? \"Creating…\" : \"Create price\"}\n </Button>\n )}\n </form.Subscribe>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction DriftTab() {\n const { toast, toastApiError, adminMutations, adminQueries } =\n useAdminServices()\n\n const queryClient = useQueryClient()\n const canRead = useMerchantConfig()\n const canRefresh = useMerchantConfigUpdates()\n const { data, isPending: loading } = useQuery(adminQueries.catalogDrift(canRead))\n const refreshDrift = useMutation(adminMutations.refreshPSPs(queryClient))\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex justify-end\">\n {canRefresh && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={refreshDrift.isPending}\n onClick={async () => {\n try {\n await refreshDrift.mutateAsync()\n toast.success(\n \"Re-reading every PSP: new drift appears here as it is found\"\n )\n } catch (err) {\n toastApiError(err, \"Refresh drift\")\n }\n }}\n >\n <HugeiconsIcon\n icon={Refresh01Icon}\n className={\n refreshDrift.isPending ? \"size-4 animate-spin\" : \"size-4\"\n }\n />\n <AdminMessage id={\"Refresh scan\"} />\n </Button>\n )}\n </div>\n {loading ? (\n <div className=\"flex flex-col gap-3 py-2\">\n {Array.from({ length: 4 }).map((_, i) => (\n <Skeleton key={i} className=\"h-6 w-full\" />\n ))}\n </div>\n ) : !data?.data?.length ? (\n <p className=\"text-sm text-muted-foreground\">\n <AdminMessage id={\"No open drift events. Catalog is in sync.\"} />\n </p>\n ) : (\n <div className=\"overflow-x-auto\">\n <Table>\n <TableHeader>\n <TableRow className=\"hover:bg-transparent\">\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Provider\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Kind\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Resource\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Field\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"OpenRails\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Remote\"} />\n </TableHead>\n <TableHead className=\"text-muted-foreground\">\n <AdminMessage id={\"Detected\"} />\n </TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {data.data.map((e) => (\n <TableRow key={e.id}>\n <TableCell>{e.provider ?? \"—\"}</TableCell>\n <TableCell>\n {e.finding_type.replace(/^catalog\\./, \"\")}\n </TableCell>\n <TableCell className=\"text-xs\">\n {e.resource_type}{\" \"}\n {shortId(e.resource_id || e.external_resource_id || \"\", 13)}\n </TableCell>\n <TableCell>{e.field || \"—\"}</TableCell>\n <TableCell className=\"max-w-40 truncate\">\n {e.openrails_value || \"—\"}\n </TableCell>\n <TableCell className=\"max-w-40 truncate\">\n {e.external_value || \"—\"}\n </TableCell>\n <TableCell>{formatDate(e.created_at)}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </div>\n )}\n </div>\n )\n}\n\n// hint carries the invisible constraint: what a value is for, or what happens if\n// it is left empty. Anything the control already says is left out.\nfunction Field({\n label,\n id,\n hint,\n children,\n}: {\n label: string\n id: string\n hint?: string\n children: React.ReactNode\n}) {\n const { id: adminId } = useAdminUI()\n\n return (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={adminId(id)}>{label}</Label>\n {hint ? (\n <p className=\"text-[13px] text-muted-foreground\">{hint}</p>\n ) : null}\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,KAA2B;CACzC,IAAM,EAAE,UAAO,kBAAe,qBAAkB,sBAC9C,EAAiB,GAEb,EAAE,IAAI,GAAS,MAAM,MAAc,EAAW,GAE9C,CAAC,GAAM,KAAW,EAAM,SAAS,EAAK,GACtC,CAAC,GAAU,KAAe,EAAM,SAAS,EAAE,GAC3C,CAAC,GAAU,KAAe,EAAM,SAAS,EAAK,GAC9C,CAAC,GAAW,KAAgB,EAAM,SAAiB,GACnD,CAAC,GAAS,KAAc,EAAM,SAAoC,GAClE,CAAC,GAAS,KAAc,EAAM,SAAS,EAAE,GACzC,CAAC,GAAS,KAAc,EAAM,SAAS,EAAK,GAC5C,CAAC,GAAe,KAAoB,EAAM,SAAiB,GAC3D,IAAQ,EAAY,EAAe,aAAa,EAAe,CAAC,CAAC,GAEjE,UAAc;EAiBlB,AAhBA,EAAiB,EAAiB,CAAC,GACnC,EACE,KAAK,UACH;GACE,gBAAgB;GAChB,OAAO;GACP,UAAU,CAAC;EACb,GACA,MACA,C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IACX,kBAAC,GAAD,EAAA,UAAY,EAAW,EAAE,UAAU,EAAa,CAAA;GACxC,EAAA,GAjBK,EAAE,EAiBP,CACX,EACQ,CAAA,CACN,EAAA,CAAA;EACJ,CAAA,IAtDL,kBAAC,KAAD;GAAG,WAAU;GACX,UAAA,kBAAC,GAAD,EAAc,IAAI,4CAA8C,CAAA;EAC/D,CAAA,CAsDF;;AAET;AAIA,SAAS,EAAM,EACb,UACA,OACA,SACA,eAMC;CACD,IAAM,EAAE,IAAI,MAAY,EAAW;CAEnC,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACE,kBAAC,GAAD;IAAO,SAAS,EAAQ,CAAE;IAAI,UAAA;GAAa,CAAA;GAC1C,IACC,kBAAC,KAAD;IAAG,WAAU;IAAqC,UAAA;GAAQ,CAAA,IACxD;GACH;EACE;;AAET"}
|
|
@@ -106,7 +106,7 @@ function ke(e) {
|
|
|
106
106
|
e.productId || H("rate-product", "Select a product.");
|
|
107
107
|
let t = e.currency.trim().toUpperCase();
|
|
108
108
|
m(t) === void 0 && H("rate-currency", `Use a supported currency: ${f.join(", ")}.`);
|
|
109
|
-
let n = Ae(e, t), r = je(e);
|
|
109
|
+
let n = Ae(e, t), r = e.model === "dynamic" ? void 0 : je(e);
|
|
110
110
|
return {
|
|
111
111
|
product_id: e.productId,
|
|
112
112
|
filter: Ne(e.filters),
|
|
@@ -115,6 +115,10 @@ function ke(e) {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
function Ae(e, t) {
|
|
118
|
+
if (e.model === "dynamic") return {
|
|
119
|
+
model: "dynamic",
|
|
120
|
+
currency: t
|
|
121
|
+
};
|
|
118
122
|
if (e.model === "per_unit") {
|
|
119
123
|
let n = Pe(e.divideBy, "Divisor", "rate-divide-by"), r = V(t, e.maximumAmount, "Maximum amount", "rate-maximum");
|
|
120
124
|
if (e.matrixEnabled) {
|
|
@@ -232,7 +236,7 @@ function W(e, t = "") {
|
|
|
232
236
|
function Ie(e) {
|
|
233
237
|
if (!e) return "Not priced";
|
|
234
238
|
let { price: t } = e, n = t.currency ?? "";
|
|
235
|
-
return t.model === "per_unit" && t.per_unit ? t.per_unit.matrix ? `${Object.keys(t.per_unit.matrix.cells ?? {}).length} matrix rates · ${n}` : `${g(t.per_unit.unit_amount ?? "0", n)} per ${t.per_unit.divide_by || 1} units` : t.model === "tiered" && t.tiered ? `${t.tiered.tiers?.length ?? 0} ${t.tiered.mode} tiers · ${n}` : t.model === "package" && t.package ? `${g(t.package.amount ?? "0", n)} per ${(t.package.package_size ?? 1).toLocaleString()} units` : `Unsupported price · ${n}`;
|
|
239
|
+
return t.model === "dynamic" ? `Event amount · ${n}` : t.model === "per_unit" && t.per_unit ? t.per_unit.matrix ? `${Object.keys(t.per_unit.matrix.cells ?? {}).length} matrix rates · ${n}` : `${g(t.per_unit.unit_amount ?? "0", n)} per ${t.per_unit.divide_by || 1} units` : t.model === "tiered" && t.tiered ? `${t.tiered.tiers?.length ?? 0} ${t.tiered.mode} tiers · ${n}` : t.model === "package" && t.package ? `${g(t.package.amount ?? "0", n)} per ${(t.package.package_size ?? 1).toLocaleString()} units` : `Unsupported price · ${n}`;
|
|
236
240
|
}
|
|
237
241
|
function Le(e, t) {
|
|
238
242
|
return t ? e.has_activity ? "Meter definitions lock after the first event." : null : "Catalog updates are disabled.";
|
|
@@ -510,7 +514,7 @@ function ze({ meter: t, writesAllowed: n = !1, products: a, productsPending: l =
|
|
|
510
514
|
let t = ke(e);
|
|
511
515
|
if (k && !await ee({
|
|
512
516
|
title: "Replace the default rate?",
|
|
513
|
-
description: "
|
|
517
|
+
description: "Amounts already charged do not change. New events use the new rate; admitted work keeps its pinned rate.",
|
|
514
518
|
confirmLabel: "Replace rate",
|
|
515
519
|
cancelLabel: "Keep current rate"
|
|
516
520
|
})) return;
|
|
@@ -633,7 +637,10 @@ function ze({ meter: t, writesAllowed: n = !1, products: a, productsPending: l =
|
|
|
633
637
|
]
|
|
634
638
|
})
|
|
635
639
|
}),
|
|
636
|
-
/* @__PURE__ */ P(Be, {
|
|
640
|
+
/* @__PURE__ */ P(Be, {
|
|
641
|
+
form: A,
|
|
642
|
+
meter: t
|
|
643
|
+
})
|
|
637
644
|
]
|
|
638
645
|
})]
|
|
639
646
|
}),
|
|
@@ -651,7 +658,11 @@ function ze({ meter: t, writesAllowed: n = !1, products: a, productsPending: l =
|
|
|
651
658
|
meter: t
|
|
652
659
|
}),
|
|
653
660
|
e === "tiered" && /* @__PURE__ */ P(Ue, { form: A }),
|
|
654
|
-
e === "package" && /* @__PURE__ */ P(We, { form: A })
|
|
661
|
+
e === "package" && /* @__PURE__ */ P(We, { form: A }),
|
|
662
|
+
e === "dynamic" && /* @__PURE__ */ P("p", {
|
|
663
|
+
className: "text-sm text-muted-foreground",
|
|
664
|
+
children: /* @__PURE__ */ P(o, { id: "Charge each event’s stated amount when it reports positive units. Missing amounts or zero units charge nothing." })
|
|
665
|
+
})
|
|
655
666
|
]
|
|
656
667
|
})
|
|
657
668
|
}),
|
|
@@ -659,7 +670,10 @@ function ze({ meter: t, writesAllowed: n = !1, products: a, productsPending: l =
|
|
|
659
670
|
form: A,
|
|
660
671
|
meter: t
|
|
661
672
|
}),
|
|
662
|
-
/* @__PURE__ */ P(
|
|
673
|
+
/* @__PURE__ */ P(A.Subscribe, {
|
|
674
|
+
selector: (e) => e.values.model,
|
|
675
|
+
children: (e) => e !== "dynamic" && /* @__PURE__ */ P(Ke, { form: A })
|
|
676
|
+
}),
|
|
663
677
|
/* @__PURE__ */ P(A.Subscribe, {
|
|
664
678
|
selector: (e) => e.values,
|
|
665
679
|
children: (e) => /* @__PURE__ */ P(qe, { values: e })
|
|
@@ -685,20 +699,20 @@ function ze({ meter: t, writesAllowed: n = !1, products: a, productsPending: l =
|
|
|
685
699
|
})
|
|
686
700
|
});
|
|
687
701
|
}
|
|
688
|
-
function Be({ form: t }) {
|
|
689
|
-
let { id:
|
|
702
|
+
function Be({ form: t, meter: n }) {
|
|
703
|
+
let { id: r } = e();
|
|
690
704
|
return /* @__PURE__ */ P(t.Field, {
|
|
691
705
|
name: "model",
|
|
692
706
|
children: (e) => /* @__PURE__ */ F("div", {
|
|
693
707
|
className: "grid gap-1.5 sm:col-span-3",
|
|
694
708
|
children: [/* @__PURE__ */ P(j, {
|
|
695
|
-
htmlFor:
|
|
709
|
+
htmlFor: r("rate-model"),
|
|
696
710
|
children: /* @__PURE__ */ P(o, { id: "Pricing model" })
|
|
697
711
|
}), /* @__PURE__ */ F(C, {
|
|
698
712
|
value: e.state.value,
|
|
699
713
|
onValueChange: (t) => e.handleChange(t),
|
|
700
714
|
children: [/* @__PURE__ */ P(b, {
|
|
701
|
-
id:
|
|
715
|
+
id: r("rate-model"),
|
|
702
716
|
className: "w-full",
|
|
703
717
|
children: /* @__PURE__ */ P(y, {})
|
|
704
718
|
}), /* @__PURE__ */ F(x, { children: [
|
|
@@ -713,6 +727,11 @@ function Be({ form: t }) {
|
|
|
713
727
|
/* @__PURE__ */ P(S, {
|
|
714
728
|
value: "package",
|
|
715
729
|
children: /* @__PURE__ */ P(o, { id: "Package" })
|
|
730
|
+
}),
|
|
731
|
+
/* @__PURE__ */ P(S, {
|
|
732
|
+
value: "dynamic",
|
|
733
|
+
disabled: n.aggregation !== "sum",
|
|
734
|
+
children: /* @__PURE__ */ P(o, { id: "Dynamic (event amount)" })
|
|
716
735
|
})
|
|
717
736
|
] })]
|
|
718
737
|
})]
|
|
@@ -1699,4 +1718,4 @@ function nt() {
|
|
|
1699
1718
|
//#endregion
|
|
1700
1719
|
export { Ze as CatalogMeteringPage, $e as MeterDetailPage };
|
|
1701
1720
|
|
|
1702
|
-
//# sourceMappingURL=admin-metering-
|
|
1721
|
+
//# sourceMappingURL=admin-metering-COFcSPQy.js.map
|