mirror of
https://github.com/hanzoai/bootnode.git
synced 2026-10-25 02:31:30 +00:00
74 files imported `lucide-react` directly, pinned ^1.26.0, while @luxfi/ui — which this console renders alongside — resolves 1.27. Two Lucide copies from two resolutions in one bundle is how a set stops being one set. Two more glyphs were not from any icon library at all: the node list drew its network in/out arrows as the literal characters "↓" and "↑", and the chain onboarding selector drew its tick as "✓". Those are font glyphs — they take the text metrics, not the icon box, so they sit on a different baseline and scale with the font, not `size-*`. One source now: `@luxfi/ui/icons`, Lucide as @hanzo/gui standardises on it and @luxfi/ui themes it. `lucide-react` is out of package.json, so per-surface drift is no longer expressible; @luxfi/ui comes in at 7.4.3, which is where `./icons` lives. The three text glyphs are ArrowDown / ArrowUp / Check. All 121 distinct icon names this console uses were checked against the 6014 symbols @luxfi/ui/icons exports before the rewrite — zero missing, with a negative control. `next build` is clean: 78 routes, Next 16.2.11 + Turbopack. The d3 chart roots (node-globe, node-map, globe-view, donut-chart, fleet-map) keep their <svg>: those are plots, not glyphs. The command menu's "↑↓" stays — it is a keyboard legend inside <kbd>, and it means the keys. Co-authored-by: Hanzo Dev <[email protected]>
239 lines
8.0 KiB
TypeScript
239 lines
8.0 KiB
TypeScript
"use client"
|
|
import { getApiUrl, load, loadError } from "@/lib/api"
|
|
|
|
import { useEffect, useState } from "react"
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
|
import { Button } from "@/components/ui/button"
|
|
import { Badge } from "@/components/ui/badge"
|
|
import { Building, Users, Settings, Key, Loader2, CreditCard, AlertCircle } from "@luxfi/ui/icons"
|
|
import Link from "next/link"
|
|
import { useAuth } from "@/lib/auth"
|
|
|
|
interface OrgStats {
|
|
name: string
|
|
tier: string
|
|
teamMembers: number
|
|
apiKeys: number
|
|
projectId: string
|
|
}
|
|
|
|
export default function OrganizationPage() {
|
|
const { user } = useAuth()
|
|
const [loading, setLoading] = useState(true)
|
|
const [error, setError] = useState<string | null>(null)
|
|
const [stats, setStats] = useState<OrgStats | null>(null)
|
|
|
|
function getAuthHeaders(): Record<string, string> {
|
|
if (typeof window === "undefined") return {}
|
|
const token = localStorage.getItem("bootnode_token")
|
|
const apiKey = localStorage.getItem("bootnode_api_key")
|
|
if (token) return { "Authorization": `Bearer ${token}` }
|
|
if (apiKey) return { "X-API-Key": apiKey }
|
|
return {}
|
|
}
|
|
|
|
useEffect(() => {
|
|
async function fetchOrgData() {
|
|
try {
|
|
const headers = getAuthHeaders()
|
|
|
|
const apiUrl = getApiUrl()
|
|
const [teamRes, keysRes] = await Promise.all([
|
|
load("/v1/team"),
|
|
load("/v1/auth/keys"),
|
|
])
|
|
|
|
const teamData = teamRes.ok ? (teamRes.data as any) : { members: [], total: 0 }
|
|
const keysData = keysRes.ok ? (keysRes.data as any) : []
|
|
setError(loadError([teamRes, keysRes]))
|
|
|
|
// Get project name from user context or default
|
|
const projectName = user?.name ? `${user.name}'s Project` : "My Project"
|
|
|
|
setStats({
|
|
name: projectName,
|
|
tier: "Free",
|
|
teamMembers: teamData.total || 0,
|
|
apiKeys: Array.isArray(keysData) ? keysData.length : 0,
|
|
projectId: user?.id || ""
|
|
})
|
|
} catch (err) {
|
|
console.error("Failed to fetch org data:", err)
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}
|
|
|
|
fetchOrgData()
|
|
}, [user])
|
|
|
|
return (
|
|
<div className="space-y-8">
|
|
{error && (
|
|
<Card className="border-destructive/50">
|
|
<CardContent className="p-4">
|
|
<div className="flex items-start gap-3">
|
|
<AlertCircle className="h-5 w-5 text-destructive shrink-0 mt-0.5" />
|
|
<div className="min-w-0">
|
|
<p className="text-sm font-medium">Some data could not be loaded</p>
|
|
<p className="text-sm text-muted-foreground break-words">{error}</p>
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
<div>
|
|
<h1 className="text-3xl font-bold">Organization</h1>
|
|
<p className="text-muted-foreground">
|
|
Manage your organization, team members, and settings
|
|
</p>
|
|
</div>
|
|
|
|
<div className="grid gap-4 md:grid-cols-3">
|
|
<Card>
|
|
<CardHeader className="pb-2">
|
|
<CardTitle className="text-sm font-medium">Organization</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
{loading ? (
|
|
<Loader2 className="h-6 w-6 animate-spin" />
|
|
) : (
|
|
<>
|
|
<div className="text-lg font-bold">{stats?.name || "My Project"}</div>
|
|
<Badge variant="outline" className="mt-1">{stats?.tier || "Free"} tier</Badge>
|
|
</>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
<Card>
|
|
<CardHeader className="pb-2">
|
|
<CardTitle className="text-sm font-medium">Team Members</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
{loading ? (
|
|
<Loader2 className="h-6 w-6 animate-spin" />
|
|
) : (
|
|
<>
|
|
<div className="text-2xl font-bold">{stats?.teamMembers || 0}</div>
|
|
<p className="text-xs text-muted-foreground">active members</p>
|
|
</>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
<Card>
|
|
<CardHeader className="pb-2">
|
|
<CardTitle className="text-sm font-medium">API Keys</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
{loading ? (
|
|
<Loader2 className="h-6 w-6 animate-spin" />
|
|
) : (
|
|
<>
|
|
<div className="text-2xl font-bold">{stats?.apiKeys || 0}</div>
|
|
<p className="text-xs text-muted-foreground">active keys</p>
|
|
</>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
|
|
<div className="grid gap-6 md:grid-cols-2">
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<Users className="h-5 w-5" />
|
|
Team
|
|
</CardTitle>
|
|
<CardDescription>
|
|
Manage team members and permissions
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="space-y-3">
|
|
<p className="text-sm text-muted-foreground">
|
|
{stats?.teamMembers === 0
|
|
? "No team members yet. Invite your first collaborator."
|
|
: `You have ${stats?.teamMembers} team member${stats?.teamMembers !== 1 ? "s" : ""}.`}
|
|
</p>
|
|
<Button variant="outline" className="w-full" asChild>
|
|
<Link href="/dashboard/organization/team">
|
|
Manage Team
|
|
</Link>
|
|
</Button>
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<Settings className="h-5 w-5" />
|
|
Settings
|
|
</CardTitle>
|
|
<CardDescription>
|
|
Organization settings and preferences
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="space-y-3">
|
|
<p className="text-sm text-muted-foreground">
|
|
Configure organization name, CORS origins, and notifications.
|
|
</p>
|
|
<Button variant="outline" className="w-full" asChild>
|
|
<Link href="/dashboard/organization/settings">
|
|
Organization Settings
|
|
</Link>
|
|
</Button>
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<Key className="h-5 w-5" />
|
|
API Keys
|
|
</CardTitle>
|
|
<CardDescription>
|
|
Manage API access credentials
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="space-y-3">
|
|
<p className="text-sm text-muted-foreground">
|
|
{stats?.apiKeys === 0
|
|
? "No API keys yet. Create one to get started."
|
|
: `You have ${stats?.apiKeys} active API key${stats?.apiKeys !== 1 ? "s" : ""}.`}
|
|
</p>
|
|
<Button variant="outline" className="w-full" asChild>
|
|
<Link href="/dashboard/api-keys">
|
|
Manage API Keys
|
|
</Link>
|
|
</Button>
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<CreditCard className="h-5 w-5" />
|
|
Billing
|
|
</CardTitle>
|
|
<CardDescription>
|
|
Subscription and payment settings
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="space-y-3">
|
|
<div className="flex items-center gap-2">
|
|
<Badge variant="outline">{stats?.tier || "Free"} Tier</Badge>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">
|
|
Upgrade to access more features and higher rate limits.
|
|
</p>
|
|
<Button variant="outline" className="w-full" asChild>
|
|
<Link href="/dashboard/organization/billing">
|
|
Manage Subscription
|
|
</Link>
|
|
</Button>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|