import { A, useLocation } from "@solidjs/router" import { createMemo, createSignal, For, Show } from "solid-js" import { useProfileMetadata, useProfilePicture, useTenantRelays, type Relay } from "@/lib/hooks" import { account, identity, PLATFORM_LOGO, PLATFORM_NAME } from "@/lib/state" import { fuzzySearch } from "@/lib/search" import { RELAY_DOMAIN } from "@/lib/subdomain" import serverIcon from "@/assets/server.svg" import Modal from "@/components/Modal" import BillingPrompts from "@/components/BillingPrompts" import CopyNpub from "@/components/CopyNpub" import { shortenNpub } from "@/lib/pubkey" function SearchIcon() { return ( ) } function RelayIcon() { return } function AdminIcon() { return ( ) } export default function AppShell(props: { children?: any }) { const location = useLocation() const picture = useProfilePicture(() => account()?.pubkey) const metadata = useProfileMetadata(() => account()?.pubkey) const [tenantRelays] = useTenantRelays() const [searchOpen, setSearchOpen] = createSignal(false) const [searchQuery, setSearchQuery] = createSignal("") const [adminOpen, setAdminOpen] = createSignal(false) const displayName = createMemo(() => metadata()?.name || metadata()?.display_name) const username = createMemo(() => { const pubkey = account()?.pubkey return displayName() || (pubkey ? shortenNpub(pubkey) : "") }) const initial = createMemo(() => (displayName() || account()?.pubkey || "?").slice(0, 1).toUpperCase()) const nip05 = createMemo(() => metadata()?.nip05) const searchedRelays = createMemo(() => { const list = tenantRelays() ?? [] const query = searchQuery().trim() return fuzzySearch(list, ["info_name", "subdomain"], query) }) const myResources = [{ href: "/relays", label: "My Relays" }] const adminResources = [ { href: "/admin/tenants", label: "Tenants" }, { href: "/admin/relays", label: "Relays" }, { href: "/admin/invoices", label: "Invoices" }, ] const navItemClass = (href: string) => { const active = location.pathname === href || location.pathname.startsWith(`${href}/`) return active ? "block rounded-lg bg-white/15 px-3 py-2 text-sm font-medium text-white" : "block rounded-lg px-3 py-2 text-sm text-white/80 hover:bg-white/10 hover:text-white" } const mobileNavItemClass = (href: string) => { const active = location.pathname === href || location.pathname.startsWith(`${href}/`) return active ? "block rounded-lg bg-gray-100 px-3 py-3 text-sm font-medium text-gray-900" : "block rounded-lg px-3 py-3 text-sm text-gray-700 hover:bg-gray-100" } const openSearchModal = () => setSearchOpen(true) const closeSearchModal = () => { setSearchOpen(false) setSearchQuery("") } const openAdminModal = () => setAdminOpen(true) const closeAdminModal = () => setAdminOpen(false) return ( {props.children} { if (searchOpen()) closeSearchModal() if (adminOpen()) closeAdminModal() }} > { e.stopPropagation() openSearchModal() }} > { e.stopPropagation() openAdminModal() }} > {initial()}} > setSearchQuery(e.currentTarget.value)} placeholder="Search your relays" class="w-full rounded-lg border border-gray-300 py-2 pl-10 pr-3" autofocus /> Close Loading relays...}> 0} fallback={No relays found.}> {(relay) => ( {relay.info_name || relay.subdomain} {relay.subdomain}.{RELAY_DOMAIN} )} Administration Close {(item) => ( {item.label} )} ) }
No relays found.
{relay.info_name || relay.subdomain}
{relay.subdomain}.{RELAY_DOMAIN}