@fonderie/vue-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 +125 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +132 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -547,23 +547,39 @@ var TokensScreen = defineComponent7({
|
|
|
547
547
|
});
|
|
548
548
|
|
|
549
549
|
// src/screens/UsersScreen.ts
|
|
550
|
-
import {
|
|
550
|
+
import {
|
|
551
|
+
useAdminLoginHistory,
|
|
552
|
+
useAdminUser,
|
|
553
|
+
useAdminUserSessions,
|
|
554
|
+
useAdminUsers
|
|
555
|
+
} from "@fonderie/vue-admin";
|
|
551
556
|
import { computed, defineComponent as defineComponent8, h as h9, ref as ref2 } from "vue";
|
|
552
557
|
var UsersScreen = defineComponent8({
|
|
553
558
|
name: "FonderieUsersScreen",
|
|
554
|
-
props: {
|
|
559
|
+
props: {
|
|
560
|
+
client: { type: Object, required: true },
|
|
561
|
+
pageSize: { type: Number, default: 50 }
|
|
562
|
+
},
|
|
555
563
|
setup(props) {
|
|
556
564
|
const input = ref2("");
|
|
557
565
|
const email = ref2("");
|
|
566
|
+
const selectedId = ref2("");
|
|
567
|
+
const list = useAdminUsers(props.client, { limit: props.pageSize });
|
|
558
568
|
const { user, isLoading, error, suspend, unsuspend, revokeSessions } = useAdminUser(
|
|
559
569
|
props.client,
|
|
560
|
-
{ email }
|
|
570
|
+
{ email, id: selectedId }
|
|
561
571
|
);
|
|
562
572
|
const userId = computed(() => user.value?.id ?? null);
|
|
563
573
|
const sessions = useAdminUserSessions(props.client, userId);
|
|
564
574
|
const history = useAdminLoginHistory(props.client, userId, { limit: 20 });
|
|
575
|
+
const showList = computed(() => !email.value && !selectedId.value);
|
|
565
576
|
const yesNo = (v) => h9("span", { style: v ? styles.ok : styles.muted }, v ? "yes" : "no");
|
|
566
577
|
const row = (k, v) => h9("tr", [td(k), td(v)]);
|
|
578
|
+
const clear = () => {
|
|
579
|
+
email.value = "";
|
|
580
|
+
selectedId.value = "";
|
|
581
|
+
input.value = "";
|
|
582
|
+
};
|
|
567
583
|
return () => {
|
|
568
584
|
const u = user.value;
|
|
569
585
|
return h9("div", { style: styles.container }, [
|
|
@@ -574,6 +590,7 @@ var UsersScreen = defineComponent8({
|
|
|
574
590
|
style: styles.toolbar,
|
|
575
591
|
onSubmit: (e) => {
|
|
576
592
|
e.preventDefault();
|
|
593
|
+
selectedId.value = "";
|
|
577
594
|
email.value = input.value.trim();
|
|
578
595
|
}
|
|
579
596
|
},
|
|
@@ -590,9 +607,48 @@ var UsersScreen = defineComponent8({
|
|
|
590
607
|
"button",
|
|
591
608
|
{ type: "submit", style: styles.button, disabled: isLoading.value },
|
|
592
609
|
"Look up"
|
|
593
|
-
)
|
|
610
|
+
),
|
|
611
|
+
showList.value ? refreshButton("Refresh", list.isLoading.value, () => void list.refresh()) : refreshButton("\u2190 All users", false, clear)
|
|
594
612
|
]
|
|
595
613
|
),
|
|
614
|
+
showList.value ? h9("div", [
|
|
615
|
+
list.error.value ? h9("p", { style: styles.error, role: "alert" }, list.error.value.explanation) : null,
|
|
616
|
+
list.users.value.length === 0 && !list.isLoading.value ? h9("p", { style: styles.muted }, "No users yet.") : table(
|
|
617
|
+
["Email", "Name", "Created", "Status"],
|
|
618
|
+
list.users.value.map(
|
|
619
|
+
(u2) => h9("tr", { key: u2.id }, [
|
|
620
|
+
td(
|
|
621
|
+
h9(
|
|
622
|
+
"button",
|
|
623
|
+
{
|
|
624
|
+
type: "button",
|
|
625
|
+
style: { ...styles.navItem, padding: 0 },
|
|
626
|
+
onClick: () => selectedId.value = u2.id
|
|
627
|
+
},
|
|
628
|
+
u2.email
|
|
629
|
+
)
|
|
630
|
+
),
|
|
631
|
+
td(
|
|
632
|
+
`${u2.firstName ?? ""} ${u2.lastName ?? ""}`.trim() || h9("span", { style: styles.muted }, "\u2014")
|
|
633
|
+
),
|
|
634
|
+
td(new Date(u2.createdAt).toLocaleDateString()),
|
|
635
|
+
td(
|
|
636
|
+
u2.suspended ? h9("span", { style: styles.badge }, "suspended") : u2.deletedAt ? h9("span", { style: styles.badge }, "deleted") : h9("span", { style: styles.muted }, "active")
|
|
637
|
+
)
|
|
638
|
+
])
|
|
639
|
+
)
|
|
640
|
+
),
|
|
641
|
+
list.isLoading.value ? h9("p", { style: styles.status }, "Loading\u2026") : null,
|
|
642
|
+
list.hasMore.value && !list.isLoading.value ? h9(
|
|
643
|
+
"button",
|
|
644
|
+
{
|
|
645
|
+
type: "button",
|
|
646
|
+
style: { ...styles.button, marginTop: "8px" },
|
|
647
|
+
onClick: () => void list.loadMore()
|
|
648
|
+
},
|
|
649
|
+
"Load more"
|
|
650
|
+
) : null
|
|
651
|
+
]) : null,
|
|
596
652
|
error.value ? h9(
|
|
597
653
|
"p",
|
|
598
654
|
{ style: styles.error, role: "alert" },
|
|
@@ -751,16 +807,26 @@ var CatalogScreen = defineComponent9({
|
|
|
751
807
|
});
|
|
752
808
|
|
|
753
809
|
// src/screens/SubscriberScreen.ts
|
|
754
|
-
import { useAdminSubscriber } from "@fonderie/vue-admin";
|
|
810
|
+
import { useAdminSubscriber, useAdminSubscribers } from "@fonderie/vue-admin";
|
|
755
811
|
import { defineComponent as defineComponent10, h as h11, ref as ref3 } from "vue";
|
|
756
812
|
var SubscriberScreen = defineComponent10({
|
|
757
813
|
name: "FonderieSubscriberScreen",
|
|
758
|
-
props: {
|
|
814
|
+
props: {
|
|
815
|
+
client: { type: Object, required: true },
|
|
816
|
+
pageSize: { type: Number, default: 50 }
|
|
817
|
+
},
|
|
759
818
|
setup(props) {
|
|
760
819
|
const type = ref3("user");
|
|
761
820
|
const idInput = ref3("");
|
|
762
821
|
const subscriber = ref3(null);
|
|
822
|
+
const list = useAdminSubscribers(props.client, { limit: props.pageSize });
|
|
763
823
|
const { subscription, wallet, ledger, hasMoreLedger, isLoading, error, loadMoreLedger, grant } = useAdminSubscriber(props.client, subscriber, { limit: 20 });
|
|
824
|
+
const open = (t, id) => {
|
|
825
|
+
granted.value = null;
|
|
826
|
+
type.value = t;
|
|
827
|
+
idInput.value = id;
|
|
828
|
+
subscriber.value = { type: t, id };
|
|
829
|
+
};
|
|
764
830
|
const amount = ref3("");
|
|
765
831
|
const note = ref3("");
|
|
766
832
|
const granted = ref3(null);
|
|
@@ -805,9 +871,69 @@ var SubscriberScreen = defineComponent10({
|
|
|
805
871
|
"button",
|
|
806
872
|
{ type: "submit", style: styles.button, disabled: isLoading.value },
|
|
807
873
|
"Look up"
|
|
874
|
+
),
|
|
875
|
+
subscriber.value ? h11(
|
|
876
|
+
"button",
|
|
877
|
+
{
|
|
878
|
+
type: "button",
|
|
879
|
+
style: styles.button,
|
|
880
|
+
onClick: () => {
|
|
881
|
+
subscriber.value = null;
|
|
882
|
+
idInput.value = "";
|
|
883
|
+
granted.value = null;
|
|
884
|
+
}
|
|
885
|
+
},
|
|
886
|
+
"\u2190 All subscribers"
|
|
887
|
+
) : h11(
|
|
888
|
+
"button",
|
|
889
|
+
{
|
|
890
|
+
type: "button",
|
|
891
|
+
style: styles.button,
|
|
892
|
+
disabled: list.isLoading.value,
|
|
893
|
+
onClick: () => void list.refresh()
|
|
894
|
+
},
|
|
895
|
+
"Refresh"
|
|
808
896
|
)
|
|
809
897
|
]
|
|
810
898
|
),
|
|
899
|
+
!subscriber.value ? h11("div", [
|
|
900
|
+
list.error.value ? h11("p", { style: styles.error, role: "alert" }, list.error.value.explanation) : null,
|
|
901
|
+
list.subscriptions.value.length === 0 && !list.isLoading.value ? h11("p", { style: styles.muted }, "No subscribers yet.") : table(
|
|
902
|
+
["Subscriber", "Plan", "Status", "Renews"],
|
|
903
|
+
list.subscriptions.value.map(
|
|
904
|
+
(sub) => h11("tr", { key: sub.id }, [
|
|
905
|
+
td(
|
|
906
|
+
h11(
|
|
907
|
+
"button",
|
|
908
|
+
{
|
|
909
|
+
type: "button",
|
|
910
|
+
style: { ...styles.navItem, padding: 0, ...styles.mono },
|
|
911
|
+
onClick: () => open(sub.subscriberType, sub.subscriberId)
|
|
912
|
+
},
|
|
913
|
+
`${sub.subscriberType}/${sub.subscriberId}`
|
|
914
|
+
)
|
|
915
|
+
),
|
|
916
|
+
td(`${sub.plan} \xB7 ${sub.interval}`),
|
|
917
|
+
td(
|
|
918
|
+
sub.cancelAtPeriodEnd ? [sub.status, " ", h11("span", { style: styles.badge }, "cancels")] : sub.status
|
|
919
|
+
),
|
|
920
|
+
td(
|
|
921
|
+
sub.currentPeriodEnd ? new Date(sub.currentPeriodEnd).toLocaleDateString() : h11("span", { style: styles.muted }, "\u2014")
|
|
922
|
+
)
|
|
923
|
+
])
|
|
924
|
+
)
|
|
925
|
+
),
|
|
926
|
+
list.isLoading.value ? h11("p", { style: styles.status }, "Loading\u2026") : null,
|
|
927
|
+
list.hasMore.value && !list.isLoading.value ? h11(
|
|
928
|
+
"button",
|
|
929
|
+
{
|
|
930
|
+
type: "button",
|
|
931
|
+
style: { ...styles.button, marginTop: "8px" },
|
|
932
|
+
onClick: () => void list.loadMore()
|
|
933
|
+
},
|
|
934
|
+
"Load more"
|
|
935
|
+
) : null
|
|
936
|
+
]) : null,
|
|
811
937
|
error.value ? h11("p", { style: styles.error, role: "alert" }, error.value.explanation) : null,
|
|
812
938
|
subscriber.value && !isLoading.value ? [
|
|
813
939
|
h11("h2", { style: styles.subtitle }, "Subscription"),
|