Make tenant creation implicit
This commit is contained in:
@@ -14,7 +14,7 @@ import AdminTenantDetail from "./pages/admin/AdminTenantDetail"
|
||||
import AdminRelayList from "./pages/admin/AdminRelayList"
|
||||
import AdminRelayDetail from "./pages/admin/AdminRelayDetail"
|
||||
import AdminRelayEdit from "./pages/admin/AdminRelayEdit"
|
||||
import { account, identity } from "./lib/hooks"
|
||||
import { identity } from "./lib/hooks"
|
||||
|
||||
function Layout(props: { children?: any }) {
|
||||
const location = useLocation()
|
||||
@@ -32,7 +32,7 @@ function Layout(props: { children?: any }) {
|
||||
|
||||
return (
|
||||
<div class="min-h-screen bg-gray-50">
|
||||
<Show when={account() && usesAppShell()} fallback={<main>{props.children}</main>}>
|
||||
<Show when={identity() && usesAppShell()} fallback={<main>{props.children}</main>}>
|
||||
<AppShell>{props.children}</AppShell>
|
||||
</Show>
|
||||
</div>
|
||||
@@ -56,8 +56,8 @@ export default function App() {
|
||||
}
|
||||
}
|
||||
|
||||
const requireAdmin = (Page: Component) => requireCondition(Page, () => Boolean(account() && identity()?.is_admin))
|
||||
const requireTenant = (Page: Component) => requireCondition(Page, () => Boolean(account() && identity()?.is_tenant))
|
||||
const requireAdmin = (Page: Component) => requireCondition(Page, () => Boolean(identity()?.is_admin))
|
||||
const requireTenant = (Page: Component) => requireCondition(Page, () => Boolean(identity()))
|
||||
|
||||
return (
|
||||
<Router root={Layout}>
|
||||
|
||||
@@ -76,7 +76,6 @@ export type Invoice = {
|
||||
export type Identity = {
|
||||
pubkey: string
|
||||
is_admin: boolean
|
||||
is_tenant: boolean
|
||||
}
|
||||
|
||||
export type CreateRelayInput = {
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
type CreateRelayInput,
|
||||
type Relay,
|
||||
type Tenant,
|
||||
type Identity,
|
||||
type UpdateRelayInput,
|
||||
} from "./api"
|
||||
|
||||
@@ -141,12 +142,6 @@ export function primeProfiles(pubkeys: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
type Identity = {
|
||||
pubkey: string
|
||||
is_admin: boolean
|
||||
is_tenant: boolean
|
||||
}
|
||||
|
||||
export const useTenant = () => createResource(() => getTenant(account()!.pubkey))
|
||||
|
||||
export const useTenantRelays = () => createResource(() => listTenantRelays(account()!.pubkey))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Show, createSignal, onCleanup } from "solid-js"
|
||||
import { Show, createSignal, createEffect, onCleanup } from "solid-js"
|
||||
import { useNavigate } from "@solidjs/router"
|
||||
import { ExtensionAccount, NostrConnectAccount, PasswordAccount, PrivateKeyAccount } from "applesauce-accounts/accounts"
|
||||
import { PasswordSigner } from "applesauce-signers"
|
||||
@@ -56,16 +56,9 @@ export default function Login() {
|
||||
let scanner: QrScanner | undefined
|
||||
let abortController: AbortController | undefined
|
||||
|
||||
async function completeLogin(account: ExtensionAccount | NostrConnectAccount | PrivateKeyAccount | PasswordAccount) {
|
||||
function completeLogin(account: ExtensionAccount | NostrConnectAccount | PrivateKeyAccount | PasswordAccount) {
|
||||
accountManager.addAccount(account)
|
||||
accountManager.setActive(account)
|
||||
|
||||
const dispose = createEffect(() => {
|
||||
if (identity()) {
|
||||
navigate("/relays")
|
||||
dispose()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function loginWithNip07() {
|
||||
@@ -196,6 +189,12 @@ export default function Login() {
|
||||
void navigator.clipboard.writeText(nostrConnectUri())
|
||||
}
|
||||
|
||||
createEffect(() => {
|
||||
if (identity()) {
|
||||
navigate("/relays")
|
||||
}
|
||||
})
|
||||
|
||||
onCleanup(() => {
|
||||
abortController?.abort()
|
||||
scanner?.destroy()
|
||||
|
||||
Reference in New Issue
Block a user