diff --git a/app/components/nav.tsx b/app/components/nav.tsx index b2427aa..ef7e53b 100644 --- a/app/components/nav.tsx +++ b/app/components/nav.tsx @@ -3,7 +3,6 @@ import { NavLink } from 'react-router'; const ITEMS = [ { to: '/chat', label: 'Chat' }, { to: '/account', label: 'Account' }, - { to: '/bee', label: 'Bee' }, ]; export function Nav() { diff --git a/app/routes.ts b/app/routes.ts index e68063d..9e3d0c5 100644 --- a/app/routes.ts +++ b/app/routes.ts @@ -7,5 +7,4 @@ export default [ route('login', 'routes/login.tsx'), route('account', 'routes/account.tsx'), route('chat', 'routes/chat.tsx'), - route('bee', 'routes/bee.tsx'), ] satisfies RouteConfig; diff --git a/app/routes/bee.tsx b/app/routes/bee.tsx deleted file mode 100644 index 40536ac..0000000 --- a/app/routes/bee.tsx +++ /dev/null @@ -1,209 +0,0 @@ -import { useEffect, useState } from 'react'; -import { Nav } from '~/components/nav'; - -const API_URL = import.meta.env.VITE_API_URL ?? 'https://api.t4t-gateway.com'; - -type Health = { status: string; version: string; apiVersion: string }; -type Addresses = { - overlay: string; - ethereum: string; - publicKey: string; - pssPublicKey: string; - underlay: string[]; -}; -type Topology = { - connected: number; - population: number; - depth: number; - reachability: string; - networkAvailability: string; -}; -type Wallet = { - bzz: string; - xdai: string; - walletAddress: string; - chainID: number; -}; -type Stamp = { - batchID: string; - label: string; - depth: number; - amount: string; - usable: boolean; - usageText: string; - durationDays: number; -}; -type ChainState = { block: number; chainTip: number; currentPrice: number }; - -type Stats = { - health: Health | null; - addresses: Addresses | null; - topology: Topology | null; - wallet: Wallet | null; - stamps: Stamp[] | null; - chain: ChainState | null; -}; - -export function meta() { - return [{ title: 'Bee · t4t Gateway' }]; -} - -async function fetchStats(): Promise { - const token = localStorage.getItem('jwt'); - if (!token) throw new Error('Not authenticated'); - const res = await fetch(`${API_URL}/bee/stats`, { - headers: { Authorization: `Bearer ${token}` }, - }); - if (res.status === 401) { - localStorage.removeItem('jwt'); - window.location.href = '/login'; - throw new Error('Unauthorized'); - } - const body = await res.json(); - if (!res.ok) throw new Error(body?.error ?? `Request failed (${res.status})`); - return body as Stats; -} - -function Card({ title, children }: { title: string; children: React.ReactNode }) { - return ( -
-

{title}

-
{children}
-
- ); -} - -function Row({ label, value }: { label: string; value: React.ReactNode }) { - return ( -
- {label} - {value} -
- ); -} - -export default function BeePage() { - const [stats, setStats] = useState(null); - const [error, setError] = useState(null); - const [loading, setLoading] = useState(true); - - useEffect(() => { - if (typeof window === 'undefined') return; - if (!localStorage.getItem('jwt')) { - window.location.href = '/login'; - return; - } - fetchStats() - .then((s) => setStats(s)) - .catch((err) => setError(err instanceof Error ? err.message : 'Unknown error')) - .finally(() => setLoading(false)); - }, []); - - if (loading) { - return ( - <> -