@fonderie/react-admin-screens 1.4.0 → 1.5.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/index.cjs CHANGED
@@ -1589,7 +1589,9 @@ var import_react_admin10 = require("@fonderie/react-admin");
1589
1589
  var import_react5 = require("react");
1590
1590
  var import_jsx_runtime11 = require("react/jsx-runtime");
1591
1591
  function SubscriberBilling({ client, subscriber }) {
1592
- const { subscription, wallet, ledger, hasMoreLedger, isLoading, error, loadMoreLedger, grant } = (0, import_react_admin10.useAdminSubscriber)(client, subscriber, { limit: 20 });
1592
+ const [currency, setCurrency] = (0, import_react5.useState)("");
1593
+ const [currencyDraft, setCurrencyDraft] = (0, import_react5.useState)("");
1594
+ const { subscription, wallet, ledger, hasMoreLedger, isLoading, error, loadMoreLedger, grant } = (0, import_react_admin10.useAdminSubscriber)(client, subscriber, { limit: 20, ...currency ? { currency } : {} });
1593
1595
  const [amount, setAmount] = (0, import_react5.useState)("");
1594
1596
  const [note, setNote] = (0, import_react5.useState)("");
1595
1597
  const [granted, setGranted] = (0, import_react5.useState)(null);
@@ -1630,7 +1632,42 @@ function SubscriberBilling({ client, subscriber }) {
1630
1632
  subscription?.providerSubscriptionId ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { ...styles.statHint, fontFamily: "var(--fonderie-mono,monospace)" }, children: subscription.providerSubscriptionId }) : null
1631
1633
  ] }),
1632
1634
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: styles.card, children: [
1633
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: styles.statLabel, children: "Credits" }),
1635
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1636
+ "div",
1637
+ {
1638
+ style: {
1639
+ display: "flex",
1640
+ justifyContent: "space-between",
1641
+ alignItems: "center",
1642
+ gap: 8
1643
+ },
1644
+ children: [
1645
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: styles.statLabel, children: "Credits" }),
1646
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1647
+ "form",
1648
+ {
1649
+ style: { display: "flex", gap: 4 },
1650
+ onSubmit: (e) => {
1651
+ e.preventDefault();
1652
+ setCurrency(currencyDraft.trim().toUpperCase());
1653
+ },
1654
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1655
+ "input",
1656
+ {
1657
+ value: currencyDraft,
1658
+ onChange: (e) => setCurrencyDraft(e.target.value),
1659
+ placeholder: wallet?.currency ?? "currency",
1660
+ maxLength: 8,
1661
+ style: { ...styles.input, height: 26, width: 84, fontSize: 12 },
1662
+ "aria-label": "Wallet currency",
1663
+ title: "Show the wallet in another currency"
1664
+ }
1665
+ )
1666
+ }
1667
+ )
1668
+ ]
1669
+ }
1670
+ ),
1634
1671
  wallet ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1635
