| 1 | "use client"; |
| 2 | |
| 3 | import { useEffect } from |
| 4 | import { use } |
| 5 | import { useRouter } |
| 6 | import { useQuery } |
| 7 | import { Globe, Copy |
| 8 | import type { LucideIcon |
| 9 | import { useTranslations } |
| 10 | import { orpc } |
| 11 | import { authClient } |
| 12 | import Loader from "@/components/loader |
| 13 | |
| 14 | function StatRow({ |
| 15 | icon: Icon, |
| 16 | label, |
| 17 | children, |
| 18 | }: { |
| 19 | icon: LucideIcon |
| 20 | label: string |
| 21 | children: React |
| 22 | }) { |
| 23 | return ( |
| 24 | <div className="flex flex-col border-b border-border last:border-b-0 |
| 25 | <div className="flex flex-col gap-1.5 px-4 pt-3 pb-2.5 |
| 26 | <div className="flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-widest text-muted-foreground |
| 27 | <Icon className=" |
| 28 | {label} |
| 29 | </div> |
| 30 | {children} |
| 31 | </div> |
| 32 | </div> |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | export default function NetworkPage |
| 37 | const t = |
| 38 | const router = |
| 39 | const { data: |
| 40 | const { id |
| 41 | |
| 42 | useEffect(() => |
| 43 | if (!isPending && |
| 44 | }, [isPending, |
| 45 | |
| 46 | const { data: |
| 47 | orpc.servers.get |
| 48 | ); |
| 49 | |
| 50 | if (isPending || |
| 51 | |
| 52 | const alloc = |
| 53 | const allocIp = |
| 54 | |
| 55 | function copy(text |
| 56 | void navigator.clipboard. |
| 57 | } |
| 58 | |
| 59 | return ( |
| 60 | <> |
| 61 | <div className="flex flex-1 flex-col gap-3 overflow-auto px-4 py-4 md:flex-row md:overflow-hidden |
| 62 | <div className="flex flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card |
| 63 | <div className="grid grid-cols-[32px_1fr_100px_120px] border-b border-border bg-muted/40 px-4 py-2.5 |
| 64 | <span /> |
| 65 | <span className="text-xs font-medium text-muted-foreground |
| 66 | <span className="text-xs font-medium text-muted-foreground |
| 67 | <span className="text-xs font-medium text-muted-foreground |
| 68 | </div> |
| 69 | <div className="flex-1 overflow-y-auto |
| 70 | {serverPending ? ( |
| 71 | <div className="flex items-center justify-center py-12 text-sm text-muted-foreground |
| 72 | ) : !alloc |
| 73 | <div className="flex flex-col items-center justify-center py-12 gap-2 |
| 74 | <Globe className=" |
| 75 | <p className="text-sm text-muted-foreground |
| 76 | </div> |
| 77 | ) : ( |
| 78 | <div className="grid grid-cols-[32px_1fr_100px_120px] items-center px-4 py-3 hover:bg-muted/40 transition-colors |
| 79 | <span className="flex items-center justify-center |
| 80 | <Star className=" |
| 81 | </span> |
| 82 | <div className="flex items-center gap-2 |
| 83 | <span className="text-sm text-foreground |
| 84 | <button |
| 85 | type="button" |
| 86 | onClick={() => |
| 87 | className="rounded p-0.5 text-muted-foreground/50 hover:bg-muted hover:text-foreground transition-colors" |
| 88 | > |
| 89 | <Copy className=" |
| 90 | </button> |
| 91 | </div> |
| 92 | <span className="text-sm text-foreground |
| 93 | <span> |
| 94 | <span className="rounded-full bg-blue-500/10 px-2 py-0.5 text-[11px] font-medium text-blue-600 dark:text-blue-400 |
| 95 | {t("typePrimary") |
| 96 | </span> |
| 97 | </span> |
| 98 | </div> |
| 99 | )} |
| 100 | </div> |
| 101 | </div> |
| 102 | |
| 103 | <aside className="flex w-full shrink-0 flex-col overflow-hidden rounded-xl border border-border bg-card md:w-[220px] |
| 104 | <div className="overflow-y-auto |
| 105 | <StatRow icon={ |
| 106 | <span className="text-sm font-semibold text-foreground leading-snug |
| 107 | {alloc ? `${ |
| 108 | </span> |
| 109 | </StatRow> |
| 110 | <StatRow icon={ |
| 111 | <span className="text-xl font-bold text-foreground |
| 112 | </StatRow> |
| 113 | <StatRow icon={ |
| 114 | <p className="text-xs text-muted-foreground leading-relaxed |
| 115 | {t("statNoteText") |
| 116 | </p> |
| 117 | </StatRow> |
| 118 | </div> |
| 119 | </aside> |
| 120 | </div> |
| 121 | </> |
| 122 | ); |
| 123 | } |