@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.js CHANGED
@@ -1885,7 +1885,9 @@ var UsersScreen = defineComponent11({
1885
1885
  const email = ref6("");
1886
1886
  const selectedId = ref6(props.openUserId ?? "");
1887
1887
  const plans = useSubscriptionIndex(props.billingClient);
1888
- const list = useAdminUsers(props.client, { limit: props.pageSize });
1888
+ const showDeleted = ref6(false);
1889
+ const activeList = useAdminUsers(props.client, { limit: props.pageSize });
1890
+ const deletedList = useAdminUsers(props.client, { limit: props.pageSize, deleted: true });
1889
1891
  const { user, isLoading, error, suspend, unsuspend, revokeSessions } = useAdminUser(
1890
1892
  props.client,
1891
1893
  { email, id: selectedId }
@@ -1913,6 +1915,7 @@ var UsersScreen = defineComponent11({
1913
1915
  };
1914
1916
  return () => {
1915
1917
  const u = user.value;
1918
+ const list = showDeleted.value ? deletedList : activeList;
1916
1919
  return h13("div", { style: styles.container }, [
1917
1920
  pageHeader(
1918
1921
  "Users",
@@ -1942,7 +1945,37 @@ var UsersScreen = defineComponent11({
1942
1945
  { type: "submit", style: styles.buttonPrimary, disabled: isLoading.value },
1943
1946
  [icon("search", 14), "Look up"]
1944
1947
  ),
1945
- showList.value ? refreshButton2("Refresh", list.isLoading.value, () => void list.refresh()) : actionButton([icon("back", 14), "All users"], false, clear, styles.buttonGhost)
1948
+ showList.value ? refreshButton2("Refresh", list.isLoading.value, () => void list.refresh()) : actionButton([icon("back", 14), "All users"], false, clear, styles.buttonGhost),
1949
+ showList.value ? h13(
1950
+ "fieldset",
1951
+ {
1952
+ style: {
1953
+ display: "flex",
1954
+ gap: "6px",
1955
+ border: "none",
1956
+ margin: "0 0 0 auto",
1957
+ padding: "0",
1958
+ minWidth: "0"
1959
+ },
1960
+ "aria-label": "Which accounts"
1961
+ },
1962
+ [false, true].map(
1963
+ (d) => h13(
1964
+ "button",
1965
+ {
1966
+ key: String(d),
1967
+ type: "button",
1968
+ "aria-pressed": showDeleted.value === d,
1969
+ onClick: () => showDeleted.value = d,
1970
+ style: {
1971
+ ...showDeleted.value === d ? styles.buttonPrimary : styles.button,
1972
+ height: "28px"
1973
+ }
1974
+ },
1975
+ d ? "Deleted" : "Active"
1976
+ )
1977
+ )
1978
+ ) : null
1946
1979
  ]
1947
1980
  ),
1948
1981
  showList.value ? h13("div", [
@@ -1976,11 +2009,29 @@ var UsersScreen = defineComponent11({
1976
2009
  list.isLoading.value ? h13("p", { style: styles.status }, "Loading\u2026") : null,
1977
2010
  list.hasMore.value && !list.isLoading.value ? loadMoreButton(() => void list.loadMore()) : null
1978
2011
  ]) : null,
1979
- error.value ? h13(
2012
+ error.value && !(error.value.status === 404 && selectedId.value) ? h13(
1980
2013
  "p",
1981
2014
  { style: styles.error, role: "alert" },
1982
2015
  error.value.status === 404 ? "No user with that email." : error.value.explanation
1983
2016
  ) : null,
2017
+ // Opened by id (e.g. from Subscriptions) and the account is gone —
2018
+ // deleted or purged — while its billing rows remain. Say so, and
2019
+ // still show the money.
2020
+ error.value?.status === 404 && selectedId.value ? [
2021
+ h13("div", { style: styles.notice, role: "status" }, [
2022
+ h13("strong", "No account with id "),
2023
+ h13("code", { style: styles.code }, selectedId.value),
2024
+ h13("strong", "."),
2025
+ " It was deleted, or never existed here. Its billing records remain."
2026
+ ]),
2027
+ props.billingClient ? h13("h2", { style: styles.subtitle }, "Plan & credits") : null,
2028
+ props.billingClient ? h13(SubscriberBilling, {
2029
+ key: `missing-${selectedId.value}`,
2030
+ client: props.billingClient,
2031
+ subscriberType: "user",
2032
+ subscriberId: selectedId.value
2033
+ }) : null
2034
+ ] : null,
1984
2035
  u ? [
1985
2036
  h13("h2", { style: styles.subtitle }, [
1986
2037
  u.firstName || u.lastName ? `${u.firstName} ${u.lastName}`.trim() : u.email,
@@ -2004,7 +2055,10 @@ var UsersScreen = defineComponent11({
2004
2055
  row("created", new Date(u.createdAt).toLocaleString())
2005
2056
  ])
2006
2057
  ]),
2007
- h13("div", { style: { ...styles.toolbar, marginTop: "12px" } }, [
2058
+ u.deletedAt ? h13("div", { style: { ...styles.notice, marginTop: "12px" }, role: "status" }, [
2059
+ h13("strong", `Deleted on ${new Date(u.deletedAt).toLocaleString()}.`),
2060
+ " The account cannot sign in, and it is erased when the retention purge runs. Its billing records stay."
2061
+ ]) : h13("div", { style: { ...styles.toolbar, marginTop: "12px" } }, [
2008
2062
  u.suspended ? actionButton("Unsuspend", isLoading.value, () => void unsuspend()) : actionButton(
2009
2063
  "Suspend",
2010
2064
  isLoading.value,
@@ -2024,46 +2078,60 @@ var UsersScreen = defineComponent11({
2024
2078
  subscriberType: "user",
2025
2079
  subscriberId: u.id
2026
2080
  }) : null,
2027
- h13("h2", { style: styles.subtitle }, "Live sessions"),
2028
- sessions.sessions.value.length === 0 ? h13("p", { style: styles.muted }, "None.") : h13(
2029
- "ul",
2030
- { style: styles.list },
2031
- sessions.sessions.value.map(
2032
- (s) => h13("li", { key: s.id, style: styles.row }, [
2033
- h13("span", { style: styles.mono }, s.ipAddress ?? "\u2014"),
2034
- " ",
2035
- h13("span", { style: styles.muted }, describeLocation(s.location) ?? ""),
2036
- " ",
2037
- h13("span", { style: styles.muted }, s.userAgent ?? ""),
2038
- " ",
2039
- h13(
2040
- "span",
2041
- { style: styles.muted },
2042
- `since ${new Date(s.createdAt).toLocaleString()}`
2043
- )
2044
- ])
2045
- )
2046
- ),
2047
- h13("h2", { style: styles.subtitle }, "Recent sign-ins"),
2048
- history.events.value.length === 0 && !history.isLoading.value ? h13("p", { style: styles.muted }, "None recorded.") : h13(
2049
- "ul",
2050
- { style: styles.list },
2051
- history.events.value.map(
2052
- (e) => h13("li", { key: e.id, style: styles.row }, [
2053
- pill(e.outcome === "success" ? "ok" : "bad", e.outcome),
2054
- " ",
2055
- h13("span", { style: styles.muted }, e.method),
2056
- " ",
2057
- h13("span", { style: styles.mono }, e.ipAddress ?? "\u2014"),
2058
- " ",
2059
- h13("span", { style: styles.muted }, describeLocation(e.location) ?? ""),
2060
- e.location?.proxy || e.location?.hosting ? [" ", pill("warn", e.location.proxy ? "proxy/VPN" : "hosting")] : "",
2061
- " ",
2062
- h13("span", { style: styles.muted }, new Date(e.createdAt).toLocaleString())
2063
- ])
2064
- )
2065
- ),
2066
- history.hasMore.value && !history.isLoading.value ? loadMoreButton(() => void history.loadMore()) : null
2081
+ u.deletedAt ? null : [
2082
+ h13("h2", { style: styles.subtitle }, "Live sessions"),
2083
+ sessions.sessions.value.length === 0 ? h13("p", { style: styles.muted }, "None.") : h13(
2084
+ "ul",
2085
+ { style: styles.list },
2086
+ sessions.sessions.value.map(
2087
+ (s) => h13("li", { key: s.id, style: styles.row }, [
2088
+ h13("span", { style: styles.mono }, s.ipAddress ?? "\u2014"),
2089
+ " ",
2090
+ h13(
2091
+ "span",
2092
+ { style: styles.muted },
2093
+ describeLocation(s.location) ?? ""
2094
+ ),
2095
+ " ",
2096
+ h13("span", { style: styles.muted }, s.userAgent ?? ""),
2097
+ " ",
2098
+ h13(
2099
+ "span",
2100
+ { style: styles.muted },
2101
+ `since ${new Date(s.createdAt).toLocaleString()}`
2102
+ )
2103
+ ])
2104
+ )
2105
+ ),
2106
+ h13("h2", { style: styles.subtitle }, "Recent sign-ins"),
2107
+ history.events.value.length === 0 && !history.isLoading.value ? h13("p", { style: styles.muted }, "None recorded.") : h13(
2108
+ "ul",
2109
+ { style: styles.list },
2110
+ history.events.value.map(
2111
+ (e) => h13("li", { key: e.id, style: styles.row }, [
2112
+ pill(e.outcome === "success" ? "ok" : "bad", e.outcome),
2113
+ " ",
2114
+ h13("span", { style: styles.muted }, e.method),
2115
+ " ",
2116
+ h13("span", { style: styles.mono }, e.ipAddress ?? "\u2014"),
2117
+ " ",
2118
+ h13(
2119
+ "span",
2120
+ { style: styles.muted },
2121
+ describeLocation(e.location) ?? ""
2122
+ ),
2123
+ e.location?.proxy || e.location?.hosting ? [" ", pill("warn", e.location.proxy ? "proxy/VPN" : "hosting")] : "",
2124
+ " ",
2125
+ h13(
2126
+ "span",
2127
+ { style: styles.muted },
2128
+ new Date(e.createdAt).toLocaleString()
2129
+ )
2130
+ ])
2131
+ )
2132
+ ),
2133
+ history.hasMore.value && !history.isLoading.value ? loadMoreButton(() => void history.loadMore()) : null
2134
+ ]
2067
2135
  ] : null
2068
2136
  ]);
2069
2137
  };