1672
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: styles.statValue, children: [
1636
1673
  wallet.balance,
@@ -2318,10 +2355,8 @@ var import_react_admin14 = require("@fonderie/react-admin");
2318
2355
  var import_react8 = require("react");
2319
2356
  var import_jsx_runtime15 = require("react/jsx-runtime");
2320
2357
  function AuditScreen({ client, pageSize = 50 }) {
2321
- const [draft, setDraft] = (0, import_react8.useState)({ workspaceId: "", type: "", actorId: "" });
2322
- const [filter, setFilter] = (0, import_react8.useState)(
2323
- {}
2324
- );
2358
+ const [draft, setDraft] = (0, import_react8.useState)({ workspaceId: "", type: "", actorId: "", from: "", to: "" });
2359
+ const [filter, setFilter] = (0, import_react8.useState)({});
2325
2360
  const { events, hasMore, isLoading, error, refresh, loadMore } = (0, import_react_admin14.useAdminAudit)(client, {
2326
2361
  ...filter,
2327
2362
  limit: pageSize
@@ -2353,13 +2388,38 @@ function AuditScreen({ client, pageSize = 50 }) {
2353
2388
  setFilter({
2354
2389
  ...draft.workspaceId.trim() ? { workspaceId: draft.workspaceId.trim() } : {},
2355
2390
  ...draft.type.trim() ? { type: draft.type.trim() } : {},
2356
- ...draft.actorId.trim() ? { actorId: draft.actorId.trim() } : {}
2391
+ ...draft.actorId.trim() ? { actorId: draft.actorId.trim() } : {},
2392
+ // Dates are whole days in the operator's time zone: "to" includes that day.
2393
+ ...draft.from ? { from: /* @__PURE__ */ new Date(`${draft.from}T00:00:00`) } : {},
2394
+ ...draft.to ? { to: /* @__PURE__ */ new Date(`${draft.to}T23:59:59.999`) } : {}
2357
2395
  });
2358
2396
  },
2359
2397
  children: [
2360
2398
  field("workspaceId", "workspace id (all if empty)"),
2361
2399
  field("type", "event type"),
2362
2400
  field("actorId", "actor id"),
2401
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2402
+ "input",
2403
+ {
2404
+ type: "date",
2405
+ value: draft.from,
2406
+ onChange: (e) => setDraft({ ...draft, from: e.target.value }),
2407
+ style: styles.input,
2408
+ "aria-label": "From date",
2409
+ title: "From (inclusive)"
2410
+ }
2411
+ ),
2412
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2413
+ "input",
2414
+ {
2415
+ type: "date",
2416
+ value: draft.to,
2417
+ onChange: (e) => setDraft({ ...draft, to: e.target.value }),
2418
+ style: styles.input,
2419
+ "aria-label": "To date",
2420
+ title: "To (inclusive)"
2421
+ }
2422
+ ),
2363
2423
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { type: "submit", style: styles.buttonPrimary, disabled: isLoading, children: [
2364
2424
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon, { name: "search", size: 14 }),
2365
2425
  "Filter"
@@ -2484,7 +2544,8 @@ function AdminShell({
2484
2544
  envLabel,
2485
2545
  footer,
2486
2546
  operators = false,
2487
- currentOperator
2547
+ currentOperator,
2548
+ publicConfigUrl
2488
2549
  }) {
2489
2550
  const narrow = useNarrow();
2490
2551
  const [drawer, setDrawer] = (0, import_react9.useState)(false);
@@ -2566,7 +2627,7 @@ function AdminShell({
2566
2627
  ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { style: { ...styles.status, padding: "32px 40px" }, children: "Pass an AuthAdminClient to look up users here." });
2567
2628
  break;
2568
2629
  case "settings":
2569
- body = !configClient ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { style: { ...styles.status, padding: "32px 40px" }, children: "Pass a ConfigAdminClient to manage config and secrets here." }) : editing && editing.kind !== "template" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2630
+ body = !configClient ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { style: { ...styles.status, padding: "32px 40px" }, children: "Pass a ConfigAdminClient to manage config and secrets here." }) : editing && (editing.kind === "config" || editing.kind === "secret") ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2570
2631
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: { padding: "24px 40px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("button", { type: "button", style: styles.buttonGhost, onClick: () => setEditing(null), children: [
2571
2632
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "back", size: 14 }),
2572
2633
  "Config & secrets"
@@ -2577,24 +2638,52 @@ function AdminShell({
2577
2638
  client: configClient,
2578
2639
  kind: editing.kind,
2579
2640
  configKey: editing.key,
2580
- ...environment !== void 0 ? { environment } : {},
2581
- onSaved: () => setEditing(null)
2582
- }
2641
+ ...editing.environment !== void 0 ? { environment: editing.environment } : environment !== void 0 ? { environment } : {},
2642
+ ...editing.environments ? { environments: editing.environments } : {},
2643
+ onSaved: () => setEditing(null),
2644
+ onDeleted: () => setEditing(null)
2645
+ },
2646
+ `${editing.kind}:${editing.key}:${editing.environment ?? ""}`
2583
2647
  )
2584
2648
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2585
2649
  import_react_config_admin_screens.ConfigListScreen,
2586
2650
  {
2587
2651
  client: configClient,
2588
2652
  ...environment !== void 0 ? { environment } : {},
2589
- onSelectConfig: (key) => setEditing({ kind: "config", key }),
2590
- onSelectSecret: (key) => setEditing({ kind: "secret", key }),
2591
- onCreateConfig: () => setEditing({ kind: "config", key: "" }),
2592
- onCreateSecret: () => setEditing({ kind: "secret", key: "" })
2653
+ ...publicConfigUrl ? { publicConfigUrl } : {},
2654
+ onSelectConfig: (key, env) => setEditing({ kind: "config", key, environment: env }),
2655
+ onSelectSecret: (key, env) => setEditing({ kind: "secret", key, environment: env }),
2656
+ onCreateConfig: (c) => setEditing({
2657
+ kind: "config",
2658
+ key: "",
2659
+ environments: c.environments,
2660
+ ...c.environment ? { environment: c.environment } : {}
2661
+ }),
2662
+ onCreateSecret: (c) => setEditing({
2663
+ kind: "secret",
2664
+ key: "",
2665
+ environments: c.environments,
2666
+ ...c.environment ? { environment: c.environment } : {}
2667
+ })
2593
2668
  }
2594
2669
  );
2595
2670
  break;
2596
2671
  case "templates":
2597
- body = !courierClient ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { style: { ...styles.status, padding: "32px 40px" }, children: "Pass a CourierAdminClient to manage templates here." }) : editing?.kind === "template" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2672
+ body = !courierClient ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { style: { ...styles.status, padding: "32px 40px" }, children: "Pass a CourierAdminClient to manage templates here." }) : editing?.kind === "template-new" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2673
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: { padding: "24px 40px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("button", { type: "button", style: styles.buttonGhost, onClick: () => setEditing(null), children: [
2674
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "back", size: 14 }),
2675
+ "Templates"
2676
+ ] }) }),
2677
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2678
+ import_react_courier_admin_screens.TemplateCreateScreen,
2679
+ {
2680
+ client: courierClient,
2681
+ ...editing.type ? { type: editing.type } : {},
2682
+ ...editing.locales ? { locales: editing.locales } : {},
2683
+ onCreated: (c) => setEditing({ kind: "template", type: c.type, locale: c.locale, system: false })
2684
+ }
2685
+ )
2686
+ ] }) : editing?.kind === "template" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2598
2687
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: { padding: "24px 40px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("button", { type: "button", style: styles.buttonGhost, onClick: () => setEditing(null), children: [
2599
2688
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "back", size: 14 }),
2600
2689
  "Templates"
@@ -2604,14 +2693,25 @@ function AdminShell({
2604
2693
  {
2605
2694
  client: courierClient,
2606
2695
  type: editing.type,
2607
- onSaved: () => setEditing(null)
2608
- }
2696
+ locale: editing.locale,
2697
+ system: editing.system,
2698
+ onSaved: () => setEditing(null),
2699
+ onDeleted: () => setEditing(null),
2700
+ onAddLocale: (type) => setEditing({ kind: "template-new", type })
2701
+ },
2702
+ `${editing.type}:${editing.locale ?? ""}`
2609
2703
  )
2610
2704
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2611
2705
  import_react_courier_admin_screens.TemplateListScreen,
2612
2706
  {
2613
2707
  client: courierClient,
2614
- onSelectTemplate: (t2) => setEditing({ kind: "template", type: t2.type })
2708
+ onSelectTemplate: (t2) => setEditing({
2709
+ kind: "template",
2710
+ type: t2.type,
2711
+ locale: t2.locale ?? null,
2712
+ system: t2.system === true
2713
+ }),
2714
+ onCreateTemplate: (c) => setEditing({ kind: "template-new", locales: c.locales })
2615
2715
  }
2616
2716
  );
2617
2717
  break;