@fonderie/react-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
@@ -1717,7 +1717,11 @@ function UsersScreen({
1717
1717
  openUserId ? { id: openUserId } : null
1718
1718
  );
1719
1719
  const plans = useSubscriptionIndex(billingClient);
1720
- const list = useAdminUsers(client, { limit: pageSize });
1720
+ const [showDeleted, setShowDeleted] = useState6(false);
1721
+ const list = useAdminUsers(client, {
1722
+ limit: pageSize,
1723
+ ...showDeleted ? { deleted: true } : {}
1724
+ });
1721
1725
  const { user, isLoading, error, suspend, unsuspend, revokeSessions } = useAdminUser(
1722
1726
  client,
1723
1727
  selected ?? {}
@@ -1775,11 +1779,57 @@ function UsersScreen({
1775
1779
  disabled: list.isLoading,
1776
1780
  children: "Refresh"
1777
1781
  }
1778
- )
1782
+ ),
1783
+ !selected ? /* @__PURE__ */ jsx12(
1784
+ "fieldset",
1785
+ {
1786
+ style: {
1787
+ display: "flex",
1788
+ gap: 6,
1789
+ border: "none",
1790
+ margin: "0 0 0 auto",
1791
+ padding: 0,
1792
+ minWidth: 0
1793
+ },
1794
+ "aria-label": "Which accounts",
1795
+ children: [false, true].map((d) => /* @__PURE__ */ jsx12(
1796
+ "button",
1797
+ {
1798
+ type: "button",
1799
+ "aria-pressed": showDeleted === d,
1800
+ onClick: () => setShowDeleted(d),
1801
+ style: {
1802
+ ...showDeleted === d ? styles.buttonPrimary : styles.button,
1803
+ height: 28
1804
+ },
1805
+ children: d ? "Deleted" : "Active"
1806
+ },
1807
+ String(d)
1808
+ ))
1809
+ }
1810
+ ) : null
1779
1811
  ]
1780
1812
  }
1781
1813
  ),
1782
- error ? /* @__PURE__ */ jsx12("p", { style: styles.error, role: "alert", children: error.status === 404 ? "No user with that email." : error.explanation }) : null,
1814
+ error && !(error.status === 404 && selected?.id) ? /* @__PURE__ */ jsx12("p", { style: styles.error, role: "alert", children: error.status === 404 ? "No user with that email." : error.explanation }) : null,
1815
+ error?.status === 404 && selected?.id ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
1816
+ /* @__PURE__ */ jsxs12("div", { style: styles.notice, role: "status", children: [
1817
+ /* @__PURE__ */ jsx12("strong", { children: "No account with id " }),
1818
+ /* @__PURE__ */ jsx12("code", { style: styles.code, children: selected.id }),
1819
+ /* @__PURE__ */ jsx12("strong", { children: "." }),
1820
+ " It was deleted, or never existed here. Its billing records remain."
1821
+ ] }),
1822
+ billingClient ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
1823
+ /* @__PURE__ */ jsx12("h2", { style: styles.subtitle, children: "Plan & credits" }),
1824
+ /* @__PURE__ */ jsx12(
1825
+ SubscriberBilling,
1826
+ {
1827
+ client: billingClient,
1828
+ subscriber: { type: "user", id: selected.id }
1829
+ }
1830
+ )
1831
+ ] }) : null
1832
+ ] }) : null,
1783
1833
  !selected ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
1784
1834
  list.error ? /* @__PURE__ */ jsx12("p", { style: styles.error, role: "alert", children: list.error.explanation }) : null,
1785
1835
  list.users.length === 0 && !list.isLoading ? /* @__PURE__ */ jsx12(Empty, { icon: "users", title: "No users yet", children: "Sign-ups appear here as they happen." }) : /* @__PURE__ */ jsxs12("table", { style: styles.table, children: [
@@ -1871,7 +1921,14 @@ function UsersScreen({
1871
1921
  /* @__PURE__ */ jsx12("td", { style: styles.td, children: new Date(user.createdAt).toLocaleString() })
1872
1922
  ] })
1873
1923
  ] }) }),
