@fonderie/react-admin-screens 0.5.0 → 0.6.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 +137 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +144 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -483,17 +483,22 @@ function TokensScreen({ client }) {
|
|
|
483
483
|
var import_react_admin8 = require("@fonderie/react-admin");
|
|
484
484
|
var import_react2 = require("react");
|
|
485
485
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
486
|
-
function UsersScreen({ client }) {
|
|
486
|
+
function UsersScreen({ client, pageSize = 50 }) {
|
|
487
487
|
const [input, setInput] = (0, import_react2.useState)("");
|
|
488
|
-
const [
|
|
488
|
+
const [selected, setSelected] = (0, import_react2.useState)(null);
|
|
489
|
+
const list = (0, import_react_admin8.useAdminUsers)(client, { limit: pageSize });
|
|
489
490
|
const { user, isLoading, error, suspend, unsuspend, revokeSessions } = (0, import_react_admin8.useAdminUser)(
|
|
490
491
|
client,
|
|
491
|
-
|
|
492
|
+
selected ?? {}
|
|
492
493
|
);
|
|
493
494
|
const userId = user?.id ?? null;
|
|
494
495
|
const sessions = (0, import_react_admin8.useAdminUserSessions)(client, userId);
|
|
495
496
|
const history = (0, import_react_admin8.useAdminLoginHistory)(client, userId, { limit: 20 });
|
|
496
497
|
const yesNo = (v) => v ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: styles.ok, children: "yes" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: styles.muted, children: "no" });
|
|
498
|
+
const clear = () => {
|
|
499
|
+
setSelected(null);
|
|
500
|
+
setInput("");
|
|
501
|
+
};
|
|
497
502
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: styles.container, children: [
|
|
498
503
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { style: styles.title, children: "Users" }),
|
|
499
504
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
@@ -502,7 +507,8 @@ function UsersScreen({ client }) {
|
|
|
502
507
|
style: styles.toolbar,
|
|
503
508
|
onSubmit: (e) => {
|
|
504
509
|
e.preventDefault();
|
|
505
|
-
|
|
510
|
+
const email = input.trim();
|
|
511
|
+
setSelected(email ? { email } : null);
|
|
506
512
|
},
|
|
507
513
|
children: [
|
|
508
514
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -516,11 +522,60 @@ function UsersScreen({ client }) {
|
|
|
516
522
|
"aria-label": "Email"
|
|
517
523
|
}
|
|
518
524
|
),
|
|
519
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "submit", style: styles.button, disabled: isLoading, children: "Look up" })
|
|
525
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "submit", style: styles.button, disabled: isLoading, children: "Look up" }),
|
|
526
|
+
selected ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", style: styles.button, onClick: clear, children: "\u2190 All users" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
527
|
+
"button",
|
|
528
|
+
{
|
|
529
|
+
type: "button",
|
|
530
|
+
style: styles.button,
|
|
531
|
+
onClick: () => void list.refresh(),
|
|
532
|
+
disabled: list.isLoading,
|
|
533
|
+
children: "Refresh"
|
|
534
|
+
}
|
|
535
|
+
)
|
|
520
536
|
]
|
|
521
537
|
}
|
|
522
538
|
),
|
|
523
539
|
error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: styles.error, role: "alert", children: error.status === 404 ? "No user with that email." : error.explanation }) : null,
|
|
540
|
+
!selected ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
541
|
+
list.error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: styles.error, role: "alert", children: list.error.explanation }) : null,
|
|
542
|
+
list.users.length === 0 && !list.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: styles.muted, children: "No users yet." }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("table", { style: styles.table, children: [
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tr", { children: [
|
|
544
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { style: styles.th, children: "Email" }),
|
|
545
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { style: styles.th, children: "Name" }),
|
|
546
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { style: styles.th, children: "Created" }),
|
|
547
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { style: styles.th, children: "Status" })
|
|
548
|
+
] }) }),
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tbody", { children: list.users.map((u) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tr", { children: [
|
|
550
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { style: styles.td, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
551
|
+
"button",
|
|
552
|
+
{
|
|
553
|
+
type: "button",
|
|
554
|
+
style: { ...styles.navItem, padding: 0 },
|
|
555
|
+
onClick: () => setSelected({ id: u.id }),
|
|
556
|
+
children: u.email
|
|
557
|
+
}
|
|
558
|
+
) }),
|
|
559
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { style: styles.td, children: `${u.firstName ?? ""} ${u.lastName ?? ""}`.trim() || /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: styles.muted, children: "\u2014" }) }),
|
|
560
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { style: styles.td, children: new Date(u.createdAt).toLocaleDateString() }),
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("td", { style: styles.td, children: [
|
|
562
|
+
u.suspended ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: styles.badge, children: "suspended" }) : null,
|
|
563
|
+
u.deletedAt ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: styles.badge, children: "deleted" }) : null,
|
|
564
|
+
!u.suspended && !u.deletedAt ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: styles.muted, children: "active" }) : null
|
|
565
|
+
] })
|
|
566
|
+
] }, u.id)) })
|
|
567
|
+
] }),
|
|
568
|
+
list.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: styles.status, children: "Loading\u2026" }) : null,
|
|
569
|
+
list.hasMore && !list.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
570
|
+
"button",
|
|
571
|
+
{
|
|
572
|
+
type: "button",
|
|
573
|
+
style: { ...styles.button, marginTop: 8 },
|
|
574
|
+
onClick: () => void list.loadMore(),
|
|
575
|
+
children: "Load more"
|
|
576
|
+
}
|
|
577
|
+
) : null
|
|
578
|
+
] }) : null,
|
|
524
579
|
user ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
525
580
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("h2", { style: styles.subtitle, children: [
|
|
526
581
|
user.firstName || user.lastName ? `${user.firstName} ${user.lastName}`.trim() : user.email,
|
|
@@ -697,14 +752,21 @@ function CatalogScreen({ client }) {
|
|
|
697
752
|
var import_react_admin10 = require("@fonderie/react-admin");
|
|
698
753
|
var import_react3 = require("react");
|
|
699
754
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
700
|
-
function SubscriberScreen({ client }) {
|
|
755
|
+
function SubscriberScreen({ client, pageSize = 50 }) {
|
|
701
756
|
const [type, setType] = (0, import_react3.useState)("user");
|
|
702
757
|
const [idInput, setIdInput] = (0, import_react3.useState)("");
|
|
703
758
|
const [subscriber, setSubscriber] = (0, import_react3.useState)(null);
|
|
759
|
+
const list = (0, import_react_admin10.useAdminSubscribers)(client, { limit: pageSize });
|
|
704
760
|
const { subscription, wallet, ledger, hasMoreLedger, isLoading, error, loadMoreLedger, grant } = (0, import_react_admin10.useAdminSubscriber)(client, subscriber, { limit: 20 });
|
|
705
761
|
const [amount, setAmount] = (0, import_react3.useState)("");
|
|
706
762
|
const [note, setNote] = (0, import_react3.useState)("");
|
|
707
763
|
const [granted, setGranted] = (0, import_react3.useState)(null);
|
|
764
|
+
const open = (t, id) => {
|
|
765
|
+
setGranted(null);
|
|
766
|
+
setType(t);
|
|
767
|
+
setIdInput(id);
|
|
768
|
+
setSubscriber({ type: t, id });
|
|
769
|
+
};
|
|
708
770
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: styles.container, children: [
|
|
709
771
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { style: styles.title, children: "Subscriber" }),
|
|
710
772
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
@@ -740,11 +802,79 @@ function SubscriberScreen({ client }) {
|
|
|
740
802
|
"aria-label": "Subscriber id"
|
|
741
803
|
}
|
|
742
804
|
),
|
|
743
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "submit", style: styles.button, disabled: isLoading, children: "Look up" })
|
|
805
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "submit", style: styles.button, disabled: isLoading, children: "Look up" }),
|
|
806
|
+
subscriber ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
807
|
+
"button",
|
|
808
|
+
{
|
|
809
|
+
type: "button",
|
|
810
|
+
style: styles.button,
|
|
811
|
+
onClick: () => {
|
|
812
|
+
setSubscriber(null);
|
|
813
|
+
setIdInput("");
|
|
814
|
+
setGranted(null);
|
|
815
|
+
},
|
|
816
|
+
children: "\u2190 All subscribers"
|
|
817
|
+
}
|
|
818
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
819
|
+
"button",
|
|
820
|
+
{
|
|
821
|
+
type: "button",
|
|
822
|
+
style: styles.button,
|
|
823
|
+
onClick: () => void list.refresh(),
|
|
824
|
+
disabled: list.isLoading,
|
|
825
|
+
children: "Refresh"
|
|
826
|
+
}
|
|
827
|
+
)
|
|
744
828
|
]
|
|
745
829
|
}
|
|
746
830
|
),
|
|
747
831
|
error ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { style: styles.error, role: "alert", children: error.explanation }) : null,
|
|
832
|
+
!subscriber ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
833
|
+
list.error ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { style: styles.error, role: "alert", children: list.error.explanation }) : null,
|
|
834
|
+
list.subscriptions.length === 0 && !list.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { style: styles.muted, children: "No subscribers yet." }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("table", { style: styles.table, children: [
|
|
835
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("tr", { children: [
|
|
836
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { style: styles.th, children: "Subscriber" }),
|
|
837
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { style: styles.th, children: "Plan" }),
|
|
838
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { style: styles.th, children: "Status" }),
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { style: styles.th, children: "Renews" })
|
|
840
|
+
] }) }),
|
|
841
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tbody", { children: list.subscriptions.map((s) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("tr", { children: [
|
|
842
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { style: styles.td, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
843
|
+
"button",
|
|
844
|
+
{
|
|
845
|
+
type: "button",
|
|
846
|
+
style: { ...styles.navItem, padding: 0, ...styles.mono },
|
|
847
|
+
onClick: () => open(s.subscriberType, s.subscriberId),
|
|
848
|
+
children: [
|
|
849
|
+
s.subscriberType,
|
|
850
|
+
"/",
|
|
851
|
+
s.subscriberId
|
|
852
|
+
]
|
|
853
|
+
}
|
|
854
|
+
) }),
|
|
855
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("td", { style: styles.td, children: [
|
|
856
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("strong", { children: s.plan }),
|
|
857
|
+
" \xB7 ",
|
|
858
|
+
s.interval
|
|
859
|
+
] }),
|
|
860
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("td", { style: styles.td, children: [
|
|
861
|
+
s.status,
|
|
862
|
+
s.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: styles.badge, children: "cancels" }) : null
|
|
863
|
+
] }),
|
|
864
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { style: styles.td, children: s.currentPeriodEnd ? new Date(s.currentPeriodEnd).toLocaleDateString() : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: styles.muted, children: "\u2014" }) })
|
|
865
|
+
] }, s.id)) })
|
|
866
|
+
] }),
|
|
867
|
+
list.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { style: styles.status, children: "Loading\u2026" }) : null,
|
|
868
|
+
list.hasMore && !list.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
869
|
+
"button",
|
|
870
|
+
{
|
|
871
|
+
type: "button",
|
|
872
|
+
style: { ...styles.button, marginTop: 8 },
|
|
873
|
+
onClick: () => void list.loadMore(),
|
|
874
|
+
children: "Load more"
|
|
875
|
+
}
|
|
876
|
+
) : null
|
|
877
|
+
] }) : null,
|
|
748
878
|
subscriber && !isLoading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
749
879
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { style: styles.subtitle, children: "Subscription" }),
|
|
750
880
|
subscription ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("table", { style: styles.table, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("tbody", { children: [
|