@fonderie/vue-admin-screens 1.3.0 → 1.4.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
@@ -1920,7 +1920,9 @@ var UsersScreen = (0, import_vue14.defineComponent)({
1920
1920
  const email = (0, import_vue14.ref)("");
1921
1921
  const selectedId = (0, import_vue14.ref)(props.openUserId ?? "");
1922
1922
  const plans = useSubscriptionIndex(props.billingClient);
1923
- const list = (0, import_vue_admin11.useAdminUsers)(props.client, { limit: props.pageSize });
1923
+ const showDeleted = (0, import_vue14.ref)(false);
1924
+ const activeList = (0, import_vue_admin11.useAdminUsers)(props.client, { limit: props.pageSize });
1925
+ const deletedList = (0, import_vue_admin11.useAdminUsers)(props.client, { limit: props.pageSize, deleted: true });
1924
1926
  const { user, isLoading, error, suspend, unsuspend, revokeSessions } = (0, import_vue_admin11.useAdminUser)(
1925
1927
  props.client,
1926
1928
  { email, id: selectedId }
@@ -1948,6 +1950,7 @@ var UsersScreen = (0, import_vue14.defineComponent)({
1948
1950
  };
1949
1951
  return () => {
1950
1952
  const u = user.value;
1953
+ const list = showDeleted.value ? deletedList : activeList;
1951
1954
  return (0, import_vue14.h)("div", { style: styles.container }, [
1952
1955
  pageHeader(
1953
1956
  "Users",
@@ -1977,7 +1980,37 @@ var UsersScreen = (0, import_vue14.defineComponent)({
1977
1980
  { type: "submit", style: styles.buttonPrimary, disabled: isLoading.value },
1978
1981
  [icon("search", 14), "Look up"]
1979
1982
  ),
1980
- showList.value ? refreshButton2("Refresh", list.isLoading.value, () => void list.refresh()) : actionButton([icon("back", 14), "All users"], false, clear, styles.buttonGhost)
1983
+ showList.value ? refreshButton2("Refresh", list.isLoading.value, () => void list.refresh()) : actionButton([icon("back", 14), "All users"], false, clear, styles.buttonGhost),
1984
+ showList.value ? (0, import_vue14.h)(
1985
+ "fieldset",
1986
+ {
1987
+ style: {
1988
+ display: "flex",
1989
+ gap: "6px",
1990
+ border: "none",
1991
+ margin: "0 0 0 auto",
1992
+ padding: "0",
1993
+ minWidth: "0"
1994
+ },
1995
+ "aria-label": "Which accounts"
1996
+ },
1997
+ [false, true].map(
1998
+ (d) => (0, import_vue14.h)(
1999
+ "button",
2000
+ {
2001
+ key: String(d),
2002
+ type: "button",
2003
+ "aria-pressed": showDeleted.value === d,
2004
+ onClick: () => showDeleted.value = d,
2005
+ style: {
2006
+ ...showDeleted.value === d ? styles.buttonPrimary : styles.button,
2007
+ height: "28px"
2008
+ }
2009
+ },
2010
+ d ? "Deleted" : "Active"
2011
+ )
2012
+ )
2013
+ ) : null
1981
2014
  ]
1982
2015
  ),
1983
2016
  showList.value ? (0, import_vue14.h)("div", [
@@ -2011,11 +2044,29 @@ var UsersScreen = (0, import_vue14.defineComponent)({
2011
2044
  list.isLoading.value ? (0, import_vue14.h)("p", { style: styles.status }, "Loading\u2026") : null,
2012
2045
  list.hasMore.value && !list.isLoading.value ? loadMoreButton(() => void list.loadMore()) : null
2013
2046
  ]) : null,
2014
- error.value ? (0, import_vue14.h)(
2047
+ error.value && !(error.value.status === 404 && selectedId.value) ? (0, import_vue14.h)(
2015
2048
  "p",
2016
2049
  { style: styles.error, role: "alert" },
2017
2050
  error.value.status === 404 ? "No user with that email." : error.value.explanation
2018
2051
  ) : null,
2052
+ // Opened by id (e.g. from Subscriptions) and the account is gone —
2053
+ // deleted or purged — while its billing rows remain. Say so, and
2054
+ // still show the money.
2055
+ error.value?.status === 404 && selectedId.value ? [
2056
+ (0, import_vue14.h)("div", { style: styles.notice, role: "status" }, [
2057
+ (0, import_vue14.h)("strong", "No account with id "),
2058
+ (0, import_vue14.h)("code", { style: styles.code }, selectedId.value),
2059
+ (0, import_vue14.h)("strong", "."),
2060
+ " It was deleted, or never existed here. Its billing records remain."
2061
+ ]),
2062
+ props.billingClient ? (0, import_vue14.h)("h2", { style: styles.subtitle }, "Plan & credits") : null,
2063
+ props.billingClient ? (0, import_vue14.h)(SubscriberBilling, {
2064
+ key: `missing-${selectedId.value}`,
2065
+ client: props.billingClient,
2066
+ subscriberType: "user",
2067
+ subscriberId: selectedId.value
2068
+ }) : null
2069
+ ] : null,
2019
2070
  u ? [
2020
2071
  (0, import_vue14.h)("h2", { style: styles.subtitle }, [
2021
2072
  u.firstName || u.lastName ? `${u.firstName} ${u.lastName}`.trim() : u.email,
@@ -2039,7 +2090,10 @@ var UsersScreen = (0, import_vue14.defineComponent)({
2039
2090
  row("created", new Date(u.createdAt).toLocaleString())
2040
2091
  ])
2041
2092
  ]),
2042
- (0, import_vue14.h)("div", { style: { ...styles.toolbar, marginTop: "12px" } }, [
2093
+ u.deletedAt ? (0, import_vue14.h)("div", { style: { ...styles.notice, marginTop: "12px" }, role: "status" }, [
2094
+ (0, import_vue14.h)("strong", `Deleted on ${new Date(u.deletedAt).toLocaleString()}.`),
2095
+ " The account cannot sign in, and it is erased when the retention purge runs. Its billing records stay."
2096
+ ]) : (0, import_vue14.h)("div", { style: { ...styles.toolbar, marginTop: "12px" } }, [
2043
2097
  u.suspended ? actionButton("Unsuspend", isLoading.value, () => void unsuspend()) : actionButton(
2044
2098
  "Suspend",
2045
2099
  isLoading.value,
@@ -2059,46 +2113,60 @@ var UsersScreen = (0, import_vue14.defineComponent)({
2059
2113
  subscriberType: "user",
2060
2114
  subscriberId: u.id
2061
2115
  }) : null,
2062
- (0, import_vue14.h)("h2", { style: styles.subtitle }, "Live sessions"),
2063
- sessions.sessions.value.length === 0 ? (0, import_vue14.h)("p", { style: styles.muted }, "None.") : (0, import_vue14.h)(
2064
- "ul",
2065
- { style: styles.list },
2066
- sessions.sessions.value.map(
2067
- (s) => (0, import_vue14.h)("li", { key: s.id, style: styles.row }, [
2068
- (0, import_vue14.h)("span", { style: styles.mono }, s.ipAddress ?? "\u2014"),
2069
- " ",
2070
- (0, import_vue14.h)("span", { style: styles.muted }, (0, import_client.describeLocation)(s.location) ?? ""),
2071
- " ",
2072
- (0, import_vue14.h)("span", { style: styles.muted }, s.userAgent ?? ""),
2073
- " ",
2074
- (0, import_vue14.h)(
2075
- "span",
2076
- { style: styles.muted },
2077
- `since ${new Date(s.createdAt).toLocaleString()}`
2078
- )
2079
- ])
2080
- )
2081
- ),
2082
- (0, import_vue14.h)("h2", { style: styles.subtitle }, "Recent sign-ins"),
2083
- history.events.value.length === 0 && !history.isLoading.value ? (0, import_vue14.h)("p", { style: styles.muted }, "None recorded.") : (0, import_vue14.h)(
2084
- "ul",
2085
- { style: styles.list },
2086
- history.events.value.map(
2087
- (e) => (0, import_vue14.h)("li", { key: e.id, style: styles.row }, [
2088
- pill(e.outcome === "success" ? "ok" : "bad", e.outcome),
2089
- " ",
2090
- (0, import_vue14.h)("span", { style: styles.muted }, e.method),
2091
- " ",
2092
- (0, import_vue14.h)("span", { style: styles.mono }, e.ipAddress ?? "\u2014"),
2093
- " ",
2094
- (0, import_vue14.h)("span", { style: styles.muted }, (0, import_client.describeLocation)(e.location) ?? ""),
2095
- e.location?.proxy || e.location?.hosting ? [" ", pill("warn", e.location.proxy ? "proxy/VPN" : "hosting")] : "",
2096
- " ",
2097
- (0, import_vue14.h)("span", { style: styles.muted }, new Date(e.createdAt).toLocaleString())
2098
- ])
2099
- )
2100
- ),
2101
- history.hasMore.value && !history.isLoading.value ? loadMoreButton(() => void history.loadMore()) : null
2116
+ u.deletedAt ? null : [
2117
+ (0, import_vue14.h)("h2", { style: styles.subtitle }, "Live sessions"),
2118
+ sessions.sessions.value.length === 0 ? (0, import_vue14.h)("p", { style: styles.muted }, "None.") : (0, import_vue14.h)(
2119
+ "ul",
2120
+ { style: styles.list },
2121
+ sessions.sessions.value.map(
2122
+ (s) => (0, import_vue14.h)("li", { key: s.id, style: styles.row }, [
2123
+ (0, import_vue14.h)("span", { style: styles.mono }, s.ipAddress ?? "\u2014"),
2124
+ " ",
2125
+ (0, import_vue14.h)(
2126
+ "span",
2127
+ { style: styles.muted },
2128
+ (0, import_client.describeLocation)(s.location) ?? ""
2129
+ ),
2130
+ " ",
2131
+ (0, import_vue14.h)("span", { style: styles.muted }, s.userAgent ?? ""),
2132
+ " ",
2133
+ (0, import_vue14.h)(
2134
+ "span",
2135
+ { style: styles.muted },
2136
+ `since ${new Date(s.createdAt).toLocaleString()}`
2137
+ )
2138
+ ])
2139
+ )
2140
+ ),
2141
+ (0, import_vue14.h)("h2", { style: styles.subtitle }, "Recent sign-ins"),
2142
+ history.events.value.length === 0 && !history.isLoading.value ? (0, import_vue14.h)("p", { style: styles.muted }, "None recorded.") : (0, import_vue14.h)(
2143
+ "ul",
2144
+ { style: styles.list },
2145
+ history.events.value.map(
2146
+ (e) => (0, import_vue14.h)("li", { key: e.id, style: styles.row }, [
2147
+ pill(e.outcome === "success" ? "ok" : "bad", e.outcome),
2148
+ " ",
2149
+ (0, import_vue14.h)("span", { style: styles.muted }, e.method),
2150
+ " ",
2151
+ (0, import_vue14.h)("span", { style: styles.mono }, e.ipAddress ?? "\u2014"),
2152
+ " ",
2153
+ (0, import_vue14.h)(
2154
+ "span",
2155
+ { style: styles.muted },
2156
+ (0, import_client.describeLocation)(e.location) ?? ""
2157
+ ),
2158
+ e.location?.proxy || e.location?.hosting ? [" ", pill("warn", e.location.proxy ? "proxy/VPN" : "hosting")] : "",
2159
+ " ",
2160
+ (0, import_vue14.h)(
2161
+ "span",
2162
+ { style: styles.muted },
2163
+ new Date(e.createdAt).toLocaleString()
2164
+ )
2165
+ ])
2166
+ )
2167
+ ),
2168
+ history.hasMore.value && !history.isLoading.value ? loadMoreButton(() => void history.loadMore()) : null
2169
+ ]
2102
2170
  ] : null
2103
2171
  ]);
2104
2172
  };