1874
- /* @__PURE__ */ jsxs12("div", { style: { ...styles.toolbar, marginTop: 12 }, children: [
1924
+ user.deletedAt ? /* @__PURE__ */ jsxs12("div", { style: { ...styles.notice, marginTop: 12 }, role: "status", children: [
1925
+ /* @__PURE__ */ jsxs12("strong", { children: [
1926
+ "Deleted on ",
1927
+ new Date(user.deletedAt).toLocaleString(),
1928
+ "."
1929
+ ] }),
1930
+ " The account cannot sign in, and it is erased when the retention purge runs. Its billing records stay."
1931
+ ] }) : /* @__PURE__ */ jsxs12("div", { style: { ...styles.toolbar, marginTop: 12 }, children: [
1875
1932
  user.suspended ? /* @__PURE__ */ jsx12(
1876
1933
  "button",
1877
1934
  {
@@ -1912,46 +1969,48 @@ function UsersScreen({
1912
1969
  }
1913
1970
  )
1914
1971
  ] }) : null,
1915
- /* @__PURE__ */ jsx12("h2", { style: styles.subtitle, children: "Live sessions" }),
1916
- sessions.sessions.length === 0 ? /* @__PURE__ */ jsx12("p", { style: styles.muted, children: "None." }) : /* @__PURE__ */ jsx12("ul", { style: styles.list, children: sessions.sessions.map((s) => /* @__PURE__ */ jsxs12("li", { style: styles.row, children: [
1917
- /* @__PURE__ */ jsx12("span", { style: styles.mono, children: s.ipAddress ?? "\u2014" }),
1918
- " ",
1919
- describeLocation(s.location) ? /* @__PURE__ */ jsxs12("span", { style: styles.muted, children: [
1920
- describeLocation(s.location),
1921
- " "
1922
- ] }) : null,
1923
- /* @__PURE__ */ jsx12("span", { style: styles.muted, children: s.userAgent ?? "" }),
1924
- " ",
1925
- /* @__PURE__ */ jsxs12("span", { style: styles.muted, children: [
1926
- "since ",
1927
- new Date(s.createdAt).toLocaleString()
1928
- ] })
1929
- ] }, s.id)) }),
1930
- /* @__PURE__ */ jsx12("h2", { style: styles.subtitle, children: "Recent sign-ins" }),
1931
- history.events.length === 0 && !history.isLoading ? /* @__PURE__ */ jsx12("p", { style: styles.muted, children: "None recorded." }) : /* @__PURE__ */ jsx12("ul", { style: styles.list, children: history.events.map((e) => /* @__PURE__ */ jsxs12("li", { style: styles.row, children: [
1932
- /* @__PURE__ */ jsx12(Pill, { tone: e.outcome === "success" ? "ok" : "bad", children: e.outcome }),
1933
- " ",
1934
- /* @__PURE__ */ jsx12("span", { style: styles.muted, children: e.method }),
1935
- " ",
1936
- /* @__PURE__ */ jsx12("span", { style: styles.mono, children: e.ipAddress ?? "\u2014" }),
1937
- " ",
1938
- describeLocation(e.location) ? /* @__PURE__ */ jsx12("span", { style: styles.muted, children: describeLocation(e.location) }) : null,
1939
- e.location?.proxy || e.location?.hosting ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
1972
+ !user.deletedAt ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
1973
+ /* @__PURE__ */ jsx12("h2", { style: styles.subtitle, children: "Live sessions" }),
1974
+ sessions.sessions.length === 0 ? /* @__PURE__ */ jsx12("p", { style: styles.muted, children: "None." }) : /* @__PURE__ */ jsx12("ul", { style: styles.list, children: sessions.sessions.map((s) => /* @__PURE__ */ jsxs12("li", { style: styles.row, children: [
1975
+ /* @__PURE__ */ jsx12("span", { style: styles.mono, children: s.ipAddress ?? "\u2014" }),
1940
1976
  " ",
1941
- /* @__PURE__ */ jsx12(Pill, { tone: "warn", children: e.location.proxy ? "proxy/VPN" : "hosting" })
1942
- ] }) : null,
1943
- " ",
1944
- /* @__PURE__ */ jsx12("span", { style: styles.muted, children: new Date(e.createdAt).toLocaleString() })
1945
- ] }, e.id)) }),
1946
- history.hasMore && !history.isLoading ? /* @__PURE__ */ jsx12(
1947
- "button",
1948
- {
1949
- type: "button",
1950
- style: { ...styles.button, marginTop: 8 },
1951
- onClick: () => void history.loadMore(),
1952
- children: "Load more"
1953
- }
1954
- ) : null
1977
+ describeLocation(s.location) ? /* @__PURE__ */ jsxs12("span", { style: styles.muted, children: [
1978
+ describeLocation(s.location),
1979
+ " "
1980
+ ] }) : null,
1981
+ /* @__PURE__ */ jsx12("span", { style: styles.muted, children: s.userAgent ?? "" }),
1982
+ " ",
1983
+ /* @__PURE__ */ jsxs12("span", { style: styles.muted, children: [
1984
+ "since ",
1985
+ new Date(s.createdAt).toLocaleString()
1986
+ ] })
1987
+ ] }, s.id)) }),
1988
+ /* @__PURE__ */ jsx12("h2", { style: styles.subtitle, children: "Recent sign-ins" }),
1989
+ history.events.length === 0 && !history.isLoading ? /* @__PURE__ */ jsx12("p", { style: styles.muted, children: "None recorded." }) : /* @__PURE__ */ jsx12("ul", { style: styles.list, children: history.events.map((e) => /* @__PURE__ */ jsxs12("li", { style: styles.row, children: [
1990
+ /* @__PURE__ */ jsx12(Pill, { tone: e.outcome === "success" ? "ok" : "bad", children: e.outcome }),
1991
+ " ",
1992
+ /* @__PURE__ */ jsx12("span", { style: styles.muted, children: e.method }),
1993
+ " ",
1994
+ /* @__PURE__ */ jsx12("span", { style: styles.mono, children: e.ipAddress ?? "\u2014" }),
1995
+ " ",
1996
+ describeLocation(e.location) ? /* @__PURE__ */ jsx12("span", { style: styles.muted, children: describeLocation(e.location) }) : null,
1997
+ e.location?.proxy || e.location?.hosting ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
1998
+ " ",
1999
+ /* @__PURE__ */ jsx12(Pill, { tone: "warn", children: e.location.proxy ? "proxy/VPN" : "hosting" })
2000
+ ] }) : null,
2001
+ " ",
2002
+ /* @__PURE__ */ jsx12("span", { style: styles.muted, children: new Date(e.createdAt).toLocaleString() })
2003
+ ] }, e.id)) }),
2004
+ history.hasMore && !history.isLoading ? /* @__PURE__ */ jsx12(
2005
+ "button",
2006
+ {
2007
+ type: "button",
2008
+ style: { ...styles.button, marginTop: 8 },
2009
+ onClick: () => void history.loadMore(),
2010
+ children: "Load more"
2011
+ }
2012
+ ) : null
2013
+ ] }) : null
1955
2014
  ] }) : null
1956
2015
  ] });
1957
2016
  }